lantern-harness 0.1.44 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/CHANGELOG.md +224 -0
  2. package/README.md +25 -8
  3. package/builtin/session/lh-fs.mjs +93 -4
  4. package/builtin/session/lh-nav-groups.mjs +3 -0
  5. package/builtin/session/mcp-client.mjs +7 -3
  6. package/builtin/session/session-runs.mjs +5 -1
  7. package/builtin/session/skill-validation.mjs +72 -0
  8. package/builtin/session/space-skills.mjs +751 -0
  9. package/cli/data-root.mjs +21 -4
  10. package/cli/lantern.mjs +26 -1
  11. package/cli/mcp-server.mjs +2779 -0
  12. package/cli/server.mjs +8 -2
  13. package/config/app.defaults.json +4 -2
  14. package/dist/500.html +9 -6
  15. package/dist/_astro/Base.Du_-4L-4.css +1 -0
  16. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js +2 -0
  17. package/dist/_astro/BusinessMapBoard.mRxl2G3D.js +5 -0
  18. package/dist/_astro/CaseExecBoard.Cqkxuf5c.js +1 -0
  19. package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +5 -0
  20. package/dist/_astro/CaseGenerateApp.acgnxl79.js +10 -0
  21. package/dist/_astro/CasesLibrary.zmzOQwdn.js +21 -0
  22. package/dist/_astro/ChatApp.Ben9LFra.js +1 -0
  23. package/dist/_astro/ChatApp.DBi6q7Qv.js +262 -0
  24. package/dist/_astro/{ConfirmDialog.DrrPf1MB.js → ConfirmDialog.DQFd6g2r.js} +1 -1
  25. package/dist/_astro/DashboardBoard.CAJVE2G4.js +5 -0
  26. package/dist/_astro/{DatePicker.Bkl71M49.js → DatePicker.BRO_CjVQ.js} +1 -1
  27. package/dist/_astro/DefectSubmitEntry.BzKXJ-zq.js +2 -0
  28. package/dist/_astro/DocsFileBrowser.apKMbGVf.js +1 -0
  29. package/dist/_astro/{DocsPager.Duf4I68E.js → DocsPager.DMN9-Tjg.js} +1 -1
  30. package/dist/_astro/{DrawerField.BH3p4Q4D.js → DrawerField.CLdvmHc6.js} +1 -1
  31. package/dist/_astro/KnowledgeLibrary.BcoMQeUd.js +1 -0
  32. package/dist/_astro/LifeKrTasksBoard.DJU0-QI-.js +1 -0
  33. package/dist/_astro/LifeKrTodosBoard.GK7KRAO3.js +1 -0
  34. package/dist/_astro/LifeObjectivesBoard.DuKa6Q3k.js +1 -0
  35. package/dist/_astro/LifePlanTypeSelect.Cm2lUmnH.js +1 -0
  36. package/dist/_astro/{LifeReviewsBoard.BPXeVpg1.js → LifeReviewsBoard.BWOOVMtz.js} +3 -3
  37. package/dist/_astro/{LifeShared.tnT7aQON.js → LifeShared.bY2l01Ha.js} +2 -2
  38. package/dist/_astro/LifeStagesBoard.CIzxPOJB.js +1 -0
  39. package/dist/_astro/LifeYearCycleSelect.BlsyPmmI.js +1 -0
  40. package/dist/_astro/LifeYearPlansBoard.DaA9O08j.js +1 -0
  41. package/dist/_astro/MultiSelectDropdown.D-rbpivp.js +1 -0
  42. package/dist/_astro/{NamePromptDialog.Csfnh5eM.js → NamePromptDialog.KPCeXmri.js} +1 -1
  43. package/dist/_astro/NavLibraries.DVR5Ua-S.js +1 -0
  44. package/dist/_astro/PluginsPage.B063QIlQ.js +18 -0
  45. package/dist/_astro/PmBugsBoard.Cu-v0Gfd.js +1 -0
  46. package/dist/_astro/PmIterationsBoard.CgRzkP-j.js +1 -0
  47. package/dist/_astro/{PmProjectDetail.DneFVBpy.js → PmProjectDetail.DVCEh0Lm.js} +1 -1
  48. package/dist/_astro/PmProjectsBoard.z-bQa98r.js +1 -0
  49. package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +1 -0
  50. package/dist/_astro/PmRequirementsBoard.CyfBI0u_.js +1 -0
  51. package/dist/_astro/PmShared.BQVzwsiz.js +1 -0
  52. package/dist/_astro/ReportsPage.najSzJeT.js +1 -0
  53. package/dist/_astro/ReqAnalysisBoard.BQb8dHFD.js +39 -0
  54. package/dist/_astro/RequirementBreakdownLibrary.Cn6OV6xt.js +2 -0
  55. package/dist/_astro/RequirementsLibrary.CqKNFVsP.js +1 -0
  56. package/dist/_astro/SearchableSelect.DXclLMJI.js +1 -0
  57. package/dist/_astro/SelectDropdown.D7IeyHDI.js +1 -0
  58. package/dist/_astro/SettingsDialog.db3BpFw0.js +1 -0
  59. package/dist/_astro/SlideOverDrawer.BMg2tce6.js +1 -0
  60. package/dist/_astro/SpaceSwitcher.DSUVAPOi.js +7 -0
  61. package/dist/_astro/{TableFieldConfig.C7O-mL-p.js → TableFieldConfig.72AL-8p-.js} +1 -1
  62. package/dist/_astro/{TagSelect.UUXgkMqJ.js → TagSelect.B_r2p0fp.js} +1 -1
  63. package/dist/_astro/TasksBoard.CCDhCSR7.js +1 -0
  64. package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +1 -0
  65. package/dist/_astro/TestReportsLibrary.fWiEyCRx.js +1 -0
  66. package/dist/_astro/TestStatsBoard.BSUBsWSu.js +1 -0
  67. package/dist/_astro/Toast.BydY-X7T.js +1 -0
  68. package/dist/_astro/TodosBoard.By5YdlUe.js +1 -0
  69. package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +3 -0
  70. package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +10 -0
  71. package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +12 -0
  72. package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +3 -0
  73. package/dist/_astro/app-config.Dvfzl5_N.js +1 -0
  74. package/dist/_astro/app-version.CNpnKIb9.js +1 -0
  75. package/dist/_astro/{bash-tools.D9HCzC_7.js → bash-tools.CS2w8LOb.js} +1 -1
  76. package/dist/_astro/business-map.BiJ85oxm.js +1 -0
  77. package/dist/_astro/business-map.DKwdW1VL.css +1 -0
  78. package/dist/_astro/case-gen-run.Cvvdv_kv.js +26 -0
  79. package/dist/_astro/case-prompt.CZ3vWUju.js +2 -0
  80. package/dist/_astro/{case-review.TdDs1WFM.js → case-review.DFWZkoR9.js} +1 -1
  81. package/dist/_astro/{case-template.Cd2xNbgy.js → case-template.Clb7HrDB.js} +1 -1
  82. package/dist/_astro/defect-submit.Dc49lFjm.css +1 -0
  83. package/dist/_astro/defect-workbench.CjTb4FDv.js +6 -0
  84. package/dist/_astro/dialog.XgRGNF_Q.js +1 -0
  85. package/dist/_astro/doc-roots.C-20VD0x.js +1 -0
  86. package/dist/_astro/{hydrate-cache.B15Nrpq0.js → hydrate-cache.O4CIma9y.js} +1 -1
  87. package/dist/_astro/i18n.Cp4so7KR.js +7 -0
  88. package/dist/_astro/{llm.DN5S1KBK.js → llm.BCYNgppW.js} +1 -1
  89. package/dist/_astro/mcp-tools.Kf-lupGn.js +7 -0
  90. package/dist/_astro/{open-docs-in-session.CRiZT022.js → open-docs-in-session.BpcAcBSI.js} +1 -1
  91. package/dist/_astro/plugins.Db9xoFZb.js +1 -0
  92. package/dist/_astro/project-docs.bB9lQ1Ki.js +1 -0
  93. package/dist/_astro/prompts-meta.VAjE4OET.js +2 -0
  94. package/dist/_astro/report-prompt.CwHuOcRN.js +1 -0
  95. package/dist/_astro/req-analysis.C_gARMrB.js +31 -0
  96. package/dist/_astro/requirement-breakdown-library.l0rPd7b3.js +1 -0
  97. package/dist/_astro/{settings.38J2uD5M.js → settings.D02wZj3w.js} +2 -2
  98. package/dist/_astro/space-skills.CPucW8zt.js +1 -0
  99. package/dist/_astro/{spaces-client.DV04tRyD.js → spaces-client.BAtG6PkW.js} +1 -1
  100. package/dist/_astro/story-review.DTN91Vl9.js +7 -0
  101. package/dist/_astro/test-points.C7ZgggQT.js +8 -0
  102. package/dist/_astro/test-reports.0gr6-c_0.js +19 -0
  103. package/dist/_astro/ui-auto-prompt.BmO3ja2m.js +8 -0
  104. package/dist/_astro/{view-prefs.DhdLZjGh.js → view-prefs.COAKEQtZ.js} +1 -1
  105. package/dist/business-map/index.html +983 -0
  106. package/dist/case-exec/index.html +10 -7
  107. package/dist/{prompts → case-execution}/index.html +12 -9
  108. package/dist/cases/generate/index.html +9 -6
  109. package/dist/cases/library/index.html +10 -7
  110. package/dist/dashboard/index.html +10 -7
  111. package/dist/defect-rules/index.html +690 -0
  112. package/dist/defect-submit/index.html +690 -0
  113. package/dist/defect-submit/templates/index.html +690 -0
  114. package/dist/docs/changelog/index.html +265 -51
  115. package/dist/docs/install/index.html +44 -12
  116. package/dist/docs/manual/index.html +213 -75
  117. package/dist/knowledge/index.html +10 -7
  118. package/dist/life/kr-tasks/index.html +10 -7
  119. package/dist/life/kr-todos/index.html +10 -7
  120. package/dist/life/objectives/index.html +10 -7
  121. package/dist/life/reviews/index.html +10 -7
  122. package/dist/life/stages/index.html +10 -7
  123. package/dist/life/year-plans/index.html +10 -7
  124. package/dist/plugins/index.html +10 -7
  125. package/dist/pm/bugs/index.html +10 -7
  126. package/dist/pm/iterations/index.html +10 -7
  127. package/dist/pm/projects/detail/index.html +10 -7
  128. package/dist/pm/projects/index.html +10 -7
  129. package/dist/pm/requirements/index.html +10 -7
  130. package/dist/reports/index.html +10 -7
  131. package/dist/requirement-analysis/index.html +10 -7
  132. package/dist/requirement-breakdowns/index.html +983 -0
  133. package/dist/requirements/index.html +10 -7
  134. package/dist/tasks/index.html +10 -7
  135. package/dist/templates/index.html +10 -7
  136. package/dist/test-automation/index.html +10 -7
  137. package/dist/test-automation/projects/index.html +10 -7
  138. package/dist/test-reports/index.html +10 -7
  139. package/dist/test-stats/index.html +10 -7
  140. package/dist/todos/index.html +10 -7
  141. package/dist/workbench/index.html +9 -6
  142. package/docs/Codex-MCP/351/233/206/346/210/220.md +296 -0
  143. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/204/344/274/260.md +39 -0
  144. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/206/345/210/253/351/207/215/346/236/204/346/226/271/346/241/210.md +88 -0
  145. package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +22 -3
  146. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +41 -1
  147. package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +63 -17
  148. package/docs//346/217/222/344/273/266/344/273/223/345/272/223/344/270/216/346/212/200/350/203/275/346/225/264/345/220/210/346/226/271/346/241/210.md +187 -0
  149. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +208 -69
  150. package/lh-plugins/business-map/assistant.mjs +958 -0
  151. package/lh-plugins/business-map/auth-paths.mjs +61 -0
  152. package/lh-plugins/business-map/jobs.mjs +749 -0
  153. package/lh-plugins/business-map/login.mjs +295 -0
  154. package/lh-plugins/business-map/sources.mjs +1014 -0
  155. package/lh-plugins/case-execution/files.mjs +777 -0
  156. package/lh-plugins/case-execution/service.mjs +959 -0
  157. package/lh-plugins/case-execution-prompt.mjs +33 -0
  158. package/lh-plugins/lh-business-map.mjs +2431 -0
  159. package/lh-plugins/lh-case-execution.mjs +304 -0
  160. package/lh-plugins/lh-config.mjs +13 -0
  161. package/lh-plugins/lh-defect-submit.mjs +989 -0
  162. package/lh-plugins/lh-project-docs.mjs +31 -140
  163. package/lh-plugins/lh-reports.mjs +29 -57
  164. package/lh-plugins/lh-req-analysis.mjs +32 -3
  165. package/lh-plugins/lh-req-breakdown-library.mjs +1084 -0
  166. package/lh-plugins/lh-uiauto.mjs +514 -22
  167. package/lh-plugins/plugin-prompts.mjs +19 -15
  168. package/lh-plugins/req-analysis-revision.mjs +24 -0
  169. package/lh-plugins/test-points-prompt.mjs +2 -3
  170. package/lh-plugins/uiauto-auth-setup.mjs +218 -0
  171. package/lh-plugins/uiauto-explorer/apps.mjs +13 -2
  172. package/lh-plugins/uiauto-explorer/runner.mjs +15 -2
  173. package/lh-plugins/uiauto-explorer/sessions.mjs +305 -17
  174. package/lh-plugins/uiauto-node.mjs +102 -11
  175. package/lh-plugins/uiauto-prompt.mjs +20 -15
  176. package/lh-plugins/uiauto-sso.mjs +407 -0
  177. package/package.json +5 -2
  178. package/skills/case-execution/SKILL.md +30 -0
  179. package/skills/lantern-defect-submit/SKILL.md +15 -0
  180. package/skills/lantern-workflow/SKILL.md +57 -0
  181. package/skills/office/SKILL.md +26 -0
  182. package/dist/_astro/Base.DIbzr8uT.css +0 -1
  183. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CPR_CfsE.js +0 -2
  184. package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
  185. package/dist/_astro/CaseGenerateApp.CcAtVSQJ.js +0 -10
  186. package/dist/_astro/CasesLibrary.Ci_0hYqL.js +0 -21
  187. package/dist/_astro/ChatApp.DFKZOkZy.js +0 -227
  188. package/dist/_astro/DashboardBoard.Qvf8o4v1.js +0 -5
  189. package/dist/_astro/DocsFileBrowser.DwKBffbM.js +0 -1
  190. package/dist/_astro/KnowledgeLibrary.MDpMqeOd.js +0 -1
  191. package/dist/_astro/LifeKrTasksBoard.DsvW_S66.js +0 -1
  192. package/dist/_astro/LifeKrTodosBoard.D2KTqvg1.js +0 -1
  193. package/dist/_astro/LifeObjectivesBoard.B0cDK934.js +0 -1
  194. package/dist/_astro/LifePlanTypeSelect.BELDvMWU.js +0 -1
  195. package/dist/_astro/LifeStagesBoard.CZftLR9K.js +0 -1
  196. package/dist/_astro/LifeYearCycleSelect.Bw2eRbSm.js +0 -1
  197. package/dist/_astro/LifeYearPlansBoard.DB-RJFEl.js +0 -1
  198. package/dist/_astro/MultiSelectDropdown.CBC7aNOv.js +0 -1
  199. package/dist/_astro/NavLibraries.DdQYsZbe.js +0 -1
  200. package/dist/_astro/OverflowHint.CHZeFfUj.js +0 -1
  201. package/dist/_astro/PluginsPage.BVrMtkLi.js +0 -17
  202. package/dist/_astro/PluginsPage.xdbDGigE.js +0 -1
  203. package/dist/_astro/PmBugsBoard.CGpXUTPu.js +0 -1
  204. package/dist/_astro/PmIterationsBoard.BaKiFIam.js +0 -1
  205. package/dist/_astro/PmProjectsBoard.BxoMF9gK.js +0 -1
  206. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +0 -1
  207. package/dist/_astro/PmRequirementsBoard.DsK6RF7Q.js +0 -1
  208. package/dist/_astro/PmShared.BK8kWRSV.js +0 -1
  209. package/dist/_astro/PromptMountDialog.mrTx3U5T.js +0 -1
  210. package/dist/_astro/PromptsLibrary.B2LMGsrj.js +0 -1
  211. package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
  212. package/dist/_astro/ReqAnalysisBoard.D-KmRwQM.js +0 -39
  213. package/dist/_astro/RequirementsLibrary.cJc-bnGQ.js +0 -1
  214. package/dist/_astro/SearchableSelect.SyLRS-Jj.js +0 -1
  215. package/dist/_astro/SelectDropdown.T3CKHaLt.js +0 -1
  216. package/dist/_astro/SettingsDialog.C62iJkMt.js +0 -1
  217. package/dist/_astro/SpaceSwitcher.C47_S1g9.js +0 -7
  218. package/dist/_astro/TasksBoard.BUEg2BYk.js +0 -1
  219. package/dist/_astro/TemplatesLibrary.BLVIphXO.js +0 -1
  220. package/dist/_astro/TestReportsLibrary.DVq30Jae.js +0 -1
  221. package/dist/_astro/TestStatsBoard.-5BWQ6bI.js +0 -1
  222. package/dist/_astro/Toast.BO2NFckG.js +0 -1
  223. package/dist/_astro/TodosBoard.DI_lTp2e.js +0 -1
  224. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +0 -2
  225. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +0 -19
  226. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +0 -1
  227. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +0 -3
  228. package/dist/_astro/app-config.DkyjuL-S.js +0 -1
  229. package/dist/_astro/app-version.3eY3FSw1.js +0 -1
  230. package/dist/_astro/case-gen-run.BQeK-XUw.js +0 -22
  231. package/dist/_astro/case-types.DlFkbZJN.js +0 -1
  232. package/dist/_astro/dialog.DZHZCe_T.js +0 -1
  233. package/dist/_astro/doc-roots.CO3IBiY6.js +0 -1
  234. package/dist/_astro/i18n.D_aOCHSN.js +0 -7
  235. package/dist/_astro/markdown-client.BS19nLL3.js +0 -62
  236. package/dist/_astro/plugins.BRvXWHLe.js +0 -1
  237. package/dist/_astro/project-docs.CCjtiFjB.js +0 -1
  238. package/dist/_astro/prompts-meta.BUGutlsk.js +0 -2
  239. package/dist/_astro/report-prompt.B9C4cv84.js +0 -1
  240. package/dist/_astro/req-analysis.FrD6BfwK.js +0 -31
  241. package/dist/_astro/story-review.R8iWiFzl.js +0 -14
  242. package/dist/_astro/test-reports.CuIjlEyK.js +0 -19
  243. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +0 -9
  244. package/dist/_astro/ui-auto.DMv940x4.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./app-config.Dvfzl5_N.js";import{t}from"./settings.D02wZj3w.js";import{a as n,r}from"./plugins.Db9xoFZb.js";import{t as i}from"./app-version.CNpnKIb9.js";import{t as ee}from"./update.Fq2CGmCX.js";var a=100,te=1010,ne=420,o=14,re=150,s=6,ie=3200,ae=180,c=null,l=null,u=null,d=null,f=null,p=!1,m=0,h=0,g=0,_=0,v=!1,y=0,b=null,x=null,S=0,C=!1,w=null,T=!1;function E(e){if(!e.isConnected||e.closest(`[data-closed]`)||e.checkVisibility&&!e.checkVisibility({checkVisibilityCSS:!0}))return!0;let t=e.getBoundingClientRect();return t.width===0&&t.height===0}function D(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;if(n<0||r<0||n>window.innerWidth||r>window.innerHeight)return!1;let i=document.elementFromPoint(n,r);return i?!(i===e||e.contains(i)||i.contains(e)):!1}function O(e){let t=e.getBoundingClientRect();b&&b.left===t.left&&b.top===t.top&&b.width===t.width&&b.height===t.height||(M(),N())}function k(e){let t=e.getBoundingClientRect();return t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth}function oe(e,t,n){return t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}function A(){_&&=(cancelAnimationFrame(_),0)}function j(){x=null,S&&=(window.clearTimeout(S),0)}function se(){A();let e=()=>{_=0;let t=d;t&&(E(t)||k(t)||D(t)||C&&w&&!oe(t.getBoundingClientRect(),w.x,w.y)||!C&&!t.contains(document.activeElement)?L():(O(t),_=requestAnimationFrame(e)))};_=requestAnimationFrame(e)}function ce(){c&&c.isConnected||(c=document.createElement(`div`),c.setAttribute(`role`,`tooltip`),c.className=`tw-tooltip tw-tooltip-anim pointer-events-none fixed rounded-md px-2 py-1 text-[12px] leading-5 break-all text-stone-700 shadow-lg`,c.style.zIndex=String(a),c.style.maxHeight=`40vh`,c.style.overflowY=`auto`,c.dataset.closed=``,l=document.createElement(`span`),l.setAttribute(`aria-hidden`,`true`),l.className=`tw-tooltip-arrow absolute h-2 w-2`,l.style.transform=`translateX(-50%) rotate(45deg)`,u=document.createTextNode(``),c.append(l,u),document.body.appendChild(c))}function M(){if(!d)return;let e=d.getBoundingClientRect(),t=Math.min(Math.max(e.width,160),ne),n=e.bottom+72>window.innerHeight-8,r=n?e.top-s:e.bottom+s,i=Math.max(8,Math.min(e.left,Math.max(8,window.innerWidth-t-8)));f={top:r,left:i,maxWidth:t,openUp:n,arrowLeft:Math.max(o,Math.min(e.left+e.width/2-i,t-o))},b={left:e.left,top:e.top,width:e.width,height:e.height}}function N(){if(!c||!l||!f)return;let e=d?.dataset.hintLayer===`popover`;c.style.zIndex=String(e?te:a),c.style.maxHeight=e?``:`40vh`,c.style.overflowY=e?`visible`:`auto`,c.style.top=`${f.top}px`,c.style.left=`${f.left}px`,c.style.maxWidth=`${f.maxWidth}px`,c.classList.toggle(`is-up`,f.openUp),c.classList.toggle(`is-down`,!f.openUp),l.classList.toggle(`is-up`,f.openUp),l.classList.toggle(`is-down`,!f.openUp),l.style.left=`${f.arrowLeft}px`,l.style.top=f.openUp?``:`-5px`,l.style.bottom=f.openUp?`-5px`:``}function le(e){let t=e.innerText||``;return e.querySelectorAll(`[class*="sr-only"]`).forEach(e=>{let n=e.innerText;n&&(t=t.replace(n,``))}),t.replace(/\s+/g,` `).trim()}function ue(e){return e.scrollWidth>e.clientWidth+1||e.scrollHeight>e.clientHeight+1}function P(e){return e.dataset.hintAlways!==void 0||e.dataset.hintFit===void 0&&!le(e)||ue(e)}function F(e){return!!e.dataset.hint&&P(e)}function I(e,t){let n=e.dataset.hint??``;if(!n||!P(e))return;let r=e.getBoundingClientRect();if(!r.width||!r.height||e.checkVisibility&&!e.checkVisibility({checkVisibilityCSS:!0})||D(e)||(ce(),!c||!u))return;d=e,C=t,h&&=(window.clearTimeout(h),0),u.data=n,c.style.whiteSpace=n.includes(`
