lantern-harness 0.1.38 → 0.1.40

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 (118) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/Base.CQ_XCsxM.css +1 -0
  4. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.C17uMscj.js → Base.astro_astro_type_script_index_0_lang.rrUCMnye.js} +1 -1
  5. package/dist/_astro/CaseExecBoard.1aCJ_MsC.js +1 -0
  6. package/dist/_astro/CaseGenerateApp.C9bJ0es1.js +10 -0
  7. package/dist/_astro/CasesLibrary.DBxhr8Z1.js +21 -0
  8. package/dist/_astro/ChatApp.CRCMwSjv.js +226 -0
  9. package/dist/_astro/{DashboardBoard.BTFyQf9w.js → DashboardBoard.B-EpZOnS.js} +1 -1
  10. package/dist/_astro/{DocsFileBrowser.9WTBumS5.js → DocsFileBrowser.DceJyP9V.js} +1 -1
  11. package/dist/_astro/{DocsPager.BS20yicJ.js → DocsPager.D0TMvJ67.js} +1 -1
  12. package/dist/_astro/{DrawerField.CiHAvXHQ.js → DrawerField.CWpOf3L_.js} +1 -1
  13. package/dist/_astro/{KnowledgeLibrary.CiBRybeE.js → KnowledgeLibrary.C-_UybI5.js} +1 -1
  14. package/dist/_astro/LifeKrTasksBoard.DktIT_uO.js +1 -0
  15. package/dist/_astro/LifeKrTodosBoard.DVUmgRmh.js +1 -0
  16. package/dist/_astro/LifeObjectivesBoard.Cjg3hCkJ.js +1 -0
  17. package/dist/_astro/LifePlanTypeSelect.C63oD8zZ.js +1 -0
  18. package/dist/_astro/{LifeReviewsBoard.Bn-uxMI5.js → LifeReviewsBoard.Bj4otl26.js} +1 -1
  19. package/dist/_astro/LifeShared.-pwCbSyP.js +3 -0
  20. package/dist/_astro/LifeStagesBoard.DJpc4f7A.js +1 -0
  21. package/dist/_astro/LifeYearCycleSelect.CObXQA5s.js +1 -0
  22. package/dist/_astro/{LifeYearPlansBoard.ChAoQUB5.js → LifeYearPlansBoard.Bt6Hc8M9.js} +1 -1
  23. package/dist/_astro/PluginsPage.BWrcEbFk.js +1 -0
  24. package/dist/_astro/PluginsPage.CMeKGbb1.js +17 -0
  25. package/dist/_astro/PmBugsBoard.NUiKlz46.js +1 -0
  26. package/dist/_astro/PmIterationsBoard.C8F55feg.js +1 -0
  27. package/dist/_astro/{PmProjectDetail.DH8Z3nHb.js → PmProjectDetail.CMiWhGxn.js} +1 -1
  28. package/dist/_astro/{PmProjectsBoard.Dokaj4V1.js → PmProjectsBoard.-g9KAiZJ.js} +1 -1
  29. package/dist/_astro/PmRequirementsBoard.C0_6ye63.js +1 -0
  30. package/dist/_astro/PmRequirementsBoard.C5_NcAzj.js +1 -0
  31. package/dist/_astro/{PmShared.BJpoEYvk.js → PmShared.D6iq_Z9g.js} +1 -1
  32. package/dist/_astro/{PromptsLibrary.CNLcQ66B.js → PromptsLibrary.BLEjapm6.js} +1 -1
  33. package/dist/_astro/ReportsPage.DFsDsjow.js +1 -0
  34. package/dist/_astro/ReqAnalysisBoard.C1ki8w9Z.js +39 -0
  35. package/dist/_astro/{RequirementsLibrary.BnY7_YXU.js → RequirementsLibrary.Dat8rP5c.js} +1 -1
  36. package/dist/_astro/{SearchableSelect.5SfNLwNW.js → SearchableSelect.DFZBUFIs.js} +1 -1
  37. package/dist/_astro/SelectDropdown.Dmk5n225.js +1 -0
  38. package/dist/_astro/{SettingsDialog.DFnXkw7a.js → SettingsDialog.D486FVZ4.js} +1 -1
  39. package/dist/_astro/{SpaceSwitcher.Cy4UrzbH.js → SpaceSwitcher.Bw13MkIw.js} +2 -2
  40. package/dist/_astro/TableFieldConfig.C_NeWm8L.js +1 -0
  41. package/dist/_astro/TasksBoard.wGJOOJpR.js +1 -0
  42. package/dist/_astro/TemplatesLibrary.YIgI089k.js +1 -0
  43. package/dist/_astro/TestStatsBoard.ETea2KcX.js +1 -0
  44. package/dist/_astro/TodosBoard.OfBeAGWO.js +1 -0
  45. package/dist/_astro/UiAutoBoard.Df2ky1Cs.js +9 -0
  46. package/dist/_astro/app-version.DaJuJwsd.js +1 -0
  47. package/dist/_astro/{export.joBT53eb.js → case-fields.CmePqYfh.js} +1 -1
  48. package/dist/_astro/case-gen-run.CxlmN4EC.js +22 -0
  49. package/dist/_astro/{case-review.s1w_mD4l.js → case-review.TdDs1WFM.js} +1 -1
  50. package/dist/_astro/case-template.C-GBxgBC.js +8 -0
  51. package/dist/_astro/{req-analysis.ilj0McI3.js → req-analysis.BAC_bd4R.js} +1 -1
  52. package/dist/_astro/{story-review.Bsm2JWdj.js → story-review.CCSxTgNL.js} +1 -1
  53. package/dist/_astro/tasks.DEyD8pmq.js +1 -0
  54. package/dist/case-exec/index.html +5 -5
  55. package/dist/cases/generate/index.html +5 -5
  56. package/dist/cases/library/index.html +5 -5
  57. package/dist/dashboard/index.html +5 -5
  58. package/dist/docs/changelog/index.html +69 -44
  59. package/dist/docs/install/index.html +4 -4
  60. package/dist/docs/manual/index.html +22 -21
  61. package/dist/knowledge/index.html +5 -5
  62. package/dist/life/kr-tasks/index.html +5 -5
  63. package/dist/life/kr-todos/index.html +5 -5
  64. package/dist/life/objectives/index.html +5 -5
  65. package/dist/life/reviews/index.html +5 -5
  66. package/dist/life/stages/index.html +5 -5
  67. package/dist/life/year-plans/index.html +5 -5
  68. package/dist/plugins/index.html +5 -5
  69. package/dist/pm/bugs/index.html +5 -5
  70. package/dist/pm/iterations/index.html +5 -5
  71. package/dist/pm/projects/detail/index.html +5 -5
  72. package/dist/pm/projects/index.html +5 -5
  73. package/dist/pm/requirements/index.html +5 -5
  74. package/dist/prompts/index.html +5 -5
  75. package/dist/reports/index.html +5 -5
  76. package/dist/requirement-analysis/index.html +5 -5
  77. package/dist/requirements/index.html +5 -5
  78. package/dist/tasks/index.html +5 -5
  79. package/dist/templates/index.html +5 -5
  80. package/dist/test-automation/index.html +5 -5
  81. package/dist/test-stats/index.html +5 -5
  82. package/dist/todos/index.html +5 -5
  83. package/dist/workbench/index.html +5 -5
  84. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +18 -17
  85. package/lh-plugins/lh-mcp.mjs +4 -1
  86. package/lh-plugins/lh-todos.mjs +27 -10
  87. package/package.json +1 -1
  88. package/dist/_astro/Base.B-G3Zgu4.css +0 -1
  89. package/dist/_astro/CaseExecBoard.BWxBjYPI.js +0 -1
  90. package/dist/_astro/CaseGenerateApp.fUXTG_NE.js +0 -10
  91. package/dist/_astro/CasesLibrary.CVPhAnFf.js +0 -24
  92. package/dist/_astro/ChatApp.KceL1TNg.js +0 -226
  93. package/dist/_astro/LifeKrTasksBoard.RENBU_z9.js +0 -1
  94. package/dist/_astro/LifeKrTodosBoard.CbNnGHSZ.js +0 -1
  95. package/dist/_astro/LifeObjectivesBoard.BTGFpny2.js +0 -1
  96. package/dist/_astro/LifePlanTypeSelect.BGtEEsL-.js +0 -1
  97. package/dist/_astro/LifeShared.SnLIiFdN.js +0 -3
  98. package/dist/_astro/LifeStagesBoard.DrbIVrCK.js +0 -1
  99. package/dist/_astro/LifeYearCycleSelect.CuiWO8Tc.js +0 -1
  100. package/dist/_astro/PluginsPage.BFEwg0vr.js +0 -17
  101. package/dist/_astro/PluginsPage.CPEoYrlx.js +0 -1
  102. package/dist/_astro/PmBugsBoard.Cu1uf0TC.js +0 -1
  103. package/dist/_astro/PmIterationsBoard.RzRKkAH0.js +0 -1
  104. package/dist/_astro/PmRequirementsBoard.DET5YIVX.js +0 -1
  105. package/dist/_astro/PmRequirementsBoard.i203nmYC.js +0 -1
  106. package/dist/_astro/ReportsPage.BU3GtBvl.js +0 -1
  107. package/dist/_astro/ReqAnalysisBoard.DaOV-2Z2.js +0 -39
  108. package/dist/_astro/SelectDropdown.TgxIOKMD.js +0 -1
  109. package/dist/_astro/TasksBoard.CWkx5cD1.js +0 -1
  110. package/dist/_astro/TemplatesLibrary.phzK5kho.js +0 -1
  111. package/dist/_astro/TestStatsBoard.Dp1TWEf7.js +0 -1
  112. package/dist/_astro/TodosBoard.ofiKHKcQ.js +0 -1
  113. package/dist/_astro/UiAutoBoard.Cpb_EF46.js +0 -9
  114. package/dist/_astro/app-version.BsRPDlqD.js +0 -1
  115. package/dist/_astro/case-fields.Dqkws1iX.js +0 -1
  116. package/dist/_astro/case-gen-run.BaUxa_BR.js +0 -22
  117. package/dist/_astro/case-template.F1Nv08GV.js +0 -5
  118. package/dist/_astro/tasks.DefXqRfI.js +0 -1