2
+ `)?`pre-wrap`:``,M(),N(),c.style.display=``,p||(c.dataset.closed=``),cancelAnimationFrame(m);let i=++y;m=requestAnimationFrame(()=>{m=requestAnimationFrame(()=>{c&&i===y&&d===e&&(p=!0,delete c.dataset.closed)})}),se(),g&&window.clearTimeout(g),g=window.setTimeout(()=>{g=0,d===e&&L()},ie)}function L(){A(),j(),y+=1,m&&=(cancelAnimationFrame(m),0),d=null,C=!1,b=null,g&&=(window.clearTimeout(g),0),c&&(p=!1,c.dataset.closed=``,h&&window.clearTimeout(h),h=window.setTimeout(()=>{h=0,!p&&c&&(c.style.display=`none`)},re))}function R(e){if(!(e instanceof Element))return null;let t=e.closest(`[data-hint]`);return t instanceof HTMLElement?t:null}function z(e){T=!0,(e.clientX!==0||e.clientY!==0)&&(w={x:e.clientX,y:e.clientY});let t=R(e.target);t!==d&&(!t||!F(t)?(j(),d&&L()):t!==x&&(j(),x=t,S=window.setTimeout(()=>{S=0;let e=x;x=null,e&&e!==d&&I(e,!0)},ae)))}function B(e){let t=R(e.target);if(t&&t===x&&j(),!t||t!==d)return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||L()}function V(e){if(T)return;let t=R(e.target);t!==d&&(!t||!F(t)?d&&L():I(t,!1))}function H(e){let t=R(e.target);if(!t||t!==d)return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||L()}function U(){j(),d&&L()}function W(){d&&(E(d)||k(d)||D(d)?L():O(d))}function de(e){w={x:e.clientX,y:e.clientY},T=!0}function fe(){T=!0,j(),d&&L()}function pe(e){T=!1,e.key===`Escape`&&d&&L()}function me(){typeof document>`u`||v||(v=!0,document.addEventListener(`mouseover`,z,!0),document.addEventListener(`mouseout`,B,!0),document.addEventListener(`pointermove`,de,{capture:!0,passive:!0}),document.addEventListener(`pointerdown`,fe,!0),document.addEventListener(`focusin`,V,!0),document.addEventListener(`focusout`,H,!0),document.addEventListener(`click`,U,!0),document.addEventListener(`keydown`,pe,!0),window.addEventListener(`scroll`,W,!0),window.addEventListener(`resize`,W),window.addEventListener(`blur`,()=>{d&&L()}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&d&&L()}),document.documentElement.addEventListener(`mouseleave`,()=>{d&&L()}),document.addEventListener(`astro:after-swap`,()=>{A(),y+=1,m&&=(cancelAnimationFrame(m),0),g&&=(window.clearTimeout(g),0),d=null,p=!1,b=null,c?.isConnected&&c.remove(),c=null,l=null,u=null}))}var he=[`dashboard`,`tasks`,`todos`,`projects`,`iterations`,`pmRequirements`,`bugs`,`reports`,`testStats`,`caseExec`,`businessMap`,`defectSubmit`,`cases`,`knowledgeLib`,`requirements`,`templates`,`testReports`];function ge(e){return`pluginOff${e.charAt(0).toUpperCase()}${e.slice(1)}`}function G(){let e=document.documentElement;for(let t of he){let n=ge(t);r(t)?delete e.dataset[n]:e.dataset[n]=`1`}}function _e(){G(),n(()=>G()),e().then(()=>G()),document.addEventListener(`astro:page-load`,G)}var ve=`tw-update-dot`,ye=3e5,K=`tw.update.badge.checked-at.v1`,be=15e3,xe=4,q=0,J=null,Y=!1,X=`tw.update.stale.reload.v1`;function Se(e){let t=e.status?.phase;return t===`installing`||t===`restarting`}function Ce(e){if(e.mode===`dev`&&!Se(e)&&e.current&&e.current!==i){try{let e=Number(localStorage.getItem(X))||0;if(Date.now()-e<6e4)return;localStorage.setItem(X,String(Date.now()))}catch{}window.location.reload()}}function we(){try{return Number(localStorage.getItem(K))||0}catch{return 0}}function Te(){try{localStorage.setItem(K,String(Date.now()))}catch{}}function Z(e,t,n){e.hidden=!n,e.closest(`.tw-nav-brand-ver`)?.classList.toggle(`has-update`,n),n&&e.setAttribute(`aria-label`,t?`有新版本可用 v${t}`:`有新版本可更新`)}function Ee(e,t){q>=xe||(q+=1,J!==null&&window.clearTimeout(J),J=window.setTimeout(()=>{J=null,Q(e,t)},be))}async function Q(e,t){if(!Y){Y=!0;try{let n=await ee(t);if(!n){Ee(e,t);return}q=0,Te();let r=!!n.current&&n.current!==i;Z(e,n.latest,!!n.hasUpdate||r),r&&Ce(n)}finally{Y=!1}}}function $(){let e=document.getElementById(ve);if(!e)return;e.dataset.bound!==`1`&&(e.dataset.bound=`1`,e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),window.dispatchEvent(new CustomEvent(t,{detail:{tab:`general`}}))}));let n=Date.now()-we()>ye;q=0,Q(e,n)}function De(){document.addEventListener(`astro:page-load`,$),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&$()}),document.readyState!==`loading`&&$()}me(),_e(),De();
@@ -0,0 +1,5 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as a,t as o}from"./dialog.XgRGNF_Q.js";import{i as s,n as c,r as l,t as u}from"./menu.Dnrpz489.js";import{C as d,D as f,E as p,O as m,S as h,T as g,_,a as v,b as y,c as b,d as x,f as S,g as C,h as ee,i as te,l as ne,m as re,n as ie,o as ae,r as oe,s as se,t as w,u as ce,v as le,x as ue,y as de}from"./business-map.BiJ85oxm.js";import{u as fe}from"./settings.D02wZj3w.js";import{t as T}from"./jsx-runtime.DUg_B_vD.js";import{t as pe}from"./ConfirmDialog.DQFd6g2r.js";import{a as E,n as D,o as O,t as k}from"./view-prefs.COAKEQtZ.js";import{n as A,t as j}from"./SelectDropdown.D7IeyHDI.js";import{m as M}from"./PmShared.BQVzwsiz.js";import{showToast as N}from"./Toast.BydY-X7T.js";var P=e(t(),1);async function F(e,t={}){let n=await fetch(`${w}${e}`,{...t,headers:{...t.body?{"Content-Type":`application/json`}:{},...t.headers||{}}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new ie(r.error||`HTTP ${n.status}`,n.status,r.code||``);return r}var I=(e,t=``)=>`/systems/${encodeURIComponent(e)}/assistant${t}`;async function L(e){return(await F(I(e))).session}async function R(e,t){return(await F(I(e,`/messages`),{method:`POST`,body:JSON.stringify(t)})).session}async function z(e){return(await F(I(e,`/stop`),{method:`POST`,body:JSON.stringify({})})).session}async function me(e){return(await F(I(e,`/reset`),{method:`POST`,body:JSON.stringify({})})).session}async function he(e,t){let n=await F(I(e,`/apply`),{method:`POST`,body:JSON.stringify({revision:t})});return{session:n.session,store:de(n.store)}}function ge(e,t,n){let r=new AbortController,i=n.signal,a=!1,o=Math.max(0,t),s=0,c,l=()=>{a=!0,c&&clearTimeout(c),r.abort()};i?.addEventListener(`abort`,l,{once:!0});let u=async()=>{if(!(a||i?.aborted))try{let t=await fetch(`${w}${I(e,`/events`)}?after=${encodeURIComponent(o)}`,{headers:{Accept:`text/event-stream`},signal:r.signal});if(!t.ok||!t.body)throw Error(`SSE ${t.status}`);s=0;let l=t.body.getReader(),d=new TextDecoder,f=``;for(;;){let{done:e,value:t}=await l.read();if(e){!a&&!i?.aborted&&(c=setTimeout(()=>void u(),800));break}f+=d.decode(t,{stream:!0});let r=f.split(`
2
+ `);f=r.pop()||``;for(let e of r){let t=e.trim();if(t.startsWith(`data:`))try{let e=JSON.parse(t.slice(5).trim());Number.isFinite(e.seq)&&(o=Math.max(o,e.seq)),n.onEvent(e)}catch{}}}}catch(e){if(a||i?.aborted)return;if(s+=1,s>=8){n.onDisconnect?.(e instanceof Error?e:Error(String(e)));return}n.onDisconnect?.(e instanceof Error?e:Error(String(e))),c=setTimeout(()=>void u(),Math.min(5e3,500*s))}};return u(),l}var B=T(),V={idle:`等待指令`,running:`AI 正在整理`,awaiting_confirmation:`等待应用草案`,stopped:`已停止`,error:`识别失败`,interrupted:`已中断`};function H(e){return e.type===`error`?`is-error`:e.type===`warning`?`is-warning`:e.type===`proposal`?`is-success`:e.type===`progress`?`is-progress`:``}function U({proposal:e}){let t=new Map;for(let n of e.directories){let e=t.get(n.parentKey)||[];e.push(n),t.set(n.parentKey,e)}let n=new Map;for(let t of e.functions){let e=n.get(t.directoryKey)||[];e.push(t),n.set(t.directoryKey,e)}function r(e,i){return(t.get(e)||[]).map(e=>(0,B.jsxs)(`div`,{className:`tw-bm-ai-proposal-branch`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-ai-proposal-directory`,style:{paddingLeft:`${i*14}px`},children:[(0,B.jsx)(M,{name:`folder`,size:13}),(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:e.menuPath.join(` / `)})]}),r(e.key,i+1),(n.get(e.key)||[]).map(t=>(0,B.jsxs)(`div`,{className:`tw-bm-ai-proposal-function`,style:{paddingLeft:`${(i+1)*14}px`},children:[(0,B.jsx)(`span`,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:t.name}),(0,B.jsx)(`small`,{children:t.purpose||`待补充作用`})]})]},`${e.key}-${t.name}`))]},e.key))}return(0,B.jsxs)(`div`,{className:`tw-bm-ai-proposal-tree`,children:[r(``,0),(n.get(``)||[]).map(e=>(0,B.jsxs)(`div`,{className:`tw-bm-ai-proposal-function`,children:[(0,B.jsx)(`span`,{}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:e.purpose||`待补充作用`})]})]},`root-${e.name}`))]})}function _e({proposal:e}){return(0,B.jsx)(`div`,{className:`tw-bm-ai-flow-proposals`,children:e.flows.map(e=>(0,B.jsxs)(`article`,{children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsxs)(`span`,{children:[e.steps.length,` 步`]})]}),(0,B.jsx)(`p`,{children:e.result||`最终结果待补充`}),(0,B.jsx)(`ol`,{children:e.steps.map(t=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{children:t.n}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:t.title}),(0,B.jsx)(`small`,{children:[t.role,t.system,t.manual?`人工环节`:``].filter(Boolean).join(` · `)}),t.input||t.output?(0,B.jsxs)(`span`,{children:[t.input||`输入`,` → `,t.output||`输出`]}):null]})]},`${e.name}-${t.n}`))})]},e.name))})}function ve({system:e,revision:t,closing:s,onClose:c,onChanged:l,onApplied:u}){let[d,f]=(0,P.useState)(null),[p,m]=(0,P.useState)(`directory`),[h,g]=(0,P.useState)(``),[_,v]=(0,P.useState)(``),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(!1),[C,ee]=(0,P.useState)(()=>fe()?.model||`未配置模型`),[te,ne]=(0,P.useState)(()=>window.innerWidth>=1280),[re,ie]=(0,P.useState)(!1),[ae,oe]=(0,P.useState)(!0),[se,w]=(0,P.useState)(()=>Date.now()),ce=(0,P.useRef)(null),le=(0,P.useRef)(null),ue=(0,P.useRef)(null),de=(0,P.useRef)(null),T=(0,P.useRef)(0),E=!!(d?.directoryApplied||e.functions.length),D=d?.status===`running`,O=d?.proposal||null,k=d?.progress,A=k?.startedAt&&D?Math.max(Number(k.elapsedSeconds)||0,Math.max(0,Math.floor((se-Date.parse(k.startedAt))/1e3))):Math.max(0,Number(k?.elapsedSeconds)||0),j=!(!D||!k?.indeterminate&&k?.total),F=(0,P.useMemo)(()=>[...d?.events||[]].sort((e,t)=>e.seq-t.seq),[d?.events]);(0,P.useEffect)(()=>{T.current=d?.seq||0},[d?.seq]),(0,P.useEffect)(()=>{ee(fe()?.model||`未配置模型`)},[]),(0,P.useEffect)(()=>{let e=ue.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(180,Math.max(52,e.scrollHeight))}px`)},[h]),(0,P.useEffect)(()=>{if(!x)return;let e=e=>{le.current?.contains(e.target)||S(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[x]),(0,P.useEffect)(()=>{if(!D)return;w(Date.now());let e=window.setInterval(()=>w(Date.now()),1e3);return()=>window.clearInterval(e)},[D]);let I=(0,P.useCallback)(async()=>{let t=await L(e.id);return f(t),t},[e.id]);(0,P.useEffect)(()=>{let t=!0;return oe(!0),L(e.id).then(e=>{t&&(f(e),m(e.phase||`directory`))}).catch(e=>{t&&v(e instanceof Error?e.message:String(e))}).finally(()=>{t&&oe(!1)}),()=>{t=!1}},[e.id]),(0,P.useEffect)(()=>{if(de.current?.(),de.current=null,d?.status!==`running`)return;let t=new AbortController,n;return de.current=ge(e.id,T.current,{signal:t.signal,onEvent:e=>{f(t=>{if(!t)return t;let n=new Set(t.events.map(e=>e.seq));return{...t,seq:Math.max(t.seq,e.seq),progress:e.progress||t.progress,events:n.has(e.seq)?t.events:[...t.events,e].slice(-500)}}),([`proposal`,`error`].includes(e.type)||e.status===`stopped`)&&(n&&window.clearTimeout(n),n=window.setTimeout(()=>{I().catch(()=>void 0)},120)),e.type===`status`&&[`completed`,`stopped`,`error`,`interrupted`].includes(e.status||``)&&t.abort()},onDisconnect:()=>void 0}),()=>{n&&window.clearTimeout(n),t.abort(),de.current?.(),de.current=null}},[I,d?.runId,d?.status,e.id]),(0,P.useEffect)(()=>{ce.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[d?.messages.length,O]);async function ve(n=h){let r=n.trim();if(!r||y||D)return;let i=fe();if(!i)v(`请先在模型设置中配置可用模型`);else{ee(i.model),b(!0),v(``);try{let n=await R(e.id,{revision:t,phase:p,message:r,settings:i});f(n),g(``),S(!1)}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}}}async function ye(){b(!0);try{f(await z(e.id))}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}}async function W(){if(O){b(!0),v(``);try{let n=await he(e.id,t);f(n.session),m(n.session.phase),u(),N(O.kind===`directory`?`功能目录已应用到地图`:`业务流程已应用到地图`,`success`)}catch(e){v(e instanceof Error?e.message:String(e)),l()}finally{b(!1)}}}async function be(){b(!0);try{let t=await me(e.id);f(t),m(`directory`),ie(!1),N(`AI 会话已重置`,`success`)}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}}return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(a,{open:!0,onClose:c,className:`tw-bm-theme relative z-110`,children:[(0,B.jsx)(o,{className:`tw-bm-overlay ${s?`is-closing`:``}`}),(0,B.jsxs)(n,{className:`tw-bm-assistant-dialog ${s?`is-closing`:``} ${te?`with-logs`:``}`,children:[(0,B.jsxs)(`header`,{className:`tw-bm-assistant-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`tw-bm-badge accent`,children:`AI 助手`}),(0,B.jsx)(i,{as:`h2`,children:e.name}),(0,B.jsx)(r,{children:`先识别并确认功能目录,再基于已确认功能梳理业务流程。`})]}),(0,B.jsxs)(`div`,{className:`tw-bm-assistant-head-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:te?`active`:``,onClick:()=>ne(e=>!e),children:`任务栏`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>ie(!0),children:`重置会话`}),(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-icon-btn`,"aria-label":`关闭`,onClick:c,children:`×`})]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-assistant-phases`,children:[(0,B.jsxs)(`button`,{type:`button`,className:p===`directory`?`active`:``,onClick:()=>m(`directory`),children:[(0,B.jsx)(`span`,{children:`1`}),(0,B.jsx)(`strong`,{children:`功能目录`}),(0,B.jsx)(`small`,{children:d?.directoryApplied?`已应用`:`识别目录与功能`})]}),(0,B.jsx)(`i`,{}),(0,B.jsxs)(`button`,{type:`button`,className:p===`flow`?`active`:``,disabled:!E,onClick:()=>m(`flow`),children:[(0,B.jsx)(`span`,{children:`2`}),(0,B.jsx)(`strong`,{children:`业务流程`}),(0,B.jsx)(`small`,{children:E?`基于功能树识别`:`先应用功能目录`})]}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`span`,{className:`tw-bm-ai-status is-${d?.status||`idle`}`,children:d?V[d.status]:`加载中`}),D?(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn danger ghost`,onClick:()=>void ye(),children:`停止`}):null]}),(0,B.jsxs)(`div`,{className:`tw-bm-assistant-body`,children:[(0,B.jsxs)(`main`,{className:`tw-bm-assistant-chat`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-assistant-messages`,children:[!d?.messages.length&&!ae?(0,B.jsxs)(`div`,{className:`tw-bm-assistant-empty`,children:[(0,B.jsx)(`span`,{children:`AI`}),(0,B.jsx)(`strong`,{children:`从真实菜单开始整理业务地图`}),(0,B.jsx)(`p`,{children:`可以直接输入要求,也可以使用下面的快捷指令。`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void ve(`识别系统全部菜单,整理为功能目录树和业务功能。`),children:`识别功能目录`}),E?(0,B.jsx)(`button`,{type:`button`,onClick:()=>{m(`flow`),ve(`基于当前已确认功能目录,识别全部业务流程。`)},children:`识别业务流程`}):null]})]}):null,d?.messages.map(e=>(0,B.jsxs)(`article`,{className:`tw-bm-assistant-message ${e.role}`,children:[(0,B.jsx)(`span`,{children:e.role===`assistant`?`AI`:`我`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{children:e.content}),e.applied?(0,B.jsx)(`small`,{children:`已应用到正式地图`}):null]})]},e.id)),D&&!O?(0,B.jsxs)(`div`,{className:`tw-bm-assistant-thinking`,role:`status`,"aria-live":`polite`,children:[(0,B.jsxs)(`span`,{"aria-hidden":`true`,children:[(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:k?.label||`正在处理`}),(0,B.jsx)(`p`,{children:j?A?`已等待 ${A} 秒,模型连接仍然正常。可以继续等待或停止任务。`:`正在等待模型响应,任务会在后台继续。`:`正在校验返回结果,请稍候。`})]})]}):null,O?(0,B.jsxs)(`section`,{className:`tw-bm-ai-proposal`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`tw-bm-badge accent`,children:O.kind===`directory`?`目录草案`:`流程草案`}),(0,B.jsx)(`strong`,{children:O.kind===`directory`?`${O.directories.length} 个目录 · ${O.functions.length} 个功能`:`${O.flows.length} 条业务流程`})]}),(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn primary`,disabled:y,onClick:()=>void W(),children:O.kind===`directory`?`应用为功能目录`:`应用业务流程`})]}),O.kind===`directory`?(0,B.jsx)(U,{proposal:O}):(0,B.jsx)(_e,{proposal:O}),O.warnings.length?(0,B.jsxs)(`details`,{children:[(0,B.jsxs)(`summary`,{children:[O.warnings.length,` 项识别说明`]}),(0,B.jsx)(`ul`,{children:O.warnings.map(e=>(0,B.jsx)(`li`,{children:e},e))})]}):null]}):null,(0,B.jsx)(`div`,{ref:ce})]}),_?(0,B.jsx)(`p`,{className:`tw-bm-field-error`,children:_}):null,(0,B.jsxs)(`div`,{className:`tw-bm-assistant-composer`,ref:le,children:[x?(0,B.jsxs)(`div`,{className:`tw-bm-assistant-add-menu`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{m(`directory`),g(`识别系统全部菜单,整理为功能目录树和业务功能。`),S(!1),requestAnimationFrame(()=>ue.current?.focus())},children:[(0,B.jsx)(M,{name:`folder`,size:14}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:`识别功能目录`}),(0,B.jsx)(`small`,{children:`按系统菜单整理目录和功能`})]})]}),(0,B.jsxs)(`button`,{type:`button`,disabled:!E,onClick:()=>{m(`flow`),g(`基于当前已确认功能目录,识别全部业务流程。`),S(!1),requestAnimationFrame(()=>ue.current?.focus())},children:[(0,B.jsx)(M,{name:`chat`,size:14}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:`识别业务流程`}),(0,B.jsx)(`small`,{children:E?`基于已应用功能生成流程`:`请先应用功能目录`})]})]})]}):null,(0,B.jsx)(`textarea`,{ref:ue,rows:1,value:h,disabled:D||y,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`&&x?(e.preventDefault(),S(!1)):e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ve())},className:`tw-chat-input`,placeholder:p===`directory`?`例如:识别全部菜单;把新建工单归到工单受理;忽略系统设置菜单`:`例如:识别全部业务流程;只分析工单受理和工单办理`}),(0,B.jsxs)(`div`,{className:`tw-composer-bar`,children:[(0,B.jsx)(`button`,{type:`button`,className:`tw-icon-btn tw-bm-composer-add ${x?`is-open`:``}`,"aria-label":`添加快捷指令`,onClick:()=>S(e=>!e),children:(0,B.jsx)(M,{name:`plus`,size:16})}),(0,B.jsxs)(`span`,{className:`tw-bm-composer-chip`,title:e.name,children:[(0,B.jsx)(M,{name:`folder`,size:13}),(0,B.jsx)(`span`,{children:e.name})]}),(0,B.jsxs)(`span`,{className:`tw-bm-composer-chip is-readonly`,title:`仅执行只读页面采集`,children:[(0,B.jsx)(`i`,{}),`只读采集`]}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`span`,{className:`tw-bm-composer-model`,title:C,children:C}),(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-composer-send ${D?`is-stop`:``}`,disabled:!D&&(!h.trim()||y),"aria-label":D?`停止识别`:`发送`,onClick:()=>{D?ye():ve()},children:D?(0,B.jsx)(`span`,{className:`tw-bm-composer-stop`}):(0,B.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`m5 12 14-7-4 14-3-5Z`})})})]})]})]}),te?(0,B.jsxs)(`aside`,{className:`tw-bm-assistant-logs`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`strong`,{children:`任务执行`}),(0,B.jsx)(`span`,{children:V[d?.status||`idle`]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-assistant-progress`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:k?.label||`等待开始`}),(0,B.jsx)(`strong`,{children:j?A?`${A}s`:`处理中`:`${k?.percent||0}%`})]}),(0,B.jsx)(`i`,{className:j?`is-indeterminate`:``,children:(0,B.jsx)(`span`,{style:{width:`${k?.percent||0}%`}})}),j?(0,B.jsx)(`small`,{children:A?`已等待 ${A} 秒,仍在等待模型返回`:`正在等待模型返回,界面会持续更新`}):k?.total?(0,B.jsxs)(`small`,{children:[k.current,` / `,k.total]}):null]}),(0,B.jsxs)(`div`,{className:`tw-bm-assistant-log-title`,children:[(0,B.jsx)(`strong`,{children:`执行日志`}),(0,B.jsxs)(`span`,{children:[F.length,` 条`]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-assistant-event-list`,children:[F.map(e=>(0,B.jsxs)(`div`,{className:`tw-bm-assistant-event ${H(e)}`,children:[(0,B.jsx)(`span`,{children:e.at?new Date(e.at).toLocaleTimeString():``}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.title}),e.detail?(0,B.jsx)(`small`,{children:e.detail}):null]})]},e.seq)),F.length?null:(0,B.jsx)(`p`,{children:`还没有执行记录。`})]})]}):null]})]})]}),re?(0,B.jsx)(pe,{open:!0,title:`重置 AI 会话`,message:`将清空当前会话消息、草案和日志,不会修改已经应用的业务地图。`,confirmLabel:`重置会话`,danger:`solid`,onClose:()=>ie(!1),onConfirm:()=>void be()}):null]})}var ye={revision:``,mode:`none`,username:``,loginUrl:``,endpoint:``,bodyTemplate:`{"username":"{{username}}","password":"{{password}}"}`,tokenPath:``,tokenStorageKey:`token`,usernameSelector:``,passwordSelector:``,submitSelector:``};async function W(e,t=``,n=`GET`,r){let i=await fetch(`${w}/systems/${encodeURIComponent(e)}/login${t?`/`+t:``}`,{method:n,cache:`no-store`,...r===void 0?{}:{headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}}),a=await i.json();if(i.status===405||a.code===`revision_conflict`||i.ok&&!a.config)throw new ie(`当前 Lantern 后端尚未加载登录配置接口,请重启 Lantern 服务后再试`,i.status,`login_api_unavailable`);if(!i.ok)throw new ie(a.error||`登录操作失败`,i.status,a.code);return a}var be=(0,P.forwardRef)(function({systemId:e,entryChanged:t=!1},n){let[r,i]=(0,P.useState)({...ye}),[a,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),[d,f]=(0,P.useState)(!0),[p,m]=(0,P.useState)(``),[h,g]=(0,P.useState)(``),[_,v]=(0,P.useState)(`idle`),y=s?.status===`awaiting_login`,b=d||!s||!!p||y;function x(e){c(e),i({...ye,...e.config}),o(``),u(!1)}(0,P.useEffect)(()=>{let t=!0;return W(e).then(e=>{t&&x(e)}).catch(e=>{t&&N(e.message,`error`)}).finally(()=>{t&&f(!1)}),()=>{t=!1}},[e]),(0,P.useEffect)(()=>{if(!y)return;let t=window.setInterval(()=>{W(e).then(e=>{c(e),e.status===`ready`&&v(`success`)}).catch(e=>{N(e.message,`error`),c(e=>e?{...e,status:`idle`}:null)})},2e3);return()=>window.clearInterval(t)},[e,y]);function S(e,t){i(n=>({...n,[e]:t})),u(!0),g(``),v(`idle`)}async function C(){if(l){if(!s)throw Error(`当前登录配置接口不可用,请重启 Lantern 服务后再试`);if(d||p)throw Error(`登录配置正在处理,请稍后再保存`);x(await W(e,``,`PUT`,{...r,password:a}))}}(0,P.useImperativeHandle)(n,()=>({save:C}));async function ee(t){g(``);try{m(t),t===`start`&&await C();let n=await W(e,t,`POST`,{});x(n),v(t===`start`||t===`complete`?n.status===`ready`?`success`:n.status===`awaiting_login`?`waiting`:`idle`:`idle`);let r=n.message||(t===`cancel`?`已关闭登录窗口`:`登录操作已完成`);n.status===`awaiting_login`?g(r):N(r,`success`)}catch(e){(t===`start`||t===`complete`)&&v(`error`),N(e instanceof Error?e.message:`登录操作失败`,`error`)}finally{m(``)}}return(0,B.jsxs)(`section`,{className:`tw-bm-login-settings tw-bm-form`,"aria-label":`系统登录配置`,children:[(0,B.jsx)(`h3`,{children:`登录配置`}),(0,B.jsx)(`p`,{className:`tw-bm-form-note`,children:`账号密码和登录态仅保存在当前空间的本机配置,不写入业务地图或发送给模型;配置会随「保存设置」或「验证登录」一并保存。`}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`登录方式`}),(0,B.jsx)(j,{ariaLabel:`登录方式`,value:r.mode,disabled:b,onChange:e=>S(`mode`,e),options:[{value:`none`,label:`无需登录`},{value:`password`,label:`账号密码登录`},{value:`sso`,label:`SSO / 接口登录`},{value:`manual`,label:`手动登录(验证码 / 扫码)`}]})]}),r.mode===`none`?null:(0,B.jsxs)(B.Fragment,{children:[r.mode===`sso`?null:(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`登录地址(可选,默认系统入口)`}),(0,B.jsx)(`input`,{value:r.loginUrl,disabled:b,placeholder:`https://...`,onChange:e=>S(`loginUrl`,e.target.value)})]}),r.mode===`password`||r.mode===`sso`?(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`登录账号`}),(0,B.jsx)(`input`,{value:r.username,disabled:b,autoComplete:`off`,onChange:e=>S(`username`,e.target.value)})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`登录密码`}),(0,B.jsx)(`input`,{type:`password`,value:a,disabled:b,autoComplete:`new-password`,placeholder:s?.hasPassword?`••••••••••••`:`请输入密码`,onChange:e=>{o(e.target.value),u(!0),v(`idle`)}})]})]}):null,r.mode===`sso`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`登录接口地址`}),(0,B.jsx)(`input`,{value:r.endpoint,disabled:b,placeholder:`https://... 或 /api/login`,onChange:e=>S(`endpoint`,e.target.value)})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`请求体模板`}),(0,B.jsx)(`textarea`,{rows:3,value:r.bodyTemplate,disabled:b,onChange:e=>S(`bodyTemplate`,e.target.value)})]}),(0,B.jsx)(`p`,{className:`tw-bm-form-note`,children:`使用 {{username}} 和 {{password}} 引用账号密码。接口需支持返回 Token 或 Cookie;验证码不会自动绕过。`}),(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Token 路径(可选)`}),(0,B.jsx)(`input`,{value:r.tokenPath,disabled:b,placeholder:`data.token`,onChange:e=>S(`tokenPath`,e.target.value)})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Token 存储名称`}),(0,B.jsx)(`input`,{value:r.tokenStorageKey,disabled:b,onChange:e=>S(`tokenStorageKey`,e.target.value)})]})]})]}):null,r.mode===`password`?(0,B.jsxs)(`details`,{children:[(0,B.jsx)(`summary`,{children:`自定义登录控件(可选)`}),(0,B.jsx)(`div`,{className:`tw-bm-form`,children:[[`usernameSelector`,`账号输入框`],[`passwordSelector`,`密码输入框`],[`submitSelector`,`登录按钮`]].map(([e,t])=>(0,B.jsxs)(`label`,{children:[(0,B.jsxs)(`span`,{children:[t,`选择器`]}),(0,B.jsx)(`input`,{value:r[e],disabled:b,onChange:t=>S(e,t.target.value)})]},e))})]}):null]}),r.mode===`none`?null:(0,B.jsxs)(`div`,{className:`tw-bm-login-status is-${p===`start`?`checking`:_===`idle`&&s?.stateReady&&!l?`ready`:_}`,role:`status`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-login-status-copy`,children:[(0,B.jsx)(`span`,{className:`tw-bm-login-status-icon`,"aria-hidden":`true`,children:(0,B.jsx)(M,{name:p===`start`?`sliders`:_===`error`?`bug`:_===`success`||s?.stateReady&&!l?`check`:r.mode===`manual`?`play`:`file`,size:15})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:p===`start`?`正在验证登录`:_===`success`?`登录验证成功`:_===`waiting`?`等待完成登录`:_===`error`?`登录验证失败`:l?`配置已修改`:s?.stateReady?`登录状态已就绪`:r.mode===`manual`?`手动登录待验证`:`尚未验证登录`}),(0,B.jsx)(`p`,{children:t?`系统入口已修改,请先保存系统设置再做登录验证。`:p===`start`?r.mode===`manual`?`正在保存配置并打开登录页面。`:`正在保存配置并检查账号、Token 或浏览器登录态。`:_===`success`?`账号与登录态验证通过,自动识别可直接复用。`:_===`waiting`?h||s?.message||(r.mode===`manual`?`登录页面已打开;完成登录并进入业务系统后,回到这里点「保存登录态」。`:`请在登录窗口完成验证码、扫码或二次验证。`):_===`error`?`请检查账号、密码、接口地址或登录页面后重试。`:s?.stateReady?l?r.mode===`manual`?`已切换到手动登录;点击「打开登录页面」会跳转登录地址,完成登录后回来点击「保存登录态」。`:r.mode===`sso`?`当前修改尚未验证;点击「验证接口登录」会先保存再检查。`:`当前修改尚未验证;点击「验证账号密码」会先保存再检查。`:`已保存有效登录态,可继续自动识别或重新验证。`:r.mode===`manual`?`点击「打开登录页面」后完成登录;登录态不会自动保存,需回来点「保存登录态」。`:l?r.mode===`sso`?`保存设置会保存配置;点击「验证接口登录」会调用接口并检查 Token / Cookie。`:`保存设置会保存配置;点击「验证账号密码」会打开页面并检查登录态。`:r.mode===`sso`?`验证会直接调用登录接口并检查返回的 Token / Cookie。`:`验证会打开登录页面,自动填写账号密码;遇到验证码时等待你完成。`})]})]}),(0,B.jsx)(`div`,{className:`tw-bm-login-actions`,children:y?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!p,onClick:()=>void ee(`complete`),children:p===`complete`?`保存中…`:`保存登录态`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,disabled:!!p,onClick:()=>void ee(`cancel`),children:`取消登录`})]}):(0,B.jsxs)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:b||t,onClick:()=>void ee(`start`),children:[(0,B.jsx)(M,{name:r.mode===`manual`?`play`:`check`,size:14}),p===`start`?`验证中…`:r.mode===`manual`?`打开登录页面`:r.mode===`sso`?`验证接口登录`:`验证账号密码`]})})]})]})}),xe=[{value:`all`,label:`全部功能`},{value:`unconfirmed`,label:`待确认`},{value:`no-evidence`,label:`缺少证据`},{value:`unlinked`,label:`未关联流程`}];function G(e){let t=new Set(e.flows.flatMap(e=>e.steps.map(e=>e.functionId)).filter(Boolean)),n=e.directories.length?e.directories.filter(e=>!e.parentId).map(t=>{let n=new Set([t.id]),r=[t.id];for(;r.length;){let t=r.shift();for(let i of e.directories)i.parentId===t&&!n.has(i.id)&&(n.add(i.id),r.push(i.id))}let i=e.functions.filter(e=>n.has(e.directoryId));return{name:t.name,functions:i,confirmed:i.filter(e=>e.confirmed).length}}):[...new Set(e.functions.map(e=>e.domain||`未归类`))].map(t=>{let n=e.functions.filter(e=>(e.domain||`未归类`)===t);return{name:t,functions:n,confirmed:n.filter(e=>e.confirmed).length}}),r=e.functions.filter(e=>e.evidence.length>0).length;return{domains:n,withEvidence:r,evidencePercent:e.functions.length?Math.round(r/e.functions.length*100):0,confirmed:e.functions.filter(e=>e.confirmed).length,unconfirmed:e.functions.filter(e=>!e.confirmed).length,noEvidence:e.functions.length-r,unlinked:e.functions.filter(e=>!t.has(e.id)).length,pending:ue(e).length,linked:t}}function K(e,t,n,r){let i=n.trim().toLowerCase();return e.filter(e=>t===`pending`&&!ue(e).length||(t===`draft`||t===`published`)&&e.status!==t?!1:!i||[e.name,e.description,e.entryUrl,...e.directories.flatMap(e=>[e.name,...e.menuPath]),...e.functions.flatMap(e=>[e.domain,e.module,e.name])].join(` `).toLowerCase().includes(i)).sort((e,t)=>r===`name`?e.name.localeCompare(t.name,`zh-CN`):(Date.parse(t.updatedAt)||0)-(Date.parse(e.updatedAt)||0)||e.name.localeCompare(t.name,`zh-CN`))}function q(e){let t=new Date(e);return Number.isNaN(t.getTime())?`尚未更新`:`${new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,timeZone:`Asia/Shanghai`}).format(t)} 更新`}var Se=`business-map.navigation`,Ce=`business-map.systems.sort`,we=[`functions`,`flows`],Te=[`overview`,`rules`,`evidence`],Ee=[`updated`,`name`],De=xe.map(e=>e.value);function J(e,t=200){return typeof e==`string`?e.slice(0,t):``}function Oe(e,t,n){return typeof e==`string`&&t.includes(e)?e:n}function ke(){let e=k(Se,null);if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return{systemId:J(t.systemId),view:Oe(t.view,we,`functions`),systemQuery:J(t.systemQuery),query:J(t.query),domain:J(t.domain,100)||`全部`,functionFilter:Oe(t.functionFilter,De,`all`),selectedFunctionId:J(t.selectedFunctionId),selectedDirectoryId:J(t.selectedDirectoryId),expandedDirectoryIds:Array.isArray(t.expandedDirectoryIds)?t.expandedDirectoryIds.map(e=>J(e,64)).filter(Boolean).slice(0,500):[],selectedFlowId:J(t.selectedFlowId),selectedStepId:J(t.selectedStepId),detailTab:Oe(t.detailTab,Te,`overview`),...typeof t.detailOpen==`boolean`?{detailOpen:t.detailOpen}:{}}}function Ae(e){E(Se,e)}function je(){return D(Ce,Ee,`updated`)}function Me(e){O(Ce,e)}function Ne({systems:e,query:t,onQuery:n,onSelect:r,onSettings:i,onCopy:a,onCreate:o,onDemo:s,busy:c}){let[l,u]=(0,P.useState)(je);(0,P.useEffect)(()=>Me(l),[l]);let d=K(e,`all`,t,l),f=e.reduce((e,t)=>e+t.functions.length,0),p=e.reduce((e,t)=>e+t.flows.length,0);return(0,B.jsxs)(`div`,{className:`tw-bm-portfolio`,children:[(0,B.jsxs)(`header`,{className:`tw-bm-portfolio-head tw-pm-page-header`,children:[(0,B.jsx)(`span`,{className:`tw-pm-page-ico`,"aria-hidden":`true`,children:(0,B.jsx)(M,{name:`folder`,size:18})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`tw-page-title`,children:`业务地图`}),(0,B.jsx)(`p`,{className:`tw-page-desc`,children:`从系统到功能与流程,让业务结构有迹可循。`})]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-portfolio-tools`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-portfolio-meta`,children:[(0,B.jsxs)(`span`,{children:[e.length,` 个业务系统`]}),(0,B.jsxs)(`span`,{children:[f,` 个功能`]}),(0,B.jsxs)(`span`,{children:[p,` 条业务流程`]}),d.length===e.length?null:(0,B.jsxs)(`span`,{children:[`筛选出 `,d.length,` 个`]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-portfolio-actions`,children:[(0,B.jsxs)(`label`,{className:`tw-bm-portfolio-search`,children:[(0,B.jsx)(M,{name:`search`,size:14}),(0,B.jsx)(`input`,{name:`systemSearch`,autoComplete:`off`,"aria-label":`搜索业务系统`,value:t,onChange:e=>n(e.target.value),placeholder:`搜索系统、业务域或功能…`}),t?(0,B.jsx)(`button`,{type:`button`,onClick:()=>n(``),"aria-label":`清空系统搜索`,children:`×`}):null]}),(0,B.jsx)(j,{compact:!0,ariaLabel:`系统排序`,value:l,onChange:u,options:[{value:`updated`,label:`最近更新`},{value:`name`,label:`系统名称`}],className:`tw-bm-portfolio-sort`}),(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-btn primary`,onClick:o,children:[(0,B.jsx)(M,{name:`plus`,size:15}),`新建系统`]})]})]}),(0,B.jsxs)(`span`,{className:`sr-only`,"aria-live":`polite`,children:[`找到 `,d.length,` 个系统`]}),d.length?(0,B.jsx)(`div`,{className:`tw-bm-portfolio-grid`,children:d.map(e=>{let t=G(e);return(0,B.jsxs)(`article`,{className:`tw-bm-portfolio-card-shell`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-portfolio-card`,onClick:()=>r(e.id),"aria-label":`查看 ${e.name} 的业务地图`,children:[(0,B.jsxs)(`span`,{className:`tw-bm-portfolio-card-head`,children:[(0,B.jsx)(`span`,{className:`tw-bm-system-card-avatar`,"aria-hidden":`true`,children:e.name.trim()[0]||`?`}),(0,B.jsxs)(`span`,{className:`tw-bm-portfolio-card-title`,children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{title:e.entryUrl,children:e.entryUrl||`尚未配置系统入口`})]})]}),(0,B.jsx)(`span`,{className:`tw-bm-portfolio-card-desc`,children:e.description||`补充系统说明,明确业务范围与使用场景。`}),(0,B.jsxs)(`span`,{className:`tw-bm-portfolio-card-stats`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e.functions.length}),`功能`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e.flows.length}),`流程`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e.functions.length?`${t.evidencePercent}%`:`—`}),`证据覆盖`]})]}),(0,B.jsxs)(`span`,{className:`tw-bm-portfolio-domains`,children:[t.domains.length?t.domains.slice(0,3).map(e=>(0,B.jsxs)(`span`,{children:[e.name,(0,B.jsx)(`small`,{children:e.functions.length})]},e.name)):(0,B.jsx)(`span`,{className:`is-empty`,children:`尚未整理功能目录`}),t.domains.length>3?(0,B.jsxs)(`span`,{children:[`+`,t.domains.length-3]}):null]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-portfolio-card-foot`,children:[(0,B.jsx)(`span`,{children:q(e.updatedAt)}),(0,B.jsxs)(`span`,{className:`tw-bm-portfolio-card-actions`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-portfolio-card-settings`,"aria-label":`复制系统配置:${e.name}`,disabled:c,onClick:()=>a(e.id),children:[(0,B.jsx)(M,{name:`copy`,size:14}),`复制`]}),(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-portfolio-card-settings`,"aria-label":`系统设置:${e.name}`,disabled:c,onClick:()=>i(e.id),children:[(0,B.jsx)(M,{name:`sliders`,size:14}),`系统设置`]})]})]})]},e.id)})}):(0,B.jsxs)(`div`,{className:`tw-bm-portfolio-empty`,children:[(0,B.jsx)(`span`,{className:`tw-pm-page-ico`,"aria-hidden":`true`,children:(0,B.jsx)(M,{name:`folder`,size:24})}),(0,B.jsx)(`h2`,{children:e.length?`没有匹配的业务系统`:`建立第一张业务地图`}),(0,B.jsx)(`p`,{children:e.length?`换个关键词,或重置筛选条件。`:`先创建业务系统,再整理功能、业务流程和证据。也可以先用示例了解维护方式。`}),(0,B.jsx)(`div`,{className:`tw-bm-empty-actions`,children:e.length?(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn`,onClick:()=>{n(``)},children:`重置筛选`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn primary`,onClick:o,children:`新建系统`}),(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn`,disabled:c,onClick:s,children:`查看示例地图`})]})})]})]})}function Pe({className:e=``,open:t=!1}){return(0,B.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:t?(0,B.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,B.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 Fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=[],i=new Set,a=n.get(t);for(;a&&!i.has(a.id);)i.add(a.id),r.unshift(a),a=a.parentId?n.get(a.parentId):void 0;return r}function Ie({directories:e,functions:t,query:n,selectedFunctionId:r,expandedIds:i,onSelectDirectory:a,onSelectFunction:o,onToggleDirectory:d,onCreateDirectory:f,onRenameDirectory:p,onCreateFunction:m,onDeleteDirectory:h,onMove:g}){let[_,v]=(0,P.useState)(null),[y,b]=(0,P.useState)(null),x=n.trim().toLowerCase(),S=(0,P.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.parentId)||[];e.push(n),t.set(n.parentId,e)}for(let[e,n]of t)n.sort((t,n)=>{if(!e){let e=[t.name,...t.menuPath].some(e=>e.trim()===`首页`);if(e!==[n.name,...n.menuPath].some(e=>e.trim()===`首页`))return e?-1:1}return t.order-n.order||t.name.localeCompare(n.name)});return t},[e]),C=(0,P.useMemo)(()=>{let e=new Map;for(let n of t){let t=e.get(n.directoryId)||[];t.push(n),e.set(n.directoryId,t)}for(let t of e.values())t.sort((e,t)=>e.order-t.order||e.code.localeCompare(t.code));return e},[t]),ee=(0,P.useMemo)(()=>{let n=t.find(e=>e.id===r);return n?.directoryId?new Set(Fe(e,n.directoryId).map(e=>e.id)):new Set},[e,t,r]);function te(e){return!x||[e.code,e.name,e.purpose,e.entry,e.domain,e.module].join(` `).toLowerCase().includes(x)}function ne(e){let t=[e.name,...e.menuPath].join(` `).toLowerCase().includes(x);return!x||t?!0:(S.get(e.id)||[]).some(ne)||(C.get(e.id)||[]).some(te)}function re(e,t){let n=e.currentTarget.getBoundingClientRect(),r=(e.clientY-n.top)/Math.max(1,n.height);return t===`directory`&&r>.28&&r<.72?`inside`:r<.5?`before`:`after`}function ie(e,t){e.preventDefault(),e.stopPropagation();let n=_,r=re(e,t.kind);if(v(null),b(null),!n||n.id===t.id)return;if(t.kind===`function`){let e=C.get(t.parentId)||[],i=e.findIndex(e=>e.id===t.id);g({kind:n.kind,id:n.id,parentId:t.parentId,beforeId:r===`before`?t.id:e[i+1]?.id});return}if(r===`inside`){n.kind,g({kind:n.kind,id:n.id,parentId:t.id});return}let i=S.get(t.parentId)||[],a=i.findIndex(e=>e.id===t.id);g({kind:n.kind,id:n.id,parentId:t.parentId,beforeId:r===`before`?t.id:i[a+1]?.id})}function ae(e,t){if(!ne(e))return null;let n=S.get(e.id)||[],g=(C.get(e.id)||[]).filter(te),oe=n.length+g.length,se=oe>0,w=x?!0:i.has(e.id),ce=y?.id===e.id?y.position:``,le=()=>{a(e.id),se&&d(e.id)};return(0,B.jsxs)(`div`,{className:`tw-bm-tree-branch`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-tree-row directory ${ce?`is-drop-${ce}`:``}`,style:{paddingLeft:`${8+t*16}px`},role:`treeitem`,"aria-expanded":se?w:void 0,tabIndex:0,draggable:!0,onDragStart:t=>{t.stopPropagation(),v({kind:`directory`,id:e.id}),t.dataTransfer.effectAllowed=`move`},onDragOver:t=>{_&&_.id!==e.id&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,b({id:e.id,position:re(t,`directory`)}))},onDrop:t=>ie(t,{kind:`directory`,id:e.id,parentId:e.parentId}),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||b(null)},onClick:le,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),le()),t.key===`ArrowRight`&&se&&!w&&d(e.id),t.key===`ArrowLeft`&&se&&w&&d(e.id)},children:[(0,B.jsx)(Pe,{className:`tw-bm-tree-folder ${ee.has(e.id)?`is-selected-path`:``}`,open:se&&w}),(0,B.jsx)(A,{text:e.name,className:`tw-bm-tree-label`}),(0,B.jsxs)(`small`,{children:[`(`,oe,`)`]}),(0,B.jsxs)(l,{children:[(0,B.jsx)(u,{type:`button`,className:`tw-bm-tree-more`,"aria-label":`目录操作:${e.name}`,onClick:e=>e.stopPropagation(),children:`⋯`}),(0,B.jsxs)(s,{transition:!0,anchor:{to:`bottom end`,gap:4},className:`tw-bm-tree-menu tw-menu-anim`,children:[(0,B.jsxs)(c,{as:`button`,type:`button`,onClick:()=>f(e.id),children:[(0,B.jsx)(M,{name:`plus`,size:14}),(0,B.jsx)(`span`,{children:`新建子目录`})]}),(0,B.jsxs)(c,{as:`button`,type:`button`,onClick:()=>m(e.id),children:[(0,B.jsx)(M,{name:`file`,size:14}),(0,B.jsx)(`span`,{children:`新建功能`})]}),(0,B.jsxs)(c,{as:`button`,type:`button`,onClick:()=>p(e),children:[(0,B.jsx)(M,{name:`pencil`,size:14}),(0,B.jsx)(`span`,{children:`重命名`})]}),(0,B.jsx)(`div`,{className:`tw-bm-tree-menu-divider`,role:`separator`}),(0,B.jsxs)(c,{as:`button`,type:`button`,className:`danger`,onClick:()=>h(e),children:[(0,B.jsx)(M,{name:`trash`,size:14}),(0,B.jsx)(`span`,{children:`删除目录`})]})]})]})]}),(0,B.jsx)(`div`,{className:`tw-collapse ${w?`is-open`:``}`,"aria-hidden":!w,inert:!w,children:(0,B.jsxs)(`div`,{className:`tw-collapse-inner`,role:`group`,children:[n.map(e=>ae(e,t+1)),g.map(e=>{let n=y?.id===e.id?y.position:``;return(0,B.jsxs)(`div`,{className:`tw-bm-tree-row function ${r===e.id?`active`:``} ${n?`is-drop-${n}`:``}`,style:{paddingLeft:`${36+(t+1)*16}px`},role:`treeitem`,tabIndex:0,draggable:!0,onDragStart:t=>{t.stopPropagation(),v({kind:`function`,id:e.id}),t.dataTransfer.effectAllowed=`move`},onDragOver:t=>{_&&_.id!==e.id&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,b({id:e.id,position:re(t,`function`)}))},onDrop:t=>ie(t,{kind:`function`,id:e.id,parentId:e.directoryId}),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||b(null)},onClick:()=>o(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.id))},children:[(0,B.jsx)(`span`,{className:`tw-bm-tree-dot ${e.confirmed?`confirmed`:`ai`}`}),(0,B.jsx)(A,{text:e.name,className:`tw-bm-tree-label`}),(0,B.jsx)(`small`,{children:e.code})]},e.id)})]})})]},e.id)}let oe=(S.get(``)||[]).filter(ne),se=(C.get(``)||[]).filter(te),w=t.filter(t=>te(t)&&(!t.directoryId||!e.some(e=>e.id===t.directoryId)));return(0,B.jsxs)(`div`,{className:`tw-bm-function-tree`,role:`tree`,"aria-label":`功能目录树`,children:[oe.map(e=>ae(e,0)),se.map(e=>(0,B.jsxs)(`div`,{className:`tw-bm-tree-row function root ${r===e.id?`active`:``}`,role:`treeitem`,tabIndex:0,onClick:()=>o(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.id))},children:[(0,B.jsx)(`span`,{className:`tw-bm-tree-dot ${e.confirmed?`confirmed`:`ai`}`}),(0,B.jsx)(A,{text:e.name,className:`tw-bm-tree-label`}),(0,B.jsx)(`small`,{children:e.code})]},e.id)),w.filter(e=>!se.some(t=>t.id===e.id)).map(e=>(0,B.jsxs)(`div`,{className:`tw-bm-tree-row function root ${r===e.id?`active`:``}`,role:`treeitem`,tabIndex:0,onClick:()=>o(e.id),children:[(0,B.jsx)(`span`,{className:`tw-bm-tree-dot ${e.confirmed?`confirmed`:`ai`}`}),(0,B.jsx)(A,{text:`${e.name}(未归档)`,className:`tw-bm-tree-label`}),(0,B.jsx)(`small`,{children:e.code})]},e.id)),!oe.length&&!se.length&&!w.length?(0,B.jsx)(`div`,{className:`tw-bm-tree-empty`,children:x?`没有匹配的目录或功能`:`还没有功能目录`}):null]})}function Le(e,t=180){let[n,r]=(0,P.useState)(e),[i,a]=(0,P.useState)(!1),o=(0,P.useRef)(null);return(0,P.useEffect)(()=>{o.current!==null&&window.clearTimeout(o.current),e?(r(!0),a(!1)):n&&(a(!0),o.current=window.setTimeout(()=>{r(!1),a(!1),o.current=null},t))},[t,n,e]),(0,P.useEffect)(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]),{mounted:n,closing:i}}var Re={name:``,description:``,entryUrl:``,sourceDir:``},ze={id:``,code:``,name:``,directoryId:``,order:0,domain:`受理域`,module:`未归类`,status:`在用`,purpose:``,roles:``,entry:``,inputs:``,outputs:``,rules:``,writes:``,exceptions:``,implementation:``,evidenceText:``};function Be(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}function Y(e){return(e||[]).join(`
3
+ `)}function Ve(e){return{id:e.id,code:e.code,name:e.name,directoryId:e.directoryId,order:e.order,domain:e.domain,module:e.module,status:e.status,purpose:e.purpose,roles:Y(e.roles),entry:e.entry,inputs:Y(e.inputs),outputs:Y(e.outputs),rules:Y(e.rules),writes:Y(e.writes),exceptions:Y(e.exceptions),implementation:Y(e.implementation),evidenceText:e.evidence.map(e=>`${e.type}|${e.title}|${e.ref}`).join(`
4
+ `)}}function He(e,t=[]){return Be(e).map(e=>{let[n,r,i]=e.split(`|`).map(e=>e.trim()),a=[`page`,`doc`,`code`,`manual`].includes(n)?n:`manual`,o=r||i||e;return t.find(e=>e.type===a&&e.title===o&&e.ref===(i||``))||{id:``,type:a,title:o,ref:i||``,note:``,confidence:a===`manual`?`medium`:`high`}})}function Ue(e,t){return{code:e.code,name:e.name,directoryId:e.directoryId,order:e.order,domain:e.domain,module:e.module,status:e.status,purpose:e.purpose,roles:Be(e.roles),entry:e.entry,inputs:Be(e.inputs),outputs:Be(e.outputs),rules:Be(e.rules),writes:Be(e.writes),exceptions:Be(e.exceptions),implementation:Be(e.implementation),evidence:He(e.evidenceText,t?.evidence),confidence:t?.confidence||`low`,source:t&&t.source!==`manual`?`mixed`:`manual`,confirmed:!0}}function We(e){return{name:e.name,description:e.description,entryUrl:e.entryUrl,sourceDir:e.sourceDir}}function Ge(e){return e instanceof Error?e.message:String(e)}function Ke(e){return e===`page`?`page`:e===`doc`?`doc`:e===`code`?`code`:`manual`}function qe(e){return e===`high`?`较高`:e===`low`?`待补`:`中等`}function Je(e){return e.steps.length?e.steps.some(e=>e.branchBroken||!e.manual&&!e.functionId)?`待补全`:`健康`:`草稿`}function Ye({title:e,subtitle:t,children:s,footer:c,onClose:l,className:u=``,initialFocus:d}){let[f,p]=(0,P.useState)(!1),m=(0,P.useRef)(null);(0,P.useEffect)(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);function h(){f||(p(!0),m.current=window.setTimeout(l,120))}return(0,B.jsxs)(a,{open:!0,onClose:h,initialFocus:d,className:`tw-bm-theme relative z-110`,children:[(0,B.jsx)(o,{className:`tw-bm-modal-backdrop ${f?`is-closing`:``}`,"aria-hidden":`true`}),(0,B.jsx)(`div`,{className:`tw-bm-modal-layer`,children:(0,B.jsxs)(n,{className:`tw-bm-modal ${f?`is-closing`:``} ${u}`,"aria-label":e,children:[(0,B.jsxs)(`header`,{className:`tw-bm-modal-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(i,{as:`h2`,children:e}),t?(0,B.jsx)(r,{children:t}):null]}),(0,B.jsx)(`button`,{className:`tw-bm-icon-btn`,type:`button`,onClick:h,"aria-label":`关闭`,children:`×`})]}),(0,B.jsx)(`div`,{className:`tw-bm-modal-body`,children:s}),c?(0,B.jsx)(`footer`,{className:`tw-bm-modal-foot`,onClickCapture:e=>{e.target.closest(`[data-modal-dismiss]`)&&(e.preventDefault(),e.stopPropagation(),h())},children:c}):null]})})]})}function Xe(){let[e]=(0,P.useState)(()=>ke()),[t,n]=(0,P.useState)(null),[r,i]=(0,P.useState)(e?.systemId||``),[a,o]=(0,P.useState)(e?.systemQuery||``),[s,c]=(0,P.useState)(e?.view||`functions`),[l,u]=(0,P.useState)(e?.query||``),[w,ue]=(0,P.useState)(e?.domain||`全部`),[de,fe]=(0,P.useState)(e?.functionFilter||`all`),[T,E]=(0,P.useState)(e?.selectedFunctionId||``),[D,O]=(0,P.useState)(e?.selectedDirectoryId||``),[k,F]=(0,P.useState)(()=>new Set(e?.expandedDirectoryIds||[])),[I,L]=(0,P.useState)(e?.selectedFlowId||``),[R,z]=(0,P.useState)(e?.selectedStepId||``),[me,he]=(0,P.useState)(e?.detailTab||`overview`),[ge,V]=(0,P.useState)(()=>e?.detailOpen??(typeof window>`u`||window.innerWidth>1120)),[H,U]=(0,P.useState)(null),[_e,ye]=(0,P.useState)(!1),[W,xe]=(0,P.useState)(null),[G,K]=(0,P.useState)(null),[q,Se]=(0,P.useState)(``),[Ce,we]=(0,P.useState)(``),[Te,Ee]=(0,P.useState)(null),[De,J]=(0,P.useState)(``),[Oe,je]=(0,P.useState)(`configuration`),[Me,Pe]=(0,P.useState)(``),[Y,He]=(0,P.useState)(Re),[Xe,Ze]=(0,P.useState)(``),[Qe,$e]=(0,P.useState)(``),[et,tt]=(0,P.useState)(!1),nt=(0,P.useRef)(null),rt=(0,P.useRef)(null),[it,at]=(0,P.useState)(!1),[ot,st]=(0,P.useState)(!1),[ct,lt]=(0,P.useState)({name:``,result:``}),[ut,dt]=(0,P.useState)(!1),[ft,pt]=(0,P.useState)(null),mt=Le(ut),ht=Le(ge),X=(0,P.useMemo)(()=>t?.systems.find(e=>e.id===r)||null,[t,r]),gt=t?.systems.find(e=>e.id===Me)||null,_t=t?.systems.find(e=>e.id===De)||null,vt=(0,P.useMemo)(()=>{let e=l.trim().toLowerCase();return(X?.flows||[]).filter(t=>!e||[t.code,t.name,t.result].join(` `).toLowerCase().includes(e))},[X,l]),Z=(0,P.useMemo)(()=>X?.functions.find(e=>e.id===T)||null,[X,T]),yt=(0,P.useMemo)(()=>X&&Z?.directoryId?Fe(X.directories,Z.directoryId):[],[Z,X]),bt=(0,P.useMemo)(()=>X?.directories.find(e=>e.id===D)||null,[X,D]),xt=(0,P.useMemo)(()=>X&&D?Fe(X.directories,D):[],[X,D]),St=(0,P.useMemo)(()=>(X?.directories||[]).filter(e=>e.parentId===D).sort((e,t)=>e.order-t.order||e.name.localeCompare(t.name)),[X,D]),Ct=(0,P.useMemo)(()=>{let e=l.trim().toLowerCase();return(X?.functions||[]).filter(e=>e.directoryId===D).filter(t=>!e||[t.code,t.name,t.purpose,t.entry].join(` `).toLowerCase().includes(e)).sort((e,t)=>e.order-t.order||e.code.localeCompare(t.code))},[X,l,D]),Q=(0,P.useMemo)(()=>{let e=s===`flows`?vt:X?.flows||[];return e.find(e=>e.id===I)||e[0]||null},[X,vt,I,s]),wt=(0,P.useMemo)(()=>(R?Q?.steps.find(e=>e.id===R):Q?.steps[0])||null,[Q,R]);(0,P.useEffect)(()=>{let t=!0;return C().then(r=>{if(!t)return;n(r);let a=r.systems.find(t=>t.id===e?.systemId);if(i(a?.id||``),!a){E(``),L(``),z(``);return}E(a.functions.some(t=>t.id===e?.selectedFunctionId)?e?.selectedFunctionId||``:a.functions[0]?.id||``),O(a.directories?.some(t=>t.id===e?.selectedDirectoryId)?e?.selectedDirectoryId||``:a.directories?.find(e=>!e.parentId)?.id||``),F(new Set(a.directories.filter(e=>!e.parentId).map(e=>e.id)));let o=a.flows.find(t=>t.id===e?.selectedFlowId)||a.flows[0];L(o?.id||``),z(o?.steps.some(t=>t.id===e?.selectedStepId)?e?.selectedStepId||``:o?.steps[0]?.id||``)}).catch(e=>we(Ge(e))).finally(()=>{t&&Se(``)}),()=>{t=!1}},[e]),(0,P.useEffect)(()=>{t&&Ae({systemId:r,view:s,systemQuery:a,query:l,domain:w,functionFilter:de,selectedFunctionId:T,selectedDirectoryId:D,expandedDirectoryIds:[...k],selectedFlowId:I,selectedStepId:R,detailTab:me,detailOpen:ge})},[ge,me,w,k,de,l,I,D,T,R,t,r,a,s]),(0,P.useEffect)(()=>{X&&(T&&!X.functions.some(e=>e.id===T)&&E(X.functions[0]?.id||``),X.flows.some(e=>e.id===I)||L(X.flows[0]?.id||``),D&&!X.directories.some(e=>e.id===D)&&O(X.directories.find(e=>!e.parentId)?.id||``))},[X,D,I,T]),(0,P.useEffect)(()=>{if(!Q){z(``),K(null);return}if(R.startsWith(`temp_`)&&!Q.steps.some(e=>e.id===R))return;let e=Q.steps.find(e=>e.id===R)||Q.steps[0]||null;z(e?.id||``),K(e?{...e,dependencies:[...e.dependencies]}:null)},[Q,R]);let Tt=(0,P.useMemo)(()=>{let e=l.trim().toLowerCase();return(X?.functions||[]).filter(e=>!D||e.directoryId===D).filter(t=>!e||[t.code,t.name,t.purpose,t.entry].join(` `).toLowerCase().includes(e))},[X,l,D]);(0,P.useEffect)(()=>{s!==`functions`||H||Tt.some(e=>e.id===T)||E(Tt[0]?.id||``)},[Tt,H,T,s]);function Et(e=`all`,t=`全部`){fe(e),ue(t),u(``),c(`functions`),V(window.innerWidth>1120)}function Dt(e){u(``),c(`flows`);let t=X?.flows.find(t=>t.id===e)||X?.flows[0];L(t?.id||``),z(t?.steps[0]?.id||``),V(window.innerWidth>1120)}function $(e,t=r){n(e);let a=t&&e.systems.find(e=>e.id===t)||null;i(a?.id||``),a&&!a.functions.some(e=>e.id===T)&&E(a.functions[0]?.id||``),a&&D&&!a.directories.some(e=>e.id===D)&&O(a.directories.find(e=>!e.parentId)?.id||``),a&&!a.flows.some(e=>e.id===I)&&L(a.flows[0]?.id||``)}async function Ot(e,t){if(!q){Se(e);try{await t()}catch(e){if(e instanceof ie&&e.code===`revision_conflict`){let e=await C().catch(()=>null);e&&n(e),N(`业务地图已被其他页面修改,已刷新到最新版本`,`error`)}else N(Ge(e),`error`)}finally{Se(``)}}}function kt(e){let n=t?.systems.find(t=>t.id===e);n&&(i(e),E(n.functions[0]?.id||``),O(n.directories.find(e=>!e.parentId)?.id||``),F(new Set(n.directories.filter(e=>!e.parentId).map(e=>e.id))),L(n.flows[0]?.id||``),z(n.flows[0]?.steps[0]?.id||``),U(null),K(null),u(``),ue(`全部`),c(`functions`),fe(`all`),V(window.innerWidth>1120))}function At(){He(Re),Ze(``),$e(``),Ee(`create`)}function jt(e){let n=t?.systems.find(t=>t.id===e);n&&(Pe(e),He(We(n)),Ze(``),$e(``),Ee(`edit`))}async function Mt(){$e(``),tt(!0);try{let e=await h();e&&He(t=>({...t,sourceDir:e}))}catch(e){$e(Ge(e))}finally{tt(!1)}}let Nt=(0,P.useRef)(null);function Pt(){t&&(Y.name.trim()?(Ze(``),Ot(`保存系统`,async()=>{if(Te===`create`){let e=await b(t.revision,{...Y,docs:{requirements:!0,knowledge:!0,scope:`当前系统关联文档`}});$(e.store,e.systemId),c(`functions`),fe(`all`),u(``),ue(`全部`),V(window.innerWidth>1120);let n=e.store.systems.find(t=>t.id===e.systemId);n&&(E(n.functions[0]?.id||``),O(n.directories.find(e=>!e.parentId)?.id||``),L(n.flows[0]?.id||``)),N(`业务系统已创建`,`success`)}else gt&&(await Nt.current?.save(),$(await m(t.revision,gt.id,Y)),N(`系统设置已保存`,`success`));Ee(null)})):(Ze(`请输入系统名称`),nt.current?.focus()))}function Ft(){if(!t||!gt)return;let e=gt.id,n=gt.name;Ee(null),pt({title:`删除业务系统`,message:`将删除「${n}」及其全部功能、流程和待审核提案。此操作无法撤销。`,confirmLabel:`删除系统`,danger:!0,onConfirm:async()=>{$(await S(t.revision,e),``),Ee(null),N(`业务系统已删除`,`success`)}})}function It(e){let t=X?.functions.find(t=>t.id===e);E(e),t?.directoryId&&(O(t.directoryId),F(e=>{let n=new Set(e);for(let e of Fe(X?.directories||[],t.directoryId))n.add(e.id);return n})),U(null),he(`overview`),V(!0)}function Lt(e){F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Rt(e=``){xe({mode:`create`,id:``,parentId:e,name:``})}function zt(e){xe({mode:`rename`,id:e.id,parentId:e.parentId,name:e.name})}function Bt(){if(!t||!X||!W)return;let e=W.name.trim();e?Ot(`保存目录`,async()=>{if(W.mode===`create`){let n=await te(t.revision,X.id,{name:e,parentId:W.parentId});$(n.store,X.id),O(n.item.id),W.parentId&&F(e=>new Set([...e,W.parentId,n.item.id])),N(`功能目录已新建`,`success`)}else $((await g(t.revision,X.id,W.id,{name:e})).store,X.id),N(`目录名称已更新`,`success`);xe(null)}):N(`目录名称不能为空`,`error`)}function Vt(e){t&&X&&Ot(`移动目录节点`,async()=>{$(await _(t.revision,X.id,e),X.id),e.parentId&&F(t=>new Set([...t,e.parentId])),N(`目录结构已更新`,`success`)})}function Ht(e){if(!t||!X)return;let n=new Set([e.id]),r=[e.id];for(;r.length;){let e=r.shift();for(let t of X.directories)t.parentId===e&&!n.has(t.id)&&(n.add(t.id),r.push(t.id))}let i=X.functions.filter(e=>n.has(e.directoryId)),a=new Set(i.map(e=>e.id)),o=X.flows.filter(e=>e.steps.some(e=>a.has(e.functionId)));pt({title:`删除功能目录`,message:n.size===1&&!i.length?`删除目录「${e.name}」?`:`删除「${e.name}」将同时删除 ${n.size} 个目录、${i.length} 个功能;${o.length} 条流程中的关联功能会被清空,步骤标题保留。此操作无法撤销。`,confirmLabel:n.size>1||i.length?`确认级联删除`:`删除目录`,danger:!0,onConfirm:async()=>{$(await ne(t.revision,X.id,e.id,n.size>1||i.length>0),X.id),O(e.parentId||``),N(`功能目录已删除`,`success`)}})}function Ut(e=D){fe(`all`),u(``);let t=new Set(X?.functions.map(e=>e.code)),n=1;for(;t.has(`F-${String(n).padStart(3,`0`)}`);)n+=1;let r=`F-${String(n).padStart(3,`0`)}`;ye(!0),U({...ze,code:r,directoryId:e,domain:bt?.name||w,module:bt?.name||`未归类`}),c(`functions`),he(`overview`),V(!0)}function Wt(){Z&&(ye(!1),U(Ve(Z)),V(!0))}function Gt(){t&&X&&H&&(H.name.trim()?Ot(`保存功能`,async()=>{let e=Ue(H,_e?null:Z);if(_e){let n=await ae(t.revision,X.id,e);$(n.store,X.id),E(n.item.id),N(`功能已新建`,`success`)}else if(Z){let n=await f(t.revision,X.id,Z.id,e);$(n.store,X.id),E(n.item.id),N(`功能已保存,相关字段已标记为人工确认`,`success`)}U(null)}):N(`功能名称不能为空`,`error`))}function Kt(){if(!t||!X||!Z)return;let e=Z.id,n=Z.name;pt({title:`删除功能`,message:`删除「${n}」后,流程中引用它的步骤会变为未关联。`,confirmLabel:`删除功能`,danger:!0,onConfirm:async()=>{$(await x(t.revision,X.id,e),X.id),U(null),N(`功能已删除`,`success`)}})}function qt(e=!1){st(e),lt(e&&Q?{name:Q.name,result:Q.result}:{name:``,result:``}),at(!0)}function Jt(){t&&X&&(ct.name.trim()?Ot(`保存流程`,async()=>{if(ot&&Q){$((await p(t.revision,X.id,Q.id,ct)).store,X.id),at(!1),N(`流程设置已保存`,`success`);return}let e=await v(t.revision,X.id,{name:ct.name,result:ct.result,steps:[]});$(e.store,X.id),c(`flows`),L(e.item.id),at(!1),N(`流程已创建,请添加步骤`,`success`)}):N(`请填写流程名称`,`error`))}function Yt(){t&&X&&Q&&G&&(G.title.trim()?Ot(`保存步骤`,async()=>{let e=Q.steps.some(e=>e.id===G.id)?Q.steps.map(e=>e.id===G.id?G:e):ee(Q.steps,G);$((await p(t.revision,X.id,Q.id,{steps:e,status:e.some(e=>e.branchBroken)?`待补全`:`健康`})).store,X.id),z(G.id),N(`流程步骤已保存`,`success`)}):N(`步骤名称不能为空`,`error`))}function Xt(e){if(!Q){N(`请先新建一条流程`,`error`);return}let t=e?Q.steps.findIndex(t=>t.id===e)+1:Q.steps.length,n=le({id:`temp_${Date.now().toString(36)}`,n:t+1,title:`新步骤`,role:`待填写`,system:X?.name||``,functionId:X?.functions[0]?.id||``,input:``,output:``,next:Q.steps[t]?String(Q.steps[t].n):`结束`,branch:``,dependencies:[],evidence:[]},t);V(!0),K(n),z(n.id)}function Zt(e){if(!t||!X||!Q||!G)return;let n=Q.steps.findIndex(e=>e.id===G.id),r=n+e;if(n<0||r<0||r>=Q.steps.length)return;let i=Q.steps.map(e=>e.id===G.id?G:e);[i[n],i[r]]=[i[r],i[n]];let a=d(Q.steps,i);Ot(`调整步骤顺序`,async()=>{$((await p(t.revision,X.id,Q.id,{steps:a})).store,X.id),N(`步骤顺序已更新`,`success`)})}function Qt(){if(!t||!X||!Q||!G)return;let e=Q,n=G;pt({title:`删除流程步骤`,message:`删除第 ${n.n} 步「${n.title}」?后续步骤会自动重新编号。`,confirmLabel:`删除步骤`,danger:!0,onConfirm:async()=>{let r=d(e.steps,e.steps.filter(e=>e.id!==n.id));$((await p(t.revision,X.id,e.id,{steps:r,status:r.some(e=>e.branchBroken)?`待补全`:`健康`})).store,X.id),z(r[0]?.id||``),N(`流程步骤已删除`,`success`)}})}function $t(){if(!t||!X||!Q)return;let e=Q;pt({title:`删除业务流程`,message:`将删除「${e.name}」及其全部步骤。功能不会被删除。`,confirmLabel:`删除流程`,danger:!0,onConfirm:async()=>{$(await ce(t.revision,X.id,e.id),X.id),N(`业务流程已删除`,`success`)}})}function en(){X?dt(!0):N(`请先创建业务系统`,`error`)}if(q===`加载`||!t&&!Ce)return(0,B.jsxs)(`div`,{className:`tw-bm-loading tw-hydrate-pending`,role:`status`,"aria-busy":`true`,"aria-label":`正在读取业务地图`,children:[(0,B.jsx)(`div`,{className:`tw-bm-loading-heading`}),(0,B.jsx)(`div`,{className:`tw-bm-loading-toolbar`}),(0,B.jsxs)(`div`,{className:`tw-bm-loading-card`,children:[(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{})]})]});if(Ce)return(0,B.jsxs)(`div`,{className:`tw-bm-state is-error`,children:[(0,B.jsx)(`strong`,{children:`业务地图加载失败`}),(0,B.jsx)(`p`,{children:Ce}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,onClick:()=>location.reload(),children:`重新加载`})]});if(!t)return null;if(!X)return(0,B.jsxs)(`div`,{className:`tw-bm-page tw-bm-redesign`,children:[(0,B.jsx)(Ne,{systems:t.systems,query:a,onQuery:o,onSelect:kt,onSettings:jt,onCopy:e=>{J(e),je(`configuration`)},onCreate:At,busy:!!q,onDemo:()=>void Ot(`创建示例`,async()=>{let e=await se(t.revision);$(e.store,e.systemId),c(`functions`),N(`示例业务地图已创建`,`success`)})}),Te?rn():null,_t?an():null,ft?cn():null]});let tn=Z?re(X,Z.id):[],nn=[...new Set(tn.map(e=>e.flow.id))].map(e=>{let t=tn.filter(t=>t.flow.id===e);return{flow:t[0]?.flow,steps:t.map(e=>e.step)}}).filter(e=>!!e.flow);function rn(){return(0,B.jsx)(Ye,{title:Te===`create`?`新建业务系统`:`系统设置`,subtitle:`一个业务系统对应一个主要入口和一个源码目录。`,className:`tw-bm-system-modal`,initialFocus:nt,onClose:()=>Ee(null),footer:(0,B.jsxs)(B.Fragment,{children:[Te===`edit`?(0,B.jsx)(`button`,{className:`tw-bm-btn danger ghost`,type:`button`,onClick:Ft,children:`删除系统`}):null,(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,"data-modal-dismiss":!0,onClick:()=>Ee(null),children:`取消`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!q||et,onClick:Pt,children:Te===`create`?`创建系统`:`保存设置`})]}),children:(0,B.jsxs)(`div`,{className:`tw-bm-form`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-field`,children:[(0,B.jsxs)(`label`,{htmlFor:`bm-system-name`,children:[`系统名称`,(0,B.jsx)(`span`,{className:`tw-bm-required`,"aria-hidden":`true`,children:`*`})]}),(0,B.jsx)(`input`,{id:`bm-system-name`,name:`systemName`,ref:nt,required:!0,"aria-required":`true`,"aria-invalid":Xe?!0:void 0,"aria-describedby":Xe?`bm-system-name-error`:void 0,value:Y.name,onChange:e=>{Ze(``),He({...Y,name:e.target.value})},placeholder:`例如:12345 工单系统`}),Xe?(0,B.jsx)(`p`,{className:`tw-bm-field-error`,id:`bm-system-name-error`,role:`alert`,children:Xe}):null]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`系统说明`}),(0,B.jsx)(`textarea`,{name:`systemDescription`,rows:3,value:Y.description,onChange:e=>He({...Y,description:e.target.value}),placeholder:`这个系统主要解决什么业务问题`})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`系统入口`}),(0,B.jsx)(`input`,{name:`systemEntryUrl`,value:Y.entryUrl,onChange:e=>He({...Y,entryUrl:e.target.value}),placeholder:`https://...`})]}),(0,B.jsxs)(`div`,{className:`tw-bm-field`,children:[(0,B.jsx)(`label`,{htmlFor:`bm-system-source-dir`,children:`本地源码目录`}),(0,B.jsxs)(`div`,{className:`tw-bm-path-field`,children:[(0,B.jsx)(`input`,{id:`bm-system-source-dir`,name:`systemSourceDir`,value:Y.sourceDir,onChange:e=>{$e(``),He({...Y,sourceDir:e.target.value})},placeholder:`/repos/work-order`,spellCheck:!1,"aria-invalid":Qe?!0:void 0,"aria-describedby":Qe?`bm-source-dir-error`:void 0}),(0,B.jsxs)(`button`,{className:`tw-bm-btn`,type:`button`,disabled:!!q||et,onClick:()=>void Mt(),children:[(0,B.jsx)(M,{name:`folder`,size:14}),et?`选择中…`:`浏览…`]})]}),Qe?(0,B.jsx)(`p`,{className:`tw-bm-field-error`,id:`bm-source-dir-error`,role:`alert`,children:Qe}):null]}),(0,B.jsx)(`div`,{className:`tw-bm-form-note`,children:`源码目录只会被读取,并忽略 .git、node_modules、构建产物和二进制文件。`}),Te===`edit`&&gt?(0,B.jsx)(be,{ref:Nt,systemId:gt.id,entryChanged:Y.entryUrl!==gt.entryUrl}):(0,B.jsx)(`p`,{className:`tw-bm-form-note`,children:`创建系统后,可在「系统设置 → 登录配置」维护账号密码、SSO 或手动登录。`})]})})}function an(){return!_t||!t?null:(0,B.jsxs)(Ye,{title:`复制业务系统`,subtitle:`只复制系统级配置;功能、流程、证据和历史数据不会复制。`,className:`tw-bm-copy-modal`,onClose:()=>J(``),footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,"data-modal-dismiss":!0,children:`取消`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!q,onClick:()=>{let e=_t.id,n=Oe;J(``),Ot(`复制系统`,async()=>{$((await oe(t.revision,e,n)).store,``),N(`系统配置已复制;${n===`credentials`?`已复制登录账号密码,未复制登录态`:n===`configuration`?`仅复制登录配置,未复制密码和登录态`:`未复制登录配置`}`,`success`)})},children:q===`复制系统`?`正在复制…`:`创建副本`})]}),children:[(0,B.jsxs)(`div`,{className:`tw-bm-copy-summary`,children:[(0,B.jsx)(`span`,{children:`来源系统`}),(0,B.jsx)(`strong`,{children:_t.name}),(0,B.jsx)(`small`,{children:_t.entryUrl||`尚未配置系统入口`})]}),(0,B.jsxs)(`fieldset`,{className:`tw-bm-copy-options`,children:[(0,B.jsx)(`legend`,{children:`登录配置`}),[{value:`configuration`,title:`仅复制登录配置`,detail:`保留登录方式、地址、选择器和 SSO 参数;不复制已保存密码与登录态。`},{value:`credentials`,title:`复制登录配置和账号密码`,detail:`适合创建同一系统的测试副本;仍不会复制 Cookie、浏览器状态或登录成功状态。`},{value:`none`,title:`不复制登录配置`,detail:`副本只保留系统名称、说明、入口、源码目录和文档范围,登录方式保持未配置。`}].map(e=>(0,B.jsxs)(`label`,{className:`tw-bm-copy-option ${Oe===e.value?`is-selected`:``}`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`loginCopyMode`,value:e.value,checked:Oe===e.value,onChange:()=>je(e.value)}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e.title}),(0,B.jsx)(`small`,{children:e.detail})]})]},e.value))]})]})}function on(e=!1){return(0,B.jsx)(ve,{system:X,revision:t.revision,closing:e,onClose:()=>dt(!1),onChanged:()=>{C().then(e=>$(e,X.id)).catch(e=>N(Ge(e),`error`))},onApplied:()=>{C().then(e=>$(e,X.id)).catch(e=>N(Ge(e),`error`))}})}function sn(){return(0,B.jsx)(Ye,{title:ot?`编辑业务流程`:`新建业务流程`,subtitle:`先填写流程名称和最终结果,步骤可以创建后继续补充。`,initialFocus:rt,onClose:()=>at(!1),footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,"data-modal-dismiss":!0,onClick:()=>at(!1),children:`取消`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!q,onClick:Jt,children:ot?`保存流程`:`创建流程`})]}),children:(0,B.jsxs)(`div`,{className:`tw-bm-form`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`流程名称`}),(0,B.jsx)(`input`,{name:`flowName`,ref:rt,value:ct.name,onChange:e=>lt({...ct,name:e.target.value}),placeholder:`例如:投诉受理到派发签收`})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`最终业务结果`}),(0,B.jsx)(`textarea`,{name:`flowResult`,rows:3,value:ct.result,onChange:e=>lt({...ct,result:e.target.value}),placeholder:`例如:工单状态为已签收,承办单位明确`})]})]})})}function cn(){return ft?(0,B.jsx)(pe,{open:!0,title:ft.title,message:ft.message,confirmLabel:ft.confirmLabel,danger:ft.danger?`solid`:!1,onClose:()=>pt(null),onConfirm:()=>{let e=ft.onConfirm;pt(null),Ot(ft.title,e)}}):null}function ln(){if(!W)return null;let e=W.mode===`create`&&!!W.parentId,t=W.parentId?Fe(X?.directories||[],W.parentId).map(e=>e.name).join(` / `):`根目录`;return(0,B.jsx)(Ye,{title:W.mode===`create`?e?`新建子目录`:`新建功能目录`:`重命名功能目录`,subtitle:W.mode===`create`&&!e?`将在功能目录树根级平铺显示`:`位置:${t}`,onClose:()=>xe(null),footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,"data-modal-dismiss":!0,onClick:()=>xe(null),children:`取消`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!q,onClick:Bt,children:`保存目录`})]}),children:(0,B.jsx)(`div`,{className:`tw-bm-form`,children:(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`目录名称`}),(0,B.jsx)(`input`,{name:`directoryName`,autoFocus:!0,value:W.name,onChange:e=>xe({...W,name:e.target.value}),placeholder:`例如:工单受理`})]})})})}return(0,B.jsxs)(`div`,{className:`tw-bm-page tw-bm-redesign`,children:[(0,B.jsxs)(`header`,{className:`tw-bm-system-head`,children:[(0,B.jsxs)(`button`,{className:`tw-bm-back-btn`,type:`button`,onClick:()=>i(``),children:[(0,B.jsx)(M,{name:`arrowLeft`,size:14}),`全部系统`]}),(0,B.jsx)(`span`,{className:`tw-pm-page-ico`,"aria-hidden":`true`,children:(0,B.jsx)(M,{name:`folder`,size:18})}),(0,B.jsx)(`div`,{className:`tw-bm-system-head-title`,children:(0,B.jsx)(`div`,{className:`tw-bm-system-title-row`,children:(0,B.jsx)(`h1`,{className:`tw-page-title`,children:(0,B.jsx)(A,{text:X.name,className:`block truncate`})})})}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`div`,{className:`tw-bm-system-actions`,role:`group`,"aria-label":`系统操作`,children:(0,B.jsxs)(`button`,{type:`button`,className:`is-ai`,onClick:()=>en(),children:[(0,B.jsx)(M,{name:`search`,size:14}),(0,B.jsx)(`span`,{className:`tw-bm-system-action-label`,children:`AI 助手`})]})})]}),(0,B.jsxs)(`nav`,{className:`tw-bm-system-nav`,"aria-label":`系统视图`,children:[[{value:`functions`,label:`功能目录`},{value:`flows`,label:`业务流程`}].map(e=>(0,B.jsxs)(`button`,{type:`button`,"aria-current":s===e.value?`page`:void 0,className:s===e.value?`active`:``,onClick:()=>{e.value===`functions`?Et():Dt()},children:[e.label,(0,B.jsx)(`span`,{children:e.value===`functions`?X.functions.length:X.flows.length})]},e.value)),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsxs)(`label`,{className:`tw-bm-search tw-bm-system-search`,children:[(0,B.jsx)(M,{name:`search`,size:14}),(0,B.jsx)(`input`,{"aria-label":s===`functions`?`搜索功能`:`搜索流程`,name:`businessMapSearch`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),placeholder:s===`functions`?`搜索目录或功能`:`搜索流程`})]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-workbench`,children:[(0,B.jsxs)(`aside`,{className:`tw-bm-context`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-context-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:s===`functions`?`功能目录`:`业务流程`}),(0,B.jsx)(`span`,{children:s===`functions`?`${X.directories.length} 目录 · ${X.functions.length} 功能`:`${X.flows.length} 条流程`})]}),s===`functions`?(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-tree-head-action`,onClick:()=>Rt(``),title:`新建根目录`,children:`+`}):null]}),(0,B.jsx)(`div`,{className:`tw-bm-tree`,children:s===`functions`?(0,B.jsx)(Ie,{directories:X.directories,functions:X.functions,query:l,selectedFunctionId:T,expandedIds:k,onSelectDirectory:e=>{O(e),u(``),c(`functions`)},onSelectFunction:It,onToggleDirectory:Lt,onCreateDirectory:e=>Rt(e),onRenameDirectory:zt,onCreateFunction:e=>Ut(e),onDeleteDirectory:Ht,onMove:Vt}):(0,B.jsx)(B.Fragment,{children:vt.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-tree-item flow ${e.id===Q?.id?`active`:``}`,onClick:()=>{L(e.id),z(e.steps[0]?.id||``),V(!0)},children:[(0,B.jsx)(`span`,{className:`flow-no`,children:e.code.replace(`P`,``)}),(0,B.jsxs)(`span`,{children:[e.name,(0,B.jsxs)(`small`,{children:[e.steps.length,` 步 · `,Je(e)]})]}),Je(e)===`待补全`?(0,B.jsx)(`i`,{className:`warn`}):null]},e.id))})})]}),(0,B.jsxs)(`main`,{className:`tw-bm-main`,children:[(0,B.jsxs)(`header`,{className:`tw-bm-main-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{children:s===`functions`?bt?.name||`功能目录`:`业务流程`}),(0,B.jsx)(`p`,{children:s===`functions`?xt.map(e=>e.name).join(` / `)||`按真实菜单建立目录,再维护目录下的业务功能。`:`按实际执行顺序维护步骤;跨系统依赖直接挂在对应步骤下。`})]}),(0,B.jsx)(`span`,{className:`spacer`}),s===`functions`?(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,onClick:()=>Ut(D),children:`+ 新建功能`})}):(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,onClick:()=>qt(),children:`+ 新建流程`})]}),s===`functions`?(0,B.jsxs)(`div`,{className:`tw-bm-main-body`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-catalog-toolbar`,children:[(0,B.jsxs)(`span`,{children:[St.length,` 个子目录 · `,Ct.length,` `,`个功能`]}),(0,B.jsx)(`span`,{className:`spacer`}),l?(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-text-action`,onClick:()=>u(``),children:`清空搜索`}):null]}),(0,B.jsxs)(`section`,{className:`tw-bm-directory-board`,children:[St.length?(0,B.jsxs)(`div`,{className:`tw-bm-directory-section`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`strong`,{children:`子目录`}),(0,B.jsx)(`span`,{children:`拖拽目录可调整层级和顺序`})]}),(0,B.jsx)(`div`,{className:`tw-bm-directory-grid`,children:St.map(e=>{let t=X.functions.filter(t=>t.directoryId===e.id).length,n=X.directories.filter(t=>t.parentId===e.id).length;return(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-directory-card`,onClick:()=>{O(e.id),F(t=>new Set([...t,e.id]))},children:[(0,B.jsx)(M,{name:`folder`,size:16}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:(0,B.jsx)(A,{text:e.name})}),(0,B.jsxs)(`small`,{children:[n,` 个子目录 · `,t,` 个功能`]})]}),(0,B.jsx)(M,{name:`chevronRight`,size:14})]},e.id)})})]}):null,(0,B.jsxs)(`div`,{className:`tw-bm-directory-section`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`strong`,{children:`功能`}),(0,B.jsx)(`span`,{children:`功能必须有页面、文档或明确人工说明作为依据`})]}),(0,B.jsx)(`div`,{className:`tw-bm-function-grid`,children:Ct.map(e=>{let t=re(X,e.id);return(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-function-node ${e.id===T&&!H?`active`:``}`,onClick:()=>It(e.id),children:[(0,B.jsxs)(`span`,{className:`tw-bm-function-node-head`,children:[(0,B.jsx)(`strong`,{children:(0,B.jsx)(A,{text:e.name})}),(0,B.jsx)(`i`,{className:e.confirmed?`confirmed`:`ai`})]}),(0,B.jsx)(`span`,{className:`tw-bm-function-node-purpose`,children:e.purpose||`尚未填写功能作用`}),(0,B.jsxs)(`span`,{className:`tw-bm-function-node-meta`,children:[(0,B.jsx)(`small`,{children:e.code}),(0,B.jsxs)(`small`,{children:[t.length,` 个流程步骤`]}),(0,B.jsxs)(`small`,{children:[e.evidence.length,` 条证据`]})]})]},e.id)})}),Ct.length?null:(0,B.jsxs)(`div`,{className:`tw-bm-empty-inline`,children:[(0,B.jsx)(`strong`,{children:l?`没有匹配的功能`:`这个目录还没有功能`}),(0,B.jsx)(`p`,{children:l?`清空搜索或切换到其他目录。`:`可以手工新建,或稍后让 AI 根据菜单页面识别。`}),l?null:(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn primary`,onClick:()=>Ut(D),children:`新建功能`})]})]})]})]}):(0,B.jsx)(`div`,{className:`tw-bm-main-body`,children:Q?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`tw-bm-flow-toolbar`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{children:Q.name}),(0,B.jsx)(`span`,{className:`tw-bm-badge ${Je(Q)===`待补全`?`warn`:`ok`}`,children:Je(Q)})]}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,onClick:()=>qt(!0),children:`编辑流程`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,onClick:()=>Xt(),children:`+ 添加步骤`}),(0,B.jsx)(`button`,{className:`tw-bm-btn danger ghost`,type:`button`,onClick:$t,children:`删除流程`})]}),(0,B.jsxs)(`section`,{className:`tw-bm-flow-card`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{children:`最终业务结果`}),(0,B.jsx)(`strong`,{children:Q.result||`尚未填写最终结果`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:Q.steps.length}),(0,B.jsx)(`span`,{children:`步骤`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:y(Q).length}),(0,B.jsx)(`span`,{children:`参与系统`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:Q.steps.filter(e=>e.branch).length}),(0,B.jsx)(`span`,{children:`分支`})]})]}),(0,B.jsxs)(`div`,{className:`tw-bm-participants`,children:[(0,B.jsx)(`span`,{children:`参与系统`}),y(Q).map(e=>(0,B.jsx)(`span`,{className:`tw-bm-system-pill`,children:e},e))]}),(0,B.jsxs)(`div`,{className:`tw-bm-flow-sequence`,children:[Q.steps.map(e=>{let t=X.functions.find(t=>t.id===e.functionId);return(0,B.jsxs)(`div`,{className:`tw-bm-step-wrap`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`tw-bm-flow-step ${e.id===wt?.id?`active`:``} ${e.manual?`manual`:``}`,onClick:()=>{z(e.id),K({...e,dependencies:[...e.dependencies]}),V(!0)},children:[(0,B.jsx)(`span`,{className:`step-no`,children:e.n}),(0,B.jsxs)(`span`,{className:`step-main`,children:[(0,B.jsx)(`strong`,{children:e.title}),(0,B.jsxs)(`small`,{children:[(0,B.jsx)(`span`,{className:`tw-bm-system-pill`,children:e.system}),e.role,` · `,e.manual?`人工环节`:`系统动作`]})]}),(0,B.jsx)(`span`,{className:`step-function`,children:t?.name||`未关联功能`}),(0,B.jsxs)(`span`,{className:`step-io`,children:[e.input||e.output?`${e.input||`输入`} → ${e.output||`输出`}`:`尚未填写输入输出`,(0,B.jsxs)(`small`,{children:[`下一步:`,e.next||`未设置`]})]}),(0,B.jsx)(`span`,{className:`step-edit`,children:`编辑 ›`})]}),e.dependencies.map((e,t)=>(0,B.jsxs)(`div`,{className:`tw-bm-dependency`,children:[(0,B.jsx)(`span`,{children:`↳`}),(0,B.jsx)(`span`,{className:`tw-bm-system-pill`,children:e.system}),(0,B.jsx)(`span`,{children:e.label})]},`${e.system}-${t}`)),e.branch?(0,B.jsxs)(`div`,{className:`tw-bm-branch ${e.branchBroken?`broken`:``}`,children:[(0,B.jsx)(`span`,{children:`⑂`}),(0,B.jsx)(`span`,{children:e.branch}),(0,B.jsx)(`i`,{children:e.branchBroken?`未连接`:`已连接`})]}):null,e.n<Q.steps.length?(0,B.jsxs)(`button`,{className:`tw-bm-insert-step`,type:`button`,onClick:()=>Xt(e.id),children:[`+ 在第 `,e.n,` 步后添加`]}):null]},e.id)}),Q.steps.length?null:(0,B.jsxs)(`div`,{className:`tw-bm-empty-inline`,children:[(0,B.jsx)(`strong`,{children:`流程还没有步骤`}),(0,B.jsx)(`p`,{children:`按“触发 → 关键动作 → 结束状态”添加第一步。`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary small`,type:`button`,onClick:()=>Xt(),children:`+ 添加步骤`})]})]})]})]}):(0,B.jsxs)(`div`,{className:`tw-bm-empty-inline tall`,children:[(0,B.jsx)(`strong`,{children:X.flows.length?`没有匹配的业务流程`:`还没有业务流程`}),(0,B.jsx)(`p`,{children:X.flows.length?`调整搜索条件,查看其他流程。`:`新建流程后,可以按角色和参与系统维护纵向步骤。`}),l?(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-btn`,onClick:()=>u(``),children:`清空流程搜索`}):null,(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,onClick:()=>qt(),children:`+ 新建流程`})]})})]}),ht.mounted?(0,B.jsx)(`button`,{className:`tw-bm-detail-scrim ${ht.closing?`is-closing`:``}`,type:`button`,"aria-label":`关闭详情`,onClick:()=>V(!1)}):null,ht.mounted?(0,B.jsx)(`aside`,{className:`tw-bm-detail ${ht.closing?`is-closing`:``}`,children:s===`functions`?H?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`header`,{className:`tw-bm-detail-head`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-detail-titlebar`,children:[(0,B.jsx)(`span`,{className:`tw-bm-badge warn`,children:_e?`新建`:`编辑中`}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-detail-close`,type:`button`,onClick:()=>V(!1),"aria-label":`关闭详情`,children:`×`})]}),(0,B.jsx)(`h2`,{children:_e?`新建功能`:`编辑功能`}),(0,B.jsx)(`p`,{children:`维护目录中的功能节点;复杂规则和实现信息可按需展开。`})]}),(0,B.jsx)(`div`,{className:`tw-bm-detail-body`,children:(0,B.jsxs)(`div`,{className:`tw-bm-form compact`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`所属目录`}),(0,B.jsx)(j,{ariaLabel:`所属目录`,value:H.directoryId,onChange:e=>U({...H,directoryId:e}),options:[{value:``,label:`未归档(根目录)`},...X.directories.map(e=>({value:e.id,label:Fe(X.directories,e.id).map(e=>e.name).join(` / `)}))],searchable:!0,searchPlaceholder:`搜索目录`,showCheck:!0,className:`tw-bm-field-select`})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`功能名称`}),(0,B.jsx)(`input`,{name:`functionName`,value:H.name,onChange:e=>U({...H,name:e.target.value}),autoFocus:!0})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`功能作用`}),(0,B.jsx)(`textarea`,{name:`functionPurpose`,rows:3,value:H.purpose,onChange:e=>U({...H,purpose:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`入口`}),(0,B.jsx)(`input`,{name:`functionEntry`,value:H.entry,onChange:e=>U({...H,entry:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`证据(格式:page/doc/code/manual|标题|位置)`}),(0,B.jsx)(`textarea`,{name:`functionEvidence`,rows:4,value:H.evidenceText,onChange:e=>U({...H,evidenceText:e.target.value}),placeholder:`page|办理页|/order/detail`})]}),(0,B.jsxs)(`details`,{className:`tw-bm-function-more`,children:[(0,B.jsx)(`summary`,{children:`更多业务字段`}),(0,B.jsxs)(`div`,{className:`tw-bm-form compact`,children:[(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`兼容业务域`}),(0,B.jsx)(`input`,{name:`functionDomain`,value:H.domain,onChange:e=>U({...H,domain:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`兼容模块`}),(0,B.jsx)(`input`,{name:`functionModule`,value:H.module,onChange:e=>U({...H,module:e.target.value})})]})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`使用角色(一行一个)`}),(0,B.jsx)(`textarea`,{name:`functionRoles`,rows:2,value:H.roles,onChange:e=>U({...H,roles:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`业务规则(一行一条)`}),(0,B.jsx)(`textarea`,{name:`functionRules`,rows:4,value:H.rules,onChange:e=>U({...H,rules:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`输入`}),(0,B.jsx)(`textarea`,{name:`functionInputs`,rows:3,value:H.inputs,onChange:e=>U({...H,inputs:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`输出`}),(0,B.jsx)(`textarea`,{name:`functionOutputs`,rows:3,value:H.outputs,onChange:e=>U({...H,outputs:e.target.value})})]})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`落库口径(一行一条)`}),(0,B.jsx)(`textarea`,{name:`functionWrites`,rows:3,value:H.writes,onChange:e=>U({...H,writes:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`异常与待确认(一行一条)`}),(0,B.jsx)(`textarea`,{name:`functionExceptions`,rows:3,value:H.exceptions,onChange:e=>U({...H,exceptions:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`实现说明(一行一条)`}),(0,B.jsx)(`textarea`,{name:`functionImplementation`,rows:3,value:H.implementation,onChange:e=>U({...H,implementation:e.target.value})})]})]})]})]})}),(0,B.jsxs)(`footer`,{className:`tw-bm-detail-foot`,children:[(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,onClick:()=>{U(null),ye(!1)},children:`取消`}),(0,B.jsx)(`span`,{className:`spacer`}),_e?null:(0,B.jsx)(`button`,{className:`tw-bm-btn danger`,type:`button`,onClick:Kt,children:`删除`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!q,onClick:Gt,children:`保存功能`})]})]}):Z?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`header`,{className:`tw-bm-detail-head`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-detail-titlebar`,children:[(0,B.jsx)(`span`,{className:`tw-bm-badge accent`,children:yt.at(-1)?.name||`未归档`}),(0,B.jsx)(`span`,{className:`tw-bm-badge`,children:Z.status}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-detail-close`,type:`button`,onClick:()=>V(!1),"aria-label":`关闭详情`,children:`×`})]}),(0,B.jsx)(`h2`,{children:Z.name}),(0,B.jsxs)(`p`,{children:[Z.code,` ·`,` `,yt.map(e=>e.name).join(` / `)||`未归档`,` `,`· `,nn.length,` 条流程引用`]})]}),(0,B.jsx)(`div`,{className:`tw-bm-detail-tabs`,children:[[`overview`,`概览`],[`rules`,`规则与落库`],[`evidence`,`实现与证据`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:me===e?`active`:``,onClick:()=>he(e),children:t},e))}),(0,B.jsxs)(`div`,{className:`tw-bm-detail-body`,children:[me===`overview`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`它解决什么问题`}),(0,B.jsx)(`p`,{children:Z.purpose||`尚未填写功能作用。`})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`使用方式`}),(0,B.jsxs)(`div`,{className:`tw-bm-kv`,children:[(0,B.jsx)(`span`,{children:`使用角色`}),(0,B.jsx)(`strong`,{children:Z.roles.join(`、`)||`未填写`}),(0,B.jsx)(`span`,{children:`入口`}),(0,B.jsx)(`strong`,{children:Z.entry||`未填写`}),(0,B.jsx)(`span`,{children:`输入`}),(0,B.jsx)(`strong`,{children:Z.inputs.join(`、`)||`未填写`}),(0,B.jsx)(`span`,{children:`输出`}),(0,B.jsx)(`strong`,{children:Z.outputs.join(`、`)||`未填写`})]})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`关联流程`}),nn.map(e=>(0,B.jsxs)(`button`,{className:`tw-bm-ref-flow`,type:`button`,onClick:()=>{c(`flows`),L(e.flow.id),z(e.steps[0]?.id||``)},children:[(0,B.jsxs)(`strong`,{children:[e.flow.code,` · `,e.flow.name]}),(0,B.jsxs)(`span`,{children:[e.steps.length,` 个步骤引用 · 第`,` `,e.steps.map(e=>e.n).join(` / `),` 步 →`]})]},e.flow.id)),nn.length?null:(0,B.jsx)(`div`,{className:`tw-bm-form-note`,children:`当前还没有流程引用这个功能。`})]})]}):null,me===`rules`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`业务规则`}),(0,B.jsx)(`ul`,{children:Z.rules.map(e=>(0,B.jsx)(`li`,{children:e},e))}),Z.rules.length?null:(0,B.jsx)(`p`,{children:`尚未填写业务规则。`})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`落库口径`}),(0,B.jsx)(`ul`,{children:Z.writes.map(e=>(0,B.jsx)(`li`,{children:e},e))}),Z.writes.length?null:(0,B.jsx)(`p`,{children:`尚未确认落库口径。`})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`异常与待确认`}),(0,B.jsx)(`ul`,{children:Z.exceptions.map(e=>(0,B.jsx)(`li`,{children:e},e))}),Z.exceptions.length?null:(0,B.jsx)(`p`,{children:`暂无登记异常。`})]})]}):null,me===`evidence`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`证据与置信度`}),(0,B.jsxs)(`div`,{className:`tw-bm-kv`,children:[(0,B.jsx)(`span`,{children:`来源`}),(0,B.jsx)(`strong`,{children:Z.source===`mixed`?`AI + 人工确认`:Z.source===`ai`?`AI 识别`:`人工维护`}),(0,B.jsx)(`span`,{children:`置信度`}),(0,B.jsx)(`strong`,{children:qe(Z.confidence)})]})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`当前证据`}),Z.evidence.map((e,t)=>(0,B.jsxs)(`div`,{className:`tw-bm-evidence-item`,children:[(0,B.jsx)(`i`,{className:Ke(e.type)}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.title}),(0,B.jsx)(`span`,{children:e.ref||e.note||e.type})]})]},`${e.title}-${t}`)),Z.evidence.length?null:(0,B.jsx)(`p`,{children:`尚未登记证据。`})]}),Z.implementation.length?(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`实现位置`}),(0,B.jsx)(`ul`,{children:Z.implementation.map(e=>(0,B.jsx)(`li`,{children:e},e))})]}):null]}):null]}),(0,B.jsxs)(`footer`,{className:`tw-bm-detail-foot`,children:[(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,onClick:()=>en(),children:`+ 证据`}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,onClick:()=>en(),children:`AI 补充`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,onClick:Wt,children:`编辑`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,onClick:Wt,children:`确认并维护`})]})]}):(0,B.jsxs)(`div`,{className:`tw-bm-detail-empty`,children:[(0,B.jsx)(`button`,{className:`tw-bm-detail-close`,type:`button`,onClick:()=>V(!1),"aria-label":`关闭详情`,children:`×`}),(0,B.jsx)(`span`,{children:`◇`}),(0,B.jsx)(`strong`,{children:`选择一个功能`}),(0,B.jsx)(`p`,{children:`查看作用、规则、落库口径和证据。`})]}):G?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`header`,{className:`tw-bm-detail-head`,children:[(0,B.jsxs)(`div`,{className:`tw-bm-detail-titlebar`,children:[(0,B.jsxs)(`span`,{className:`tw-bm-badge accent`,children:[Q?.code,` · 第 `,G.n,` 步`]}),G.manual?(0,B.jsx)(`span`,{className:`tw-bm-badge warn`,children:`人工`}):null,(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-detail-close`,type:`button`,onClick:()=>V(!1),"aria-label":`关闭详情`,children:`×`})]}),(0,B.jsx)(`h2`,{children:G.title}),(0,B.jsxs)(`p`,{children:[G.system,` · `,G.role]})]}),(0,B.jsx)(`div`,{className:`tw-bm-detail-body`,children:(0,B.jsxs)(`div`,{className:`tw-bm-form compact`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`步骤名称`}),(0,B.jsx)(`input`,{name:`stepTitle`,value:G.title,onChange:e=>K({...G,title:e.target.value})})]}),(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`执行角色`}),(0,B.jsx)(`input`,{name:`stepRole`,value:G.role,onChange:e=>K({...G,role:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`参与系统`}),(0,B.jsx)(`input`,{name:`stepSystem`,value:G.system,onChange:e=>K({...G,system:e.target.value})})]})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`承载功能`}),(0,B.jsx)(j,{ariaLabel:`承载功能`,value:G.functionId,onChange:e=>K({...G,functionId:e}),options:[{value:``,label:`未关联`},...X.functions.map(e=>({value:e.id,label:`${e.code} · ${e.name}`}))],searchable:!0,searchPlaceholder:`搜索功能名称或编号`,showCheck:!0,className:`tw-bm-field-select`})]}),(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`输入`}),(0,B.jsx)(`input`,{name:`stepInput`,value:G.input,onChange:e=>K({...G,input:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`输出`}),(0,B.jsx)(`input`,{name:`stepOutput`,value:G.output,onChange:e=>K({...G,output:e.target.value})})]})]}),(0,B.jsxs)(`div`,{className:`two`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`下一步`}),(0,B.jsx)(`input`,{name:`stepNext`,value:G.next,onChange:e=>K({...G,next:e.target.value})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`人工环节`}),(0,B.jsx)(j,{ariaLabel:`人工环节`,value:G.manual?`yes`:`no`,onChange:e=>K({...G,manual:e===`yes`}),options:[{value:`no`,label:`否`},{value:`yes`,label:`是`}],showCheck:!0,className:`tw-bm-field-select`})]})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`异常分支`}),(0,B.jsx)(`textarea`,{name:`stepBranch`,rows:3,value:G.branch,onChange:e=>K({...G,branch:e.target.value,branchBroken:e.target.value?G.branchBroken:!1}),placeholder:`例如:材料不齐 → 退回申请人`})]}),G.branch?(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`分支连接状态`}),(0,B.jsx)(j,{ariaLabel:`分支连接状态`,value:G.branchBroken?`broken`:`connected`,onChange:e=>K({...G,branchBroken:e===`broken`}),options:[{value:`broken`,label:`待补全`},{value:`connected`,label:`已连接`}],showCheck:!0,className:`tw-bm-field-select`})]}):null,(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`系统依赖(一行一个,格式:系统|说明)`}),(0,B.jsx)(`textarea`,{name:`stepDependencies`,rows:3,value:G.dependencies.map(e=>`${e.system}|${e.label}`).join(`
5
+ `),onChange:e=>K({...G,dependencies:Be(e.target.value).map(e=>{let[t,...n]=e.split(`|`);return{system:t.trim(),label:n.join(`|`).trim()}})}),placeholder:`系统设置|读取归口字典`})]})]})}),(0,B.jsxs)(`footer`,{className:`tw-bm-detail-foot`,children:[(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,disabled:!!q||!Q?.steps.some(e=>e.id===G.id)||G.n<=1,onClick:()=>Zt(-1),children:`↑ 上移`}),(0,B.jsx)(`button`,{className:`tw-bm-btn`,type:`button`,disabled:!!q||!Q?.steps.some(e=>e.id===G.id)||G.n>=Q.steps.length,onClick:()=>Zt(1),children:`↓ 下移`}),(0,B.jsx)(`span`,{className:`spacer`}),(0,B.jsx)(`button`,{className:`tw-bm-btn danger`,type:`button`,onClick:()=>{G.id.startsWith(`temp_`)?(z(Q?.steps[0]?.id||``),K(Q?.steps[0]||null)):Qt()},children:G.id.startsWith(`temp_`)?`取消新增`:`删除`}),(0,B.jsx)(`button`,{className:`tw-bm-btn primary`,type:`button`,disabled:!!q,onClick:Yt,children:`保存步骤`})]})]}):(0,B.jsxs)(`div`,{className:`tw-bm-detail-empty`,children:[(0,B.jsx)(`button`,{type:`button`,className:`tw-bm-detail-close`,onClick:()=>V(!1),"aria-label":`关闭详情`,children:`×`}),(0,B.jsx)(`span`,{children:`◇`}),(0,B.jsx)(`strong`,{children:`选择一个流程步骤`}),(0,B.jsx)(`p`,{children:`在这里修改角色、参与系统、承载功能和系统依赖。`})]})}):null]}),Te?rn():null,it?sn():null,W?ln():null,mt.mounted?on(mt.closing):null,ft?cn():null]})}export{Xe as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Dvfzl5_N.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DQFd6g2r.js";import{a,o as ee,r as te}from"./plugins.Db9xoFZb.js";import{r as ne,s as re}from"./view-prefs.COAKEQtZ.js";import{E as o}from"./PmShared.BQVzwsiz.js";import{showToast as s}from"./Toast.BydY-X7T.js";import{a as c,b as ie,c as ae,d as oe,f as se,g as ce,h as le,i as l,l as u,m as ue,n as de,o as d,p as f,r as p,s as fe,u as pe,v as m,x as me,y as he}from"./case-exec.BMNk9OyF.js";import{t as h}from"./DatePicker.BRO_CjVQ.js";import{n as ge,t as _e}from"./DocsPager.DMN9-Tjg.js";import{n as g,r as ve,t as ye}from"./TableFieldConfig.72AL-8p-.js";import{t as _}from"./TagSelect.B_r2p0fp.js";var v=e(t(),1),y=r(),be=8e3,b=600,xe=20,Se=`tw.case-exec.page-size.v1`,x=`case-exec.search`,S=[{key:`select`,width:`6%`},{key:`date`,width:`16%`},{key:`total`,width:`10%`},{key:`pending`,width:`10%`},{key:`executed`,width:`10%`},{key:`remaining`,width:`10%`},{key:`ratio`,width:`14%`},{key:`createdAt`,width:`12%`},{key:`updatedAt`,width:`12%`},{key:`action`,width:`6%`}],Ce=new Set([`select`,`date`,`action`]),we=[{key:`total`,label:`用例总数`},{key:`pending`,label:`待执行用例`},{key:`executed`,label:`已执行用例`},{key:`remaining`,label:`当前剩余用例`},{key:`ratio`,label:`执行比例`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Te=`case-exec.fields`,C=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-300 tabular-nums`,w=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`,T=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,E=(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,y.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,y.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),D=(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,y.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function O(e){let[t,n]=(0,v.useState)(e.value?String(e.value):``),r=(0,v.useRef)(e.value),i=(0,v.useRef)(e.onCommit);i.current=e.onCommit,(0,v.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,v.useEffect)(()=>{let e=t?m(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},b);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?m(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,y.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:C})}function k(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#4176e6]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function A(e){let t=c(e.item,e.baseline),n=f(e.item,e.baseline),r=p(e.item,e.baseline),i=k(t);return(0,y.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,y.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function j(){let[e,t]=(0,v.useState)(!1),[r,o]=(0,v.useState)(!0),[c,d]=(0,v.useState)(null),[f,p]=(0,v.useState)([]),[fe,m]=(0,v.useState)([]),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(!1),[S,C]=(0,v.useState)(()=>ne(x)),[w,T]=(0,v.useState)({}),[E,D]=(0,v.useState)(1),[O,k]=ge(xe,Se),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)({}),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)(null);function R(e){re(x,e),C(e),D(1)}let z=(0,v.useRef)(!0),B=(0,v.useRef)(!1),V=ve(Te,we,Ce);(0,v.useEffect)(()=>(z.current=!0,()=>{z.current=!1}),[]);let H=(0,v.useCallback)(async()=>{try{let e=await le();if(!z.current)return;p(e.items),m(e.projects),T(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),g(null)}catch(e){if(!z.current)return;g(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>{let e=a(e=>o(!!e.caseExec));return n().then(()=>{o(te(`caseExec`)),t(!0)}),e},[]),(0,v.useEffect)(()=>{e&&r&&(async()=>{let e=await se();z.current&&(e?(await H(),z.current&&d(!0)):d(!1))})()},[e,r,H]),(0,v.useEffect)(()=>{if(c!==!0)return;let e=window.setInterval(()=>{B.current||H()},be),t=()=>{B.current||H()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[c,H]);let U=he(),W=(0,v.useMemo)(()=>de(f),[f]),G=(0,v.useMemo)(()=>ue(f,{keyword:S}),[f,S]),De=Math.max(1,Math.ceil(G.length/O)),K=Math.min(E,De),q=(0,v.useMemo)(()=>G.slice((K-1)*O,K*O),[G,K,O]),J=(0,v.useMemo)(()=>q.flatMap(e=>M[e.key]?[]:e.items),[q,M]),Y=(0,v.useMemo)(()=>f.filter(e=>w[e.id]),[f,w]),Oe=J.length>0&&J.every(e=>w[e.id]);function ke(e){N(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function Ae(e){N(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function X(e,t){T(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Z(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return f.filter(t=>t.project===e.project).map(e=>e.id)}(0,v.useEffect)(()=>{if(!A)return;let e=G.findIndex(e=>e.items.some(e=>e.id===A));if(e<0)return;D(Math.floor(e/O)+1);let t=window.setTimeout(()=>j(null),2e3);return()=>window.clearTimeout(t)},[A,G,O]);async function je(){if(!_){b(!0),g(null),R(``);try{let e=await u([{date:U,project:``,startDate:U,endDate:U}],{mode:`manual`});if(!z.current)return;let t=e.items[0];if(e.projects.length&&m(e.projects),await H(),!z.current||!t)return;j(t.id)}catch(e){z.current&&g(e instanceof Error?e.message:String(e))}finally{z.current&&b(!1)}}}async function Me(e){if(!_&&e.project){b(!0),g(null);try{let t=await u([{date:U,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!z.current)return;let n=t.items[0];if(t.projects.length&&m(t.projects),Ae(e.key),await H(),!z.current||!n)return;j(n.id)}catch(e){z.current&&g(e instanceof Error?e.message:String(e))}finally{z.current&&b(!1)}}}async function Q(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await ie(e,t);if(!z.current)return;p(t=>t.map(t=>t.id===e?n:t)),m(r),g(null)}catch(e){if(!z.current)return;g(e instanceof Error?e.message:String(e)),await H()}}function Ne(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){s(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&Q(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await me(i,{startDate:n,endDate:r});if(!z.current)return;p(e.items),m(e.projects),g(null)}catch(e){if(!z.current)return;g(e instanceof Error?e.message:String(e)),s(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await H()}})()}function Pe(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)$(e.project,n);else{let t=e.items[0];t&&Q(t.id,{project:n})}}}function Fe(e,t){e.pending>0?Q(e.id,{total:t,executed:l(t,e.pending)}):Q(e.id,{total:t})}function Ie(e,t){Q(e.id,{pending:t,executed:l(e.total,t)})}async function $(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ce(e,n);if(!z.current)return;p(t.items),m(t.projects),g(null),s(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!z.current)return;s(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Le(e){let t=ae(f,e);if(t>0)s(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await oe(e);if(!z.current)return;p(t.items),m(t.projects),g(null),s(`已删除项目名称「${e}」`,`success`)}catch(e){if(!z.current)return;s(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Re(){let e=P;if(e&&e.length!==0){F(null),b(!0);try{if(await pe(e.map(e=>e.id)),!z.current)return;T({}),g(null),await H(),s(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!z.current)return;let t=e instanceof Error?e.message:String(e);g(t),s(`删除失败:${t}`,`error`)}finally{z.current&&b(!1)}}}async function ze(){let e=I;if(!e)return;L(null);let t=Z(e);if(t.length){b(!0);try{if(await pe(t),!z.current)return;X(t,!1),g(null),await H(),s(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!z.current)return;let t=e instanceof Error?e.message:String(e);g(t),s(`删除失败:${t}`,`error`)}finally{z.current&&b(!1)}}}return e?r?c===null?(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):c?(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.records}),` 条统计`,(0,y.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,W.projects,` 个项目 · 已执行 `,W.executed,` / `,W.baseline,` 个用例 · 整体执行率 `,W.percent.toFixed(2),`%`,Y.length?` · 已选 ${Y.length} 条`:``]})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Oe,disabled:J.length===0,onChange:e=>X(J.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,y.jsx)(`input`,{value:S,onChange:e=>R(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#4176e6]`}),(0,y.jsx)(`button`,{type:`button`,disabled:_||Y.length===0,onClick:()=>F(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,y.jsx)(ye,{fields:V.fields,isVisible:V.isVisible,onToggle:V.toggle}),(0,y.jsx)(`button`,{type:`button`,disabled:_,onClick:()=>void je(),className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 添加项目`})]})]}),h?(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:h}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>g(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,y.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{B.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{B.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[G.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,q.map(e=>{let t=Z(e);return(0,y.jsx)(Ee,{group:e,collapsed:!!M[e.key],groupSelected:t.length>0&&t.every(e=>!!w[e]),recordCount:t.length,projects:fe,addedId:A,selected:w,busy:_,isVisible:V.isVisible,onToggle:()=>ke(e.key),onToggleGroupSelect:e=>X(t,e),onToggleRow:(e,t)=>X([e],t),onCommitProject:t=>Pe(e,t),onRenameProject:(e,t)=>void $(e,t),onRemoveProject:e=>void Le(e),onCommitCycle:t=>Ne(e,t),onAddStatDate:()=>void Me(e),onDeleteGroup:()=>L(e),onPatch:Q,onCommitTotal:Fe,onCommitPending:Ie,onDeleteRow:e=>F([e])},e.key)})]}),G.length>0?(0,y.jsx)(_e,{page:K,totalPages:De,pageSize:O,busy:_,unit:`个项目`,onPage:D,onPageSize:e=>{k(e),D(1)}}):(0,y.jsx)(`div`,{className:`pb-1`}),(0,y.jsx)(i,{open:P!==null,title:`删除用例执行统计`,message:P&&P.length>1?`确定删除选中的 ${P.length} 条记录吗?删除后不可恢复。`:`确定删除「${P?.[0]?.project??``} ${P?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>F(null),onConfirm:()=>void Re()}),(0,y.jsx)(i,{open:I!==null,title:`删除整个项目的统计`,message:I?.project?`确定删除「${I.project}」的全部 ${Z(I).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>L(null),onConfirm:()=>void ze()})]}):(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`caseExec`)}):(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function Ee(e){let{group:t,isVisible:n}=e,r=k(t.percent),i=(0,v.useMemo)(()=>g(S,n),[n]);return(0,y.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,y.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,y.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:D})}),(0,y.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,y.jsx)(_,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:w})}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:w})})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,y.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${T} border-stone-200 text-stone-700 hover:border-[#4176e6] hover:text-[#4176e6]`,children:`添加统计`}),(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${T} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,y.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,y.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,y.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${r.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,y.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${r.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,y.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,y.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[980px] table-fixed text-sm`,children:[(0,y.jsx)(`colgroup`,{children:i.map(e=>(0,y.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,y.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),n(`total`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}):null,n(`pending`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}):null,n(`executed`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`已执行用例`}):null,n(`remaining`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}):null,n(`ratio`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}):null,n(`createdAt`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`创建日期`}):null,n(`updatedAt`)?(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`修改日期`}):null,(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,y.jsx)(`tbody`,{children:t.items.map(r=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${r.id===e.addedId?`bg-[#e8f0fe]`:`hover:bg-[#f7f8fa]`}`,children:[(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${r.date}`,checked:!!e.selected[r.id],onChange:t=>e.onToggleRow(r.id,t.target.checked)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(h,{value:r.date,onChange:t=>e.onPatch(r.id,{date:t}),placeholder:`选择日期`,className:w})}),n(`total`)?(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:r.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(r,t)})}):null,n(`pending`)?(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:r.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(r,t)})}):null,n(`executed`)?(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,children:fe(r)}):null,n(`remaining`)?(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:d(r)}):null,n(`ratio`)?(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(A,{item:r,baseline:t.baseline||r.total})}):null,n(`createdAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:o(r.createdAt)}):null,n(`updatedAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:o(r.updatedAt)}):null,(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(r),"aria-label":`删除 ${t.project} ${r.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:E})})]},r.id))})]})})})})]})}export{j as default};
@@ -0,0 +1,5 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.Dvfzl5_N.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as ee,o as te,r as ne}from"./plugins.Db9xoFZb.js";import{n as re,t as ie}from"./SelectDropdown.D7IeyHDI.js";import{t as ae}from"./SlideOverDrawer.BMg2tce6.js";import{showToast as l}from"./Toast.BydY-X7T.js";import{h as oe}from"./case-exec.BMNk9OyF.js";import{t as se}from"./DatePicker.BRO_CjVQ.js";import{t as ce}from"./defect-workbench.CjTb4FDv.js";var u=e(t(),1),d=`/__tb_case_run`;function f(e){let t=e.trim();return[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`].includes(t)?t:/^(p|pass|passed|ok|成功|true|1)$/i.test(t)?`通过`:/^(f|fail|failed|失败|false|0)$/i.test(t)?`不通过`:/block/i.test(t)?`阻塞`:/skip|n\/?a/i.test(t)?`跳过`:`待验证`}function le(e){let t={total:e.length,executed:0,pending:0,passed:0,failed:0,blocked:0,skipped:0,executionRate:0};for(let n of e){let e=f(n.status);e!==`待验证`&&(t.executed+=1,e===`通过`&&(t.passed+=1),e===`不通过`&&(t.failed+=1),e===`阻塞`&&(t.blocked+=1),e===`跳过`&&(t.skipped+=1))}return t.pending=Math.max(0,t.total-t.executed),t.executionRate=t.total?Math.round(t.executed/t.total*100):0,t}async function p(e=``,t){let n=await fetch(`${d}${e}`,{...t,headers:{...t?.body?{"Content-Type":`application/json`}:{},...t?.headers||{}}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}function m(e){return{method:`POST`,body:JSON.stringify(e)}}async function ue(){try{return(await fetch(`${d}/health?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function de(){return((await p(`/files`)).files||[]).filter(Boolean)}async function fe(e){let t=await p(`/cases?path=${encodeURIComponent(e)}`);if(!t.document)throw Error(`用例文件读取失败`);return t.document}async function pe(e=``){return(await p(`/runs?path=${encodeURIComponent(e)}`)).runs||[]}async function me(e){let t=await p(`/runs/${encodeURIComponent(e)}`);if(!t.run)throw Error(`执行记录不存在`);return t.run}async function he(e){return!!(await p(`/auth/status?url=${encodeURIComponent(e)}`)).exists}async function ge(e){return p(`/auth/start`,m({url:e}))}async function _e(){return p(`/auth/complete`,m({}))}async function ve(){await p(`/auth/cancel`,m({}))}async function ye(e){let t=await p(`/runs`,m(e));if(!t.run)throw Error(`用例执行启动失败`);return t.run}async function be(e){let t=await p(`/runs/${encodeURIComponent(e)}/stop`,m({}));if(!t.run)throw Error(`停止执行失败`);return t.run}async function xe(e,t){let n=await p(`/runs/${encodeURIComponent(e)}/apply`,m(t));if(!n.run)throw Error(`结果写入失败`);return n.run}async function Se(e){let t=await p(`/fields`,m(e));if(!t.applied?.fileHash)throw Error(`字段保存失败`);return{fileHash:t.applied.fileHash,backup:t.applied.backup||``}}function Ce(e,t,n,r){let i=new EventSource(`${d}/runs/${encodeURIComponent(e)}/events?after=${t}`);return i.onmessage=e=>{try{n(JSON.parse(e.data))}catch{}},i.onerror=()=>{i.close(),r()},()=>i.close()}async function we(e){return p(`/stats/sync`,m(e))}var h=s(),Te={通过:`border-emerald-200 bg-emerald-50 text-emerald-700`,不通过:`border-red-200 bg-red-50 text-red-700`,阻塞:`border-amber-200 bg-amber-50 text-amber-700`,跳过:`border-stone-200 bg-stone-50 text-stone-600`,待验证:`border-sky-200 bg-sky-50 text-sky-700`};function Ee(e){return Te[e]||`border-stone-200 bg-stone-50 text-stone-500`}function g(e){return e.trim()?f(e):`未执行`}function De(e){let t=f(e);return t===`不通过`||t===`阻塞`}function Oe(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.href:``}catch{return``}}function ke(e,t){return t.length>80||/标题|步骤|预期|条件|实际|备注|内容|说明|描述/.test(e)}function Ae(e){return e.fields?.length?e.fields:[[`用例编号`,e.no],[`用例标题`,e.title],[`所属模块`,e.module],[`优先级`,e.priority],[`前置条件`,e.precondition],[`测试步骤`,e.steps],[`预期结果`,e.expected],[`用例状态`,e.status],[`实际结果`,e.actual],[`执行人`,e.executor],[`执行时间`,e.executedAt],[`执行证据`,e.evidence],[`缺陷编号`,e.defectNo],[`缺陷地址`,e.defectUrl]].map(([e,t])=>({name:e,value:t})).filter(e=>e.value)}function je({value:e,onChange:t,onBlur:n,disabled:r,className:i,placeholder:a,ariaLabel:o}){let s=(0,u.useRef)(null),c=(0,u.useCallback)(e=>{e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`},[]);return(0,u.useLayoutEffect)(()=>{let e=s.current;if(!e)return;c(e);let t=window.requestAnimationFrame(()=>c(e)),n=()=>c(e);return window.addEventListener(`resize`,n),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,n)}},[c,e]),(0,h.jsx)(`textarea`,{ref:s,value:e,onInput:e=>{c(e.currentTarget),t(e.currentTarget.value)},onBlur:n,disabled:r,rows:2,className:`${i} min-h-[4.25rem] resize-none overflow-hidden`,placeholder:a,"aria-label":o})}function Me(e){return e?.status===`running`}function Ne(e,t,n,r,i,a){return[`用例文件:${e.path}`,`用例编号:${t.no||`未填写`}`,`用例标题:${t.title}`,`模块:${t.module||`未填写`}`,`优先级:${t.priority||`未填写`}`,`目标地址:${a||n?.target.url||`未填写`}`,`执行结论:${r}`,`前置条件:\n${t.precondition||`无`}`,`测试步骤:\n${t.steps||`无`}`,`预期结果:\n${t.expected||`无`}`,`实际结果:\n${i||n?.result?.actualResult||`无`}`,`判定依据:\n${n?.result?.rationale||`人工记录`}`,...n?.result?.blocker?[`阻塞原因:\n${n.result.blocker}`]:[],...n?.result?.unverified?.length?[`未验证项:\n${n.result.unverified.map(e=>`- ${e}`).join(`
2
+ `)}`]:[],...n?.events.some(e=>e.type===`screenshot`)?[`执行证据:\n${n.events.filter(e=>e.type===`screenshot`).map(e=>e.url).filter(Boolean).join(`
3
+ `)}`]:[]].join(`
4
+
5
+ `)}function Pe(){let[e,t]=(0,u.useState)(!1),[s,d]=(0,u.useState)(!0),[p,m]=(0,u.useState)(null),[Te,Pe]=(0,u.useState)([]),[Fe,Ie]=(0,u.useState)(``),[_,Le]=(0,u.useState)(null),[Re,v]=(0,u.useState)([]),[y,ze]=(0,u.useState)(``),[b,Be]=(0,u.useState)(``),[Ve,He]=(0,u.useState)(!1),[Ue,x]=(0,u.useState)(!1),[We,S]=(0,u.useState)(!1),[Ge,C]=(0,u.useState)(!1),[Ke,w]=(0,u.useState)(``),[T,qe]=(0,u.useState)(!1),[E,D]=(0,u.useState)(null),[Je,Ye]=(0,u.useState)(null),[O,k]=(0,u.useState)(`待验证`),[Xe,A]=(0,u.useState)(``),[Ze,j]=(0,u.useState)(``),[Qe,M]=(0,u.useState)(``),[$e,et]=(0,u.useState)({}),[N,P]=(0,u.useState)(`idle`),[tt,nt]=(0,u.useState)(null),[rt,it]=(0,u.useState)(!1),[at,F]=(0,u.useState)(!1),[ot,st]=(0,u.useState)(null),[I,ct]=(0,u.useState)(``),[lt,ut]=(0,u.useState)(()=>new Date().toISOString().slice(0,10)),[L,dt]=(0,u.useState)(null),[ft,pt]=(0,u.useState)(!1),mt=(0,u.useRef)(null),R=(0,u.useRef)(``),ht=(0,u.useRef)({}),z=(0,u.useRef)(new Map),B=(0,u.useRef)(null),V=(0,u.useRef)(Promise.resolve()),gt=(0,u.useRef)(new Set),_t=(0,u.useRef)(``),vt=(0,u.useMemo)(()=>Te.map(e=>({value:e.path,label:e.name,secondary:`${e.caseCount} 条用例 · ${e.executable?`可执行`:e.ext===`.xls`?`需另存为 xlsx`:e.executionIssue||e.error||`不可执行`}`})),[Te]),H=E?_?.cases.find(e=>e.rowIndex===E.rowIndex)||E.case:Je,U=(0,u.useMemo)(()=>H?Ae(H):[],[H]),W=_?.columns.status||``,G=_?.columns.actual||``,K=_?.columns.defectNo||``,yt=_?.columns.defectUrl||`缺陷地址`,bt=_?.columns.expected||``,q=_?.columns.priority||``,xt=(0,u.useMemo)(()=>{let e=new Set([W,G,K,yt,q].filter(Boolean));return U.filter(t=>!e.has(t.name))},[U,G,K,yt,q,W]),St=$e[q]??U.find(e=>e.name===q)?.value??``,Ct=(0,u.useMemo)(()=>new Set([`用例编号`,`需求编号`,`模块`,`子模块`]),[]),J=!!E,wt=!!y.trim(),Tt=!!(Ve||b.trim()),Et=wt&&Tt,Y=E?.status===`running`,Dt=`测试地址:${wt?`已填写`:`未填写`};登录态:${Tt?`已准备`:`未准备`}`,X=(0,u.useMemo)(()=>le(_?.cases||[]),[_?.cases]),Ot=[{label:`总数`,value:X.total,className:`text-stone-900`},{label:`已执行`,value:X.executed,className:`text-[#275fc8]`},{label:`未执行`,value:X.pending,className:`text-stone-700`},{label:`通过`,value:X.passed,className:`text-emerald-600`},{label:`未通过`,value:X.failed,className:`text-red-600`},{label:`阻塞`,value:X.blocked,className:`text-amber-600`},{label:`跳过`,value:X.skipped,className:`text-stone-600`}],kt=(0,u.useCallback)(e=>Re.find(t=>t.rowIndex===e.rowIndex&&t.casePath===_?.path)||null,[_?.path,Re]),At=(0,u.useCallback)(async()=>{let e=await de();Pe(e),Ie(t=>t&&e.some(e=>e.path===t)?t:e.find(e=>e.executable)?.path||e[0]?.path||``)},[]),Z=(0,u.useCallback)(async e=>{if(!e){Le(null),v([]),R.current=``;return}let[t,n]=await Promise.all([fe(e),pe(e)]);Le(t),v(n),R.current=t.fileHash},[]);(0,u.useEffect)(()=>{let e=ee(e=>d(!!e.caseExecution));return o().then(()=>{d(ne(`caseExecution`)),t(!0)}),e},[]),(0,u.useEffect)(()=>{e&&s&&(async()=>{let e=await ue();if(m(e),e)try{await At()}catch(e){w(e instanceof Error?e.message:String(e))}})()},[s,e,At]),(0,u.useEffect)(()=>{Fe&&(w(``),Z(Fe).catch(e=>w(e instanceof Error?e.message:String(e))))},[Z,Fe]),(0,u.useEffect)(()=>{if(!T||!H){T||(_t.current=``);return}let e=`${E?.casePath||_?.path||``}:${H.rowIndex}`;if(_t.current===e)return;_t.current=e;let t=new Set([W,G,K].filter(Boolean)),n=Object.fromEntries(Ae(H).filter(e=>!t.has(e.name)).map(e=>[e.name,e.value]));ht.current=n,et(n),z.current.clear(),B.current!==null&&window.clearTimeout(B.current),B.current=null,P(`idle`)},[H,E?.casePath,G,K,_?.path,T,W]),(0,u.useEffect)(()=>{if(!y.trim()){He(!1);return}let e=window.setTimeout(()=>{he(y).then(He).catch(()=>He(!1))},250);return()=>window.clearTimeout(e)},[y]),(0,u.useEffect)(()=>()=>mt.current?.(),[]);async function jt(){if(!y.trim())x(!0),w(`请先填写测试地址`);else{S(!0),w(``);try{await ge(y.trim()),l(`登录窗口已打开,请完成验证后回到页面保存登录态`)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}}}async function Mt(){S(!0),w(``);try{await _e(),He(!0),l(`登录态已保存`,`success`)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}}async function Nt(){S(!0);try{await ve()}finally{S(!1)}}function Pt(){P(`pending`),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,$()},650)}function Q(e,t){e&&(z.current.set(e,t),Pt())}function Ft(e,t){let n={...ht.current,[e]:t};ht.current=n,et(n),Q(e,t)}async function $(){if(!_||!H||!z.current.size)return;let e=_.path,t=H.rowIndex,n=[...z.current.entries()].map(([e,t])=>({header:e,value:t}));z.current.clear(),B.current!==null&&(window.clearTimeout(B.current),B.current=null),P(`saving`),V.current=V.current.then(async()=>{try{let r=await Se({casePath:e,expectedFileHash:R.current||_.fileHash,rowIndex:t,updates:n});R.current=r.fileHash,await Z(e),w(``),P(`saved`)}catch(e){P(`error`),w(e instanceof Error?e.message:String(e))}})}function It(e,t){let n=_?.columns.status;if(!_||!n||J)return;let r=_.path;Le(r=>r&&{...r,cases:r.cases.map(r=>r.rowIndex===e.rowIndex?{...r,status:t,fields:r.fields?.map(e=>e.name===n?{...e,value:t}:e)}:r)}),P(`saving`),V.current=V.current.then(async()=>{try{let i=await Se({casePath:r,expectedFileHash:R.current||_.fileHash,rowIndex:e.rowIndex,updates:[{header:n,value:t}]});R.current=i.fileHash,await Z(r),P(`saved`),w(``)}catch(e){P(`error`),w(e instanceof Error?e.message:String(e)),await Z(r)}})}async function Lt(e){if(e.result&&!gt.current.has(e.id)&&[`awaiting_confirmation`,`stopped`,`error`].includes(e.status)){gt.current.add(e.id),P(`saving`);try{let t=await xe(e.id,{status:e.result.status,actualResult:e.result.actualResult,defectNo:e.case.defectNo});D(t),v(e=>[t,...e.filter(e=>e.id!==t.id)]),k(t.confirmed?.status||e.result.status),A(t.confirmed?.actualResult||e.result.actualResult),j(e.case.defectNo||``),t.confirmed?.fileHash&&(R.current=t.confirmed.fileHash),await Z(e.casePath),P(`saved`),l(`AI 执行结果已自动保存到用例文件`,`success`)}catch(t){gt.current.delete(e.id),P(`error`),w(t instanceof Error?t.message:String(t))}}}function Rt(e){D(e),qe(!0),mt.current?.(),mt.current=Ce(e.id,e.seq,t=>{D(n=>n&&n.id===e.id?{...n,events:[...n.events,t],seq:Math.max(n.seq,t.seq)}:n)},()=>{me(e.id).then(e=>{D(e),e.result&&(k(e.result.status),A(e.result.actualResult)),v(t=>[e,...t.filter(t=>t.id!==e.id)]),e.result&&Lt(e)})})}async function zt(e){if(!_||!y.trim())x(!0),w(`请先选择用例文件并填写测试地址`);else if(!Ve&&!b.trim())x(!0),w(`请先填写登录态文件路径,或点「打开登录页面」完成手动登录`);else{C(!0),w(``);try{let t=await ye({casePath:_.path,rowIndex:e.rowIndex,url:y.trim(),storageStatePath:b.trim()||void 0});k(`待验证`),A(``),j(``),M(e.defectUrl),Rt(t),v(e=>[t,...e])}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}}}function Bt(e,t=!1){t&&!_?.executable?w(_?.executionIssue||`该用例文件暂不可执行`):(D(null),Ye(e),k(f(e.status)),A(e.actual),j(e.defectNo),M(e.defectUrl),qe(!0))}function Vt(e){Bt(e,!0)}async function Ht(){if(E){pt(!1);try{let e=await be(E.id);D(e),e.result&&(k(e.result.status),A(e.result.actualResult))}catch(e){w(e instanceof Error?e.message:String(e))}}}async function Ut(e=H,t=E,n=O,r=Xe){if(_&&e){it(!0);try{let i=await fetch(`/__tb_defect_submit/templates`),a=await i.json();if(!i.ok)throw Error(a.error||`缺陷规则读取失败`);let o=a.templates||[];if(!o.length)throw Error(`还没有缺陷规则,请先在「缺陷规则」页面创建`);nt({templates:o,context:Ne(_,e,t,n,r||e.actual,y)})}catch(e){l(e instanceof Error?e.message:String(e),`error`)}finally{it(!1)}}}async function Wt(){if(_){C(!0);try{st(await oe()),ct(_.path.split(/[\\/]/).pop()?.split(`_`)[0]||``),dt(null),F(!0)}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}}}async function Gt(){if(_&&I.trim())try{dt(await we({casePath:_.path,project:I.trim(),date:lt,mode:`preview`}))}catch(e){w(e instanceof Error?e.message:String(e))}}async function Kt(e){if(_&&I.trim()){C(!0);try{let t=await we({casePath:_.path,project:I.trim(),date:lt,mode:e});dt(t),l(t.skipped?`已跳过已有统计`:`用例执行统计已同步`,`success`),F(!1)}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}}}return e?s?p===null?(0,h.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-5 py-16 text-center text-sm text-stone-500`,children:`正在连接用例执行服务…`}):p?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`flex h-[calc(100vh-4rem)] min-h-[640px] flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,h.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`min-w-[240px] max-w-[460px] flex-1`,children:(0,h.jsx)(ie,{value:Fe,onChange:Ie,options:vt,disabled:J,searchable:!0,searchPlaceholder:`搜索用例文件…`,ariaLabel:`选择用例文件`})}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>x(e=>!e),"aria-expanded":Ue,"data-hint":Dt,className:`flex h-8 min-w-[136px] flex-1 items-center justify-center gap-2 rounded-lg border border-stone-200 px-3 text-xs font-medium text-stone-700 hover:bg-stone-100 md:max-w-[220px]`,children:[(0,h.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Et?`bg-emerald-500`:`bg-amber-500`}`}),`执行配置`,(0,h.jsx)(`span`,{className:`text-[10px] ${Ue?`rotate-180`:``}`,children:`⌄`})]}),E?(0,h.jsx)(`button`,{type:`button`,onClick:()=>qe(!0),className:`h-8 whitespace-nowrap rounded-lg border px-3 text-xs font-medium ${Me(E)?`border-[#b8cdf7] bg-[#f2f6ff] text-[#275fc8] hover:bg-[#e8f0fe]`:`border-stone-200 text-stone-700 hover:bg-stone-100`}`,children:Me(E)?`查看进度`:`查看结果`}):null,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Wt(),disabled:!_?.executable,className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium text-stone-700 hover:bg-stone-100 disabled:opacity-40`,children:`同步统计`})]}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 rounded-lg bg-stone-50 px-3 py-2 text-xs text-stone-500`,children:[Ot.map(e=>(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,"data-hint":e.label===`已执行`?`不包含待验证`:void 0,children:[(0,h.jsx)(`span`,{children:e.label}),(0,h.jsx)(`span`,{className:`font-semibold tabular-nums ${e.className}`,children:e.value})]},e.label)),(0,h.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{children:`执行率`}),(0,h.jsxs)(`span`,{className:`font-semibold tabular-nums text-stone-800`,children:[X.executionRate,`%`]}),(0,h.jsx)(`span`,{className:`h-1.5 w-20 overflow-hidden rounded-full bg-stone-200`,children:(0,h.jsx)(`span`,{className:`block h-full rounded-full bg-[#4176e6] transition-[width] duration-300`,style:{width:`${X.executionRate}%`}})})]})]}),Ue?(0,h.jsxs)(`div`,{className:`mt-2 grid gap-2 md:grid-cols-2`,children:[(0,h.jsx)(`input`,{value:y,onChange:e=>ze(e.target.value),"aria-label":`测试地址`,placeholder:`测试地址:https://业务系统地址`,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6]`}),(0,h.jsx)(`input`,{value:b,onChange:e=>Be(e.target.value),"aria-label":`登录态文件`,placeholder:Ve?`已保存当前地址登录态,可留空`:`登录态文件:/path/to/storageState.json`,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6]`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 md:col-span-2 md:justify-end`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>void jt(),disabled:We||!y.trim(),className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium hover:bg-stone-100 disabled:opacity-40`,children:`打开登录页面`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Mt(),disabled:We,className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium hover:bg-stone-100 disabled:opacity-40`,children:`保存登录态`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Nt(),disabled:We,className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium text-stone-500 hover:bg-stone-100 disabled:opacity-40`,children:`取消`})]})]}):null,_&&!_.executable?(0,h.jsx)(`p`,{className:`mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:_.executionIssue||`该用例文件暂不能执行。`}):null,Ke?(0,h.jsx)(`p`,{className:`mt-2 text-xs text-red-600`,children:Ke}):null]}),(0,h.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,h.jsxs)(`table`,{className:`w-full min-w-[730px] table-fixed text-sm`,children:[(0,h.jsx)(`thead`,{className:`sticky top-0 z-10 bg-stone-50 text-xs text-stone-500`,children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`用例`}),(0,h.jsx)(`th`,{className:`w-[110px] px-3 py-2 text-center font-medium`,children:`执行结果`}),(0,h.jsx)(`th`,{className:`w-[150px] px-3 py-2 text-center font-medium`,children:`缺陷地址`}),(0,h.jsx)(`th`,{className:`w-[230px] px-3 py-2 text-center font-medium`,children:`操作`})]})}),(0,h.jsx)(`tbody`,{children:_?.cases.map(e=>(0,h.jsxs)(`tr`,{tabIndex:J?-1:0,"aria-label":`查看用例:${e.title||`未命名用例`}`,onClick:()=>{J||Bt(e)},onKeyDown:t=>{J||t.target!==t.currentTarget||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Bt(e))},className:`border-t border-stone-100 hover:bg-stone-100 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#4176e6]/50 focus-visible:outline-none ${J?``:`cursor-pointer`}`,children:[(0,h.jsxs)(`td`,{className:`px-3 py-2 align-top`,children:[(0,h.jsx)(re,{text:[e.no?`#${e.no}`:``,e.module||``,e.priority||``].filter(Boolean).join(` · `)||`未编号`,className:`block truncate text-[11px] text-stone-400`}),(0,h.jsx)(re,{text:e.title||`未命名用例`,className:`mt-0.5 block truncate font-medium text-stone-800`}),(0,h.jsx)(re,{text:e.steps||e.expected||`无步骤`,className:`mt-1 block truncate text-[11px] text-stone-400`})]}),(0,h.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:_?.columns.status?(0,h.jsx)(ie,{value:g(e.status),onChange:t=>It(e,t),options:[...g(e.status)===`未执行`?[{value:`未执行`,label:`未执行`}]:[],...(_.statuses||[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`]).map(e=>({value:e,label:e}))],ariaLabel:`选择用例状态:${e.title||`未命名用例`}`,disabled:J,unstyled:!0,fitContent:!0,menuMatchTrigger:!1,menuMinWidth:120,triggerClassName:`h-6 cursor-pointer whitespace-nowrap rounded-full border px-2 text-[11px] font-medium shadow-sm transition-colors hover:opacity-80 focus-visible:ring-2 focus-visible:ring-[#4176e6]/40 ${Ee(g(e.status))} disabled:opacity-50`,renderTrigger:()=>(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[g(e.status),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`text-[9px] opacity-70`,children:`▼`})]})}):(0,h.jsx)(`span`,{className:`inline-flex whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] ${Ee(g(e.status))}`,children:g(e.status)})}),(0,h.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:Oe(e.defectUrl)?(0,h.jsx)(`a`,{href:Oe(e.defectUrl),target:`_blank`,rel:`noreferrer`,className:`inline-flex max-w-full items-center gap-1 truncate text-xs font-medium text-[#4176e6] hover:underline`,children:`打开缺陷`}):(0,h.jsx)(`span`,{className:`text-xs text-stone-400`,children:`—`})}),(0,h.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,children:(0,h.jsxs)(`div`,{className:`flex justify-center gap-1.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,h.jsx)(`button`,{type:`button`,disabled:Ge||!_?.executable||J,onClick:()=>void zt(e),className:`h-7 rounded-md bg-[#4176e6] px-2.5 text-xs font-medium text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`AI执行`}),(0,h.jsx)(`button`,{type:`button`,disabled:Ge||!_?.executable||J,onClick:()=>Vt(e),className:`h-7 rounded-md border border-stone-200 px-2.5 text-xs text-stone-700 hover:bg-stone-100 disabled:opacity-40`,children:`手动记录`}),De(e.status)?(0,h.jsx)(`button`,{type:`button`,disabled:Ge||rt||J,onClick:()=>{let t=kt(e);Ut(e,t,f(e.status),t?.confirmed?.actualResult||e.actual)},className:`h-7 rounded-md border border-red-200 px-2.5 text-xs font-medium text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`创建缺陷`}):null]})})]},e.id))})]}),_?.cases.length?null:(0,h.jsx)(`div`,{className:`px-4 py-20 text-center text-sm text-stone-400`,children:`暂无可执行用例`})]})]}),(0,h.jsx)(ae,{open:T,onClose:()=>{$(),qe(!1)},title:E&&E.status===`running`?`AI 正在执行用例`:`用例详情与执行结果`,widthClass:`max-w-3xl`,escDisabled:!1,bodyClassName:`flex flex-col gap-4`,footer:E?.status===`running`?(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>pt(!0),className:`mr-auto h-8 rounded-lg border border-red-200 px-3 text-xs font-medium text-red-600 hover:bg-red-50`,children:`停止执行`})}):void 0,children:H?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`rounded-lg bg-stone-50 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-400`,children:[(0,h.jsx)(`span`,{children:H.no?`#${H.no}`:`未编号`}),H.module?(0,h.jsxs)(`span`,{children:[`· `,H.module]}):null,H.priority?(0,h.jsxs)(`span`,{children:[`· `,H.priority]}):null]}),(0,h.jsx)(`div`,{className:`mt-1 text-sm font-semibold text-stone-900`,children:H.title})]}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`字段内容`}),(0,h.jsx)(`span`,{className:`text-[11px] ${N===`error`?`text-red-600`:N===`saved`?`text-emerald-600`:`text-stone-400`}`,children:N===`pending`?`等待自动保存`:N===`saving`?`正在保存…`:N===`saved`?`已自动保存`:N===`error`?`保存失败`:`${U.length} 个字段`})]}),(0,h.jsxs)(`div`,{className:`grid gap-x-4 gap-y-3 md:grid-cols-2`,children:[xt.map((e,t)=>{let n=$e[e.name]??e.value,r=ke(e.name,n);return(0,h.jsxs)(u.Fragment,{children:[(0,h.jsxs)(`label`,{className:`block ${r?`md:col-span-2`:``}`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:e.name}),Ct.has(e.name)?(0,h.jsx)(`input`,{value:n,onChange:t=>Ft(e.name,t.target.value),onBlur:()=>void $(),disabled:Y,className:`h-9 w-full rounded-md border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`}):(0,h.jsx)(je,{value:n,onChange:t=>Ft(e.name,t),onBlur:()=>void $(),disabled:Y,className:`w-full rounded-md border border-stone-200 bg-white px-2.5 py-2 text-sm leading-6 text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`})]}),G&&e.name===bt?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:G}),(0,h.jsx)(je,{value:Xe,onChange:e=>{A(e),Q(G,e)},onBlur:()=>void $(),disabled:Y,className:`w-full rounded-md border border-stone-200 bg-white px-2.5 py-2 text-sm leading-6 text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`记录实际操作、页面现象和与预期的差异`})]}):null,e.name===bt?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:`缺陷地址`}),(0,h.jsx)(`input`,{type:`url`,value:Qe,onChange:e=>{M(e.target.value),Q(yt,e.target.value)},onBlur:()=>void $(),disabled:Y,className:`h-9 w-full rounded-md border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`https://缺陷管理平台/...`})]}):null]},`${e.name}-${t}`)}),G&&!xt.some(e=>e.name===bt)?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:G}),(0,h.jsx)(je,{value:Xe,onChange:e=>{A(e),Q(G,e)},onBlur:()=>void $(),disabled:Y,className:`w-full rounded-md border border-stone-200 bg-white px-2.5 py-2 text-sm leading-6 text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`记录实际操作、页面现象和与预期的差异`})]}):null,xt.some(e=>e.name===bt)?null:(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:`缺陷地址`}),(0,h.jsx)(`input`,{type:`url`,value:Qe,onChange:e=>{M(e.target.value),Q(yt,e.target.value)},onBlur:()=>void $(),disabled:Y,className:`h-9 w-full rounded-md border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`https://缺陷管理平台/...`})]})]})]}),E?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,h.jsx)(`span`,{className:`font-medium text-stone-700`,children:E.progress.label}),(0,h.jsxs)(`span`,{className:`text-stone-400`,children:[E.progress.elapsedSeconds,`s · `,E.progress.toolCount,` 次操作`]})]}),(0,h.jsx)(`div`,{className:`mt-3 max-h-56 space-y-2 overflow-y-auto`,children:E.events.slice(-40).map(e=>(0,h.jsxs)(`div`,{className:`rounded-md bg-stone-50 px-2.5 py-2 text-xs`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-medium text-stone-700`,children:e.title}),(0,h.jsx)(`span`,{className:`text-stone-400`,children:e.detail||``})]}),e.url&&e.type===`screenshot`?(0,h.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-block text-[#4176e6]`,children:`查看截图`}):null]},`${e.seq}-${e.type}`))})]}):null,(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`执行信息`}),(0,h.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:E?.status===`running`?`执行完成后可编辑`:`修改后自动保存到文件`})]}),_?.executable?null:(0,h.jsx)(`p`,{className:`rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-800`,children:_?.executionIssue||`该文件缺少执行列;其他已有字段仍可编辑,补齐后可记录完整执行结果。`}),(0,h.jsxs)(`div`,{className:`grid gap-x-4 gap-y-3 md:grid-cols-2`,children:[q?(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:q}),(0,h.jsx)(`input`,{value:St,onChange:e=>Ft(q,e.target.value),onBlur:()=>void $(),disabled:Y,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6] disabled:opacity-60`})]}):null,W?(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:W}),(0,h.jsx)(ie,{value:O,onChange:e=>{k(e),Q(W,e)},ariaLabel:`选择${W}`,disabled:Y,options:(_?.statuses||[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`]).map(e=>({value:e,label:e}))})]}):null,K?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsxs)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:[K,`(可选)`]}),(0,h.jsx)(`input`,{value:Ze,onChange:e=>{j(e.target.value),Q(K,e.target.value)},onBlur:()=>void $(),disabled:Y,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`后续提交缺陷后回填`})]}):null]})]}),E?.result?.rationale?(0,h.jsxs)(`div`,{className:`rounded-lg border border-sky-200 bg-sky-50 p-3 text-xs text-sky-800`,children:[(0,h.jsx)(`div`,{className:`font-medium`,children:`AI 判定依据`}),(0,h.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:E.result.rationale}),E.result.blocker?(0,h.jsxs)(`p`,{className:`mt-1 text-amber-700`,children:[`阻塞原因:`,E.result.blocker]}):null]}):null,E?.status!==`running`&&(O===`不通过`||O===`阻塞`)?(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Ut(),disabled:rt,className:`h-9 rounded-lg border border-red-200 px-3 text-sm font-medium text-red-600 hover:bg-red-50 disabled:opacity-40`,children:O===`阻塞`?`仍要创建缺陷`:`创建缺陷`}):null]}):null}),(0,h.jsxs)(i,{open:!!tt,onClose:()=>nt(null),className:`relative z-110`,children:[(0,h.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,h.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,h.jsxs)(n,{className:`w-full max-w-md rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,h.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`选择缺陷规则`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`选择后将进入缺陷提交工作台,不会自动提交。`}),(0,h.jsx)(`div`,{className:`mt-4 space-y-2`,children:tt?.templates.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>void ce(e,tt.context),className:`w-full rounded-lg border border-stone-200 px-3 py-2.5 text-left text-sm hover:border-[#4176e6] hover:bg-[#f7f9ff]`,children:[(0,h.jsx)(`span`,{className:`block font-medium text-stone-800`,children:e.name}),(0,h.jsx)(`span`,{className:`mt-0.5 block text-xs text-stone-500`,children:e.config.target.sheetTitle||e.config.target.platform||`缺陷入口`})]},e.id))}),(0,h.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>nt(null),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-600`,children:`取消`})})]})})]}),(0,h.jsxs)(i,{open:at,onClose:()=>F(!1),className:`relative z-110`,children:[(0,h.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,h.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,h.jsxs)(n,{className:`w-full max-w-lg rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,h.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`同步到用例执行统计`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`同步不会自动覆盖手工统计,覆盖前会再次确认。`}),(0,h.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,h.jsxs)(`label`,{className:`grid gap-1 text-xs text-stone-600`,children:[`统计项目`,(0,h.jsx)(`input`,{list:`case-execution-stats-projects`,value:I,onChange:e=>ct(e.target.value),className:`h-9 rounded-lg border border-stone-200 px-3 text-sm`,placeholder:`选择或输入项目名称`}),(0,h.jsx)(`datalist`,{id:`case-execution-stats-projects`,children:(ot?.projects||[]).map(e=>(0,h.jsx)(`option`,{value:e},e))})]}),(0,h.jsxs)(`label`,{className:`grid gap-1 text-xs text-stone-600`,children:[`统计日期`,(0,h.jsx)(se,{value:lt,onChange:ut,className:`h-9 rounded-lg border border-stone-200 px-3 text-sm`})]}),L?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50 p-3 text-sm text-stone-700`,children:[(0,h.jsxs)(`div`,{children:[`总数:`,L.preview.total]}),(0,h.jsxs)(`div`,{children:[`已执行:`,L.preview.executed]}),(0,h.jsxs)(`div`,{children:[`剩余:`,L.preview.pending]}),L.preview.existing?(0,h.jsx)(`div`,{className:`mt-1 text-amber-700`,children:`该日期已有手工统计,不会自动覆盖。`}):null]}):null]}),(0,h.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>F(!1),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-600`,children:`取消`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Gt(),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-700`,children:`预览`}),L?.preview.existing?(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Kt(`skip`),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-700`,children:`跳过`}):null,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Kt(L?.preview.existing?`overwrite`:`skip`),className:`h-8 rounded-lg bg-[#4176e6] px-3 text-xs text-white`,children:`同步`})]})]})})]}),(0,h.jsx)(c,{open:ft,title:`停止用例执行`,message:`停止后可以重新执行,已产生的截图和日志会保留。`,confirmLabel:`停止`,danger:!0,onClose:()=>pt(!1),onConfirm:()=>void Ht()})]}):(0,h.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行需要本地服务,当前未就绪。`}):(0,h.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:te(`caseExecution`)}):(0,h.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-5 py-16 text-center text-sm text-stone-500`,children:`正在读取插件状态…`})}export{Pe as default};
@@ -0,0 +1,10 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
2
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Dvfzl5_N.js";import{b as r,m as i,p as a,u as o}from"./settings.D02wZj3w.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./SelectDropdown.D7IeyHDI.js";import{showToast as l}from"./Toast.BydY-X7T.js";import{_ as u,d,f,g as p,m,p as h,r as g,u as _}from"./case-gen-run.Cvvdv_kv.js";import{a as v}from"./case-fields.CmePqYfh.js";import{_ as y,c as b,f as x,l as S,p as C,r as w,u as T,v as E}from"./project-docs.bB9lQ1Ki.js";import{a as ee,i as te,n as D,o as ne,r as O,s as re,t as ie}from"./case-template.Clb7HrDB.js";import{o as ae}from"./llm.BCYNgppW.js";import{n as k}from"./doc-roots.C-20VD0x.js";import{n as oe,t as se}from"./case-prompt.CZ3vWUju.js";import{t as ce}from"./ExcelFieldTags.CXif3Ilh.js";import{t as le}from"./MultiSelectDropdown.D-rbpivp.js";import{t as ue}from"./SearchableSelect.DXclLMJI.js";var A=e(t(),1),j=s(),de=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function fe(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title;return{docTitle:typeof r==`string`?r.trim():``,cases:n}}}catch{return null}return null}function pe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function me(e){let t=e.match(/^#\s+(.+)$/m);if(t?.[1])return t[1].trim().slice(0,48);let n=e.match(/^标题[::]\s*(.+)$/m);return n?.[1]?n[1].trim().slice(0,48):``}function he(e,t){let n=[];if(!e.length)return n.push(`未生成任何用例`),n;for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}e.length<15&&n.push(`用例数量偏少(${e.length} 条),建议核对需求覆盖`);let r=e.map(e=>{for(let t of[`用例标题`,`标题`,`测试分项目`,`测试项目`])if(e[t]?.trim())return e[t].trim();return``}).filter(Boolean),i=new Set(r);return r.length>=4&&i.size<r.length*.6&&n.push(`用例标题/分项重复偏多,可能覆盖不足`),n}function ge(e){if(e==null||e<0)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)} s`;let n=Math.floor(t/60);return`${n} 分 ${Math.round(t-n*60)} 秒`}function _e(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function ve(e){let t=p(e).templateFolder;try{let{entries:e}=await b(`templates`,t),n=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of n){let t=e.name.toLowerCase(),n=[...v],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await x(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=te(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await C(`templates`,e.path),r=D(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await C(`templates`,e.path),r=O(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function ye(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await C(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await x(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let i=atob(n.contentBase64),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return((await(await r(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2]))).extractRawText({arrayBuffer:a.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function M(){let[e,t]=(0,A.useState)(null),[r,s]=(0,A.useState)(!1),[x,te]=(0,A.useState)([]),[D,O]=(0,A.useState)(``),[M,N]=(0,A.useState)(`functional`),[P,be]=(0,A.useState)([]),[F,I]=(0,A.useState)(``),[L,xe]=(0,A.useState)(``),[Se,R]=(0,A.useState)(``),[Ce,we]=(0,A.useState)([]),[z,B]=(0,A.useState)([]),[V,H]=(0,A.useState)(`md`),[U,Te]=(0,A.useState)(``),[W,G]=(0,A.useState)(null),[K,Ee]=(0,A.useState)(!1),[De,q]=(0,A.useState)(null),[J,Y]=(0,A.useState)(null),X=(0,A.useRef)(null),Oe=(0,A.useRef)(null),Z=(0,A.useMemo)(()=>P.find(e=>e.id===F)??P[0],[P,F]),Q=M,ke=p(Q).label;(0,A.useEffect)(()=>{n().then(()=>t(o()));let e=a(()=>t(o()));return(async()=>{await d();let e=await w(`requirements`),t=await w(`cases`),n=await w(`templates`),r=await w(`knowledge`);s(e&&t&&n);async function i(e,t,n){let{entries:r}=await b(e,t);for(let t of r)t.type===`file`?n.push(t):await i(e,t.path,n)}if(e)try{let e=[];await i(`requirements`,`.`,e),te(e)}catch{}if(r)try{let e=[];await i(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),we(e)}catch{}let a=new URLSearchParams(window.location.search),o=a.get(`session`),c=a.get(`path`),l=f();if(o){let e=l.sessions.find(e=>e.id===o);e&&(G(e),N(e.caseType),H(e.outputFormat),O(e.reqPaths[0]??``),e.templateId&&I(e.templateId),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0}))}else if(c){let e=l.sessions.find(e=>e.linkedCasePath===c);if(e)G(e),N(e.caseType),H(e.outputFormat),O(e.reqPaths[0]??``),e.templateId&&I(e.templateId),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0});else{let e=c.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=c.split(`/`)[0]??``,r=u().find(e=>e.casesFolder===n)?.id??u()[0]?.id??`functional`,i=_({title:c.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=m(i.id,{linkedCasePath:c}).sessions.find(e=>e.id===i.id)??null;G(a),N(r),H(t),Y({path:c,count:0})}}})(),e},[]),(0,A.useEffect)(()=>{if(!r)return;let e=!1;return ve(M).then(t=>{e||(be(t),I(e=>e&&t.some(t=>t.id===e)?e:W?.templateId&&t.some(e=>e.id===W.templateId)?W.templateId:t[0]?.id??``))}),()=>{e=!0}},[r,M,W?.templateId]),(0,A.useEffect)(()=>{let e=!0;return se().then(()=>oe(M,p(M).label)).then(({skill:t,content:n})=>{e&&(xe(t.legacyPath),R(n),n.trim()||l(`技能「${t.name}」正文为空,请先到技能页补全`,`error`))}).catch(t=>{e&&(xe(``),R(``),l(t instanceof Error?t.message:String(t),`error`))}),()=>{e=!1}},[M]),(0,A.useEffect)(()=>{Oe.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[W?.messages,K]);function $(e){if(!W)return;let t=m(W.id,e);G(t.sessions.find(e=>e.id===W.id)??W)}async function Ae(){let e=``;if(D)try{let t=await ye(D);e+=`\n### 需求文档:${D}\n${t}\n`}catch{e+=`\n### 需求文档:${D}\n(无法读取正文)\n`}Z?.body?e+=`\n### 用例模板:${Z.title}\n${Z.body}\n`:Z&&(e+=`\n### 用例模板:${Z.title}\n字段:${(Z.headers.length?Z.headers:v).join(`、`)}\n`);for(let t of z)try{let n=await C(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function je(e,t,n,r){let i=p(t.caseType),a=n||t.title||i.label,o=g(a,t.caseType),s=i.casesFolder;try{await S(`cases`,`.`,s)}catch{}let c=`${s}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,l=r.length?r:[...v];return t.outputFormat===`md`?await E(`cases`,c,ne(e,a,l)):t.outputFormat===`csv`?await E(`cases`,c,ee(e,l)):await y(`cases`,c,await re(e,l,i.label)),c}async function Me(){if(!D)return``;let e=pe(D);try{return me(await ye(D))||e}catch{return e}}async function Ne(t,n){if(!e){i(`model`);return}if(!r){q(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let a=await Me(),o=n;o?(m(o.id,{caseType:M,outputFormat:V,reqPaths:D?[D]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:L||void 0,knowledgePaths:z.length?[...z]:void 0}),o={...o,caseType:M,outputFormat:V,reqPaths:D?[D]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:L||void 0,knowledgePaths:z.length?[...z]:void 0}):(o=_({title:a||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:V,reqPaths:D?[D]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:L||void 0,knowledgePaths:z.length?[...z]:void 0}),G(o));let s=await Ae(),c=p(M).label,u=Z?.headers?.length?Z.headers:[...v],d=V===`md`?`最终结果将保存为 Markdown 表格文件`:V===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,f=Se.trim();if(!f){let e=L?`默认技能「${L}」没读到内容,请先在技能页补上`:`默认用例生成技能尚未就绪,请重新打开插件`;q(e),l(e,`error`);return}let h=`${f}
3
+
4
+ 【运行时约束】
5
+ - 用例类型:${c}
6
+ - ${d}
7
+ - 需求名称默认可用「${a||`未命名需求`}」
8
+ - 「用例」对象键必须与模板字段完全一致(另可多写「备注」):${u.includes(`备注`)?u.join(`、`):[...u,`备注`].join(`、`)}
9
+ - 「待业务确认 / 待确认」项也要写成用例,在「备注」写「待业务确认:…」,不要只丢进未覆盖说明
10
+ - 仅输出 JSON 对象:{"需求名称":"...","覆盖需求率":0-100,"未覆盖说明":[],"编写说明":"...","用例":[...]},不要其他解释`,g=[{role:`system`,content:h},{role:`user`,content:`${s}\n\n【用户请求】\n${t}`}];if(n&&n.messages.length){g.length=0,g.push({role:`system`,content:h});for(let e of n.messages.slice(-8))(e.role===`user`||e.role===`assistant`)&&g.push({role:e.role,content:e.content});g.push({role:`user`,content:t})}let y=Date.now(),b={role:`user`,content:t,time:y},x={role:`assistant`,content:``,time:y,result:{ok:!1,count:0}},S=[...o.messages||[],b,x],C=o.messages.length>0?o.title:a||t.slice(0,24)||o.title;o={...o,messages:S,title:C},G(o),m(o.id,{messages:S,title:o.title}),Ee(!0),q(null);let w=new AbortController;X.current=w;let T=``;function E(e,t=``){let n=[...S];n[n.length-1]={role:`assistant`,content:t,time:Date.now(),result:e};let r={messages:n,outputFormat:o.outputFormat,caseType:o.caseType};e.ok&&e.path&&(r.linkedCasePath=e.path,e.path&&Y({path:e.path,count:e.count}));let i=m(o.id,r);G(i.sessions.find(e=>e.id===o.id)??null)}try{for await(let t of ae(e,g,w.signal,{thinking:!1}))t.type===`content`&&(T+=t.delta);let t=Date.now()-y,n=fe(T);if(n){let e=Z?.headers?.length?Z.headers:[...v],r=ie(n.cases,e),i=a||o.title||n.docTitle||p(o.caseType).label,s=await je(r,{...o,title:i},i,e),c=he(r,e);m(o.id,{title:i}),E({ok:!0,count:r.length,path:s,durationMs:t,finishedAt:Date.now(),omissions:c})}else{let e=`未能解析出用例 JSON`;q(`${e},可调整关联技能或需求后重试。`),E({ok:!1,count:0,durationMs:t,finishedAt:Date.now(),error:e,omissions:[`输出无法解析,未写入用例文件`]})}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)E({ok:!1,count:0,durationMs:Date.now()-y,finishedAt:Date.now(),error:`已停止`,omissions:[`用户停止生成`]});else{let t=e instanceof Error?e.message:String(e);q(t),E({ok:!1,count:0,durationMs:Date.now()-y,finishedAt:Date.now(),error:t,omissions:[`生成过程中断或失败`]})}}finally{Ee(!1),X.current=null}}async function Pe(){let e=U.trim();e&&!K&&(Te(``),await Ne(e,W??void 0))}let Fe=!!U.trim()&&!K,Ie=x.map(e=>({value:e.path,label:e.path})),Le=P.map(e=>({value:e.id,label:e.title}));return(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 max-w-4xl mx-auto`,children:[r?null:(0,j.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900`,children:`本地文档或技能服务未就绪,无法读写需求 / 模板 / 技能 / 用例库。`}),(0,j.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`用例类型`}),(0,j.jsx)(c,{options:u().map(e=>({value:e.id,label:e.label})),value:Q,onChange:e=>{N(e),$({caseType:e})}})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`输出格式`}),(0,j.jsx)(c,{options:de,value:V,onChange:e=>{if(H(e),W?.linkedCasePath){let t=`${W.linkedCasePath.replace(/\.[^.]+$/,``)}${e===`md`?`.md`:e===`csv`?`.csv`:`.xlsx`}`;$({outputFormat:e,linkedCasePath:t}),Y(e=>e?{...e,path:t}:{path:t,count:0})}else $({outputFormat:e})}})]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`需求文档`}),(0,j.jsx)(ue,{options:Ie,value:D,onChange:e=>{O(e),$({reqPaths:e?[e]:[]})},allowEmpty:!1,placeholder:`未选择需求文档`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:[`用例模板`,(0,j.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,ke,` · `,p(Q).templateFolder,`)`]})]}),(0,j.jsx)(ue,{options:Le,value:Z?.id??``,onChange:e=>{I(e),$({templateId:e,templateTitle:P.find(t=>t.id===e)?.title})},allowEmpty:!1,placeholder:Le.length?`搜索并选择模板…`:`暂无「${p(Q).templateFolder}」模板`}),Z?.headers?.length?(0,j.jsx)(ce,{fields:Z.headers}):Z?(0,j.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:`未识别到模板字段`}):null]})]}),(0,j.jsx)(`div`,{children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`引用知识库(可多选)`}),(0,j.jsx)(le,{options:Ce.map(e=>({value:e.path,label:e.path.replace(/\.[^.]+$/,``)})),values:z,onChange:e=>{B(e),$({knowledgePaths:e.length?e:void 0})},placeholder:Ce.length?`选择知识库文档…`:`暂无知识库文档`})]})}),W?.linkedCasePath&&!J?(0,j.jsxs)(`p`,{className:`text-xs text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-md px-3 py-2`,children:[`已关联用例文件:`,k(`cases`),W.linkedCasePath]}):null]}),(0,j.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-[#f8f9fb] flex flex-col h-[min(520px,60vh)]`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-4 py-4 space-y-3`,children:[W?.messages.length?(()=>{let e=[];for(let t of W.messages)if(t.role===`user`)e.push({user:t});else if(t.role===`assistant`){let n=e[e.length-1];n&&!n.assistant?n.assistant=t:e.push({assistant:t})}return e.map((t,n)=>{let r=n===e.length-1,i=K&&r&&!t.assistant?.result?.finishedAt,a=t.assistant?.result;return(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 items-stretch`,children:[(0,j.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-3 min-h-22`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-1.5`,children:`提问`}),(0,j.jsx)(`div`,{className:`text-sm text-stone-800 whitespace-pre-wrap leading-6`,children:t.user?.content||`—`})]}),(0,j.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-3 min-h-22`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-1.5`,children:`生成结果`}),i?(0,j.jsx)(`div`,{className:`text-sm text-[#4176e6]`,children:`生成中…`}):a?(0,j.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsx)(`span`,{className:`inline-flex items-center h-6 px-2 rounded-md text-xs font-medium ${a.ok?`bg-emerald-50 text-emerald-700`:`bg-red-50 text-red-700`}`,children:a.ok?`成功`:`失败`}),(0,j.jsx)(`span`,{className:`text-xs text-stone-500`,children:_e(a.finishedAt??t.assistant?.time)}),(0,j.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`耗时 `,ge(a.durationMs)]})]}),(0,j.jsxs)(`div`,{className:`text-stone-700`,children:[`用例数量:`,(0,j.jsx)(`span`,{className:`font-medium text-stone-900`,children:a.count}),` 条`]}),a.path?(0,j.jsxs)(`button`,{type:`button`,className:`text-xs text-[#4176e6] hover:underline text-left truncate max-w-full`,"data-hint":`本地打开`,onClick:()=>void T(`cases`,a.path).catch(e=>q(e instanceof Error?e.message:String(e))),children:[k(`cases`),a.path]}):null,a.error?(0,j.jsx)(`div`,{className:`text-xs text-red-600`,children:a.error}):null,(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1`,children:`遗漏检测`}),a.omissions&&a.omissions.length>0?(0,j.jsx)(`ul`,{className:`text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-md px-2.5 py-2 space-y-1`,children:a.omissions.map(e=>(0,j.jsxs)(`li`,{children:[`· `,e]},e))}):a.ok?(0,j.jsx)(`div`,{className:`text-xs text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-md px-2.5 py-2`,children:`未发现明显遗漏`}):(0,j.jsx)(`div`,{className:`text-xs text-stone-400`,children:`—`})]})]}):(0,j.jsx)(`div`,{className:`text-sm text-stone-400`,children:`等待结果`})]})]},n)})})():(0,j.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-stone-400 py-16`,children:`选择上下文后,在下方输入需求说明并提交,将创建一条用例会话。`}),(0,j.jsx)(`div`,{ref:Oe})]}),De?(0,j.jsx)(`div`,{className:`shrink-0 mx-4 mb-2 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:De}):null,J?(0,j.jsxs)(`div`,{className:`shrink-0 mx-4 mb-3`,children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:`生成的用例文件`}),(0,j.jsxs)(`button`,{type:`button`,"data-hint":`点击在本地打开`,onClick:()=>{T(`cases`,J.path).catch(e=>q(e instanceof Error?e.message:String(e)))},onDoubleClick:()=>{T(`cases`,J.path).catch(e=>q(e instanceof Error?e.message:String(e)))},className:`w-full flex items-center gap-3 rounded-lg border border-stone-200 bg-white px-3 py-2.5 text-left hover:border-[#4176e6] hover:bg-[#f5f8ff] transition-colors`,children:[(0,j.jsx)(`span`,{className:`w-9 h-9 rounded-lg bg-emerald-50 text-emerald-700 flex items-center justify-center text-xs font-semibold shrink-0`,children:J.path.split(`.`).pop()?.toUpperCase()||`FILE`}),(0,j.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`span`,{className:`block text-sm text-stone-800 truncate`,children:J.path.split(`/`).pop()}),(0,j.jsxs)(`span`,{className:`block text-[11px] text-stone-400 truncate`,children:[k(`cases`),J.path,J.count>0?` · ${J.count} 条`:``,` · 点击打开`]})]})]})]}):null,(0,j.jsxs)(`div`,{className:`shrink-0 p-3 border-t border-stone-200 bg-white rounded-b-xl`,children:[(0,j.jsxs)(`div`,{className:`rounded-2xl border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/25`,children:[(0,j.jsx)(`textarea`,{value:U,onChange:e=>Te(e.target.value),rows:3,placeholder:e?`描述要生成或修改的用例… Enter 发送,Shift+Enter 换行`:`请先配置模型`,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Pe())},className:`w-full px-4 pt-3 pb-2 text-sm resize-none outline-none bg-transparent`}),(0,j.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-3 pb-2`,children:[e?null:(0,j.jsx)(`button`,{type:`button`,onClick:()=>i(`model`),className:`text-xs text-amber-700 hover:underline`,children:`配置模型`}),K?(0,j.jsx)(`button`,{type:`button`,onClick:()=>X.current?.abort(),className:`h-8 px-3 text-sm rounded-full bg-stone-200 text-stone-700`,children:`停止`}):null,(0,j.jsx)(`button`,{type:`button`,disabled:!Fe,onClick:()=>void Pe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-full hover:bg-[#3565c7] disabled:opacity-40`,children:`提交`})]})]}),W?(0,j.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-stone-400 hover:text-stone-600`,onClick:()=>{G(null),Y(null),q(null);let e=f();h({...e,activeId:``})},children:`开始新的用例会话`}):null]})]})]})}export{M as default};