@@ -0,0 +1,39 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{s as r}from"./plugins.C0NrHGZv.js";import{a as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./view-prefs.8MPl3A7e.js";import{i as d,n as f,r as p,t as m}from"./dialog.DZHZCe_T.js";import{t as h}from"./jsx-runtime.DUg_B_vD.js";import{t as g}from"./ConfirmDialog.D5qXeML0.js";import{t as _}from"./OverflowHint.pvo2Xc8R.js";import{t as v}from"./SelectDropdown.Dmk5n225.js";import{A as ee,S as y,_ as b,g as te,m as x,u as S}from"./PmShared.D6iq_Z9g.js";import{showToast as C}from"./Toast.BO2NFckG.js";import{o as w}from"./project-docs.DAw9bzgk.js";import{m as ne,p as re,u as ie}from"./settings.NTeTjmxg.js";import{$ as ae,A as T,B as oe,C as se,D as ce,E as le,F as ue,G as de,H as fe,I as pe,J as me,K as he,L as ge,M as _e,N as ve,O as E,P as ye,Q as be,R as xe,S as Se,T as Ce,U as we,V as Te,W as Ee,X as De,Y as Oe,Z as ke,_ as Ae,a as je,at as Me,b as Ne,c as Pe,ct as D,d as Fe,et as Ie,f as Le,g as Re,h as ze,i as Be,it as Ve,j as He,k as Ue,l as We,m as Ge,n as O,nt as Ke,o as qe,ot as Je,p as Ye,q as Xe,r as k,s as Ze,st as Qe,t as $e,tt as et,u as tt,w as nt,x as rt,y as it}from"./req-analysis.BAC_bd4R.js";import{s as at}from"./llm.DyweO-KK.js";import{t as ot}from"./MultiSelectDropdown.y8JMbCxO.js";import{_ as st,a as ct,c as lt,d as ut,f as dt,g as ft,h as pt,i as mt,l as ht,m as gt,n as _t,o as vt,p as yt,r as bt,s as xt,u as St,y as Ct}from"./story-review.CCSxTgNL.js";import{t as wt}from"./hydrate-cache.DI6vqM0o.js";var A=e(t(),1),Tt=`可用工具(只调用这些,不要自己编工具名):
2
+ - req_set_outline:在已播种的文档条目下提交查询/修改子点(带 parentId、kind),返回 id 供 sourceRefs 引用。不要另造文档里没有的条目标题。同一 parentId 下按能力点拆多条子点(可多个 query、多个 mutate),勿把多个能力点合并成一条。
3
+ - req_insert_outline_after:在指定已有子点下方插入新的查询/修改子点(用户补充需求内容时用);afterId 固定为消息里给出的锚点;插入后同父级子点 id 按序号顺延。
4
+ - req_update_outline_point:按 id 更新已有查询/修改子点的标题 / 类型 / 原文(id 不变);用户变更当前点内容时用。
5
+ - req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
6
+ - req_save_check:提交待确认缺口(原文不清、需业务拍板等),不要报故事字段缺失类质检。
7
+ - req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3);补充点标 supplemental。
8
+
9
+ 提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`;async function Et(e,t,n,r=new Set){let i=await e.saveOutline(t);if(!n.size&&!r.size)return i;let a=e.getDoc();if(!a)return i;let o=Xe({stories:a.stories,check:a.check,ignoredGaps:a.ignoredGaps},n,r);return JSON.stringify(o.stories)!==JSON.stringify(a.stories)&&await e.saveStories(o.stories),o.check&&JSON.stringify(o.check)!==JSON.stringify(a.check)&&await e.saveCheck(o.check),JSON.stringify(o.ignoredGaps??[])!==JSON.stringify(a.ignoredGaps??[])&&await e.saveIgnoredGaps(o.ignoredGaps??[]),e.getDoc()?.outline??i}var Dt=[`pending-confirm`,`uncovered-outline`,`conflict`,`other`,`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`over-split`];function Ot(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function j(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function kt(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function At(e){let t=j(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function M(e){let t=j(e,40);return Dt.includes(t)?t:`other`}var jt=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function N(e){let t=j(e,40);if(jt.includes(t))return t;let n=j(e,20);return jt.find(e=>lt[e]===n)??`functional`}function P(e){let t=j(e,4).toUpperCase();return ut.includes(t)?t:`P1`}function F(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=j(n.title,200);if(!r)return null;let i=j(n.storyId,20),a={id:``,storyId:t.has(i)?i:``,dimension:N(n.dimension),priority:P(n.priority),title:r,precondition:j(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>j(e,500)).filter(Boolean).slice(0,20):[],expected:j(n.expected,1e3)};return n.supplemental===!0&&(a.supplemental=!0),a}var Mt=[{type:`function`,function:{name:`req_set_outline`,description:`在已播种的文档需求条目下提交查询/修改子点。一个可独立验收的能力点交一条;同一 parentId 可有多条 query/mutate,勿合并。title 写清该能力(可贴近父级标题加短后缀);必须带 parentId 与 kind(query|mutate)。禁止另造文档没有的条目。每条 quote/body 只支撑本能力点,勿把连续多条编号或整段粘贴塞进同一子点。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`贴近文档的条目标题,可带查询/修改后缀`},quote:{type:`string`,description:`从父级原文摘出支撑本子点的相关段落,尽量 verbatim;本能力点对应的编号项/字段即可,勿把后续其它编号项一并塞入;可至约 2000 字`},body:{type:`string`,description:`可选;与 quote 同段的更完整原文切片(仍限本能力点),可至约 4000 字`},kind:{type:`string`,enum:[`query`,`mutate`],description:`query=查询类能力;mutate=修改/写入类能力`},parentId:{type:`string`,description:`所属文档条目 id(消息里「需求条目」已列出的父级 id)`}},required:[`title`,`kind`,`parentId`,`quote`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_source_export`,description:`提交本段需求原文的分组。category、title、body 必须是原文里连续出现的原句,禁止改写或概括。body 给该标题下的整段原文,不要自行拆步骤,也不要把需求编号拆出去。`,parameters:{type:`object`,properties:{groups:{type:`array`,items:{type:`object`,properties:{category:{type:`string`,description:`大类或模块,必须是原文原句`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`需求标题,必须是原文原句`},body:{type:`string`,description:`该标题下的整段原文,不要改写`}},required:[`title`,`body`]}}},required:[`category`,`items`]}}},required:[`groups`]}}},{type:`function`,function:{name:`req_insert_outline_after`,description:`在指定查询/修改子点下方插入新子点(用户补充的需求内容拆出来的能力点)。afterId 必须是消息里给出的锚点子点;新点继承其 parentId;写入后同父级子点 id 按序号顺延为 parentId-1..n。每条 quote/body 只支撑本能力点,勿把连续多条编号或用户整段粘贴塞进同一子点。`,parameters:{type:`object`,properties:{afterId:{type:`string`,description:`锚点子点 id;新点插在它下方`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`能力点标题`},quote:{type:`string`,description:`支撑本子点的需求原文摘录,尽量 verbatim;只含本能力点,勿塞入后续编号项`},body:{type:`string`,description:`可选;更完整原文切片(仍限本能力点)`},kind:{type:`string`,enum:[`query`,`mutate`],description:`query=查询类;mutate=修改/写入类`}},required:[`title`,`kind`,`quote`]}}},required:[`afterId`,`items`]}}},{type:`function`,function:{name:`req_update_outline_point`,description:`按 id 更新已有查询/修改子点的标题、类型与原文摘录(id 与 parentId 不变)。用户变更当前需求点内容时用;若还要拆出额外能力点,另调 req_insert_outline_after。`,parameters:{type:`object`,properties:{id:{type:`string`,description:`要更新的子点 id(消息里给出的锚点)`},title:{type:`string`,description:`能力点标题`},quote:{type:`string`,description:`支撑本子点的需求原文摘录,尽量 verbatim`},body:{type:`string`,description:`可选;更完整原文切片`},kind:{type:`string`,enum:[`query`,`mutate`],description:`query=查询类;mutate=修改/写入类`}},required:[`id`,`quote`]}}},{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`},minItems:1,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`,`sourceRefs`,`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:[`pending-confirm`,`uncovered-outline`,`conflict`,`other`],description:`待确认类`},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`需要确认什么 + 原文依据`},suggestion:{type:`string`,description:`建议如何确认或补故事`},outlineId:{type:`string`,description:`相关需求点 id,可选`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:五维全覆盖,每条标 P0–P3。正式点优先;扩展场景标 supplemental=true。一次提交全部。`,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:jt,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:ut},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有数值写具体数值`},supplemental:{type:`boolean`,description:`true=补充扩展点;落到用例备注「补充:」`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function Nt(e,t,n){let r=Ot(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,kind:n,parentId:r})=>({id:e,title:t,kind:n??null,parentId:r??null})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.filter(e=>!e.parentId&&!e.kind).map(e=>e.id)),o=(e,t,n)=>`${n}|${t}|${kt(e)}`,s=new Set(t.map(e=>o(e.title,e.kind??``,e.parentId??``))),c=new Set(t.map(e=>e.id)),l=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=j(e.title,200)||j(e.quote,200),i=j(e.kind,16),u=i===`query`||i===`mutate`?i:void 0,d=j(e.parentId,32);if(!r||!u||!d||!a.has(d))continue;let f=o(r,u,d);if(s.has(f))continue;s.add(f);let p=`RO-${n.batch+1}-${l.length+1}`,m=p,h=1;for(;c.has(m);)m=`${p}-${h++}`;c.add(m);let g=j(e.quote,2e3),_=j(e.body,4e3),v={id:m,title:r,quote:g,kind:u,parentId:d};_&&(v.body=_),l.push(v)}let u=[...t,...l],d=ge(u),f=await Et(n,d.outline,d.idMap);return JSON.stringify({ok:!0,added:l.length,total:f.length,items:f.map(({id:e,title:t,kind:n,parentId:r})=>({id:e,title:t,kind:n??null,parentId:r??null})),note:l.length>0?`子点已保存并按父级原文序顺延编号(parentId-n)。接下来用 req_set_stories 提交故事,sourceRefs 只能引用返回的 id(优先挂查询/修改子点)。`:`这些子点已存在或 parentId/kind 无效,没有写入;请对照消息里的文档条目父级 id。`})}if(e===`req_insert_outline_after`){let e=j(r.afterId,64),t=Array.isArray(r.items)?r.items:[];if(!e)return JSON.stringify({ok:!1,error:`缺少 afterId`});let a=[];for(let e of t){let t=e&&typeof e==`object`?e:{},n=j(t.title,200)||j(t.quote,200),r=j(t.kind,16),i=r===`query`||r===`mutate`?r:``,o=j(t.quote,2e3);if(!n||!i||!o)continue;let s={title:n,kind:i,quote:o},c=j(t.body,4e3);c&&(s.body=c),a.push(s)}if(!a.length)return JSON.stringify({ok:!1,error:`没有有效的子点(需要 title、kind、quote)`});let o=T(i.outline,e,a);if(o.error)return JSON.stringify({ok:!1,error:o.error});let s=await Et(n,o.outline,o.idMap);return JSON.stringify({ok:!0,added:o.addedIds.length,addedIds:o.addedIds,idMap:Object.fromEntries(o.idMap),total:s.length,items:s.filter(e=>e.parentId&&e.kind).map(({id:e,title:t,kind:n,parentId:r})=>({id:e,title:t,kind:n??null,parentId:r??null})),note:`已在 ${e} 下方插入 ${o.addedIds.length} 条子点,同父级序号已顺延。`})}if(e===`req_update_outline_point`){let e=j(r.id,64),t=j(r.quote,2e3);if(!e)return JSON.stringify({ok:!1,error:`缺少 id`});if(!t)return JSON.stringify({ok:!1,error:`缺少 quote`});let a=j(r.kind,16),o=a===`query`||a===`mutate`?a:void 0,s=j(r.title,200),c=j(r.body,4e3),l={quote:t};s&&(l.title=s),o&&(l.kind=o),r.body!==void 0&&(l.body=c);let u=Qe(i.outline,e,l);if(u.error)return JSON.stringify({ok:!1,error:u.error});let d=(await n.saveOutline(u.outline)).find(t=>t.id===e);return JSON.stringify({ok:!0,id:e,item:d?{id:d.id,title:d.title,kind:d.kind??null,parentId:d.parentId??null}:null,note:`已更新需求点 ${e}(id 未变)。若还要拆出额外子点,用 req_insert_outline_after,afterId 仍为 ${e}。`})}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=pe(i.stories,e),{stories:o,filled:s}=rt(a,i.outline),c=await n.saveStories(o),l=new Set(i.outline.map(e=>e.id)),u=c.stories.flatMap(e=>e.sourceRefs).filter(e=>!l.has(e)),d=c.stories.filter(e=>!e.sourceRefs.length).length;return JSON.stringify({ok:!0,added:Math.max(0,c.stories.length-t),total:c.stories.length,stories:c.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),autoLinked:s,danglingSourceRefs:Array.from(new Set(u)).slice(0,10),note:u.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:d>0?`故事已保存;仍有 ${d} 条未挂上需求点,请对照条目 id 补上。`:s>0?`故事已保存(自动补挂了 ${s} 条需求点)。`:`故事已保存。`})}if(e===`req_save_check`){let e=tt(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[kt(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=j(n.title,200);if(!r)continue;let i=j(n.storyId,20),o=a.has(i)&&i||t.get(kt(j(n.storyTitle,200)))||``,c=M(n.type);(c===`missing-scenario`||c===`missing-dimension`||c===`untestable-acceptance`||c===`over-split`||c===`missing-field`)&&(c=`pending-confirm`);let l=j(n.outlineId,32);s.push({id:E(c,o||l,r),storyId:o,outlineId:l||void 0,type:c,severity:At(n.severity),title:r,detail:j(n.detail,1e3),suggestion:j(n.suggestion,1e3),origin:`model`,selected:!1})}let c=se(ye(e.gaps,s)),l=j(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=>F(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:j(r.summary,2e3),points:a})).testPoints?.points??a,s=jt.map(e=>({dimension:lt[e],count:o.filter(t=>t.dimension===e).length})),c=ut.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 Pt(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 Ft(e){let t=Pt(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 It(e,t=[]){let n=new Set(t),r=Pt(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=>F(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?j(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var I=h(),Lt=`text-xs font-semibold tracking-wide text-stone-500`,Rt=`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`,L=`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`,R=[`pending`,`ignored`],z=`reqanalysis.reviewListTab`;function zt(e){let t=e?.parentElement??null;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return null}function Bt({check:e,stories:t,outlineTitles:n,ignoredGaps:r=[],busy:i,onToggleGap:a,onToggleAll:c,onFix:l,onReview:u,onFullScan:h,onExport:g,onExportPending:v,onIgnoreGap:ee,onIgnoreSelected:y,onSaveGapConclusion:b,onRestoreIgnored:te,onPromoteIgnored:x}){let[S,C]=(0,A.useState)(()=>o(z,R,`pending`)),[w,ne]=(0,A.useState)(null),[re,ie]=(0,A.useState)(``),ae=(0,A.useRef)(null),T=(0,A.useRef)(null),oe=(0,A.useRef)(null),se=(0,A.useRef)(!1);(0,A.useEffect)(()=>{s(z,S)},[S]),(0,A.useEffect)(()=>{if(!w)return;ie(w.conclusion?.trim()||``);let e=window.setTimeout(()=>{ae.current?.focus(),ae.current?.select()},50);return()=>window.clearTimeout(e)},[w]),(0,A.useLayoutEffect)(()=>{let e=T.current,t=oe.current,n=zt(e);if(!e||!t||!n)return;let r=Math.max(0,n.clientHeight-e.offsetHeight-16);if(t.style.minHeight=`${r}px`,!se.current)return;se.current=!1;let i=e.getBoundingClientRect().top-n.getBoundingClientRect().top;Math.abs(i)>.5&&(n.scrollTop+=i)},[S,e?.gaps.length,r.length]);let ce=e=>{if(e===S)return;let t=T.current,n=zt(t);t&&n?se.current=t.getBoundingClientRect().top<=n.getBoundingClientRect().top+1:se.current=!1,C(e)};if(!e)return(0,I.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,I.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,I.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`生成用户故事成功后会自动审查;也可在这里手动开始。审查核对需求点覆盖,并标出需要业务确认的点。`}),(0,I.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:i||!t.length,onClick:u,children:`开始审查`})]});let le=vt(e.gaps),ue=e.gaps.filter(e=>e.selected).length,de=e.coverage.total?Math.round(e.coverage.rate*100):0,fe=_t(e.gaps),pe=new Map(t.map(e=>[e.id,e.title])),me=[{id:`pending`,label:`待确认清单`,count:e.gaps.length},{id:`ignored`,label:`忽略`,count:r.length}];return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:Lt,children:`需求点覆盖率`}),(0,I.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,I.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,I.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[de,`%`]})]})]}),(0,I.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,I.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full transition-all ${de>=90?`bg-emerald-500`:de>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(de,e.coverage.total?2:0)}%`}})}),(0,I.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的需求点算覆盖;未覆盖会进待确认清单`:`还没有需求条目,先做一次拆解`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`p`,{className:Lt,children:`待确认`}),(0,I.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,I.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,fe.high,` · 中 `,fe.medium,` · 低 `,fe.low]})]})]})]}),e.summary?(0,I.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null,(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-2 border-t border-stone-100 pt-2`,children:[(0,I.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`重新审查只刷新上轮清单;需要再挖新问题用全量扫描(已忽略仍不回潮)`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,className:L,disabled:i||!t.length,onClick:u,children:`重新审查`}),h?(0,I.jsx)(`button`,{type:`button`,className:L,disabled:i||!t.length,onClick:h,children:`重新全量扫描`}):null]})]})]}),(0,I.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,I.jsx)(`p`,{className:Lt,children:`维度覆盖(仅供参考,无原文依据不进待确认)`}),(0,I.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,I.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,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,I.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,I.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,I.jsx)(_,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,I.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,I.jsx)(`div`,{ref:T,className:`sticky top-0 z-10 -mx-0.5 rounded-xl border border-stone-200 bg-white px-2 shadow-sm sm:px-3`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`flex items-center gap-0.5`,role:`tablist`,"aria-label":`审查清单`,children:me.map(e=>{let t=S===e.id;return(0,I.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.5 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>ce(e.id),children:[e.label,(0,I.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)})}),S===`pending`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1.5 sm:px-0`,children:[(0,I.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,ue,` 条`]}),(0,I.jsx)(`button`,{type:`button`,className:L,onClick:g,children:`导出 Markdown`}),v?(0,I.jsx)(`button`,{type:`button`,className:L,onClick:v,children:`导出待确认`}):null,(0,I.jsx)(`button`,{type:`button`,className:L,onClick:()=>c(ue!==e.gaps.length),children:ue===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),y?(0,I.jsx)(`button`,{type:`button`,className:L,disabled:i||!ue,onClick:y,children:`批量忽略`}):null,(0,I.jsx)(`button`,{type:`button`,className:Rt,disabled:i||!ue,onClick:l,children:`补写选中缺口`})]}):(0,I.jsx)(`span`,{className:`px-1 py-1.5 text-xs text-stone-400 sm:px-0`,children:`忽略项可恢复或落成用户故事`})]})}),(0,I.jsx)(`div`,{ref:oe,className:`rounded-xl border border-stone-200 bg-white`,children:S===`pending`?le.length?(0,I.jsx)(`div`,{className:`divide-y divide-stone-100`,children:le.map(e=>(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,I.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,I.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,I.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,I.jsx)(Vt,{gap:e,storyTitle:pe.get(e.storyId)??``,outlineLabel:e.outlineId?n?.get(e.outlineId)??e.outlineId:``,onToggle:a,onIgnore:ee,onFillConclusion:b?e=>ne(e):void 0,busy:i},e.id))})]},e.key))}):(0,I.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有待确认项。需求点覆盖与待确认都过了,可再人工过一遍故事。`}):r.length?(0,I.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:r.map(e=>(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:k[e.type]}),e.outlineId?(0,I.jsx)(`span`,{className:`rounded bg-[#eaf1ff] px-1.5 py-0.5 text-[11px] text-[#3370ff]`,children:n?.get(e.outlineId)??e.outlineId}):null,(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.ignoredAt.slice(0,16).replace(`T`,` `)})]}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-stone-800`,children:e.title}),e.detail?(0,I.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-xs text-stone-500`,children:e.detail}):null,e.conclusion?.trim()?(0,I.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs text-emerald-700`,children:[`结论:`,e.conclusion.trim()]}):null,(0,I.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap justify-end gap-2`,children:[te?(0,I.jsx)(`button`,{type:`button`,className:L,disabled:i,onClick:()=>te(e.id),children:`恢复`}):null,x?(0,I.jsx)(`button`,{type:`button`,className:Rt,disabled:i,onClick:()=>x(e.id),children:`落成用户故事`}):null]})]},e.id))}):(0,I.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`忽略后不进用户故事,可随时恢复或落成。`})}),(0,I.jsxs)(p,{open:!!w,onClose:()=>ne(null),className:`relative z-110`,children:[(0,I.jsx)(m,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,I.jsxs)(d,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-md rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,I.jsx)(f,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:`填写结论`}),w?(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-stone-400 line-clamp-2`,children:w.title}):null,(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-stone-400`,children:`把产品/项目确认的结论写在这里;勾选后点「补写选中缺口」时会带给模型。`}),(0,I.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[`结论`,(0,I.jsx)(`textarea`,{ref:ae,value:re,onChange:e=>ie(e.target.value),rows:3,placeholder:`例如:倒计时是提交后 3 秒关页,时间到自动关,不能取消…`,className:`mt-1.5 block w-full resize-y rounded-lg border border-stone-200 px-3 py-2 text-sm leading-relaxed text-stone-800 outline-none transition-colors focus:border-[#4176e6] focus:ring-2 focus:ring-[#4176e6]/30`})]}),(0,I.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,className:`tw-confirm-cancel h-8 rounded-lg px-3 text-sm text-stone-600 transition-colors hover:bg-stone-100`,onClick:()=>ne(null),children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`h-8 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white transition-colors hover:bg-[#3565c7] disabled:opacity-40`,disabled:i||!re.trim(),onClick:()=>{if(!w||!b||!re.trim())return;let e=w,t=re.trim();ne(null),b(e,t)},children:`保存结论`})]})]})})]})]})}function Vt({gap:e,storyTitle:t,outlineLabel:n,onToggle:r,onIgnore:i,onFillConclusion:a,busy:o}){return(0,I.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>r(e.id,t.target.checked)}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsx)(y,{tone:O[e.severity],children:$e[e.severity]}),(0,I.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:k[e.type]}),n?(0,I.jsx)(`span`,{className:`rounded bg-[#eaf1ff] px-1.5 py-0.5 text-[11px] text-[#3370ff]`,children:n}):null,e.storyId?(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,I.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,I.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500 whitespace-pre-wrap`,children:e.detail}):null,e.suggestion?(0,I.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null,e.conclusion?.trim()?(0,I.jsxs)(`p`,{className:`mt-1 line-clamp-3 text-xs text-emerald-700`,children:[`结论:`,e.conclusion.trim()]}):null,a||i?(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2`,children:[a?(0,I.jsx)(`button`,{type:`button`,className:L,disabled:o,onClick:()=>a(e),children:`填结论`}):null,i?(0,I.jsx)(`button`,{type:`button`,className:L,disabled:o,onClick:()=>i(e.id),children:`忽略`}):null]}):null]})]})}var Ht=`reqanalysis.testPointsView`,Ut=[`map`,`list`],Wt=`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 Gt({point:e}){return(0,I.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,I.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function Kt({req:e,onJumpToRequirement:t}){return(0,I.jsxs)(`div`,{className:`flex items-stretch gap-0`,children:[(0,I.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,I.jsx)(`p`,{className:`text-[11px] text-[#5b7fd6]`,children:`需求`}),t?(0,I.jsx)(`button`,{type:`button`,className:`text-left text-sm font-semibold leading-snug text-[#1f4fd8] hover:underline`,onClick:()=>t(e.title,e.storyIds),children:e.title}):(0,I.jsx)(`p`,{className:`text-sm font-semibold leading-snug text-stone-800`,children:e.title}),(0,I.jsxs)(`p`,{className:`mt-1 text-[11px] tabular-nums text-stone-400`,children:[e.points.length,` 条`]})]}),(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-hidden rounded-r-xl border border-stone-200 bg-white`,children:e.dimensions.map((n,r)=>{let i=ht[n.key];return(0,I.jsxs)(`div`,{className:`flex w-[9.5rem] shrink-0 flex-col ${r>0?`border-l border-stone-100`:``}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2 py-1.5`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${i.accent}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`truncate text-[11px] font-medium text-stone-700`,children:i.label})]}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:n.points.length})]}),(0,I.jsx)(`div`,{className:`max-h-52 space-y-1.5 overflow-y-auto px-1.5 py-1.5`,children:n.points.length?n.points.map(n=>(0,I.jsx)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/70 px-1.5 py-1`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,I.jsx)(y,{tone:St[n.priority].tone,children:n.priority}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`break-words text-[11px] leading-snug text-stone-700`,children:n.title}),t?(0,I.jsxs)(`button`,{type:`button`,className:`mt-0.5 text-left text-[10px] text-[#3370ff] hover:underline`,onClick:()=>t(e.title,e.storyIds),children:[`所属需求:`,e.title]}):(0,I.jsxs)(`p`,{className:`mt-0.5 text-[10px] text-[#3370ff]`,children:[`所属需求:`,e.title]})]})]})},n.id)):(0,I.jsx)(`p`,{className:`py-3 text-center text-[11px] text-stone-300`,children:`无`})})]},n.key)})})]})}function qt({doc:e,idealTitles:t,onJumpToRequirement:n}){let r=(0,A.useMemo)(()=>st(e,t),[e,t]);return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,I.jsx)(`div`,{className:`min-w-[62rem] space-y-3`,children:r.length?r.map(e=>(0,I.jsx)(Kt,{req:e,onJumpToRequirement:n},e.key)):(0,I.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`还没有测试点。`})})}),(0,I.jsx)(`p`,{className:`text-center text-[11px] text-stone-400`,children:`每条需求横向展开五个维度;列过窄时整行左右滑动。导出 XMind 为同结构的向右逻辑图。`})]})}function Jt({doc:e,idealTitles:t,onJumpToRequirement:n}){let r=(0,A.useMemo)(()=>st(e,t),[e,t]);return(0,I.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,I.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,I.jsxs)(`div`,{className:`border-b border-stone-100 bg-[#f8fafc] px-3.5 py-2.5`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`需求`}),n?(0,I.jsx)(`button`,{type:`button`,className:`text-left text-sm font-semibold text-[#1f4fd8] hover:underline`,onClick:()=>n(e.title,e.storyIds),children:e.title}):(0,I.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title}),(0,I.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[e.points.length,` 条`]})]}),(0,I.jsx)(`div`,{className:`divide-y divide-stone-100`,children:e.dimensions.map(t=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${ht[t.key].accent}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:t.label}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:t.hint})]}),(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:t.points.length})]}),t.points.length?(0,I.jsx)(`ul`,{className:`border-t border-stone-50`,children:t.points.map(t=>(0,I.jsx)(`li`,{className:`border-t border-stone-50 first:border-t-0`,children:(0,I.jsxs)(`details`,{className:`group px-3.5 py-2 pl-8`,children:[(0,I.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,I.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,I.jsx)(y,{tone:St[t.priority].tone,children:t.priority})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block text-sm text-stone-800`,children:t.title}),n?(0,I.jsxs)(`button`,{type:`button`,className:`mt-0.5 block text-left text-xs text-[#3370ff] hover:underline`,onClick:t=>{t.preventDefault(),n(e.title,e.storyIds)},children:[`所属需求:`,e.title]}):(0,I.jsxs)(`span`,{className:`mt-0.5 block text-xs text-[#3370ff]`,children:[`所属需求:`,e.title]}),(0,I.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-xs text-stone-400`,children:[(0,I.jsxs)(`span`,{children:[t.steps.length,` 步`]}),t.supplemental?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,I.jsx)(`span`,{className:`text-amber-600`,children:`补充`})]}):null,t.expected?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,I.jsx)(_,{text:t.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,I.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,I.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,I.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,I.jsx)(Gt,{point:t})})]})},t.id))}):(0,I.jsx)(`p`,{className:`px-3.5 py-2 pl-8 text-[11px] text-stone-300`,children:`本维度没有测试点。`})]},t.key))})]},e.key))})}function Yt({doc:e,idealTitles:t=[],generating:n,busy:r,promptReady:i,onExportXmind:a,onExportMarkdown:c,onJumpToRequirement:l}){let[u,d]=(0,A.useState)(()=>o(Ht,Ut,`map`)),f=e.testPoints,p=yt(f),m=!!e.sourcePath&&t.length===0,h=(0,A.useMemo)(()=>m?0:st(e,t).length,[e,t,m]),g=e=>{d(e),s(Ht,e)};if(!f){let t=e.stories.length?i?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,I.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,I.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,I.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`按需求文档每一行整理标题,再按功能 / 边界值 / 异常 / 业务规则 / 非功能拆测试点;导图左右展开,可导出 XMind(向右逻辑图)与 Markdown。`}),t?(0,I.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:t}):null,(0,I.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:n?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.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,I.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`需求 `,(0,I.jsx)(`span`,{className:`font-medium text-stone-700`,children:h}),` · 测试点`,` `,(0,I.jsx)(`span`,{className:`font-medium text-stone-700`,children:p.total})]}),(0,I.jsx)(`span`,{className:`flex items-center gap-1`,children:ut.map(e=>(0,I.jsxs)(y,{tone:St[e].tone,children:[e,` `,p.byPriority[e]]},e))}),(0,I.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,p.coveredDimensions,`/5`]}),(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,I.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${u===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>g(e.id),children:e.label},e.id))}),(0,I.jsx)(`button`,{type:`button`,className:Wt,disabled:r,onClick:a,children:`导出 XMind`}),(0,I.jsx)(`button`,{type:`button`,className:Wt,disabled:r,onClick:c,children:`导出 Markdown`})]})]}),m?(0,I.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,I.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),`正在按需求文档行整理…`]}):u===`map`?(0,I.jsx)(qt,{doc:e,idealTitles:t,onJumpToRequirement:l}):(0,I.jsx)(Jt,{doc:e,idealTitles:t,onJumpToRequirement:l}),f.summary?(0,I.jsxs)(`details`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-stone-600`,children:`生成说明`}),(0,I.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed whitespace-pre-wrap text-stone-500`,children:f.summary})]}):null]})}var B=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],Xt=`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`,Zt=`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`,V=`text-xs font-semibold tracking-wide text-stone-500`,Qt=`text-[11px] font-medium tracking-wide text-stone-400`,$t={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function H({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,I.jsx)(`p`,{className:`${Qt} pt-0.5`,children:e}),(0,I.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function en(e){return e.split(`
10
+ `).map(e=>e.trim()).filter(Boolean)}function tn({label:e,value:t,placeholder:n,onChange:r}){return(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsxs)(`span`,{className:V,children:[e,`(一行一条)`]}),(0,I.jsx)(`textarea`,{className:`${Zt} mt-1 min-h-[64px]`,value:t.join(`
11
+ `),placeholder:n,onChange:e=>r(en(e.target.value))})]})}function nn({value:e,onChange:t}){return(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`主流程(一行一步:动作 -> 结果)`}),(0,I.jsx)(`textarea`,{className:`${Zt} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
12
+ `),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(en(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 rn({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
13
+ `)).join(`
14
+
15
+ `);return(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,I.jsx)(`textarea`,{className:`${Zt} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
16
+ 1. 提交后进入人工队列
17
+ 2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
18
+ `).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 an({value:e,onChange:t}){return(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`异常场景(一行一条:场景 -> 预期)`}),(0,I.jsx)(`textarea`,{className:`${Zt} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
19
+ `),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(en(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 on({value:e,onChange:t}){return(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`验收标准(一行一条:Given | When | Then)`}),(0,I.jsx)(`textarea`,{className:`${Zt} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
20
+ `),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(en(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function sn({story:e,index:t,total:n,gaps:r,outlineTitles:i,outlineOptions:a,completenessHints:o,busy:s,onSave:c,onDelete:l,onMove:u,onJumpOutline:d,domId:f}){let[p,m]=(0,A.useState)(!1),[h,g]=(0,A.useState)(!1),[_,ee]=(0,A.useState)(e),[b,te]=(0,A.useState)(!1);(0,A.useEffect)(()=>{if(p||h){te(!0);return}let e=window.setTimeout(()=>te(!1),200);return()=>window.clearTimeout(e)},[p,h]);let S=()=>{ee({...e}),g(!0),m(!0)},C=e=>ee(t=>({...t,...e})),w=r.filter(e=>e.severity===`high`).length;return(0,I.jsxs)(`li`,{id:f,className:`tw-req-card-bounce overflow-hidden rounded-xl border border-stone-200 bg-white ${p||h?`shadow-sm`:``}`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":p,"aria-label":p?`收起 ${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:()=>m(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m(e=>!e))},children:[(0,I.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${$t[e.priority]}`,"aria-hidden":`true`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,I.jsx)(y,{tone:qe[e.priority],children:e.priority}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,I.jsxs)(y,{tone:w?`red`:`amber`,children:[r.length,` 个待确认`,w?` · 高 ${w}`:``]}):null,o?.length?(0,I.jsxs)(y,{tone:`gray`,children:[`待补全 `,o.length]}):null]}),e.sourceRefs.length?(0,I.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.sourceRefs.map(e=>{let t=i?.get(e)??e;return(0,I.jsx)(`button`,{type:`button`,className:`rounded bg-[#eaf1ff] px-1.5 py-0.5 text-[11px] text-[#3370ff] hover:opacity-80`,onClick:t=>{t.stopPropagation(),d?.(e)},children:t},e)})}):null,(0,I.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(` · `)||`还没有写角色与目标`}),o?.length?(0,I.jsxs)(`p`,{className:`mt-1 text-[11px] text-amber-700`,children:[`待补全:`,o.map(e=>e.label).join(`、`)]}):null,p?null:(0,I.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,I.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:s||t===0,onClick:()=>u(-1),children:(0,I.jsx)(x,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,I.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:s||t>=n-1,onClick:()=>u(1),children:(0,I.jsx)(x,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,I.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":h?`取消编辑`:`编辑`,onClick:()=>h?g(!1):S(),children:(0,I.jsx)(x,{name:`pencil`,size:14})}),(0,I.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:s,onClick:l,children:(0,I.jsx)(x,{name:`trash`,size:14})}),(0,I.jsx)(x,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${p||h?`rotate-90`:``}`})]})]}),(0,I.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${p||h?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,I.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[b&&h?(0,I.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`标题`}),(0,I.jsx)(`input`,{className:`${Xt} mt-1`,value:_.title,onChange:e=>C({title:e.target.value})})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`角色`}),(0,I.jsx)(`input`,{className:`${Xt} mt-1`,value:_.role,onChange:e=>C({role:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`优先级`}),(0,I.jsx)(`div`,{className:`mt-1`,children:(0,I.jsx)(v,{options:B,value:_.priority,onChange:e=>C({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`目标`}),(0,I.jsx)(`input`,{className:`${Xt} mt-1`,value:_.goal,onChange:e=>C({goal:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`block`,children:[(0,I.jsx)(`span`,{className:V,children:`价值 / 备注`}),(0,I.jsx)(`input`,{className:`${Xt} mt-1`,value:_.value,onChange:e=>C({value:e.target.value})})]}),(0,I.jsx)(tn,{label:`前置条件`,value:_.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>C({preconditions:e})}),(0,I.jsx)(nn,{value:_.mainFlow,onChange:e=>C({mainFlow:e})}),(0,I.jsx)(rn,{value:_.altFlows,onChange:e=>C({altFlows:e})}),(0,I.jsx)(an,{value:_.exceptions,onChange:e=>C({exceptions:e})}),(0,I.jsx)(tn,{label:`后置条件`,value:_.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>C({postconditions:e})}),(0,I.jsx)(on,{value:_.acceptance,onChange:e=>C({acceptance:e})}),(0,I.jsx)(tn,{label:`覆盖维度`,value:_.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>C({dimensions:e})}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-stone-600`,children:`关联需求点`}),a?.length?(0,I.jsx)(`div`,{className:`flex max-h-40 flex-wrap gap-1.5 overflow-y-auto rounded-lg border border-stone-100 bg-white p-2`,children:a.filter(e=>e.kind||!a.some(t=>t.parentId===e.id)).map(e=>{let t=_.sourceRefs.includes(e.id),n=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``,r=i?.get(e.id)??e.title;return(0,I.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] ${t?`border-[#3370ff] bg-[#eaf1ff] text-[#3370ff]`:`border-stone-200 text-stone-600 hover:bg-stone-50`}`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`sr-only`,checked:t,onChange:()=>{let n=t?_.sourceRefs.filter(t=>t!==e.id):[..._.sourceRefs,e.id];C({sourceRefs:n})}}),n?(0,I.jsx)(`span`,{className:`opacity-70`,children:n}):null,(0,I.jsx)(`span`,{children:r})]},e.id)})}):(0,I.jsxs)(`p`,{className:`text-xs text-stone-400`,children:[`来源条目:`,_.sourceRefs.join(`、`)||`(未关联)`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.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:()=>g(!1),children:`取消`}),(0,I.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:s||!_.title.trim(),onClick:()=>{c(_),g(!1)},children:`保存`})]})]}):null,b&&!h?(0,I.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,I.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,I.jsx)(H,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,I.jsx)(H,{label:`前置条件`,children:(0,I.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,I.jsx)(H,{label:`主流程`,children:(0,I.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,I.jsxs)(`li`,{children:[e.actor?(0,I.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,I.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,I.jsx)(H,{label:`替代流程`,children:(0,I.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,I.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,I.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,I.jsx)(H,{label:`异常场景`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,I.jsxs)(`li`,{children:[e.scenario,e.expected?(0,I.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,I.jsx)(H,{label:`后置条件`,children:(0,I.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,I.jsx)(H,{label:`验收标准`,children:(0,I.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,I.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,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,I.jsx)(`span`,{children:e.given||`—`}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,I.jsx)(`span`,{children:e.when||`—`}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,I.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,I.jsx)(H,{label:`覆盖维度`,children:(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,I.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,I.jsx)(H,{label:`来源条目`,children:(0,I.jsx)(`div`,{className:`space-y-1.5`,children:e.sourceRefs.length?e.sourceRefs.map(e=>{let t=a?.find(t=>t.id===e),n=i?.get(e)??e,r=(t?.quote||t?.body||``).trim();return(0,I.jsxs)(`div`,{className:`rounded-md bg-white px-2 py-1.5 ring-1 ring-stone-100`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-left text-[11px] text-[#3370ff] hover:opacity-80`,onClick:()=>d?.(e),children:n}),r?(0,I.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-[11px] leading-relaxed text-stone-500`,children:r}):null]},e)}):(0,I.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,I.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,I.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,I.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,I.jsx)(y,{tone:O[e.severity],children:$e[e.severity]}),(0,I.jsx)(`span`,{className:`text-stone-500`,children:k[e.type]}),(0,I.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}function cn(e){if(!e.length)return`(尚未播种文档条目)`;let t=e.filter(e=>!e.parentId&&!e.kind),n=e.filter(e=>e.parentId);if(!t.length)return e.map(e=>{let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:`条目`;return`- ${e.id} [${t}] ${e.title}${e.quote?`(原文:${e.quote})`:``}`}).join(`
21
+ `);let r=[];for(let e of t){r.push(`- ${e.id} [文档条目] ${e.title}`),e.body?r.push(` 原文:${e.body.replace(/\s+/g,` `).slice(0,1500)}`):e.quote&&r.push(` 原文:${e.quote}`);let t=n.filter(t=>t.parentId===e.id);for(let e of t){let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:`子点`;r.push(` - ${e.id} [${t}] ${e.title}`)}t.length||r.push(` (尚无查询/修改子点:按原文能力点逐条用 req_set_outline 提交,同一父级可有多条 query/mutate,勿合并)`)}return r.join(`
22
+ `)}function ln(e){return e.length?e.map(e=>{let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:`条目`,n=(e.quote||e.body||``).replace(/\s+/g,` `).trim().slice(0,400);return`- ${e.id} [${t}] ${e.title}${n?`\n 原文:${n}`:``}`}).join(`
23
+ `):`(无)`}var un=`reqanalysis.doc`,dn=`reqanalysis.listmode`,fn=`reqanalysis.view`,pn=`reqanalysis.tab`,mn=`reqanalysis.promptCardOpen`,hn=`reqanalysis.storykeyword`,gn=[`list`,`work`],_n=[`outline`,`stories`,`check`,`points`],vn=`reqanalysis.activity`,yn=[`info`,`tool`,`done`,`error`,`stage`];function bn(e){return`${vn}.${e}`}function xn(e){if(!e)return[];let t=u(bn(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`&&yn.includes(t.kind)}).slice(-200):[]}var Sn=`reqanalysis.run`,Cn=[`decompose`,`stories`,`audit`,`fix`,`testpoints`,`change-point`],U=null,wn={current:null},Tn=new Set;function En(e){return`${Sn}.${e}`}function Dn(e){let t=e?.docId??U?.docId;U=e,t&&i(En(t),e);for(let t of Tn)t(e)}function On(e){return Tn.add(e),()=>{Tn.delete(e)}}function W(e,t){if(!U||U.status!==`running`)return;let n=Math.max(U.done,Math.max(0,Math.min(100,Math.round(e))));(n!==U.done||t!==void 0&&t!==U.message)&&Dn({...U,total:100,done:n,...t===void 0?{}:{message:t}})}var kn=96;function G(e,t=1){if(!U||U.status!==`running`)return;let n=Math.max(1,Math.min(kn,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;Dn({...U,total:100,done:Math.min(n,r+a)})}function An(e,t=1200){let n=0,r=window.setInterval(()=>{if(!U||U.status!==`running`)return;let t=Math.max(1,Math.min(kn,Math.round(e)))-U.done;t<=0||(n+=1,n%(t>40?1:t>24?2:t>12?3:t>5?5:8)==0&&G(e,1))},t);return()=>window.clearInterval(r)}function jn(e){if(!e)return null;let t=u(En(e),null);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.label!=`string`||typeof n.message!=`string`||!Cn.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 Mn={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},Nn=`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`,Pn=`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`,Fn=`text-xs font-semibold tracking-wide text-stone-500`,In=`rounded-xl border border-stone-200 bg-white`,Ln=`${In} tw-req-card-bounce`;function Rn(e){return e.split(`/`).pop()||e}function zn(e){return(e.format||Rn(e.path).split(`.`).pop()||``).toLowerCase()}function Bn(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 Vn(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 Hn(e){let t=Math.max(0,(Date.now()-e)/1e3);return t<10?`${t.toFixed(1)}s`:`${Math.round(t)}s`}function Un(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Wn({name:e,ready:t}){return(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(_,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Gn(){let e=ee(`reqAnalysis`),t=ee(`storyReview`),h=ee(`testPoints`),[T,ge]=(0,A.useState)(null),[E,ye]=(0,A.useState)([]),[O,qe]=(0,A.useState)(``),[k,$e]=(0,A.useState)(null),[st,lt]=(0,A.useState)([]),[ut,ht]=(0,A.useState)(``),[_t,vt]=(0,A.useState)(``),[yt,St]=(0,A.useState)(null),[Et,Dt]=(0,A.useState)(null),[Ot,j]=(0,A.useState)(null),[kt,At]=(0,A.useState)(null),[M,jt]=(0,A.useState)(()=>U);(0,A.useEffect)(()=>(jt(U),On(jt)),[]);let N=M?.status===`running`?M.kind:null,P=M?.status===`running`&&M.docId===O?{label:M.label,done:M.done,total:M.total,message:M.message}:null,F=M&&M.docId===O&&M.status!==`running`?M:null,[Pt,Lt]=(0,A.useState)([]),[Rt,L]=(0,A.useState)(``),[R,z]=(0,A.useState)(()=>o(pn,_n,`outline`));(0,A.useEffect)(()=>{s(pn,R)},[R]);let[zt,Vt]=(0,A.useState)(`list`),Ht=(0,A.useRef)(o(fn,gn,`list`)),[Ut,Wt]=(0,A.useState)(!0),[Gt,Kt]=(0,A.useState)(()=>o(dn,[`doc`,`story`],`doc`)),[qt,Jt]=(0,A.useState)(()=>c(hn,``));(0,A.useEffect)(()=>{l(hn,qt)},[qt]);let[B,Xt]=(0,A.useState)(null),[Zt,V]=(0,A.useState)([]),Qt=(0,A.useRef)(``),[$t,H]=(0,A.useState)(``),[en,tn]=(0,A.useState)([]),nn=(0,A.useRef)([]),[rn,an]=(0,A.useState)(!1),[on,vn]=(0,A.useState)(!1),[yn,Sn]=(0,A.useState)(!1),[Cn,Tn]=(0,A.useState)(!1),[kn,Gn]=(0,A.useState)(()=>c(mn,`1`)!==`0`),[Kn,qn]=(0,A.useState)(null),[Jn,Yn]=(0,A.useState)(``),[Xn,Zn]=(0,A.useState)(null),q=(0,A.useRef)(null),Qn=(0,A.useRef)(0),$n=(0,A.useRef)(null),er=(0,A.useRef)(null),tr=(0,A.useRef)(``),nr=(0,A.useRef)(async()=>void 0),rr=(0,A.useRef)(!0),ir=(0,A.useRef)(0),ar=(0,A.useRef)([]),or=(0,A.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?Ze[e]:Ze.decomposed,[t.on]),sr=(0,A.useMemo)(()=>{let e=e=>+!e.supported,t=e=>e.ctime||e.mtime||0;return[...st].filter(e=>!w(e.name)).sort((n,r)=>e(n)-e(r)||t(r)-t(n)||n.path.localeCompare(r.path,`zh`)).map(e=>{let t=zn(e),n=Mn[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[st]),J=(0,A.useCallback)(e=>{q.current=e,$e(e),ye(t=>Un(t.map(t=>t.id===e.id?e:t)))},[]),Y=(0,A.useCallback)((e,t=`info`,n)=>{Qn.current+=1,Lt(r=>[...r,{id:Qn.current,kind:t,text:e,detail:n?.trim()||void 0,at:new Date().toISOString()}])},[]),X=(0,A.useCallback)((e,t,n,r)=>{Dn({docId:q.current?.id??``,kind:e,label:t,done:0,total:100,message:r,startedAt:Date.now(),status:`running`})},[]),cr=(0,A.useCallback)(e=>{if(!U||U.status!==`running`)return;let t=e.done==null?U.done:Math.max(U.done,Math.max(0,Math.min(100,Math.round(e.done))));Dn({...U,...e,total:100,done:t})},[]),Z=(0,A.useCallback)((e,t,n)=>{U?.kind===e&&(wn.current=null,Dn({...U,status:t,done:t===`done`?100:U.done,total:100,message:n??U.message,finishedAt:Date.now()}))},[]);(0,A.useEffect)(()=>{O&&jt(U??jn(O))},[O]);let lr=(0,A.useCallback)(()=>{O&&i(En(O),null),Dn(null)},[O]),ur=(0,A.useRef)(!1);(0,A.useEffect)(()=>{if(!O){ur.current=!0,Lt([]);return}let e=xn(O);Qn.current=e.reduce((e,t)=>Math.max(e,t.id),0),ur.current=!0,Lt(e)},[O]),(0,A.useEffect)(()=>{ur.current?ur.current=!1:O&&i(bn(O),Pt.slice(-200))},[Pt,O]);let dr=(0,A.useCallback)((e,t)=>{let n=nn.current,r=n.length===t.length&&n.every((e,n)=>e===t[n]);nn.current=t,r||tn(t),e&&i(`reqanalysis.idealTitles.${e}`,t)},[]),fr=(0,A.useCallback)(e=>{if(q.current=e,$e(e),qe(e?.id??``),l(un,e?.id??``),e?.sourcePath&&ht(e.sourcePath),e?.id){let t=u(`reqanalysis.idealTitles.${e.id}`,[]),n=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];nn.current=n,tn(n)}else nn.current=[],tn([])},[]);(0,A.useEffect)(()=>{let e=k;if(!e?.id||tr.current===e.id)return;if(!e.outline.length||!e.stories.some(e=>!e.sourceRefs.length)){tr.current=e.id;return}let{stories:t,filled:n}=rt(e.stories,e.outline);if(tr.current=e.id,!n)return;let r=!1;return D(e.id,{stories:t}).then(e=>{r||(J(e),C(`已自动挂上 ${n} 条需求点`,`success`))}).catch(()=>void 0),()=>{r=!0}},[k,J]),(0,A.useEffect)(()=>{let e=k;if(!e?.id||e.priorMemoryDocIds!==void 0||!E.length)return;let t=He(e,E).map(e=>e.id),n=!1;return D(e.id,{priorMemoryDocIds:t}).then(e=>{n||J(e)}).catch(()=>void 0),()=>{n=!0}},[k,E,J]);let pr=(0,A.useMemo)(()=>k?He(k,E):[],[k,E]),mr=(0,A.useMemo)(()=>pr.map(e=>({value:e.id,label:Oe(e)})),[pr]),hr=(0,A.useCallback)(e=>{let t=q.current;if(!t?.priorMemoryDocIds?.length)return``;let n=ke(t.priorMemoryDocIds,E);if(!n.length)return``;let r=be(e,Le(n));if(!r.length)return``;let i=new Set(r.map(e=>e.docId)).size;return Y(`历史记忆命中 ${r.length} 条(来自 ${i} 版)`),le(r)},[E,Y]),gr=(0,A.useCallback)(e=>{Vt(e),s(fn,e)},[]),_r=(0,A.useCallback)(async e=>{if(!e?.sourcePath)return dr(``,[]),[];try{let t=await Ee(e.sourcePath),n=Ae(t);return dr(e.id,n),n}catch{return dr(e.id,nn.current),nn.current}},[dr]),vr=(0,A.useCallback)(async e=>{try{let t=await Ee(e.sourcePath),n=Ae(t);return dr(e.id,n),e}catch{return e}},[dr]),yr=(0,A.useCallback)((e,t=`outline`)=>{fr(e),z(t),gr(`work`),wt(`req-analysis`),vr(e)},[gr,fr,vr]),br=(0,A.useCallback)((e,t)=>{Qt.current=t,yr(e,`stories`)},[yr]);(0,A.useEffect)(()=>{if(zt!==`work`||!Qt.current)return;let e=Qt.current;Qt.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)}},[zt,k?.id]);let xr=(0,A.useMemo)(()=>E.map(e=>{let t=or(e.status),n=e.outline.filter(e=>!e.kind&&!e.parentId).length;return{value:e.id,label:De(e),secondary:`${t.label} · ${n||e.outline.length} 条目 · ${e.stories.length} 故事`}}),[E,or]),Sr=(0,A.useMemo)(()=>E.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[E]),Cr=Sr.length,wr=(0,A.useMemo)(()=>{let e=qt.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?Sr.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(De(e))||t(e.title)):Sr,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))},[Sr,qt]),Tr=(0,A.useMemo)(()=>new Set(B?.ids??[]),[B]),Er=(0,A.useCallback)((e,t)=>{Xt(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})},[]),Dr=(0,A.useCallback)((e,t)=>{Xt(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Or=(0,A.useCallback)(e=>{Kt(e),s(dn,e)},[]);(0,A.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;St(ie());let t=await it();if(e){if(ge(t),!t)Wt(!1);else try{let[t,n,r,i]=await Promise.all([_e(),Ne(),ct(),ft()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await Me(!0).catch(()=>void 0),a=await Ne()),!e)return;Dt(a);let o=r;if((!r.exists||!r.review.trim())&&(await xt(!0).catch(()=>void 0),o=await ct()),!e)return;o.exists&&j(o),i.exists&&At(i);let s=Un(t);ye(s);let l=c(un,``),u=s.find(e=>e.id===l)??s[0]??null;fr(u);let d=Ht.current;if(Ht.current=`list`,d===`work`&&u&&l&&u.id===l&&(gr(`work`),wt(`req-analysis`)),u&&await vr(u),!e)return;Wt(!1)}catch(t){e&&(Wt(!1),L(t instanceof Error?t.message:String(t)))}}})();let t=re(()=>St(ie()));return()=>{e=!1,t()}},[gr,fr,vr]),(0,A.useEffect)(()=>{if(!t.ready)return;if(!t.on){j(null),z(e=>e===`check`?`stories`:e);return}if(!T||Ot!==null)return;let e=!0;return(async()=>{let t=await ct();(!t.exists||!t.review.trim())&&(await xt(!0).catch(()=>void 0),t=await ct()),e&&j(t)})(),()=>{e=!1}},[t.ready,t.on,T,Ot]),(0,A.useEffect)(()=>{R===`points`&&k?.sourcePath&&(nn.current.length||_r(k))},[R,k,_r]),(0,A.useEffect)(()=>{if(!h.ready)return;if(!h.on){At(null),z(e=>e===`points`?`stories`:e);return}if(!T||kt!==null)return;let e=!0;return(async()=>{let t=await ft();(!t.exists||!t.generate.trim())&&(await Ct(!0).catch(()=>void 0),t=await ft()),e&&At(t)})(),()=>{e=!1}},[h.ready,h.on,T,kt]),(0,A.useEffect)(()=>{if(!T)return;let e=!0;return ve().then(t=>{e&&lt(t)}).catch(t=>{e&&vt(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[T]),(0,A.useEffect)(()=>{let e=k?.sourcePath;if(!e){H(``);return}let t=!0;return Ee(e).then(e=>{t&&H(et(e))}).catch(()=>{t&&H(``)}),()=>{t=!1}},[k?.sourcePath,k?.sourceHash]),(0,A.useEffect)(()=>{let e=$n.current;e&&(e.scrollTop=e.scrollHeight)},[Pt]);let kr=!!(k?.sourceHash&&$t&&k.sourceHash!==$t),Ar=(0,A.useMemo)(()=>new Set((k?.stories??[]).flatMap(e=>e.sourceRefs)),[k?.stories]),Q=Et??null,jr=!!Q?.decompose.trim(),Mr=!!(Q?.stories||Q?.decompose||``).trim(),Nr=jr||Mr,Pr=(0,A.useMemo)(()=>(k?.check?.gaps??[]).filter(e=>e.selected).length,[k?.check]),Fr=(0,A.useMemo)(()=>Se(se(k?.check?.gaps??[]),k?.ignoredGaps),[k?.check?.gaps,k?.ignoredGaps]),Ir=(0,A.useMemo)(()=>fe(k?.outline??[]),[k?.outline]),Lr=(0,A.useMemo)(()=>oe(k?.outline??[]),[k?.outline]),Rr=(0,A.useMemo)(()=>k?Ue(k.outline,k.stories):[],[k]),zr=(0,A.useMemo)(()=>k?Ie(k.stories,k.outline):[],[k]),[Br,Vr]=(0,A.useState)({}),[Hr,Ur]=(0,A.useState)({}),Wr=k?.ignoredGaps??[],Gr=(0,A.useCallback)(e=>{let t=q.current;if(!t)return;let n=t.outline.find(t=>t.id===e),r=n?.parentId||e,i=n?.parentId?e:``;z(`outline`),Vr(e=>({...e,[r]:!0})),i&&Ur(e=>({...e,[i]:!0})),requestAnimationFrame(()=>{(i&&document.getElementById(`req-outline-point-${i}`)||document.getElementById(`req-outline-${r}`))?.scrollIntoView({behavior:`smooth`,block:`nearest`})})},[]),Kr=(0,A.useCallback)((e,t=[])=>{let n=q.current;if(!n||!e.trim())return;let r=e.trim(),i=new Set(n.stories.filter(e=>t.includes(e.id)).flatMap(e=>e.sourceRefs)),a=n.outline.find(e=>e.parentId&&e.kind&&i.has(e.id));if(a){Gr(a.id);return}let o=n.outline.find(e=>!e.parentId&&!e.kind&&(e.title===r||e.title.includes(r)||r.includes(e.title)))??n.outline.find(e=>e.parentId&&e.kind&&(e.title===r||e.title.includes(r)||r.includes(e.title)));o?Gr(o.id):(z(`outline`),C(`需求条目里没找到对应项`,`info`))},[Gr]),qr=(0,A.useCallback)(async e=>{let t=q.current;if(!t?.check||!e.length)return;let n=t.check.gaps.filter(t=>e.includes(t.id));if(!n.length)return;let r=new Date().toISOString(),i=[...t.ignoredGaps??[],...n.map(e=>({...e,selected:!1,ignoredAt:r}))],a=t.check.gaps.filter(t=>!e.includes(t.id)),o=await D(t.id,{check:{...t.check,gaps:a},ignoredGaps:i});J(o),C(`已忽略 ${n.length} 项`,`success`)},[J]),Jr=(0,A.useCallback)(async e=>{let t=q.current;if(!t)return;let n=(t.ignoredGaps??[]).find(t=>t.id===e);if(!n)return;let{ignoredAt:r,...i}=n,a=(t.ignoredGaps??[]).filter(t=>t.id!==e),o=[...t.check?.gaps??[],{...i,selected:!1}],s=await D(t.id,{check:t.check?{...t.check,gaps:o}:{at:new Date().toISOString(),summary:``,coverage:{total:0,covered:0,rate:0},dimensions:[],gaps:o},ignoredGaps:a});J(s),C(`已恢复到待确认清单`,`success`)},[J]),Yr=(0,A.useCallback)(async e=>{let t=q.current;if(!t)return;let n=(t.ignoredGaps??[]).find(t=>t.id===e);if(!n)return;let r=window.prompt(`落成用户故事:请输入故事标题`,n.title.replace(/^待确认[::]/,``))||``;if(!r.trim())return;let i={id:``,title:r.trim(),role:`待确认`,goal:n.suggestion||n.detail||r.trim(),value:`由忽略项落成,请补全字段`,sourceRefs:n.outlineId?[n.outlineId]:[],priority:`P1`,preconditions:[],mainFlow:[{action:`按待确认项补齐主流程`,result:`可验收`}],altFlows:[],exceptions:[],postconditions:[],acceptance:[{given:`前置就绪`,when:`执行操作`,then:`结果可判定`}],dimensions:[]},a=pe(t.stories,[i]),o=(t.ignoredGaps??[]).filter(t=>t.id!==e),s=await D(t.id,{stories:a,ignoredGaps:o,status:t.status===`draft`?`decomposed`:t.status});J(s),z(`stories`),C(`已落成用户故事`,`success`)},[J]),Xr=(0,A.useCallback)(async(e,t)=>{let n=q.current;if(!n?.check)return;let r=t.trim();if(!r)return;let i=n.check.gaps.map(t=>t.id===e.id?{...t,conclusion:r}:t),a=await D(n.id,{check:{...n.check,gaps:i}});J(a),C(`结论已保存`,`success`)},[J]),Zr=(0,A.useCallback)(async(e,t)=>{let n=t??q.current;if(!n)throw Error(`还没有分析文档`);let r=await D(n.id,e);return J(r),r},[J]),Qr=(0,A.useCallback)(()=>{er.current&&window.clearTimeout(er.current),er.current=window.setTimeout(()=>{let e=q.current;e?.check&&D(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),$r=(0,A.useCallback)(async e=>{if(!e)return null;let t=E.find(t=>t.sourcePath===e);if(t)return yr(t,`outline`),t;try{let t=await Ee(e),n=Rn(e),r=await Ye({sourcePath:e,sourceTitle:n,sourceHash:et(t),title:n});return ye(e=>Un([r,...e])),yr(r,`outline`),Y(`新建分析:${De(r)}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),C(t,`error`),ht(q.current?.sourcePath??``),null}},[E,yr,Y]),ei=!!(yt?.baseURL&&yt.apiKey&&yt.model),ti=(0,A.useCallback)(()=>!ei||!yt?(C(`请先在设置里配置模型`,`error`),ne(`model`),null):yt,[ei,yt]),$=(0,A.useCallback)((e,t)=>({getDoc:()=>q.current,batch:t,saveOutline:async t=>{let n=await D(e.id,{outline:t});return J(n),n.outline},saveStories:async t=>{let n=await D(e.id,{stories:t});return J(n),Y(`已写入 ${n.stories.length} 个用户故事`),n},saveIgnoredGaps:async t=>{let n=await D(e.id,{ignoredGaps:t});return J(n),n},saveCheck:async t=>{let n=q.current,r=ar.current.length>0?ar.current:n?.check?.gaps??[],i=he(r,t.gaps,n?.ignoredGaps,{allowNew:rr.current});ir.current+=i.suppressed;let a={...t,gaps:i.gaps},o=await D(e.id,{check:a});return J(o),o},saveTestPoints:async t=>{let n=await D(e.id,{testPoints:t});return J(n),n}}),[J,Y]),ni=(0,A.useCallback)(async()=>{let e=q.current,t=ti();if(!e||!t)return;let n=Q?.decompose.trim()??``;if(!n){C(`没有读到「${je}」的「## 拆解需求」段落`,`error`);return}L(``),Y(`开始拆解需求`,`stage`),X(`decompose`,`拆解需求`,100,`正在读取来源文档`);let r=new AbortController;wn.current=r;let i=`done`;try{let i=await D(e.id,{status:`draft`,progress:{stage:`outline`,done:0,total:100,message:`正在读取来源文档`,at:new Date().toISOString()}});J(i);let a=await Ee(e.sourcePath);if(!a.trim())throw Error(`来源文档是空的`);let o=Ke(a);if(!o.length)throw Error(`来源文档没有可拆解的内容`);W(5,`共 ${o.length} 批,准备整理需求条目`),Y(o.length>1?`来源 ${a.length} 字,已分 ${o.length} 批整理条目`:`来源 ${a.length} 字,单批整理条目`);let s=ae(a,[]),c=await D(e.id,{replaceStories:!0,stories:[],outline:s,check:null,ignoredGaps:[],testPoints:null,status:`draft`,sourceHash:et(a)});J(c),Y(s.length?`已按文档结构播种 ${s.length} 条需求条目`:`未能从文档结构抽出条目,将仅按原文整理`);let l=ce(a);z(`outline`);let u=[];for(let i of o){if(r.signal.aborted)break;let s=q.current?.outline.length??0,c=cn(q.current?.outline??[]),d=hr(i.text),f=Q?.structure.trim()??``,p=[n,``,Tt,d?`\n${d}`:``,``,`## 需求条目(文档结构已播种;用 req_set_outline 按能力点补查询/修改子点,同一父级可多条 query/mutate,本步不要写用户故事)`,c,``,`## 原文结构`,f||`把本段原文按大类和需求标题分组。category、title、body 必须是原文原句,不要改写。`,`同一轮再调用一次 req_set_source_export。body 给标题下的整段原文,不要自行拆步骤或抽出需求编号。`].filter(Boolean).join(`
24
+ `),m=[`这一批是原始需求的第 ${i.index+1}/${o.length} 段${i.title?`(章节:${i.title})`:``}。整理这一段的查/改子点,并提交原文分组:一个可独立验收的能力点交一条,勿把多个能力点捆进同一 title;不要另造文档没有的条目标题;不要写用户故事。原文分组的句子必须来自这一段。`,``,l?`${l}\n`:``,`## 原始需求`,``,i.text].filter(Boolean).join(`
25
+ `),h=5+Math.floor(i.index/o.length*85),g=5+Math.floor((i.index+1)/o.length*85),_=i.index===o.length-1,v=Math.max(h+1,_?Math.min(90,g):Math.min(g-2,88));await Zr({progress:{stage:`outline`,done:h,total:100,message:`正在整理第 ${i.index+1}/${o.length} 批条目`,at:new Date().toISOString()}},q.current).catch(()=>void 0);let ee=Date.now();Y(`第 ${i.index+1}/${o.length} 批开始(拆解需求)`,`info`,[i.title?`章节:${i.title}`:``,`${i.text.length} 字`].filter(Boolean).join(` · `)),W(h,`正在整理第 ${i.index+1}/${o.length} 批条目`);let y=An(v),b=``,te=u.length;try{for await(let n of at(t,[{role:`system`,content:p},{role:`user`,content:m}],r.signal,{tools:Mt.filter(e=>e.function.name===`req_set_outline`||e.function.name===`req_set_source_export`),maxToolRounds:20,runTool:(t,n)=>{if(t===`req_set_source_export`){let e=null;try{e=JSON.parse(n||`{}`)}catch{e=null}let t=We(a,e);return t?.length&&u.push(t),JSON.stringify({ok:!!t?.length,groups:t?.length??0,note:t?.length?`原文分组已收下`:`句子对不上原文,这一批没有写入结构`})}return Nt(t,n,$(e,i.index))}}))n.type===`content`?(b+=n.delta,G(v,1)):n.type===`tool`&&n.status===`running`?(Y(`调用 ${n.name}`,`tool`,K(n.args)),G(v,1)):n.type===`tool`&&n.status===`done`&&(Y(`${n.name} 返回`,`tool`,K(n.result,120)),G(v,2))}finally{y()}if(u.length===te){let e=We(a,we(b));e?.length&&u.push(e)}W(Math.min(90,Math.max(v+2,g-2)),`第 ${i.index+1}/${o.length} 批返回,正在写入`);let x=Math.max(0,(q.current?.outline.length??0)-s);Y(`第 ${i.index+1}/${o.length} 批完成`,`done`,`条目变化 +${x} · 耗时 ${Hn(ee)}`),W(g,`第 ${i.index+1}/${o.length} 批已写入`)}if(r.signal.aborted){Y(`已中断:已经写入的需求条目保留`,`info`);return}W(92,`正在保存需求条目`);let d=ue(u),f=await D(e.id,{status:`decomposed`,...d.length?{sourceExport:{at:new Date().toISOString(),groups:d}}:{},progress:{stage:`done`,done:100,total:100,message:`需求条目已整理`,at:new Date().toISOString()}});if(J(f),Y(`拆解需求完成:${f.outline.length} 条需求条目`,`done`),d.length){let e=d.reduce((e,t)=>e+t.items.length,0);Y(`原文结构已一并整理:${d.length} 个大类,${e} 条`,`done`)}z(`outline`),W(100,`需求条目已整理`),C(`需求条目已整理,可继续生成用户故事`,`success`)}catch(t){let n=t instanceof Error?t.message:String(t);r.signal.aborted?(i=`stopped`,Y(`已中断:已经写入的需求条目保留`,`info`)):(i=`error`,L(n),Y(`拆解需求失败:${n}`,`error`),await D(e.id,{status:`draft`}).then(e=>J(e)).catch(()=>void 0))}finally{r.signal.aborted&&(i=`stopped`),Z(`decompose`,i,i===`done`?`需求条目已整理`:i===`stopped`?`已中断:已经写入的需求条目保留`:`拆解需求失败,详见活动日志`)}},[X,hr,Z,$,J,Y,Q,ti,Zr]),ri=(0,A.useCallback)((e,t)=>{if(!e.parentId||!e.kind)return;qn({pointId:e.id,parentId:t.id});let n=Te(e,t,[]);Yn(e.body||e.quote||n.text||``)},[]),ii=(0,A.useCallback)(async(e,t,n,r=new Set)=>{let i=Xe({stories:e.stories,check:e.check,ignoredGaps:e.ignoredGaps},n,r),a=await D(e.id,{outline:t,stories:i.stories,check:i.check,ignoredGaps:i.ignoredGaps});return J(a),a},[J]),ai=(0,A.useCallback)(async()=>{let e=q.current,t=Xn;if(!e||!t)return;let n=me(e.outline,t);n.error?(C(n.error,`error`),Zn(null)):(await ii(e,n.outline,n.idMap,n.removedIds),Y(`已删除需求点 ${t},同父级序号已顺延`,`done`),Zn(null),qn(null),C(`需求点已删除`,`success`))},[Xn,ii,Y]),oi=(0,A.useCallback)(async()=>{let e=q.current,t=ti();if(!e||!t||!Kn)return;let n=Jn.trim();if(!n){C(`请填写需求内容`,`error`);return}let r=Q?.decompose.trim()??``;if(!r){C(`没有读到「${je}」的「## 拆解需求」段落`,`error`);return}let i=e.outline.find(e=>e.id===Kn.pointId),a=e.outline.find(e=>e.id===Kn.parentId);if(!i?.parentId||!a){C(`找不到锚点需求点`,`error`);return}let o=Kn.pointId,s=Qe(e.outline,o,{quote:n.slice(0,2e3),body:n});if(s.error){C(s.error,`error`);return}let c=await D(e.id,{outline:s.outline});J(c),qn(null),Yn(``),L(``),Y(`已写入需求点原文 ${o}`,`done`),Y(`变更需求点 ${o}(模型整理)`,`stage`),X(`change-point`,`变更需求点`,100,`正在根据需求内容整理子点`);let l=new AbortController;wn.current=l;let u=`done`;try{let e=cn(c.outline),s=[r,``,Tt,``,`## 本轮任务`,`锚点 ${o} 的原文已按用户内容写入。请继续:`,`- 若标题或类型(查询/修改)需随内容调整:调用 req_update_outline_point(id 固定为 ${o});原文 quote/body 以用户内容为准,不要擅自删减用户已写的条目;`,`- 若用户内容里还含有其它独立能力点:调用 req_insert_outline_after,afterId 固定为 ${o},插到锚点下方;`,`- 若只需保留当前锚点、无需新增:可以不调工具,直接简短说明即可。`,`不要改其它无关子点,不要写用户故事,不要调用 req_set_outline。`,``,`## 需求条目`,e].join(`
26
+ `),u=[`锚点子点:${o} ${i.title}(${i.kind===`mutate`?`修改`:`查询`})`,`已写入原文:${n.slice(0,2e3)}`,`所属条目:${a.id} ${a.title}`,a.body||a.quote?`\n## 条目原文(参考)\n\n${(a.body||a.quote).slice(0,4e3)}`:``,``,`## 用户需求内容`,``,n].filter(Boolean).join(`
27
+ `);W(10,`正在整理需求点`);for await(let e of at(t,[{role:`system`,content:s},{role:`user`,content:u}],l.signal,{tools:Mt.filter(e=>e.function.name===`req_insert_outline_after`||e.function.name===`req_update_outline_point`),maxToolRounds:8,runTool:(e,t)=>Nt(e,t,$(c,0))}))e.type===`content`?G(90,1):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),G(90,1)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),G(90,2));if(l.signal.aborted){Y(`已中断:已写入的需求点保留`,`info`);return}W(100,`需求点已更新`),Y(`已变更需求点 ${o}`,`done`),C(`需求点已更新`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);l.signal.aborted?(u=`stopped`,Y(`已中断:已写入的需求点保留`,`info`)):(u=`error`,L(t),Y(`变更需求点失败:${t}`,`error`))}finally{l.signal.aborted&&(u=`stopped`),Z(`change-point`,u,u===`done`?`需求点已更新`:u===`stopped`?`已中断:已写入的需求点保留`:`变更需求点失败`)}},[X,Jn,Kn,Z,$,J,Y,Q,ti]),si=(0,A.useCallback)(async()=>{let e=q.current,n=ti();if(!e||!n)return;if(!e.outline.length){C(`还没有需求条目,请先点「拆解需求」`,`info`);return}if(e.status===`draft`){C(`请先成功拆解需求,再生成用户故事`,`info`);return}let r=(Q?.stories||Q?.decompose||``).trim();if(!r){C(`没有读到「${je}」的「## 生成用户故事」段落`,`error`);return}if(!xe(e.outline).length){C(`还没有可挂故事的需求点,请先拆解出查询/修改子点`,`info`);return}L(``),Y(`开始生成用户故事`,`stage`),X(`stories`,`生成用户故事`,100,`正在按需求点生成`);let i=new AbortController;wn.current=i;let a=`done`,o=async t=>{let a=q.current?.stories.length??0,o=cn(q.current?.outline??[]),s=hr(t.user),c=[r,``,Tt,s?`\n${s}`:``,``,`## 需求条目(sourceRefs 只能引用这些 id;本步只用 req_set_stories,不要改条目)`,o].filter(Boolean).join(`
28
+ `);W(Math.min(t.softCap,Math.max(5,t.floor??Math.max(5,t.softCap-2))),t.progressMsg);let l=An(t.softCap),u=``;try{for await(let r of at(n,[{role:`system`,content:c},{role:`user`,content:t.user}],i.signal,{tools:Mt.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:20,runTool:(n,r)=>Nt(n,r,$(e,t.batchIndex))}))r.type===`content`?(u+=r.delta,G(t.softCap,1)):r.type===`tool`&&r.status===`running`?(Y(`调用 ${r.name}`,`tool`,K(r.args)),G(t.softCap,1)):r.type===`tool`&&r.status===`done`&&(Y(`${r.name} 返回`,`tool`,K(r.result,120)),G(t.softCap,2))}finally{l()}if((q.current?.stories.length??0)===a){let n=Ft(u);if(n.length){let t=pe(q.current?.stories??[],n),r=await D(e.id,{stories:t});J(r),Y(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else Y(`${t.label}没有拿到结构化故事`,`error`)}return Math.max(0,(q.current?.stories.length??0)-a)};try{let t=await D(e.id,{progress:{stage:`stories`,done:0,total:100,message:`正在按需求点生成用户故事`,at:new Date().toISOString()}});J(t);let n=await Ee(e.sourcePath);if(!n.trim())throw Error(`来源文档是空的`);let r=await D(e.id,{replaceStories:!0,stories:[],check:null,ignoredGaps:[],testPoints:null,status:`decomposed`});J(r);let a=Fe(r.outline,12);Y(`按需求点生成:${xe(r.outline).length} 个覆盖目标 · ${a.length} 批`),z(`stories`),W(5,`共 ${a.length} 批,按需求点生成`);for(let e=0;e<a.length&&!i.signal.aborted;e++){let t=a[e],n=5+Math.floor(e/Math.max(1,a.length)*70),r=5+Math.floor((e+1)/Math.max(1,a.length)*70),i=Math.max(n+1,Math.min(r-1,74)),s=t.parent?`${t.parent.id} ${t.parent.title}`:`其它需求点`,c=t.mustCover.map(e=>e.id).join(`、`);await Zr({progress:{stage:`stories`,done:n,total:100,message:`正在生成第 ${e+1}/${a.length} 批(${s})`,at:new Date().toISOString()}},q.current).catch(()=>void 0);let l=Date.now();Y(`第 ${e+1}/${a.length} 批开始`,`info`,`${s} · 须挂 ${t.mustCover.length} 个点`);let u=(t.parent?.body||t.parent?.quote||``).trim(),d=[`按需求点生成用户故事:第 ${e+1}/${a.length} 批。`,`所属条目:${s}`,``,`## 本批必须挂上的需求点(每个 id 至少出现在一条故事的 sourceRefs 里;可多点并一条故事,不得漏 id)`,ln(t.mustCover),``,`必须覆盖的 id:${c}`,u?`\n## 条目原文(依据)\n\n${u.slice(0,6e3)}`:``].filter(Boolean).join(`
29
+ `),f=await o({label:`第 ${e+1} 批`,user:d,batchIndex:e,softCap:i,floor:n,progressMsg:`正在生成第 ${e+1}/${a.length} 批故事`});Y(`第 ${e+1}/${a.length} 批完成`,`done`,`故事变化 +${f} · 耗时 ${Hn(l)}`),W(r,`第 ${e+1}/${a.length} 批已写入`)}if(i.signal.aborted){Y(`已中断:已经写入的故事保留`,`info`);return}let s=Je(q.current?.outline??[],q.current?.stories??[]);s.length&&(Y(`补挂未覆盖需求点 ${s.length} 个`,`stage`),W(76,`正在补挂 ${s.length} 个未覆盖需求点`),await o({label:`补挂未覆盖`,user:[`以下查改子点尚未被任何故事的 sourceRefs 引用。请用 req_set_stories 为每个 id 新建故事或并入已有故事(补写带原 id),不得漏 id;不要改需求条目。`,``,`## 未挂上的需求点`,ln(s),``,`必须覆盖的 id:${s.map(e=>e.id).join(`、`)}`].join(`
30
+ `),batchIndex:90,softCap:84,floor:76,progressMsg:`正在补挂未覆盖需求点`}),s=Je(q.current?.outline??[],q.current?.stories??[]));let c=Ke(n),l=c.length?c:[{index:0,title:``,text:n}];Y(`二次卡控:对照原始需求查漏`,`stage`);for(let e=0;e<l.length&&!i.signal.aborted;e++){let t=l[e],r=85+Math.floor(e/Math.max(1,l.length)*10),i=Math.min(94,r+3),a=(q.current?.stories??[]).map(e=>`- ${e.id||`(新)`} ${e.title} · refs=${e.sourceRefs.join(`、`)||`无`}`).join(`
31
+ `);W(r,`原文卡控 ${e+1}/${l.length}${t.title?`(${t.title})`:``}`),Y(`原文卡控第 ${e+1}/${l.length} 段`,`info`,t.title||`${t.text.length} 字`),await o({label:`原文卡控 ${e+1}`,user:[`二次卡控:对照本段原始需求,找出原文里有、但当前故事尚未覆盖的能力。`,`有则用 req_set_stories 补故事或并入已有故事的 sourceRefs(能对上的挂真实子点 id);对不上条目的写进回答「待确认」,不要调用 req_set_outline、不要另造条目标题。`,``,`## 当前用户故事(摘要)`,a||`(尚无故事)`,``,ce(n)?`${ce(n)}\n`:``,`## 原始需求(第 ${t.index+1}/${l.length} 段${t.title?` · ${t.title}`:``})`,``,t.text].filter(Boolean).join(`
32
+ `),batchIndex:91+e,softCap:i,floor:r,progressMsg:`原文卡控 ${e+1}/${l.length}`})}if(i.signal.aborted){Y(`已中断:已经写入的故事保留`,`info`);return}s=Je(q.current?.outline??[],q.current?.stories??[]),W(96,`正在保存用户故事`);let u=await D(e.id,{status:`decomposed`,progress:{stage:`done`,done:100,total:100,message:`用户故事已生成`,at:new Date().toISOString()}});J(u);let d=xe(u.outline).length-s.length,f=xe(u.outline).length;if(Y(`生成用户故事完成:${u.stories.length} 个故事 · 需求点 ${d}/${f} 已挂`,`done`),z(`stories`),W(100,`用户故事已生成`),s.length){let e=s.map(e=>e.id).join(`、`);Y(`仍有 ${s.length} 个需求点未挂:${e}`,`info`),C(`用户故事已生成,仍有 ${s.length} 个需求点未挂`,`info`)}else C(`用户故事已生成,需求点已挂全`,`success`)}catch(t){let n=t instanceof Error?t.message:String(t);i.signal.aborted?(a=`stopped`,Y(`已中断:已经写入的故事保留`,`info`)):(a=`error`,L(n),Y(`生成用户故事失败:${n}`,`error`),await D(e.id,{replaceStories:!0,stories:[],check:null,ignoredGaps:[],testPoints:null,status:`decomposed`}).then(e=>J(e)).catch(()=>void 0))}finally{i.signal.aborted&&(a=`stopped`),Z(`stories`,a,a===`done`?`用户故事已生成`:a===`stopped`?`已中断:已经写入的故事保留`:`生成用户故事失败,详见活动日志`)}a===`done`&&t.on&&!i.signal.aborted&&(q.current?.stories.length??0)>0&&await nr.current({auto:!0})},[X,hr,Z,$,J,Y,Q,ti,t.on,Zr]),ci=(0,A.useCallback)(async(e=!1)=>{let t=typeof e==`boolean`?e:!!e.auto,n=typeof e==`object`&&!!e.fullScan,r=q.current;if(!r)return;if(!r.stories.length||r.status===`draft`){t||C(`请先成功生成用户故事,再审查`,`info`);return}let i=(r.check?.gaps?.length??0)>0||(r.ignoredGaps?.length??0)>0,a=n||!i;rr.current=a,ir.current=0;let o=se(r.check?.gaps??[]);ar.current=o,L(``),Y(t?`继续审查用户故事`:n?`开始全量扫描用户故事`:a?`开始审查用户故事`:`开始复审用户故事`,`stage`,t?`生成用户故事后自动接续`:a?`全量检查,可发现新待确认`:`只刷新上轮清单,不新增待确认`),t&&z(`check`),X(`audit`,a?`审查用户故事`:`复审用户故事`,100,`正在跑规则体检`);let s=new AbortController;wn.current=s;let c={status:`done`,message:`审查完成`};try{let e=Date.now();W(8,`正在跑规则体检`);let t=tt(r),i=he(o.filter(e=>e.type===`uncovered-outline`),se(t.gaps),r.ignoredGaps,{allowNew:!0}),l=[...o.filter(e=>e.type!==`uncovered-outline`),...i.gaps],u=await D(r.id,{check:{...t,gaps:l},progress:{stage:`audit`,done:18,total:100,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});J(u),Y(`规则体检:覆盖率 ${Math.round(t.coverage.rate*100)}%,${l.length} 项待确认`,`info`,`${r.outline.length} 条需求条目 · ${r.stories.length} 个故事 · 耗时 ${Hn(e)}`),W(18,`规则体检完成,等待模型评审`);let d=Ot?.review.trim()??``,f=ei?yt:null;if(!f||!d){Y(f?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),c.message=`没有配置模型,只保留规则结果`,await D(r.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:c.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),z(`check`);return}let p=!1,m=$(r,90),h=m.saveCheck;m.saveCheck=async e=>{p=!0,W(96,`正在写入审查结果`);let t={...e,gaps:se(e.gaps)},n=await h(t);return Y(`模型体检:${n.check?.gaps.length??0} 项待确认`,`done`),n};let g=q.current??u,_=await de(g.sourcePath);_.text||Y(`没有读到原始需求,只能依据需求条目摘句审查`,`info`),Y(`提交模型审查`,`tool`,`模型 ${f.model} · ${g.stories.length} 个故事 · 原文 ${_.text.length} 字`),W(22,`正在提交模型审查`);let v=nt({pending:Se(o,g.ignoredGaps),ignored:g.ignoredGaps??[]}),ee=[`## 原始需求`,_.text?_.truncated?`${_.text}\n\n(原文共 ${_.total} 字,以上为前 ${_.text.length} 字,没看到的部分不要猜)`:_.text:`(未读到原始需求,只能依据下面的需求条目摘句判断)`,``,`## 需求条目`,g.outline.length?g.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
33
+ `):`(无)`,``,`## 用户故事(${g.stories.length} 条)`,"```json",JSON.stringify(g.stories,null,2),"```",...v?[``,v]:[]].join(`
34
+ `),y=An(90);try{for await(let e of at(f,[{role:`system`,content:`${d}\n\n${Tt}`},{role:`user`,content:ee}],s.signal,{tools:Mt.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Nt(e,t,m)}))e.type===`content`?G(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{y()}p||(Y(`模型没有提交体检结果,当前只保留规则结果`,`error`),C(`模型没有提交体检结果,只保留了规则检查`,`error`)),W(100,p?`模型评审完成`:`已保留规则结果`);let b=q.current?.check?.gaps.length??0,te=q.current?.ignoredGaps?.length??0,x=ir.current;p?(a?(c.message=n?`全量扫描完成,待确认 ${b}`:`全量审查完成,待确认 ${b}`,C(c.message,`success`)):(c.message=x>0?`复审未新增;待确认 ${b} · 已忽略 ${te}(已抑制 ${x} 条新报)`:`复审未新增;待确认 ${b} · 已忽略 ${te}`,C(c.message,`success`)),Y(c.message,`done`)):c.message=`模型没提交结果,已保留规则结果`,await D(r.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:c.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),z(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);s.signal.aborted?(c.status=`stopped`,Y(`已中断:规则体检结果已保留`,`info`)):(c.status=`error`,L(t),Y(`体检失败:${t}`,`error`))}finally{s.signal.aborted&&(c.status=`stopped`),Z(`audit`,c.status,c.status===`error`?`审查失败,详见活动日志`:c.message)}},[X,Z,$,ei,J,Y,cr,Ot,yt]);nr.current=ci;let li=(0,A.useCallback)(async()=>{let e=q.current,t=ti();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){C(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=Ot?.fix.trim()??``;if(!r){C(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}L(``),Y(`开始补写选中条目`,`stage`,`勾选 ${n.length} 个缺口`),X(`fix`,`补写选中条目`,100,`正在按 ${n.length} 个勾选缺口补写`);let i=Date.now(),a=new AbortController;wn.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 de(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(`
35
+ `):`(无)`,``,`## 当前故事集(${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}`:``,e.conclusion?.trim()?` 结论:${e.conclusion.trim()}`:``,e.outlineId?` 需求点:${e.outlineId}`:``].filter(Boolean).join(`
36
+ `)}).join(`
37
+ `),``,`说明:若某条带了「结论」,优先按结论改故事;结论与原文冲突时以原文为准并在回答里说明。`].join(`
38
+ `),u=$(e,90),d=!1,f=u.saveStories;u.saveStories=async e=>(d=!0,W(90,`正在写入补写结果`),f(e)),W(12,`正在提交模型补写`);let p=An(88);try{for await(let e of at(t,[{role:`system`,content:`${r}\n\n${Tt}`},{role:`user`,content:l}],a.signal,{tools:Mt.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Nt(e,t,u)}))e.type===`content`?G(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`),C(`模型没有提交补写结果`,`error`);return}W(94,`已写入补写结果,正在重算覆盖率`);let m=q.current;if(m){let e=tt(m),t=await D(m.id,{check:e,status:`decomposed`});J(t)}let h=Math.round((q.current?.check?.coverage.rate??0)*100);Y(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`,`覆盖率 ${h}% · 耗时 ${Hn(i)}`),await Zr({progress:{stage:`done`,done:100,total:100,message:`补写完成`,at:new Date().toISOString()}},q.current).catch(()=>void 0),z(`check`),C(`补写完成,建议再跑一次体检`,`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,L(t),Y(`补写失败:${t}`,`error`))}finally{a.signal.aborted&&(o.status=`stopped`),Z(`fix`,o.status,o.status===`error`?`补写失败:${o.message}`:o.message)}},[X,Z,$,J,Y,cr,ti,Ot,Zr]),ui=(0,A.useCallback)(async()=>{let e=q.current,t=ti();if(!e||!t)return;if(!e.stories.length||e.status===`draft`){C(`请先成功生成用户故事,再生成测试点`,`info`);return}let n=kt?.generate.trim()??``;if(!n){C(`没有读到「${dt}」的「## 生成」段落`,`error`);return}L(``),Y(`开始生成测试点`,`stage`,`基于 ${e.stories.length} 个用户故事,五维覆盖 P0–P3`),X(`testpoints`,`生成测试点`,100,`正在整理用户故事,等待模型生成`),z(`points`),await Zr({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;wn.current=i;let a={status:`done`,message:`测试点已生成`};try{let o=$(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||`未命名分析`}`,``,`## 需求点(按条目;未挂故事的子点也需覆盖)`,Ce(e.outline),``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
39
+ `);W(15,`正在提交模型生成`);let u=``,d=An(88);try{for await(let e of at(t,[{role:`system`,content:`${n}\n\n${Tt}`},{role:`user`,content:l}],i.signal,{tools:Mt.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>Nt(e,t,o)}))e.type===`content`?(u+=e.delta,G(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=It(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`),C(`模型没有提交测试点,原结果保持不变`,`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`)} · 耗时 ${Hn(r)}`),W(100,`已生成 ${e.length} 条`),a.message=`测试点已生成 ${e.length} 条`,await Zr({progress:{stage:`done`,done:100,total:100,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},q.current).catch(()=>void 0),C(`测试点已生成`,`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,L(t),Y(`生成测试点失败:${t}`,`error`))}finally{i.signal.aborted&&(a.status=`stopped`),Z(`testpoints`,a.status,a.status===`error`?`生成测试点失败:${a.message}`:a.message)}},[X,Z,$,Y,cr,ti,Zr,kt]),di=(0,A.useCallback)(async()=>{let e=q.current;if(!e?.testPoints)C(`还没有测试点可导出`,`info`);else try{let t=nn.current;t.length||(t=await _r(e));let n=await pt(e,t);Y(`已导出 ${n}`,`done`)}catch(e){C(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Y,_r]),fi=(0,A.useCallback)(async()=>{let e=q.current;if(!e?.testPoints){C(`还没有测试点可导出`,`info`);return}let t=nn.current;t.length||(t=await _r(e));let n=gt(e,t);Y(`已导出 ${n}`,`done`)},[Y,_r]),pi=(0,A.useCallback)(()=>{let e=q.current;if(!e?.sourceExport?.groups.length){C(`请先拆解需求`,`info`);return}let t=ze(e);Y(`已导出 ${t}`,`done`),C(`已导出 ${t}`,`success`)},[Y]),mi=(0,A.useCallback)(async()=>{let e=q.current;if(!e?.sourceExport?.groups.length)C(`请先拆解需求`,`info`);else try{let t=await Re(e);Y(`已导出 ${t}`,`done`),C(`已导出 ${t}`,`success`)}catch(e){C(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Y]),hi=(0,A.useCallback)(async e=>{let t=q.current;if(t)try{await Zr({stories:e},t)}catch(e){C(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Zr]),gi=(0,A.useCallback)((e,t)=>{let n=q.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);hi(r)},[hi]),_i=(0,A.useCallback)(e=>{let t=q.current;t&&hi(t.stories.filter((t,n)=>n!==e))},[hi]),vi=(0,A.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,hi(i))},[hi]),yi=(0,A.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),Qr()},[J,Qr]),bi=(0,A.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),Qr()},[J,Qr]),xi=(0,A.useCallback)(async()=>{let e=q.current;if(e)try{await Ge(e.id),a(bn(e.id)),a(En(e.id)),a(`reqanalysis.idealTitles.${e.id}`),tr.current===e.id&&(tr.current=``);let t=E.filter(t=>t.id!==e.id);ye(t),fr(t[0]??null),gr(`list`),C(`已删除分析记录`,`success`)}catch(e){C(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{an(!1)}},[gr,E,fr]),Si=(0,A.useCallback)(()=>{let e=q.current;if(!e?.check)return;let t=mt(e,e.check);C(`已导出 ${t}`,`success`)},[]),Ci=(0,A.useCallback)(()=>{let e=q.current;if(!e?.check)return;let t=e.check.gaps.filter(e=>e.selected).map(e=>e.id),n=new Map(e.outline.map(e=>[e.id,(e.body||e.quote||e.title||``).trim()])),r=bt(e,e.check,{gapIds:t.length?t:void 0,outlineBodies:n,outlineTitles:Ir});C(`已导出 ${r}`,`success`)},[Ir]),wi=(0,A.useCallback)(()=>{wn.current?.abort()},[]);if(!e.ready)return(0,I.jsx)(te,{label:`正在读取插件开关`});if(!e.on)return(0,I.jsx)(b,{children:r(`reqAnalysis`)});if(T===null)return(0,I.jsx)(te,{label:`正在连接需求分析服务`});if(!T)return(0,I.jsx)(b,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(Ut)return(0,I.jsx)(te,{label:`正在回到上次的分析`});let Ti=k?.outline.filter(e=>Ar.has(e.id)).length??0,Ei=(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,I.jsxs)(`section`,{className:`shrink-0 ${In} px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,I.jsx)(`p`,{className:Fn,children:`新建分析`}),(0,I.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,I.jsx)(v,{options:sr,value:ut,onChange:e=>{ht(e),e&&$r(e)},triggerTitle:ut||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,I.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,E.length,` 份分析`]})]}),_t?(0,I.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,_t,(0,I.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,Be,` 之外的内容目录没有被移动。`]}):null]}),Rt?(0,I.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,I.jsx)(`span`,{className:`break-all`,children:Rt}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,I.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden ${In}`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>Or(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${Gt===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>Or(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${Gt===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),Gt===`story`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`label`,{className:`relative block`,children:[(0,I.jsx)(x,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,I.jsx)(`input`,{value:qt,onChange:e=>Jt(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,I.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[Cr,` 个故事`,B?` · 已选 ${B.ids.length}`:``]}),(0,I.jsx)(`button`,{type:`button`,disabled:!B,onClick:()=>{if(!B)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:B.docId,stories:B.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${Nn} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,I.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[E.length,` 份分析 · `,Cr,` 个故事`]})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:Gt===`doc`?E.length?(0,I.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:E.map(e=>{let t=or(e.status);return(0,I.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,I.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>yr(e,`stories`),children:(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:De(e)}),(0,I.jsx)(y,{tone:t.tone,children:t.label})]}),(0,I.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,I.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,I.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,I.jsx)(`span`,{children:Bn(e.updatedAt)})]})]})}),(0,I.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:()=>yr(e,`stories`),children:[`用户故事`,(0,I.jsx)(x,{name:`chevronRight`,size:13})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`删除 ${De(e)}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{fr(e),an(!0)},children:(0,I.jsx)(x,{name:`trash`,size:14})})]},e.id)})}):(0,I.jsx)(S,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析;先拆解需求条目,再生成用户故事。`}):wr.length?(0,I.jsx)(`div`,{className:`divide-y divide-stone-100`,children:wr.map(({doc:e,rows:t})=>{let n=Zt.includes(e.id),r=t.map(e=>e.story.id),i=B?.docId===e.id&&r.length>0&&r.every(e=>Tr.has(e));return(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${De(e)} 的全部故事`,checked:i,onChange:()=>Dr(e.id,r)}),(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>V(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,I.jsx)(x,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,I.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:De(e)}),(0,I.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,Bn(e.updatedAt)]})]}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>yr(e,`stories`),children:`打开分析`})]}),n?null:(0,I.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,I.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:Tr.has(t.id)&&B?.docId===e.id,onChange:()=>Er(e.id,t.id)}),(0,I.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>br(e,t.id),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,I.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,I.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,I.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,I.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,I.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,I.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,I.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,I.jsx)(S,{icon:`file`,title:qt?`没有匹配的用户故事`:`还没有用户故事`,hint:qt?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[zt===`list`?Ei:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-3`,children:[(0,I.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-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{ht(``),L(``),gr(`list`)},children:[(0,I.jsx)(x,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,I.jsx)(`div`,{className:`min-w-0 w-[min(100%,28rem)] max-w-full shrink`,children:(0,I.jsx)(v,{options:xr,value:O,onChange:e=>{let t=E.find(t=>t.id===e);t&&fr(t)},disabled:!E.length,searchable:!0,searchPlaceholder:`搜索分析记录…`,ariaLabel:`分析记录`,compact:!0,className:`min-w-0 w-full`})})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,I.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 min-h-0 flex-col gap-3`,children:[(0,I.jsxs)(`section`,{className:`shrink-0 overflow-hidden ${In} transition-colors hover:border-stone-300 focus-within:border-stone-300`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":kn,className:`flex w-full items-center justify-between px-3.5 py-2.5 text-left outline-none focus-visible:outline-none hover:bg-stone-50/80 ${kn?`border-b border-stone-100`:``}`,onClick:()=>{Gn(e=>{let t=!e;return l(mn,t?`1`:`0`),t})},children:[(0,I.jsx)(`p`,{className:Fn,children:`提示词`}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:kn?`收起`:`展开`})]}),(0,I.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${kn?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,I.jsx)(`div`,{className:`min-h-0 overflow-hidden`,"aria-hidden":!kn,inert:!kn||void 0,children:(0,I.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Wn,{name:je,ready:Nr}),(0,I.jsx)(Wn,{name:Pe,ready:!!Q?.structure.trim()}),(0,I.jsx)(Wn,{name:Ot?.file??`用户故事审查提示词.md`,ready:t.on&&!!Ot?.review.trim()&&!!Ot?.fix.trim()}),(0,I.jsx)(Wn,{name:dt,ready:h.on&&!!kt?.generate.trim()})]}),(0,I.jsx)(`p`,{className:`mt-2 text-[11px] ${ei?`text-stone-400`:`text-amber-700`}`,children:ei?`模型:${yt?.model}`:`还没配置模型`})]})})})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,I.jsxs)(`section`,{className:`shrink-0 ${In}`,children:[(0,I.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,I.jsx)(`p`,{className:Fn,children:`动作`})}),(0,I.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,I.jsx)(ot,{options:mr,values:k?.priorMemoryDocIds??[],placeholder:k?mr.length===0?`暂无同产品历史分析`:`选择历史分析`:`请先打开分析`,disabled:!k||mr.length===0||!!N,chips:!0,searchable:!0,searchPlaceholder:`搜索历史版本…`,onChange:e=>{k&&D(k.id,{priorMemoryDocIds:e}).then(e=>J(e)).catch(e=>{let t=e instanceof Error?e.message:String(e);C(t,`error`)})}}),(0,I.jsx)(`button`,{type:`button`,className:`${Nn} w-full`,disabled:!k||!!N||!k.sourcePath||!jr,onClick:()=>{(k?.outline??[]).some(e=>e.kind)||(k?.stories.length??0)>0?vn(!0):ni()},children:N===`decompose`?`拆解需求中…`:(k?.outline??[]).some(e=>e.kind)||(k?.stories.length??0)>0?`重新拆解需求`:`拆解需求`}),(0,I.jsx)(`button`,{type:`button`,className:`${Pn} w-full`,disabled:!k||!!N||!k.sourcePath||!k.outline.length||k.status===`draft`||!Mr,onClick:()=>{k?.stories.length?Sn(!0):si()},children:N===`stories`?`生成故事中…`:N===`audit`?`审查中…`:k?.stories.length?`重新生成用户故事`:`生成用户故事`}),h.on?(0,I.jsx)(`button`,{type:`button`,className:`${Pn} w-full`,disabled:!k||!!N||!k.stories.length||k.status===`draft`,onClick:()=>{k?.testPoints?.points.length?Tn(!0):ui()},children:N===`testpoints`?`生成中…`:k?.testPoints?`重新生成测试点`:`生成测试点`}):null,N?(0,I.jsx)(`button`,{type:`button`,className:`${Pn} w-full`,onClick:wi,children:`中断`}):null,k&&!N?(0,I.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:()=>an(!0),children:`删除这份分析`}):null]})]}),(0,I.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden ${In}`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,I.jsx)(`p`,{className:Fn,children:`活动日志`}),Pt.length?(0,I.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>Lt([]),children:`清空`}):null]}),(0,I.jsx)(`div`,{ref:$n,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:Pt.length?Pt.map(e=>e.kind===`stage`?(0,I.jsxs)(`div`,{className:`flex items-center gap-2 pt-1.5 first:pt-0`,children:[(0,I.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium text-stone-500`,children:e.text}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-300`,children:Vn(e.at)}),(0,I.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`})]},e.id):(0,I.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,I.jsx)(`span`,{className:`mt-px shrink-0 text-[10px] tabular-nums text-stone-300`,children:Vn(e.at)}),(0,I.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,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:e.kind===`done`?`text-stone-700`:`text-stone-500`,children:e.text}),e.detail?(0,I.jsx)(`span`,{className:`mt-0.5 block break-all text-[10px] leading-relaxed text-stone-400`,children:e.detail}):null]})]},e.id)):(0,I.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]})]}),(0,I.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[Rt?(0,I.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,I.jsx)(`span`,{className:`break-all`,children:Rt}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,F&&!N?(0,I.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border px-3 py-2 text-xs ${F.status===`done`?`border-emerald-200 bg-emerald-50 text-emerald-700`:F.status===`error`?`border-red-200 bg-red-50 text-red-700`:`border-amber-200 bg-amber-50 text-amber-700`}`,children:[(0,I.jsxs)(`span`,{className:`break-all`,children:[(0,I.jsxs)(`span`,{className:`font-medium`,children:[F.label,F.status===`done`?`已完成`:F.status===`error`?`失败`:`已中断`]}),(0,I.jsx)(`span`,{className:`ml-1.5 opacity-80`,children:F.message}),F.finishedAt?(0,I.jsxs)(`span`,{className:`ml-1.5 opacity-60`,children:[`· `,Bn(new Date(F.finishedAt).toISOString())]}):null]}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-60 transition-opacity hover:opacity-100`,"aria-label":`关闭上次任务提示`,onClick:lr,children:`✕`})]}):null,k?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`shrink-0 ${In}`,children:[(0,I.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(_,{text:De(k),matchAnchorWidth:!0,className:`min-w-0 flex-1 truncate px-1 py-0.5 text-[15px] font-semibold text-stone-800`}),N?(0,I.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,I.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),P?P.message:N===`decompose`?`拆解需求中`:N===`stories`?`生成故事中`:N===`audit`?`审查中`:N===`testpoints`?`生成测试点中`:N===`fix`?`补写中`:`处理中`,P&&P.total>0?(0,I.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(P.done,P.total)/P.total*100),`%`]}):null]}):null,(0,I.jsx)(y,{tone:or(k.status).tone,children:or(k.status).label})]}),N?(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${P?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":P&&P.total>0?Math.round(Math.min(P.done,P.total)/P.total*100):void 0,children:(0,I.jsx)(`div`,{className:P&&P.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:P&&P.total>0?{width:`${Math.round(Math.min(P.done,P.total)/P.total*100)}%`}:void 0})})}):null,(0,I.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,I.jsx)(`span`,{className:`font-medium text-stone-600`,children:k.stories.length})]}),(0,I.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,I.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[Ti,`/`,k.outline.length]}),` `,`覆盖`]}),t.on?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,I.jsx)(`span`,{className:`font-medium text-stone-600`,children:Fr.length}),Pr?` · 已选 ${Pr}`:``]}),k.check?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,I.jsx)(`span`,{className:`font-medium text-stone-600`,children:k.check.coverage.total?`${Math.round(k.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,h.on?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,I.jsx)(`span`,{className:`font-medium text-stone-600`,children:k.testPoints?.points.length??0})]})]}):null,(0,I.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,k.sourcePath]}),kr?(0,I.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,I.jsxs)(`div`,{className:`mt-2.5 flex items-end gap-2 border-b border-stone-100 px-2`,children:[(0,I.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`flex min-w-0 flex-1 items-center gap-1`,children:[{id:`outline`,label:`需求条目`,count:Rr.length||k.outline.length},{id:`stories`,label:`用户故事`,count:k.stories.length},{id:`check`,label:`审查结果`,count:Fr.length+Wr.length},{id:`points`,label:`测试点`,count:k.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||h.on)).map(e=>{let t=R===e.id;return(0,I.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:()=>z(e.id),children:[e.label,(0,I.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)})}),R===`outline`&&k.sourcePath?(0,I.jsxs)(`span`,{className:`mb-1.5 flex shrink-0 items-center gap-1.5`,children:[(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-6 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-[11px] text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,disabled:!!N,onClick:()=>void mi(),children:`原文 XMind`}),(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-6 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-[11px] text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,disabled:!!N,onClick:()=>void pi(),children:`原文 Markdown`})]}):null]})]}),(0,I.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:[R===`stories`?zr.length?(0,I.jsx)(`ul`,{className:`space-y-2 pt-1`,children:zr.map(e=>{let t=k.stories.findIndex(t=>t.id===e.id),n=t>=0?t:0;return(0,I.jsx)(sn,{story:e,index:n,total:k.stories.length,gaps:Fr.filter(t=>t.storyId===e.id),outlineTitles:Lr,outlineOptions:k.outline,completenessHints:Ve(e),busy:!!N,onSave:e=>gi(n,e),onDelete:()=>_i(n),onMove:e=>vi(n,e),onJumpOutline:Gr,domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${n}`)})}):(0,I.jsx)(`div`,{className:`flex items-center justify-center ${In}`,children:(0,I.jsx)(S,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「拆解需求」整理条目,再点「生成用户故事」。`})}):null,R===`check`&&t.on?(0,I.jsx)(Bt,{check:k.check?{...k.check,gaps:Fr}:null,stories:k.stories,outlineTitles:Ir,ignoredGaps:Wr,busy:!!N,onToggleGap:yi,onToggleAll:bi,onFix:()=>void li(),onReview:()=>void ci(),onFullScan:()=>void ci({fullScan:!0}),onExport:Si,onExportPending:Ci,onIgnoreGap:e=>void qr([e]),onIgnoreSelected:()=>{let e=Fr.filter(e=>e.selected).map(e=>e.id);qr(e)},onSaveGapConclusion:(e,t)=>void Xr(e,t),onRestoreIgnored:e=>void Jr(e),onPromoteIgnored:e=>void Yr(e)}):null,R===`points`&&h.on?(0,I.jsx)(Yt,{doc:k,idealTitles:en,generating:N===`testpoints`,busy:!!N,promptReady:!!kt?.generate.trim(),onExportXmind:()=>void di(),onExportMarkdown:()=>void fi(),onJumpToRequirement:Kr}):null,R===`outline`?Rr.length?(0,I.jsx)(`ul`,{className:`space-y-2 pt-1`,children:Rr.map(e=>{let t=!!Br[e.parent.id],n=e.totalPoints>0&&e.coveredCount===e.totalPoints;return(0,I.jsxs)(`li`,{id:`req-outline-${e.parent.id}`,className:Ln,children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 px-4 py-2.5 text-left`,onClick:()=>Vr(t=>({...t,[e.parent.id]:!t[e.parent.id]})),children:[(0,I.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${n?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,I.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.parent.id}),e.parent.title]}),(0,I.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`已整理需求点 `,e.coveredCount,`/`,e.totalPoints,` 已覆盖`,e.coveringStories.length?` · ${e.coveringStories.length} 个故事`:``]})]}),(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:t?`收起`:`展开`})]}),t?(0,I.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{className:`text-[11px] font-semibold text-stone-500`,children:[`已整理的需求点(`,e.points.length,`)`]}),e.points.length?(0,I.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:e.points.map(t=>{let n=Ar.has(t.id),r=t.kind===`query`?`查询`:t.kind===`mutate`?`修改`:``,i=!!Hr[t.id],a=Te(t,e.parent,e.points);return(0,I.jsxs)(`li`,{id:`req-outline-point-${t.id}`,className:`rounded-md border border-transparent text-xs text-stone-700`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1 text-left hover:bg-stone-50`,onClick:()=>Ur(e=>({...e,[t.id]:!e[t.id]})),children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${n?`bg-emerald-500`:`bg-amber-400`}`}),(0,I.jsx)(`span`,{className:`font-mono text-[10px] text-stone-400`,children:t.id}),r?(0,I.jsx)(`span`,{className:`rounded bg-stone-100 px-1 text-[10px] text-stone-500`,children:r}):null,(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),(0,I.jsx)(`span`,{className:n?`shrink-0 text-emerald-600`:`shrink-0 text-amber-600`,children:n?`已覆盖`:`未覆盖`})]}),(0,I.jsx)(`button`,{type:`button`,disabled:!!N,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] text-stone-500 hover:bg-stone-100 hover:text-[#3370ff] disabled:cursor-not-allowed disabled:opacity-40`,onClick:n=>{n.stopPropagation(),ri(t,e.parent)},children:`变更需求点`}),(0,I.jsx)(`button`,{type:`button`,disabled:!!N,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] text-stone-500 hover:bg-stone-100 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40`,onClick:e=>{e.stopPropagation(),Zn(t.id)},children:`删除`}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] text-stone-400 hover:bg-stone-100 hover:text-stone-600`,onClick:()=>Ur(e=>({...e,[t.id]:!e[t.id]})),children:i?`收起`:`原文`})]}),i?(0,I.jsx)(`div`,{className:`mb-1 ml-4 mt-0.5`,children:(0,I.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-stone-50 px-2 py-1.5 text-[11px] leading-relaxed text-stone-600`,children:a.text||`(无原文切片)`})}):null]},t.id)})}):(0,I.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`尚无查询/修改子点;拆解时会按原文能力补上。`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[11px] font-semibold text-stone-500`,children:`需求文档条目内容`}),(0,I.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto whitespace-pre-wrap rounded-lg bg-stone-50 px-3 py-2 text-xs leading-relaxed text-stone-600`,children:e.parent.body||e.parent.quote||`(无原文切片)`})]}),e.coveringStories.length?(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[11px] font-semibold text-stone-500`,children:`覆盖故事`}),(0,I.jsx)(`ul`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:e.coveringStories.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`rounded-md border border-stone-200 bg-white px-2 py-0.5 text-[11px] text-stone-600 hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>{z(`stories`),requestAnimationFrame(()=>{document.getElementById(`req-story-${e.id}`)?.scrollIntoView({behavior:`smooth`,block:`nearest`})})},children:[e.id,` `,e.title]},e.id))})]}):null]}):null]},e.parent.id)})}):(0,I.jsx)(`div`,{className:`flex items-center justify-center ${In}`,children:(0,I.jsx)(S,{icon:`file`,title:`还没有需求条目`,hint:`拆解时会按需求文档结构播种条目,再整理查询/修改需求点。`})}):null]})]}):(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center ${In}`,children:(0,I.jsx)(S,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,I.jsxs)(p,{open:!!Kn,onClose:()=>{N!==`change-point`&&(qn(null),Yn(``))},className:`relative z-110`,children:[(0,I.jsx)(m,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,I.jsxs)(d,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>{qn(null),Yn(``)},className:`absolute top-3.5 right-3.5 flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,"aria-label":`关闭`,children:`✕`}),(0,I.jsxs)(f,{className:`pr-8 text-base font-semibold text-stone-900`,children:[`变更需求点`,Kn?(0,I.jsx)(`span`,{className:`ml-2 font-mono text-xs font-normal text-stone-400`,children:Kn.pointId}):null]}),(0,I.jsx)(`p`,{className:`mt-3 text-[11px] text-stone-400`,children:`编辑或补充需求内容后点确认,由模型更新当前点,必要时在下方新增子点。保存后除非重新拆解,否则审查与生成故事不会改回原文。`}),(0,I.jsx)(`textarea`,{value:Jn,onChange:e=>Yn(e.target.value),spellCheck:!1,placeholder:`需求内容(可多行)`,className:`mt-2 min-h-[200px] w-full resize-y overflow-y-auto rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2.5 text-[12.5px] leading-relaxed text-stone-700 outline-none focus:border-[#4176e6]/40 focus:bg-white`}),(0,I.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>{qn(null),Yn(``)},className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-100`,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,disabled:!Jn.trim()||!!N,onClick:()=>void oi(),className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-sm text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:bg-stone-300`,children:`确认`})]})]})})]}),(0,I.jsx)(g,{open:!!Xn,title:`删除需求点`,message:`确认删除需求点「${Xn?`${Xn} ${k?.outline.find(e=>e.id===Xn)?.title??``}`.trim():``}」?同父级后续子点序号会顺延;引用它的故事会去掉该引用。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Zn(null),onConfirm:()=>void ai()}),(0,I.jsx)(g,{open:rn,title:`删除分析记录`,message:`确认删除「${k?De(k):``}」?故事、需求条目、体检报告与测试点都会一起清掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>an(!1),onConfirm:()=>void xi()}),(0,I.jsx)(g,{open:on,title:`重新拆解需求`,message:`将按文档结构重新播种需求条目并整理查/改子点。当前 ${k?.stories.length??0} 个用户故事、审查结果与测试点会一并清空(条目 id 可能变化)。`,confirmLabel:`重新拆解需求`,onClose:()=>vn(!1),onConfirm:()=>{vn(!1),ni()}}),(0,I.jsx)(g,{open:yn,title:`重新生成用户故事`,message:`将覆盖当前 ${k?.stories.length??0} 个用户故事,并清空审查结果与测试点;需求条目保留。`,confirmLabel:`重新生成用户故事`,onClose:()=>Sn(!1),onConfirm:()=>{Sn(!1),si()}}),(0,I.jsx)(g,{open:Cn,title:`重新生成测试点`,message:`将覆盖当前 ${k?.testPoints?.points.length??0} 条测试点,按现有用户故事重新生成。`,confirmLabel:`重新生成`,onClose:()=>Tn(!1),onConfirm:()=>{Tn(!1),ui()}})]})}export{Gn as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.D5qXeML0.js";import{n as c,t as ee}from"./DocsPager.BS20yicJ.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 oe,m as se,n as ce,p as le,r as ue,s as d,t as de,u as fe}from"./project-docs.DAw9bzgk.js";import{n as pe}from"./doc-roots.DAJP9Svr.js";import{t as f}from"./NamePromptDialog.Csfnh5eM.js";import{n as me,t as he}from"./docs-format.BlGh-XA_.js";import{t as ge}from"./useListAnim.BoerpmsB.js";var p=e(t(),1),m=o(),_e=5;function h({className:e=`w-4 h-4`,open:t=!1}){return(0,m.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,m.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,m.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 g({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.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,m.jsx)(`path`,{d:`m15 5 4 4`})]})}function _({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,m.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,m.jsx)(`path`,{d:`M10 11v6`}),(0,m.jsx)(`path`,{d:`M14 11v6`})]})}function v({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,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,m.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,m.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,m.jsx)(h,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,m.jsx)(v,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function y(){let[e,t]=(0,p.useState)(()=>r(`requirements`)),[o,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null),[S,ve]=(0,p.useState)([]),[ye,be]=(0,p.useState)(0),[C,w]=(0,p.useState)(`.`),[T,E]=(0,p.useState)([]),[xe,D]=(0,p.useState)({}),[O,Se]=(0,p.useState)(!0),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[N,P]=(0,p.useState)(null),[Ce,F]=(0,p.useState)(!1),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[we,B]=(0,p.useState)(1),[V,Te]=c(_e),[Ee,H]=(0,p.useState)(null),U=(0,p.useRef)(null),{cls:De,play:W}=ge(),G=(0,p.useCallback)(async()=>{let e=await ae(`requirements`);ve(e.tree),be(e.totalFiles)},[]),K=(0,p.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([u(`requirements`,e),G()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,G]);(0,p.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),y(!0)}),e},[]),(0,p.useEffect)(()=>{o&&e&&(async()=>{if(!await ue(`requirements`))x(!1);else try{let[e]=await Promise.all([u(`requirements`,`.`),G()]);E(e.entries),w(e.path),x(!0)}catch(e){A(e instanceof Error?e.message:String(e)),x(!0)}})()},[o,e,G]);function Oe(){Se(e=>!e),D({})}async function q(e){W(),w(e),B(1),P(null),H(null),A(null);try{let t=await u(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function ke(e){F(!1),M(!0),A(null);try{await oe(`requirements`,C,e),await K(C),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`新建文件夹失败:${t}`,`error`)}finally{M(!1)}}async function Ae(e){if(e.type===`file`){M(!0),A(null);try{await fe(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function je(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await re(`requirements`,C,t);await K(C),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`上传失败:${t}`,`error`)}finally{M(!1),U.current&&(U.current.value=``)}}}function Me(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?de(t):0;L({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){L({name:e.name,path:e.path,isDir:!1})}function Y(e,t){z({...e,isDir:t})}async function Ne(){let e=I;if(e&&(L(null),!e.blocked)){M(!0),A(null);try{await ce(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ne(e.path):C;await K(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`删除失败:${t}`,`error`)}finally{M(!1)}}}async function Pe(e){let t=R;if(t&&(z(null),e!==t.name)){M(!0),A(null);try{let n=await ie(`requirements`,t.path,e);await K(se(C,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`重命名失败:${t}`,`error`)}finally{M(!1)}}}let Fe=(()=>{if(!I)return``;if(!I.isDir)return`删除文件「${I.name}」?将移入系统废纸篓,可随时找回。`;if(I.blocked){let e=[];return I.files&&e.push(`${I.files} 个文件`),I.dirs&&e.push(`${I.dirs} 个子文件夹`),`文件夹「${I.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${I.name}」?将移入系统废纸篓。`})();async function Ie(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){M(!0),A(null);try{let t=await le(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,m.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(b===null)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!b)return(0,m.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=T.filter(e=>e.type===`file`).slice().sort((e,t)=>(t.ctime??t.mtime??0)-(e.ctime??e.mtime??0)),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(we,Q),Le=X.slice(($-1)*V,$*V);function Re(e){W(),Te(e),B(1)}return(0,m.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,m.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>F(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,m.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,m.jsx)(h,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,ye,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:S.map(e=>(0,m.jsx)(v,{node:e,depth:0,activePath:C,expanded:xe,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,m.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,m.jsx)(`span`,{className:`text-stone-400`,children:pe(`requirements`)}),C===`.`?``:C]}),(0,m.jsx)(`input`,{ref:U,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 je(e.target.files)}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>U.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:`上传文件`})]}),k?(0,m.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:k}):null,(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,m.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,m.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,m.jsx)(h,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"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,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,m.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,m.jsx)(`ul`,{className:`${De}space-y-1`,children:Le.map(e=>{let t=Ee===e.path;return(0,m.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,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{H(e.path),Ie(e)},onDoubleClick:t=>{t.preventDefault(),Ae(e)},children:[(0,m.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`div`,{className:`text-[11px] text-stone-400`,children:[he(e.size),e.ctime||e.mtime?` · ${me(e.ctime??e.mtime)}`:``]})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"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,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,m.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,m.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,m.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,m.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:j,onPage:e=>{W(),B(e)},onPageSize:Re}):null]}),(0,m.jsx)(f,{open:Ce,title:`新建文件夹`,onClose:()=>F(!1),onConfirm:e=>void ke(e)}),(0,m.jsx)(f,{open:R!=null,title:R?.isDir?`重命名文件夹`:`重命名文件`,label:R?.isDir?`文件夹名称`:`文件名称`,initialValue:R?.name??``,lockExtension:R!=null&&!R.isDir,confirmLabel:`保存`,onClose:()=>z(null),onConfirm:e=>void Pe(e)}),(0,m.jsx)(s,{open:I!=null,title:I?.blocked?`无法删除文件夹`:I?.isDir?`删除文件夹`:`删除需求文件`,message:Fe,confirmLabel:I?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!I?.blocked,hideCancel:!!I?.blocked,onClose:()=>L(null),onConfirm:()=>void Ne()})]})}export{y as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.D5qXeML0.js";import{n as c,t as ee}from"./DocsPager.D0TMvJ67.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 oe,m as se,n as ce,p as le,r as ue,s as d,t as de,u as fe}from"./project-docs.DAw9bzgk.js";import{n as pe}from"./doc-roots.DAJP9Svr.js";import{t as f}from"./NamePromptDialog.Csfnh5eM.js";import{n as me,t as he}from"./docs-format.BlGh-XA_.js";import{t as ge}from"./useListAnim.BoerpmsB.js";var p=e(t(),1),m=o(),_e=5;function h({className:e=`w-4 h-4`,open:t=!1}){return(0,m.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,m.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,m.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 g({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.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,m.jsx)(`path`,{d:`m15 5 4 4`})]})}function _({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,m.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,m.jsx)(`path`,{d:`M10 11v6`}),(0,m.jsx)(`path`,{d:`M14 11v6`})]})}function v({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,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,m.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,m.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,m.jsx)(h,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,m.jsx)(v,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function y(){let[e,t]=(0,p.useState)(()=>r(`requirements`)),[o,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null),[S,ve]=(0,p.useState)([]),[ye,be]=(0,p.useState)(0),[C,w]=(0,p.useState)(`.`),[T,E]=(0,p.useState)([]),[xe,D]=(0,p.useState)({}),[O,Se]=(0,p.useState)(!0),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[N,P]=(0,p.useState)(null),[Ce,F]=(0,p.useState)(!1),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[we,B]=(0,p.useState)(1),[V,Te]=c(_e),[Ee,H]=(0,p.useState)(null),U=(0,p.useRef)(null),{cls:De,play:W}=ge(),G=(0,p.useCallback)(async()=>{let e=await ae(`requirements`);ve(e.tree),be(e.totalFiles)},[]),K=(0,p.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([u(`requirements`,e),G()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,G]);(0,p.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),y(!0)}),e},[]),(0,p.useEffect)(()=>{o&&e&&(async()=>{if(!await ue(`requirements`))x(!1);else try{let[e]=await Promise.all([u(`requirements`,`.`),G()]);E(e.entries),w(e.path),x(!0)}catch(e){A(e instanceof Error?e.message:String(e)),x(!0)}})()},[o,e,G]);function Oe(){Se(e=>!e),D({})}async function q(e){W(),w(e),B(1),P(null),H(null),A(null);try{let t=await u(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function ke(e){F(!1),M(!0),A(null);try{await oe(`requirements`,C,e),await K(C),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`新建文件夹失败:${t}`,`error`)}finally{M(!1)}}async function Ae(e){if(e.type===`file`){M(!0),A(null);try{await fe(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function je(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await re(`requirements`,C,t);await K(C),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`上传失败:${t}`,`error`)}finally{M(!1),U.current&&(U.current.value=``)}}}function Me(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?de(t):0;L({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){L({name:e.name,path:e.path,isDir:!1})}function Y(e,t){z({...e,isDir:t})}async function Ne(){let e=I;if(e&&(L(null),!e.blocked)){M(!0),A(null);try{await ce(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ne(e.path):C;await K(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`删除失败:${t}`,`error`)}finally{M(!1)}}}async function Pe(e){let t=R;if(t&&(z(null),e!==t.name)){M(!0),A(null);try{let n=await ie(`requirements`,t.path,e);await K(se(C,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`重命名失败:${t}`,`error`)}finally{M(!1)}}}let Fe=(()=>{if(!I)return``;if(!I.isDir)return`删除文件「${I.name}」?将移入系统废纸篓,可随时找回。`;if(I.blocked){let e=[];return I.files&&e.push(`${I.files} 个文件`),I.dirs&&e.push(`${I.dirs} 个子文件夹`),`文件夹「${I.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${I.name}」?将移入系统废纸篓。`})();async function Ie(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){M(!0),A(null);try{let t=await le(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,m.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(b===null)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!b)return(0,m.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=T.filter(e=>e.type===`file`).slice().sort((e,t)=>(t.ctime??t.mtime??0)-(e.ctime??e.mtime??0)),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(we,Q),Le=X.slice(($-1)*V,$*V);function Re(e){W(),Te(e),B(1)}return(0,m.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,m.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>F(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,m.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,m.jsx)(h,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,ye,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:S.map(e=>(0,m.jsx)(v,{node:e,depth:0,activePath:C,expanded:xe,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,m.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,m.jsx)(`span`,{className:`text-stone-400`,children:pe(`requirements`)}),C===`.`?``:C]}),(0,m.jsx)(`input`,{ref:U,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 je(e.target.files)}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>U.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:`上传文件`})]}),k?(0,m.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:k}):null,(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,m.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,m.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,m.jsx)(h,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"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,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,m.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,m.jsx)(`ul`,{className:`${De}space-y-1`,children:Le.map(e=>{let t=Ee===e.path;return(0,m.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,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{H(e.path),Ie(e)},onDoubleClick:t=>{t.preventDefault(),Ae(e)},children:[(0,m.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`div`,{className:`text-[11px] text-stone-400`,children:[he(e.size),e.ctime||e.mtime?` · ${me(e.ctime??e.mtime)}`:``]})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"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,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,m.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,m.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,m.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,m.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:j,onPage:e=>{W(),B(e)},onPageSize:Re}):null]}),(0,m.jsx)(f,{open:Ce,title:`新建文件夹`,onClose:()=>F(!1),onConfirm:e=>void ke(e)}),(0,m.jsx)(f,{open:R!=null,title:R?.isDir?`重命名文件夹`:`重命名文件`,label:R?.isDir?`文件夹名称`:`文件名称`,initialValue:R?.name??``,lockExtension:R!=null&&!R.isDir,confirmLabel:`保存`,onClose:()=>z(null),onConfirm:e=>void Pe(e)}),(0,m.jsx)(s,{open:I!=null,title:I?.blocked?`无法删除文件夹`:I?.isDir?`删除文件夹`:`删除需求文件`,message:Fe,confirmLabel:I?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!I?.blocked,hideCancel:!!I?.blocked,onClose:()=>L(null),onConfirm:()=>void Ne()})]})}export{y as default};
@@ -1 +1 @@
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.TgxIOKMD.js";var a=e(t(),1),o=n();function s({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 truncate ${t?`text-stone-400`:``}`,children:(0,o.jsx)(r,{text:f.label,className:`block truncate`})}):(0,o.jsx)(`span`,{className:`min-w-0 truncate text-stone-400`,children:s})})}export{s as t};
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.Dmk5n225.js";var a=e(t(),1),o=n();function s({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 truncate ${t?`text-stone-400`:``}`,children:(0,o.jsx)(r,{text:f.label,className:`block truncate`})}):(0,o.jsx)(`span`,{className:`min-w-0 truncate text-stone-400`,children:s})})}export{s as t};
@@ -0,0 +1 @@
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({value:e,onChange:t,placeholder:n,ariaLabel:r,onEnterCreate:i}){let a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=a.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:a,value:e,onChange:e=>t(e.target.value),onKeyDown:t=>{if(t.key===`Enter`&&i){let n=e.trim();if(n){t.preventDefault(),t.stopPropagation(),i(n);return}}[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(t.key)||t.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 d(){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 f({options:e,value:t,onChange:o,disabled:f=!1,className:p=``,compact:m=!1,ariaLabel:h,showCheck:g=!1,centerContent:_=!1,unstyled:v=!1,fitContent:y=!1,triggerClassName:b=``,hideChevron:x=!0,flat:S=!1,menuMinWidth:C,menuMatchTrigger:w=!0,renderTrigger:T,renderOptionPrefix:E,renderOptionAction:D,searchable:O=!1,searchPlaceholder:k=`搜索…`,onSearchCreate:A,triggerTitle:j,hideTriggerHint:M=!1,dimWhenOpen:N=!1}){let P=e.find(e=>e.value===t),[F,I]=(0,c.useState)(``),L=(0,c.useMemo)(()=>{let t=F.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,F]),R=(0,c.useMemo)(()=>{if(!A)return``;let t=F.trim();return!t||e.some(e=>e.label===t)?``:t},[A,e,F]),z=_?`justify-center`:`justify-start`,B=v?y?`inline-flex !w-auto max-w-full min-w-0 items-center overflow-hidden cursor-pointer outline-none disabled:cursor-not-allowed`:`flex w-full min-w-0 items-center overflow-hidden cursor-pointer outline-none disabled:cursor-not-allowed`:m?`tw-field-trigger w-full min-w-0 h-8 flex items-center gap-1.5 overflow-hidden 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 min-w-0 h-9 flex items-center gap-2 overflow-hidden 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 min-w-0 h-9 flex items-center gap-2 overflow-hidden 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=>{I(``),o(e)},disabled:f,children:({open:i})=>(0,l.jsxs)(`div`,{className:`relative ${v?y?`inline-block max-w-full min-w-0 align-middle`:`block w-full min-w-0`:m?`inline-block`:S?``:`mt-1`} ${p}`,children:[(0,l.jsx)(n,{"aria-label":h,onClick:()=>{O&&I(``)},className:`${B} ${z} ${b} ${N&&i?`text-stone-400`:``}`,children:T?T(P,{open:i}):(0,l.jsx)(s,{text:j??P?.label??t,className:`block min-w-0 flex-1 basis-0 truncate`,disabled:M})}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:w?{width:`max(12rem, var(--button-width, 12rem))`,minWidth:`max(12rem, var(--button-width, 12rem))`}:{width:`min(280px, max(12rem, var(--button-width, 12rem)))`,maxWidth:280,minWidth:C||150},className:`tw-select-menu tw-menu-anim z-[200] flex max-h-64 min-w-0 flex-col overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${w?`w-[max(12rem,var(--button-width,12rem))]`:`w-[min(280px,max(12rem,var(--button-width,12rem)))] max-w-[280px]`}`,children:[O?(0,l.jsx)(u,{value:F,onChange:I,placeholder:k,ariaLabel:h?`${h}搜索`:`搜索选项`,onEnterCreate:A?async t=>{let n=e.find(e=>e.label===t);return n?(I(``),o(n.value),!0):(await A(t),I(``),!0)}:void 0}):null,(0,l.jsxs)(`div`,{className:`min-h-0 w-full min-w-0 flex-1 space-y-1 overflow-x-hidden overflow-y-auto p-1 pb-2`,children:[R?(0,l.jsx)(`div`,{className:`min-w-0 px-3 py-1.5 text-xs text-stone-400`,children:(0,l.jsx)(s,{text:`回车新增「${R}」`,className:`block w-full truncate`})}):null,O&&L.length===0&&!R?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,L.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex w-full min-w-0 max-w-full select-none items-center gap-2 overflow-hidden 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`} ${g?`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`:``} ${_&&!g&&!E?`justify-center px-2`:``}`,children:[g?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(d,{})}):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:`min-w-0 flex-1 basis-0 overflow-hidden`,children:[(0,l.jsx)(s,{text:e.label,className:`block w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`mt-0.5 block 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{f as t};