lantern-harness 0.1.8 → 0.1.10

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 (183) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +7 -7
  3. package/builtin/session/lh-fs.mjs +32 -14
  4. package/cli/server.mjs +2 -0
  5. package/config/app.defaults.json +1 -0
  6. package/dist/500.html +258 -22
  7. package/dist/_astro/Base.BOY6F0mi.css +1 -0
  8. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.C30xtpc6.js +1 -0
  9. package/dist/_astro/CaseExecBoard.Dttqp0wg.js +1 -0
  10. package/dist/_astro/CaseGenerateApp.DqW_nWMc.js +9 -0
  11. package/dist/_astro/CasesLibrary.8aMUUGp_.js +1 -0
  12. package/dist/_astro/ChatApp.BLxf0h1d.js +219 -0
  13. package/dist/_astro/ColumnResize.BEkEW7qw.js +1 -0
  14. package/dist/_astro/{ConfirmDialog.CBVsDJ8f.js → ConfirmDialog.BZzZWDci.js} +1 -1
  15. package/dist/_astro/{DashboardBoard.Bd3eUPwZ.js → DashboardBoard.CkSbhEDI.js} +3 -3
  16. package/dist/_astro/DatePicker.Bkl71M49.js +1 -0
  17. package/dist/_astro/DocsFileBrowser.MKVCfZrE.js +1 -0
  18. package/dist/_astro/DocsPager.DJY4foYL.js +1 -0
  19. package/dist/_astro/{DrawerField.CWMLhcPX.js → DrawerField.CHRg77LG.js} +1 -1
  20. package/dist/_astro/{ExcelFieldTags.B_XMwNNx.js → ExcelFieldTags.DXMeaDa5.js} +4 -4
  21. package/dist/_astro/KnowledgeLibrary.B-p1aoQN.js +1 -0
  22. package/dist/_astro/NamePromptDialog.Wa9O530a.js +1 -0
  23. package/dist/_astro/NavLibraries.C6LImMO_.js +1 -0
  24. package/dist/_astro/OverflowHint.D6v4Uj2N.js +1 -0
  25. package/dist/_astro/PluginsPage.-97n3x2U.js +39 -0
  26. package/dist/_astro/PluginsPage.DkmRPfbU.js +1 -0
  27. package/dist/_astro/PmBugsBoard.CMT4-eoB.js +1 -0
  28. package/dist/_astro/PmIterationsBoard.BQM_dzdZ.js +1 -0
  29. package/dist/_astro/PmProjectDetail.CzU80pat.js +1 -0
  30. package/dist/_astro/PmProjectsBoard.Cxsa7SYQ.js +1 -0
  31. package/dist/_astro/PmRequirementsBoard.4_JMDDN0.js +1 -0
  32. package/dist/_astro/PmRequirementsBoard.B8HL07cw.js +1 -0
  33. package/dist/_astro/PmShared.Ca2Ao7v_.js +1 -0
  34. package/dist/_astro/PromptsLibrary.C9BcIxKK.js +1 -0
  35. package/dist/_astro/ReportsPage.Fh5DRKLT.js +1 -0
  36. package/dist/_astro/RequirementsLibrary.CBkuWE8X.js +1 -0
  37. package/dist/_astro/SearchableSelect.DnjoSslK.js +1 -0
  38. package/dist/_astro/SelectDropdown.CuuDHa8s.js +1 -0
  39. package/dist/_astro/SettingsDialog.CJvBRcs9.js +1 -0
  40. package/dist/_astro/SlideOverDrawer.B7B5Wu8I.js +1 -0
  41. package/dist/_astro/{SpaceSwitcher.BEJo5KFi.js → SpaceSwitcher.BVQLt_tL.js} +2 -2
  42. package/dist/_astro/TagSelect.CuN5RdF4.js +1 -0
  43. package/dist/_astro/TasksBoard.Bu-fpIZ7.js +1 -0
  44. package/dist/_astro/TemplatesLibrary.DSylQGlN.js +1 -0
  45. package/dist/_astro/TestStatsBoard.CPyKW4wc.js +1 -0
  46. package/dist/_astro/Toast.R8_2OWRX.js +1 -0
  47. package/dist/_astro/TodosBoard.8kvRTEW-.js +1 -0
  48. package/dist/_astro/UiAutoBoard.DFTiDqCp.js +9 -0
  49. package/dist/_astro/active-element-history.CED-m1Zp.js +1 -0
  50. package/dist/_astro/app-config.BUPzGl9f.js +1 -0
  51. package/dist/_astro/{client.Be_SakrB.js → client.BHNTqLjv.js} +3 -3
  52. package/dist/_astro/dialog.BAPTk9a_.js +1 -0
  53. package/dist/_astro/hydrate-cache.BXX604Bw.js +1 -0
  54. package/dist/_astro/i18n.BGPnP1Bg.js +7 -0
  55. package/dist/_astro/index.astro_astro_type_script_index_0_lang.LPL9mPQY.js +1 -0
  56. package/dist/_astro/jsx-runtime.DUg_B_vD.js +1 -0
  57. package/dist/_astro/{lib.DJNDi_Ht.js → lib.CgXLzMMd.js} +15 -15
  58. package/dist/_astro/listbox.C96OCanh.js +1 -0
  59. package/dist/_astro/markdown-client.DRva7DS9.js +58 -0
  60. package/dist/_astro/menu.IPWdRoNM.js +1 -0
  61. package/dist/_astro/{open-docs-in-session.B0ZdZNj2.js → open-docs-in-session.CyFNgh1I.js} +1 -1
  62. package/dist/_astro/{plugins.D5ypJIXn.js → plugins.C2BMfzv1.js} +1 -1
  63. package/dist/_astro/{pm.BsnTv63L.js → pm.CagBA-ht.js} +4 -4
  64. package/dist/_astro/{portal.Cm9XlIPf.js → portal.C0hAhXDF.js} +2 -2
  65. package/dist/_astro/prompts-meta.Bua-j14I.js +2 -0
  66. package/dist/_astro/react-dom.DLW9pGCF.js +1 -0
  67. package/dist/_astro/{react-dom.CqAxpHMt.js → react.Blvh0GOs.js} +1 -1
  68. package/dist/_astro/report-prompt.CAfZ6RIo.js +1 -0
  69. package/dist/_astro/{settings.CnDCvwnQ.js → settings.Ceefeil5.js} +2 -2
  70. package/dist/_astro/{spaces-client.Cai2tHEI.js → spaces-client.BocUabwy.js} +1 -1
  71. package/dist/_astro/ui-auto-prompt.CX8fju7r.js +3 -0
  72. package/dist/_astro/ui-auto.BmC9JJ_X.js +1 -0
  73. package/dist/_astro/update.CvfIVwnq.js +1 -0
  74. package/dist/_astro/use-text-value.DBQvHeNl.js +1 -0
  75. package/dist/_astro/use-tree-walker.DFU2AaAP.js +1 -0
  76. package/dist/_astro/useListAnim.BoerpmsB.js +1 -0
  77. package/dist/_astro/{view-prefs.HCowOWXL.js → view-prefs.BEAZRcxF.js} +1 -1
  78. package/dist/case-exec/index.html +458 -22
  79. package/dist/cases/generate/index.html +258 -22
  80. package/dist/cases/library/index.html +458 -22
  81. package/dist/dashboard/index.html +458 -22
  82. package/dist/docs/changelog/index.html +389 -23
  83. package/dist/docs/install/index.html +258 -22
  84. package/dist/docs/manual/index.html +324 -27
  85. package/dist/index.html +2 -281
  86. package/dist/knowledge/index.html +458 -22
  87. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +258 -22
  88. package/dist/plugins/index.html +258 -22
  89. package/dist/pm/bugs/index.html +458 -22
  90. package/dist/pm/iterations/index.html +458 -22
  91. package/dist/pm/projects/detail/index.html +458 -22
  92. package/dist/pm/projects/index.html +458 -22
  93. package/dist/pm/requirements/index.html +458 -22
  94. package/dist/prompts/index.html +458 -22
  95. package/dist/reports/index.html +458 -22
  96. package/dist/requirements/index.html +458 -22
  97. package/dist/tasks/index.html +458 -22
  98. package/dist/templates/index.html +458 -22
  99. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +258 -22
  100. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +258 -22
  101. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +258 -22
  102. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +258 -22
  103. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +258 -22
  104. package/dist/test-automation/index.html +717 -0
  105. package/dist/test-stats/index.html +458 -22
  106. package/dist/todos/index.html +458 -22
  107. package/dist/workbench/index.html +517 -0
  108. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +85 -34
  109. package/lh-plugins/lh-project-docs.mjs +14 -0
  110. package/lh-plugins/lh-uiauto.mjs +2296 -0
  111. package/lh-plugins/plugin-prompts.mjs +200 -0
  112. package/lh-plugins/storage-domain.mjs +13 -0
  113. package/lh-plugins/uiauto-adapters/index.mjs +57 -0
  114. package/lh-plugins/uiauto-adapters/playwright.mjs +215 -0
  115. package/lh-plugins/uiauto-adapters/pytest.mjs +151 -0
  116. package/lh-plugins/uiauto-adapters/selenium.mjs +163 -0
  117. package/lh-plugins/uiauto-adapters/shared.mjs +371 -0
  118. package/lh-plugins/uiauto-adapters/tasks.mjs +369 -0
  119. package/lh-plugins/uiauto-argv-guard.cjs +41 -0
  120. package/lh-plugins/uiauto-explorer/apps.mjs +332 -0
  121. package/lh-plugins/uiauto-explorer/diff.mjs +159 -0
  122. package/lh-plugins/uiauto-explorer/emit-files.mjs +506 -0
  123. package/lh-plugins/uiauto-explorer/emit-python.mjs +160 -0
  124. package/lh-plugins/uiauto-explorer/emit-ts.mjs +118 -0
  125. package/lh-plugins/uiauto-explorer/emit.mjs +15 -0
  126. package/lh-plugins/uiauto-explorer/ir.mjs +114 -0
  127. package/lh-plugins/uiauto-explorer/locators.mjs +267 -0
  128. package/lh-plugins/uiauto-explorer/merge.mjs +235 -0
  129. package/lh-plugins/uiauto-explorer/plan.mjs +165 -0
  130. package/lh-plugins/uiauto-explorer/runner.mjs +370 -0
  131. package/lh-plugins/uiauto-explorer/sessions.mjs +1373 -0
  132. package/lh-plugins/uiauto-explorer/snapshot.mjs +492 -0
  133. package/lh-plugins/uiauto-prompt.mjs +122 -0
  134. package/lh-plugins/uiauto-report.mjs +111 -0
  135. package/package.json +1 -1
  136. package/dist/_astro/Base.DjIEQkT7.css +0 -1
  137. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.D0snmAJ_.js +0 -1
  138. package/dist/_astro/CaseExecBoard.BAV4EE3o.js +0 -1
  139. package/dist/_astro/CaseGenerateApp.Bz4ryNJG.js +0 -9
  140. package/dist/_astro/CasesLibrary.BPifyHUA.js +0 -1
  141. package/dist/_astro/ChatApp.DLo31SYZ.js +0 -276
  142. package/dist/_astro/ColumnResize.Bs6GL3DJ.js +0 -1
  143. package/dist/_astro/DatePicker.CMfX7F6z.js +0 -1
  144. package/dist/_astro/DocsFileBrowser.D3cKurQE.js +0 -1
  145. package/dist/_astro/DocsPager.rzu4mnzw.js +0 -1
  146. package/dist/_astro/KnowledgeLibrary.B0sO4QR1.js +0 -1
  147. package/dist/_astro/NamePromptDialog.Dl5kSnQI.js +0 -1
  148. package/dist/_astro/NavLibraries.Cvg3wery.js +0 -1
  149. package/dist/_astro/OverflowHint.lzmplP5j.js +0 -1
  150. package/dist/_astro/PluginsPage.DIltPILi.js +0 -39
  151. package/dist/_astro/PluginsPage.uvmSuXzi.js +0 -1
  152. package/dist/_astro/PmBugsBoard.CiaIhCHv.js +0 -1
  153. package/dist/_astro/PmIterationsBoard.H67QwKFw.js +0 -1
  154. package/dist/_astro/PmProjectDetail.DqDoIg8a.js +0 -1
  155. package/dist/_astro/PmProjectsBoard.nOC1Hugt.js +0 -1
  156. package/dist/_astro/PmRequirementsBoard.BPjZ7khP.js +0 -1
  157. package/dist/_astro/PmRequirementsBoard.CanxvcKg.js +0 -1
  158. package/dist/_astro/PmShared.CZnXaUq-.js +0 -1
  159. package/dist/_astro/PromptsLibrary.DU9EuSim.js +0 -1
  160. package/dist/_astro/ReportsPage.Cr88iz8c.js +0 -1
  161. package/dist/_astro/RequirementsLibrary.BwriF8F0.js +0 -1
  162. package/dist/_astro/SearchableSelect.Ctg8V1Z1.js +0 -1
  163. package/dist/_astro/SelectDropdown.Buv7rQJ_.js +0 -1
  164. package/dist/_astro/SettingsDialog.DEgsVfaL.js +0 -1
  165. package/dist/_astro/SlideOverDrawer.TPbGEoWn.js +0 -1
  166. package/dist/_astro/TagSelect.u8DTop7v.js +0 -1
  167. package/dist/_astro/TasksBoard.BZi_GBPG.js +0 -1
  168. package/dist/_astro/TemplatesLibrary.T4K9jUex.js +0 -1
  169. package/dist/_astro/TestStatsBoard.Dd1Kcmx6.js +0 -1
  170. package/dist/_astro/TodosBoard.C4yd_JFb.js +0 -1
  171. package/dist/_astro/active-element-history.CeefGkFQ.js +0 -1
  172. package/dist/_astro/app-config.DKMxjv3g.js +0 -1
  173. package/dist/_astro/dialog.DXHznyjD.js +0 -1
  174. package/dist/_astro/i18n.BXeGGutk.js +0 -7
  175. package/dist/_astro/jsx-runtime.BUXbF_vF.js +0 -1
  176. package/dist/_astro/listbox.Di-t5U37.js +0 -1
  177. package/dist/_astro/menu.Bkluqxic.js +0 -1
  178. package/dist/_astro/prompts-meta.F4wwkjUA.js +0 -2
  179. package/dist/_astro/report-prompt.Cmw4XzfY.js +0 -1
  180. package/dist/_astro/update.DXCPfU4a.js +0 -1
  181. package/dist/_astro/use-text-value.BuY0Cm1z.js +0 -1
  182. package/dist/_astro/use-tree-walker.CfTHFX43.js +0 -1
  183. package/dist/_astro/useListAnim.CpGB1cft.js +0 -1
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BUPzGl9f.js";import{i as r,o as i,s as a}from"./plugins.C2BMfzv1.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.BEAZRcxF.js";import{i as l,n as te,r as u,t as ne}from"./dialog.BAPTk9a_.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.BZzZWDci.js";import{n as p,t as m}from"./ColumnResize.BEkEW7qw.js";import{n as re,t as h}from"./DatePicker.Bkl71M49.js";import{t as g}from"./SelectDropdown.CuuDHa8s.js";import{A as _,C as v,D as ie,E as ae,M as oe,N as se,P as y,S as b,T as ce,_ as x,b as S,g as le,j as ue,k as de,n as C,u as fe,v as w,w as pe,x as me,y as T}from"./tasks.otRBFydq.js";import{a as E,c as D,i as he,l as O,n as k,o as A,r as j,s as M,t as N}from"./DrawerField.CHRg77LG.js";var P=e(t(),1),F=d(),ge=8e3,_e=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`action`,width:80,min:64}],ve=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],ye={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},be={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},I={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},xe={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Se={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Ce=[`status`,`priority`,`none`],we=`todos.group-by`,Te=[`in_progress`,`pending`,`done`,`overdue`,`cancelled`],Ee=T.map(e=>({value:e,label:S[e]})),De=[{value:``,label:`未设置`},...x.map(e=>({value:e,label:w[e]}))],Oe=Object.keys(L).map(e=>({value:e,label:L[e]})),ke=[{value:`all`,label:`全部紧急程度`},...x.map(e=>({value:e,label:w[e]}))],Ae=ke.map(e=>e.value),je=`todos.priority-filter`,Me=`todos.search`,Ne=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Pe(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${Ne} ${r&&!t?`text-stone-300`:``}`})}function Fe(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(Pe,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ie(e){return(0,F.jsx)(h,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Le(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,P.useState)({title:``}),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(!1),[v,ie]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),m(!1),ie(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:_(),dueDate:_(),...r}))},[t,n,r]);let oe=[{value:``,label:`不关联`},...i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId).map(e=>({value:e.id,label:e.title}))];function b(e){ee(t=>({...t,...e}))}let ce=ue({startDate:c.startDate??``,dueDate:c.dueDate??``}),x=se({dueDate:c.dueDate??``}),le=ae(c.status??`pending`),de=le?re((n&&ae(n.status)?n.taskEndDate:``)||_()):``,fe=x===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:x<0?`逾期 ${Math.abs(x)} 天`:x===0?`今天截止`:`${x} 天`;async function pe(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await y(n.id,t):await me([t],{mode:`manual`}),await s(),o()}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,F.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,F.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,F.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>b({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),pe())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(j,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ee,value:c.status??`pending`,onChange:e=>b({status:e}),label:S[c.status??`pending`],optionDotClassName:e=>xe[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ie(e=>!e),"aria-expanded":v,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(D,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(he,{open:v})})]}),v?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(D,{}),label:`所属任务`,children:a?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:oe,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);b({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`,children:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`})}),i.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?C[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(j,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:De,value:c.priority??``,onChange:e=>b({priority:e}),label:c.priority?w[c.priority]:`未设置`,optionDotClassName:e=>Se[e]})})()}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[de?(0,F.jsx)(`span`,{className:`text-stone-800`,children:de}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:le?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`开始日期`,children:(0,F.jsx)(h,{value:c.startDate??``,onChange:e=>b({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`截止日期`,children:(0,F.jsx)(h,{value:c.dueDate??``,onChange:e=>b({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ce===null?`—`:`${ce} 天`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:fe||`—`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`备注`,children:(0,F.jsx)(`textarea`,{value:c.note??``,onChange:e=>b({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,F.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void pe(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function R(){let[e,t]=(0,P.useState)(!1),[l,te]=(0,P.useState)(!0),[u,ne]=(0,P.useState)(null),[d,C]=(0,P.useState)([]),[T,E]=(0,P.useState)([]),[D,he]=(0,P.useState)(!1),[O,k]=(0,P.useState)(null),[A,j]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>ee(Me)),[L,Ne]=(0,P.useState)(()=>s(je,Ae,`all`)),[R,Re]=(0,P.useState)(()=>s(we,Ce,`status`)),[ze,Be]=(0,P.useState)({}),[z,Ve]=(0,P.useState)({});function He(e){o(we,e),Re(e)}function Ue(e){o(je,e),Ne(e)}function We(e){c(Me,e),N(e)}let[Ge,Ke]=(0,P.useState)({}),[B,V]=(0,P.useState)(null),[H,U]=(0,P.useState)(null),[qe,Je]=(0,P.useState)(!1),[Ye,Xe]=(0,P.useState)(null),W=(0,P.useRef)(!0),Ze=(0,P.useRef)(!1),Qe=(0,P.useRef)(!1),G=p(`lh:todos:cols:v1`,_e),$e=B!==null,K=(0,P.useRef)(B);K.current=B;let et=(0,P.useRef)(!1),tt=(0,P.useRef)(async()=>{});tt.current=ct,(0,P.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,P.useEffect)(()=>{if(!$e)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=K.current;if(!n)return;if(n.title.trim()){tt.current();return}let r=_();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&V(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[$e]);let q=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ie(),D?fe().catch(()=>[]):Promise.resolve([])]);if(!W.current)return;let n=t;if(!Ze.current&&D){Ze.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>le(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}C(e),E(n),k(null)}catch(e){if(!W.current)return;k(e instanceof Error?e.message:String(e))}},[D]);(0,P.useEffect)(()=>{let e=i(e=>{te(!!e.todos),he(!!e.tasks)});return n().then(()=>{te(r(`todos`)),he(r(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&l&&(async()=>{let e=await pe();W.current&&(e?(await q(),W.current&&ne(!0)):ne(!1))})()},[e,l,q]),(0,P.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{Qe.current||q()},ge),t=()=>{Qe.current||q()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,q]),(0,P.useEffect)(()=>{if(!D||u!==!0||T.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=T.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await y(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&C(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[D,u,d,T]);function nt(e,t,n){Ke(r=>({...r,[e]:{...r[e],[t]:n}}))}function J(e){Ke(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let rt=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...T.filter(e=>e.status!==`closed`&&e.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))],[T]);function Y(e){return e.taskId?T.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function it(e){return e.taskId?T.find(t=>t.id===e.taskId):void 0}function at(e){let t=it(e);return t?t.priority:e.priority}async function X(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await y(e,t);if(!W.current)return;C(t=>t.map(t=>t.id===e?n:t)),k(null),t.taskId&&await q()}catch(e){k(e instanceof Error?e.message:String(e)),await q()}}async function ot(e){let t=Ge[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of ve){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)J(e);else if(typeof r.title==`string`&&!r.title.trim())k(`待办名称不能为空`),J(e);else try{let t=await y(e,r);if(!W.current)return;C(n=>n.map(n=>n.id===e?t:n)),Ke(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),k(null)}catch(t){k(t instanceof Error?t.message:String(t)),J(e)}}function st(e){let t=e.newStatus??`pending`,n=e.newPriority??``;V({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:_(),dueDate:_(),note:``,baseStatus:t,basePriority:n}),Be(t=>({...t,[e.key]:!1}))}async function ct(){let e=K.current;if(!e||et.current)return;let t=e.title.trim();if(t){et.current=!0,Je(!0);try{let n=T.find(t=>t.id===e.taskId);await me([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),K.current===e&&V(null),k(null),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{et.current=!1,W.current&&Je(!1)}}}async function lt(){let e=H;if(e){U(null),j(!0),k(null);try{await b(e.map(e=>e.id)),Ve({}),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{W.current&&j(!1)}}}let Z=_(),ut=(0,P.useMemo)(()=>d.map(e=>{let t=e.taskId?T.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,T]),dt=(0,P.useMemo)(()=>ce(ut,{status:`all`,priority:L,keyword:M,today:Z}),[ut,L,M,Z]),Q=(0,P.useMemo)(()=>de(dt),[dt]),ft=(0,P.useMemo)(()=>R===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:R===`priority`?[...x,``].map(e=>({key:`priority:${e||`none`}`,label:e?w[e]:`未设置`,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Te.map(e=>({key:`status:${e}`,label:S[e],pill:ye[e],items:Q.filter(t=>v(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[R,Q,Z]).filter(e=>e.items.length>0||B?.groupKey===e.key&&!!B),pt=Object.keys(z).filter(e=>z[e]),$=(0,P.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=v(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>We(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,F.jsx)(g,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Oe,value:R,onChange:e=>He(e)}),(0,F.jsx)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:ke,value:L,onChange:e=>Ue(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:A||pt.length===0,onClick:()=>U(d.filter(e=>z[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>Xe({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),O?(0,F.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:O}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>k(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{Qe.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{Qe.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:_e.map(e=>(0,F.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>z[e.id]),onChange:e=>{let t=e.target.checked;Ve(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-left font-medium`,"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办名称`,(0,F.jsx)(m,{...G.resizeProps(2)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(m,{...G.resizeProps(3)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(m,{...G.resizeProps(4)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(m,{...G.resizeProps(5)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(m,{...G.resizeProps(6)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(m,{...G.resizeProps(7)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(m,{...G.resizeProps(8)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(m,{...G.resizeProps(9)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(m,{...G.resizeProps(10)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(m,{...G.resizeProps(11)})]}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),ft.map(e=>{let t=ze[e.key]===!0;return(0,F.jsxs)(`tbody`,{children:[(0,F.jsx)(`tr`,{className:`border-t border-stone-100 bg-white`,children:(0,F.jsx)(`td`,{colSpan:13,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>Be(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,F.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=Ge[e.id]??{},r={...e,...n},i=v(r,Z),a=ue(r),o=se(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!z[e.id],onChange:t=>Ve(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:t+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(Pe,{value:r.title,placeholder:`输入待办名称`,onChange:t=>nt(e.id,`title`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})]})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${xe[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:r.taskId,onChange:t=>{let n=T.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${Y(r)?`text-stone-800`:`text-stone-300`}`,children:Y(r)||`未关联`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:Y(r)?`${Y(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:it(r)?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[at(r)]??`text-stone-300`}`,children:at(r)?w[at(r)]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[e.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?w[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Se[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:oe(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(oe(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Fe,{value:r.note,onChange:t=>nt(e.id,`note`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})}),(0,F.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>Xe({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>U([e]),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:B?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:B.title,disabled:qe,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>V(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ct()):e.key===`Escape`&&(e.preventDefault(),V(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:B.status,onChange:e=>V(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[B.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[B.status]})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:B.taskId,onChange:e=>V(t=>{if(!t)return t;let n=T.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=T.find(e=>e.id===B.taskId);return(0,F.jsx)(`span`,{className:`truncate ${e?`text-stone-800`:`text-stone-300`}`,children:e?.title||`未关联`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=T.find(e=>e.id===B.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?w[e.priority]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:B.priority,onChange:e=>V(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[B.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:B.priority?w[B.priority]:`未设置`})})})()}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.startDate,onChange:e=>V(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.dueDate,onChange:e=>V(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ae(B.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(_())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:B.note,disabled:qe,placeholder:`—`,onChange:e=>V(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{className:`border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:11,children:(0,F.jsxs)(`button`,{type:`button`,disabled:qe,onClick:()=>st(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),ft.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:13,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,pt.length?` · 已选 ${pt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(Le,{open:Ye!==null,item:Ye?.item??null,preset:Ye?.preset,tasks:T,tasksOn:D,onClose:()=>Xe(null),onSaved:q}),(0,F.jsx)(f,{open:H!=null,title:H&&H.length>1?`批量删除`:`删除待办`,message:H&&H.length>1?`确认删除已选中的 ${H.length} 条待办?此操作不可恢复。`:`删除「${H?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>U(null),onConfirm:()=>void lt()})]}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{R as default};
@@ -0,0 +1,9 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BUPzGl9f.js";import{i as r,o as i,r as a,t as o}from"./view-prefs.BEAZRcxF.js";import{i as s,n as c,r as l,t as u}from"./dialog.BAPTk9a_.js";import{i as ee,n as d,r as te,t as f}from"./menu.IPWdRoNM.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as ne}from"./ConfirmDialog.BZzZWDci.js";import{t as m}from"./OverflowHint.D6v4Uj2N.js";import{t as re}from"./SelectDropdown.CuuDHa8s.js";import{s as ie}from"./llm.BZEzE0x2.js";import{s as ae}from"./project-docs.Cd2gKPKh.js";import{u as oe}from"./prompts-meta.Bua-j14I.js";import{f as se,l as ce,p as le}from"./settings.Ceefeil5.js";import{showToast as ue}from"./Toast.R8_2OWRX.js";import{t as de}from"./markdown-client.DRva7DS9.js";import{n as h,r as fe,t as g}from"./ui-auto-prompt.CX8fju7r.js";import{t as pe}from"./hydrate-cache.BXX604Bw.js";import{O as _,S as me,d as he,g as ge,l as v,m as _e}from"./PmShared.Ca2Ao7v_.js";import{S as ve,_ as ye,a as be,b as xe,c as Se,d as Ce,f as we,h as Te,i as Ee,l as De,m as Oe,n as ke,o as y,p as b,r as Ae,t as x,u as S,v as je,x as C,y as Me}from"./ui-auto.BmC9JJ_X.js";var w=e(t(),1),Ne=`${ke}/agent`;async function T(e,t){let n=await fetch(`${Ne}${e}`,{...t,headers:{"Content-Type":`application/json`,...t?.headers??{}}}),r=await n.text(),i=null;try{i=r?JSON.parse(r):null}catch{i=null}if(!n.ok){let e=(i&&typeof i==`object`&&`error`in i?String(i.error):``)||r.slice(0,300)||`请求失败(${n.status})`;throw Error(e)}return i??{}}async function Pe(e){return T(`/prepare`,{method:`POST`,body:JSON.stringify(e)})}async function Fe(e,t){return T(`/open`,{method:`POST`,body:JSON.stringify({sessionId:e,url:t})})}async function Ie(e,t={}){return T(`/snapshot`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function E(e,t){return T(`/action`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function D(e,t={}){return T(`/wait`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function Le(e){return T(`/console`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function Re(e){return T(`/network`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function ze(e,t,n){return T(`/probe`,{method:`POST`,body:JSON.stringify({sessionId:e,ref:t,stepId:n})})}async function Be(e,t){return T(`/screenshot`,{method:`POST`,body:JSON.stringify({sessionId:e,label:t})})}async function Ve(e){await T(`/close`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function O(e){return T(`/save`,{method:`POST`,body:JSON.stringify(e)})}async function He(e,t,n={}){return T(`/emit`,{method:`POST`,body:JSON.stringify({ir:e,target:t,...n})})}async function k(e,t,n){return T(`/verify`,{method:`POST`,body:JSON.stringify({sessionId:e,ir:t,target:n,timeoutMs:18e4})})}async function Ue(e){return T(`/write`,{method:`POST`,body:JSON.stringify(e)})}async function We(e){return T(`/sessions?projectId=${encodeURIComponent(e)}`)}async function A(e){return T(`/session?id=${encodeURIComponent(e)}`)}async function Ge(e,t){return T(`/debug`,{method:`POST`,body:JSON.stringify({sessionId:e,mode:t})})}async function Ke(e){return T(`/debug/stop`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function qe(e){return T(`/changes?sessionId=${encodeURIComponent(e)}`)}async function Je(e){return T(`/reveal`,{method:`POST`,body:JSON.stringify(e)})}var j=null;async function M(e=!1){return(!j||e)&&(j=T(`/apps`).then(e=>({apps:e.apps??[],defaultId:e.defaultId??``})).catch(e=>{throw j=null,e})),j}async function Ye(e,t){return T(`/run-file`,{method:`POST`,body:JSON.stringify({sessionId:e,path:t,timeoutMs:18e4})})}async function Xe(e){return T(`/draft/clean`,{method:`POST`,body:JSON.stringify({sessionId:e})})}var N={type:`string`,description:`快照里的 ref,例如 d1-e12。页面导航后会失效。`},Ze={type:`function`,function:{name:`ui_plan_steps`,description:`提交整份步骤计划(人可读的动作 + 目标描述,不含定位器)。这一步只做测试设计,不会打开浏览器。`,parameters:{type:`object`,properties:{title:{type:`string`,description:`用例标题,中文即可`},steps:{type:`array`,description:`按执行顺序排列的计划步骤`,items:{type:`object`,properties:{action:{type:`string`,enum:[`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`],description:`测试动作;不要写「截图」——截图是探索时给人看的,不是测试步骤`},target:{type:`string`,description:`给人看的目标描述,例如「右上角的登录按钮」「用户名输入框」`},value:{type:`string`,description:"输入内容 / 选项;账号密码等占位数据写成 ${ENV_NAME}"},url:{type:`string`,description:`goto / expectUrl 的地址,相对路径即可`},note:{type:`string`,description:`补充说明,例如断言什么结果`}},required:[`action`,`target`]}}},required:[`steps`]}}},Qe=[Ze],$e=[Ze,{type:`function`,function:{name:`ui_browser_open`,description:`在浏览器里打开一个地址(相对地址会用 baseURL 拼接),返回页面快照。`,parameters:{type:`object`,properties:{url:{type:`string`,description:`绝对地址或 / 开头的相对地址`}},required:[`url`]}}},{type:`function`,function:{name:`ui_browser_snapshot`,description:`重新获取当前页面快照。页面变化较大、或 ref 不确定时用。`,parameters:{type:`object`,properties:{depth:{type:`number`,description:`快照深度,默认 6,越大越啰嗦`},targetRef:{type:`string`,description:`只看某个元素的子树`}}}}},{type:`function`,function:{name:`ui_browser_click`,description:`点击一个元素。成功后会自动返回新快照。`,parameters:{type:`object`,properties:{ref:N,note:{type:`string`,description:`这一步在做什么`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_browser_fill`,description:`填写输入框(会先清空已有内容)。`,parameters:{type:`object`,properties:{ref:N,text:{type:`string`,description:"要填入的内容;占位数据用 ${ENV_NAME} 表示环境变量"},note:{type:`string`}},required:[`ref`,`text`]}}},{type:`function`,function:{name:`ui_browser_select`,description:`选择下拉框选项(按 value 或可见文本)。`,parameters:{type:`object`,properties:{ref:N,value:{type:`string`},note:{type:`string`}},required:[`ref`,`value`]}}},{type:`function`,function:{name:`ui_browser_press`,description:`按一个键,例如 Enter / Tab / Escape。`,parameters:{type:`object`,properties:{key:{type:`string`},ref:{type:`string`}},required:[`key`]}}},{type:`function`,function:{name:`ui_browser_hover`,description:`悬停到元素上(用于展开菜单)。`,parameters:{type:`object`,properties:{ref:N,note:{type:`string`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_browser_back`,description:`浏览器后退一步。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_browser_wait`,description:`等待:给 text 时等到页面出现该文案(比死等毫秒可靠),否则等待指定毫秒。返回等待后的快照。`,parameters:{type:`object`,properties:{text:{type:`string`,description:`要等待出现的可见文案`},ms:{type:`number`,description:`没有 text 时等待的毫秒数`},timeout:{type:`number`,description:`等待 text 的超时毫秒数,默认 15000`}}}}},{type:`function`,function:{name:`ui_browser_screenshot`,description:`截一张当前页面图,给用户看(模型看不到图片内容)。`,parameters:{type:`object`,properties:{label:{type:`string`,description:`截图标签,例如 after-login`}}}}},{type:`function`,function:{name:`ui_browser_console`,description:`读取浏览器控制台里的 error / warning / pageerror(排查偶发失败用)。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_browser_network`,description:`读取最近的失败请求(状态码 ≥ 400 或请求失败),用来判断是不是接口挂了。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_locator_probe`,description:`把一个 ref 转成可写进脚本的定位器,并校验唯一性。写步骤之前,对每个要操作的元素都调用一次。`,parameters:{type:`object`,properties:{ref:N,stepId:{type:`string`,description:`可选:左侧计划里的步骤 id(如 p2)。传了会把定位器回填到该步骤。`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_test_set_steps`,description:`提交 / 替换整份测试步骤(IR)。每次提交都会刷新右侧代码预览。先探索、再提交,不要凭想象写定位器。`,parameters:{type:`object`,properties:{title:{type:`string`,description:`用例标题,中文即可`},steps:{type:`array`,description:`按执行顺序排列的步骤`,items:{type:`object`,properties:{action:{type:`string`,enum:[`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`,`screenshot`]},locator:{type:`object`,description:`定位器。首选 ui_locator_probe 给出的 recommended,不要自己拼长 CSS`,properties:{kind:{type:`string`,enum:[`testid`,`role`,`label`,`placeholder`,`text`,`attr`,`css`]},role:{type:`string`},name:{type:`string`},value:{type:`string`},attr:{type:`string`},exact:{type:`boolean`},nth:{type:`number`,description:`同名元素有多个时取第几个(0 = 第一个)。用 ui_locator_probe 返回的 nth,不要自己猜`}},required:[`kind`]},url:{type:`string`},value:{type:`string`,description:`输入内容 / 选项值 / 截图名`},key:{type:`string`},text:{type:`string`,description:`expect 时要断言的文本`},state:{type:`string`,enum:[`visible`,`hidden`]},ms:{type:`number`},note:{type:`string`},planStepId:{type:`string`,description:`可选:对应左侧计划步骤 id,便于逐条勾掉计划`}},required:[`action`]}}},required:[`steps`]}}},{type:`function`,function:{name:`ui_test_get_steps`,description:`读取当前已提交的步骤,改之前先看一眼。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_test_verify`,description:`在临时目录试跑当前步骤对应的脚本,返回是否通过和日志尾部。`,parameters:{type:`object`,properties:{}}}}],et=`浏览器已被关闭,这一轮探索已结束`;function tt(e){if(!e||!e.includes(`error`))return!1;let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=String(t.error??``);return n.includes(`浏览器已被关闭`)||n.includes(`浏览器进程已退出`)||n.includes(`Target page, context or browser has been closed`)}var P=(e,t)=>e.length>t?`${e.slice(0,t)}…(已截断)`:e;async function nt(e,t,n){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`工具参数不是合法 JSON`})}let i=n.sessionId,a=e=>typeof r[e]==`string`?String(r[e]):``;try{if(e===`ui_plan_steps`){let e=Array.isArray(r.steps)?r.steps:[];if(!e.length){let e=await A(i).then(e=>e.session.plan??[]).catch(()=>[]);return JSON.stringify({ok:!0,stepCount:e.length,plan:e.map(e=>({id:e.id,action:e.action,target:e.target})),note:`没有提交新步骤,计划保持不变。`})}let t=(await O({sessionId:i,title:a(`title`)||void 0,plan:e,mergePlan:!0})).session.plan??[];return n.onPlan?.(t),JSON.stringify({ok:!0,stepCount:t.length,plan:t.map(e=>({id:e.id,action:e.action,target:e.target})),note:`计划已保存,用户可以在左侧调整。接下来开始探索:逐个 probe 并回填定位器。`})}if(e===`ui_browser_open`){let e=await Fe(i,a(`url`));return JSON.stringify({url:e.url,title:e.title,elements:e.count,truncated:e.truncated,snapshot:P(e.snapshot,12e3)})}if(e===`ui_browser_snapshot`){let e=await Ie(i,{depth:Number(r.depth)||void 0,targetRef:a(`targetRef`)||void 0});return JSON.stringify({url:e.url,title:e.title,elements:e.count,truncated:e.truncated,snapshot:P(e.snapshot,12e3)})}if(e===`ui_browser_click`||e===`ui_browser_fill`||e===`ui_browser_select`||e===`ui_browser_hover`){let t=await E(i,{action:e.replace(`ui_browser_`,``),ref:a(`ref`),text:a(`text`),value:a(`value`),note:a(`note`)});return JSON.stringify({ok:!0,action:t.action,url:t.url,snapshot:P(t.snapshot,9e3)})}if(e===`ui_browser_press`){let e=await E(i,{action:`press`,ref:a(`ref`),key:a(`key`)});return JSON.stringify({ok:!0,url:e.url,snapshot:P(e.snapshot,9e3)})}if(e===`ui_browser_back`){let e=await E(i,{action:`back`});return JSON.stringify({ok:!0,url:e.url,snapshot:P(e.snapshot,9e3)})}if(e===`ui_browser_wait`){let e=await D(i,{text:a(`text`)||void 0,ms:Number(r.ms)||void 0,timeout:Number(r.timeout)||void 0});return JSON.stringify({ok:!0,action:e.action,url:e.url,snapshot:P(e.snapshot,9e3)})}if(e===`ui_browser_screenshot`){let e=await Be(i,a(`label`)||`snapshot`);return n.onShot?.(e.url),JSON.stringify({ok:!0,url:e.url,note:`截图已显示在面板里;你看不到图片内容,需要判断结构请用快照。`})}if(e===`ui_browser_console`){let e=(await Le(i)).messages??[];return JSON.stringify(e.length?{count:e.length,messages:e.slice(-20)}:{count:0})}if(e===`ui_browser_network`){let e=(await Re(i)).requests??[];return JSON.stringify(e.length?{count:e.length,requests:e.slice(-20)}:{count:0})}if(e===`ui_locator_probe`){let e=a(`ref`);if(!e)return JSON.stringify({error:`缺少 ref`});let t=a(`stepId`),r=await ze(i,e,t||void 0);return t&&r.plan&&n.onPlan?.(r.plan),JSON.stringify({ref:r.ref,element:r.element,confidence:r.confidence,recommended:r.recommended,fragile:!!r.fragile,warning:r.warning??``,candidates:r.candidates.slice(0,3),boundStep:r.planStep?{id:r.planStep.id,status:r.planStep.status}:void 0,note:r.confidence===`high`?`定位器唯一且指向同一元素,可以写进步骤`:r.recommended?`能用但不稳:${r.warning||`同名元素较多`}。照抄 recommended(含 nth),并补一条结果断言`:`没有唯一候选:换一个更具体的元素,或改成对结果文案的 expect`})}if(e===`ui_test_set_steps`){let e=Array.isArray(r.steps)?r.steps:[],t={title:a(`title`)||`未命名流程`,target:n.target,steps:e},o=await O({sessionId:i,title:t.title,ir:t});return n.onIr?.(t),n.onCode?.(o.code,o.suggestedPath),JSON.stringify({ok:!0,title:t.title,stepCount:t.steps.length,previewPath:o.suggestedPath,note:`已刷新代码预览。接下来调用 ui_test_verify 试跑。`})}if(e===`ui_test_get_steps`){let e=await A(i);return JSON.stringify({title:e.session.ir?.title??``,steps:e.session.ir?.steps??[],suggestedPath:e.suggestedPath})}if(e===`ui_test_verify`){let e=await k(i),t=String(e.log??``);return typeof e.code==`string`&&n.onCode?.(e.code,e.suggestedPath??``),JSON.stringify({passed:!!e.passed,exitCode:e.exitCode??null,timedOut:!!e.timedOut,durationMs:e.durationMs??0,draftPath:e.draftPath??``,tracePath:e.tracePath??``,log:P(t.slice(-4e3),4e3),note:e.passed?`试跑通过。草稿留在 .lantern-ai 里,用户可以直接看 trace / 用 Playwright UI 调试,确认后再写入项目。`:`试跑失败:只改步骤 IR(定位器 / 等待 / 断言)。草稿和 trace 会保留,用户能打开看现场;如果是功能本身不符合预期,不要为了跑绿改断言。`})}return JSON.stringify({error:`未知工具:${e}`})}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}function rt(e){return e?.length?e.map((e,t)=>{let n=[`${t+1}. [${e.id}] ${e.action}`];return e.target&&n.push(`目标:${e.target}`),e.url&&n.push(`url=${e.url}`),e.value&&n.push(`值=${e.value}`),e.locator&&n.push(`已绑定 ${it(e.locator)}`),n.join(` · `)}).join(`
2
+ `):``}function it(e){if(!e)return``;let t=Number.isInteger(e.nth)?` nth=${e.nth}`:``;return e.kind===`role`?`role=${e.role??``}${e.name?` name="${e.name}"`:``}${t}`:e.kind===`attr`?`[${e.attr}="${e.value??``}"]${t}`:e.kind===`testid`?`testid=${e.value??``}${t}`:`${e.kind}="${e.value??e.name??``}"${t}`}function F(e){return e===`python`?`Python + pytest + playwright.sync_api`:`TypeScript + @playwright/test`}function at(e,t){return e.replaceAll(`{{project}}`,t.project).replaceAll(`{{dir}}`,t.dir).replaceAll(`{{language}}`,t.language).replaceAll(`{{plan}}`,t.plan)}function ot(e,t,n,r,i){let a=rt(n);if(r?.trim()){let n=at(r.trim(),{project:e.name,dir:e.dir,language:F(t),plan:a||`如果还没有计划:先调用 ui_plan_steps 列出计划,再开始探索。`}),o=String(i??``).trim();return o?`${n}\n\n${o}`:n}return[`你是 UI 自动化测试工程师:用浏览器把流程点一遍,确认元素能唯一定位,再提交步骤。`,`项目:${e.name}(${e.dir}),目标语言:${F(t)}。`,`ref 导航后失效要重新 snapshot;每个元素先用 ui_locator_probe 拿唯一定位器,再用 ui_test_set_steps 提交。`,"探索阶段不要自己试跑;至少一条 expect 断言用户可见的结果;账号等占位值写成 ${ENV_NAME}。",a?`\n${a}`:``,`最后用中文简短汇报。`].filter(Boolean).join(`
3
+ `)}function st(e,t,n){return n?.trim()?at(n.trim(),{project:e.name,dir:e.dir,language:F(t),plan:``}):[`你是测试设计师:只把需求拆成「动作 + 目标描述」的步骤计划,不打开浏览器、不写定位器。`,`项目:${e.name}(${e.dir}),目标语言:${F(t)}。`,`只调用一次 ui_plan_steps;4~12 步,覆盖打开页面、前置、核心操作与至少一条结果断言。`,"账号密码等写成 ${ENV_NAME}。"].join(`
4
+ `)}function ct(e,t,n){return[`需求 / 流程:`,e.trim(),``,t?`起始地址(baseURL):${t}`:`起始地址:从需求里判断,用相对路径。`,`目标语言:${n===`python`?`Python (pytest)`:`TypeScript`}`,``,`请给出步骤计划。`].join(`
5
+ `)}function lt(e,t,n,r){return[`要自动化的流程 / 需求:`,e.trim(),``,t?`起始地址(baseURL):${t}`:`起始地址:从需求里判断,用相对路径。`,`目标语言:${n===`python`?`Python (pytest)`:`TypeScript`}`,r?.length?`
6
+ 已确认的步骤计划(按顺序执行,probe 时带上 stepId):
7
+ `+rt(r):``,``,`请开始:打开页面、探索并确认元素、提交步骤。`].filter(Boolean).join(`
8
+ `)}var I=p(),ut=`ui-auto.openapp`,dt={finder:`#3b82f6`,terminal:`#334155`,editor:`#64748b`};function ft({app:e,size:t=16}){let[n,r]=(0,w.useState)(!1);return!e.iconUrl||n?e.kind===`finder`?(0,I.jsx)(`svg`,{className:`shrink-0 text-[#3b82f6]`,width:t,height:t,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M2 5.5A1.5 1.5 0 013.5 4h4l1.5 2h7.5A1.5 1.5 0 0118 7.5v7A1.5 1.5 0 0116.5 16h-13A1.5 1.5 0 012 14.5v-9z`})}):e.kind===`terminal`?(0,I.jsxs)(`svg`,{className:`shrink-0 text-stone-700`,width:t,height:t,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:`2.5`,y:`3.5`,width:`15`,height:`13`,rx:`2`}),(0,I.jsx)(`path`,{d:`M6 8l2.5 2L6 12M10.5 12.5h3.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]}):(0,I.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-[4px] text-[9px] font-semibold text-white`,style:{width:t,height:t,backgroundColor:dt[e.kind]??`#94a3b8`},"aria-hidden":`true`,children:e.label.slice(0,1).toUpperCase()}):(0,I.jsx)(`img`,{src:e.iconUrl,alt:``,width:t,height:t,className:`shrink-0 rounded-[4px] object-contain`,onError:()=>r(!0)})}function pt({onOpen:e,disabled:t=!1,compact:n=!1}){let[r,o]=(0,w.useState)([]),[s,c]=(0,w.useState)(``),[l,u]=(0,w.useState)(()=>a(ut)),[p,ne]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let e=!0;return M().then(t=>{e&&(o(t.apps),c(t.defaultId))}).catch(()=>void 0).finally(()=>{e&&ne(!0)}),()=>{e=!1}},[]);let m=r.find(e=>e.id===l)??r.find(e=>e.id===s),re=r.length>0,ie=t||!re,ae=t=>{t&&(u(t.id),i(ut,t.id),e(t))};return(0,I.jsxs)(`div`,{className:`inline-flex shrink-0 overflow-hidden rounded-lg border border-stone-200 bg-white ${n?`h-7`:`h-8`} ${ie?`opacity-50`:``}`,children:[(0,I.jsx)(`button`,{type:`button`,className:`flex items-center px-1.5 transition-colors enabled:hover:bg-stone-50 disabled:cursor-not-allowed`,onClick:()=>{re&&e(m??null)},disabled:ie,"aria-label":m?`用 ${m.label} 打开`:`打开方式`,children:m?(0,I.jsx)(ft,{app:m,size:n?14:16}):(0,I.jsx)(`span`,{className:`px-1 text-[11px] text-stone-400`,children:p?`无可用应用`:`加载中`})}),(0,I.jsx)(`span`,{className:`my-1 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsxs)(te,{as:`div`,className:`relative flex`,children:[(0,I.jsx)(f,{type:`button`,className:`flex w-7 items-center justify-center text-stone-400 transition-colors enabled:hover:bg-stone-50 enabled:hover:text-stone-600 disabled:cursor-not-allowed`,disabled:ie,"aria-label":`选择打开方式`,children:(0,I.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,I.jsxs)(ee,{anchor:{to:`bottom end`,gap:4,padding:12},transition:!0,className:`tw-select-menu tw-menu-anim z-80 w-max min-w-[180px] space-y-0.5 rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[r.map(e=>{let t=e.id===(l||s);return(0,I.jsx)(d,{children:(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full select-none items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm ${t?`bg-(--tw-accent-soft) font-medium text-(--tw-accent)`:`text-stone-700 data-[focus]:bg-stone-50`}`,onClick:()=>ae(e),children:[(0,I.jsx)(ft,{app:e,size:18}),(0,I.jsx)(`span`,{className:`truncate`,children:e.label}),e.id===s?(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-[11px] text-stone-400`,children:`默认`}):null]})},e.id)}),r.length?null:(0,I.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-stone-400`,children:`没有探测到可用应用`})]})]})]})}var mt=`bg-[var(--tw-surface-panel)] border-[var(--tw-border)]`,L=`text-[var(--tw-label-primary)]`,ht=`text-[var(--tw-label-secondary)]`,gt=`text-[var(--tw-label-tertiary)]`,R=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,_t=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tw-border)] px-3 text-sm text-[var(--tw-label-secondary)] transition-colors hover:bg-[var(--tw-session-hover-bg)] disabled:cursor-not-allowed disabled:opacity-50`;function z({open:e,prompts:t,value:n,force:r=!1,onClose:i,onMount:a}){let[o,ee]=(0,w.useState)(n),[d,te]=(0,w.useState)(!1),[f,p]=(0,w.useState)(``);(0,w.useEffect)(()=>{e&&(ee(n),te(!1),p(``))},[e,n]);let ne=async()=>{if(!d&&o){te(!0),p(``);try{await a(o)}catch(e){p(e instanceof Error?e.message:String(e))}finally{te(!1)}}};return(0,I.jsxs)(l,{open:e,onClose:d||r?()=>void 0:i,className:`relative z-50`,children:[(0,I.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,I.jsxs)(s,{transition:!0,className:`tw-dialog-panel-anim w-full max-w-md overflow-hidden rounded-xl border shadow-xl ${mt}`,children:[(0,I.jsxs)(`div`,{className:`border-b border-[var(--tw-border)] px-5 py-4`,children:[(0,I.jsx)(c,{className:`text-base font-semibold ${L}`,children:r?`先挂载提示词`:`挂载提示词`}),(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${ht}`,children:r?`这个项目还没有挂载提示词,选一份挂上才能开始生成。`:`一个项目只挂一份提示词,换新的会立即取消上一份的引用`})]}),(0,I.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto px-5 py-4`,children:[t.length?(0,I.jsx)(`div`,{className:`space-y-1 rounded-lg border border-[var(--tw-border)] p-1`,children:t.map(e=>{let t=o===e;return(0,I.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>ee(e),"aria-pressed":t,className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed ${t?`bg-(--tw-accent-soft) font-medium text-(--tw-accent)`:`text-[var(--tw-label-primary)] hover:bg-[var(--tw-session-hover-bg)]`}`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 shrink-0 rounded-full border ${t?`border-[#4176e6] bg-[#4176e6] shadow-[inset_0_0_0_2px_var(--tw-surface-panel)]`:`border-[var(--tw-border)]`}`}),(0,I.jsx)(m,{text:e,className:`min-w-0 flex-1 truncate`})]},e)})}):(0,I.jsx)(`p`,{className:`rounded-lg border border-dashed border-[var(--tw-border)] px-3 py-6 text-center text-xs ${gt}`,children:`提示词管理里还没有可用的提示词,先去那里新建一份再回来挂载。`}),f?(0,I.jsx)(`p`,{className:`mt-3 rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed break-words text-red-600`,children:f}):null]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-[var(--tw-border)] px-5 py-3`,children:[r?(0,I.jsx)(`span`,{className:`mr-auto text-[11px] ${gt}`,children:`不挂载无法生成脚本`}):(0,I.jsx)(`button`,{type:`button`,className:_t,onClick:i,disabled:d,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:R,onClick:()=>void ne(),disabled:d||!o||!t.length,children:d?`保存中…`:`挂载`})]})]})})]})}var B=`bg-[var(--tw-surface-panel)] border-[var(--tw-border)]`,V=`divide-[var(--tw-border)]`,H=`border-[var(--tw-border)]`,vt=`text-[var(--tw-label-primary)]`,U=`text-[var(--tw-label-secondary)]`,W=`text-[var(--tw-label-tertiary)]`,yt=`hover:bg-[var(--tw-session-hover-bg)]`,G=`h-8 min-w-0 rounded-lg border ${H} bg-[var(--tw-surface-recessed)] px-2.5 text-xs ${vt} outline-none transition-colors placeholder:text-[var(--tw-label-tertiary)] focus:border-[#3370ff]`,bt=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,xt=`shrink-0 rounded px-1.5 py-0.5 text-[11px] ${W} transition-colors`;function St({open:e,projectName:t,detected:n,customTasks:r,hiddenCount:i,editedCount:a,error:o,onClose:ee,onAdd:d,onRemove:te,onEdit:f,onHide:p,onReset:ne,onRescan:m}){let[re,ie]=(0,w.useState)(``),[ae,oe]=(0,w.useState)(``),[se,ce]=(0,w.useState)(!1),[le,ue]=(0,w.useState)(!1),[de,h]=(0,w.useState)(``),[fe,g]=(0,w.useState)(``),[pe,_]=(0,w.useState)(``),[me,he]=(0,w.useState)(``);(0,w.useEffect)(()=>{e&&(ie(``),oe(``),ce(!1),ue(!1),h(``),g(``))},[e]);let ge=async()=>{let e=ae.trim();if(e&&!se){ce(!0);try{await d(re.trim(),e),ie(``),oe(``)}finally{ce(!1)}}},v=async()=>{if(!le){ue(!0);try{await m(),h(new Date().toLocaleTimeString(`zh-CN`,{hour12:!1}))}finally{ue(!1)}}},ve=e=>{g(e.id),_(e.edited?e.display:``),he(e.command)},ye=async()=>{if(!fe)return;let e=fe;g(``),await f(e,pe,me)};return(0,I.jsxs)(l,{open:e,onClose:ee,transition:!0,className:`relative z-110`,children:[(0,I.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,I.jsxs)(s,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border shadow-xl ${B}`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 ${H}`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(c,{className:`text-base font-semibold ${vt}`,children:`运行配置`}),(0,I.jsxs)(`p`,{className:`mt-1 truncate text-xs leading-relaxed ${W}`,children:[t,` · 命令在该项目目录下用 shell 执行,支持引号与 &&`]})]}),(0,I.jsx)(`button`,{type:`button`,onClick:ee,className:`tw-confirm-cancel -mr-1 -mt-1 flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${W} transition-colors hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)]`,"aria-label":`关闭`,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,I.jsxs)(`section`,{className:`border-b px-5 py-4 ${H}`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium ${U}`,children:`自定义命令`}),(0,I.jsxs)(`span`,{className:`text-[11px] ${W}`,children:[r.length,` 条`]})]}),r.length?(0,I.jsx)(`ul`,{className:`mt-2 divide-y rounded-lg border ${V} ${H}`,children:r.map(e=>(0,I.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-1.5`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${U}`,children:e.name?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-xs`,children:e.name}),(0,I.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] ${W}`,children:e.command})]}):(0,I.jsx)(`span`,{className:`font-mono text-[11px] ${U}`,children:e.command})}),(0,I.jsx)(`button`,{type:`button`,className:`${xt} hover:bg-red-50 hover:text-red-600`,onClick:()=>void te(e.id),children:`删除`})]},e.id))}):(0,I.jsx)(`p`,{className:`mt-2 rounded-lg border border-dashed px-2.5 py-2 text-[11px] ${H} ${W}`,children:`还没有自定义命令。名称可以不填,不填时下拉里直接显示命令。`}),(0,I.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`input`,{className:`${G} w-28 shrink-0`,value:re,onChange:e=>ie(e.target.value),placeholder:`名称(可选)`,"aria-label":`运行任务名称`}),(0,I.jsx)(`input`,{className:`${G} flex-1 font-mono`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ge()},placeholder:`npm run test:smoke`,"aria-label":`运行命令`,spellCheck:!1}),(0,I.jsxs)(`button`,{type:`button`,className:bt,onClick:()=>void ge(),disabled:!ae.trim()||se,children:[(0,I.jsx)(_e,{name:`plus`,size:13}),`添加`]})]})]}),(0,I.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium ${U}`,children:`自动发现`}),(0,I.jsxs)(`span`,{className:`text-[11px] ${W}`,children:[n.length,` 条`,de?` · ${de} 已扫描`:` · 挂载时扫描项目配置`]}),i||a?(0,I.jsxs)(`span`,{className:`text-[11px] ${W}`,children:[`已改 `,a,` · 已删 `,i]}):null,(0,I.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i||a?(0,I.jsx)(`button`,{type:`button`,className:`${xt} hover:bg-[var(--tw-session-hover-bg)] hover:text-[#4176e6]`,onClick:()=>void ne(),children:`恢复默认`}):null,(0,I.jsxs)(`button`,{type:`button`,className:`${xt} inline-flex items-center gap-1 hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void v(),disabled:le,children:[(0,I.jsxs)(`svg`,{className:`h-3 w-3 shrink-0 ${le?`animate-spin`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.6-6.4`}),(0,I.jsx)(`path`,{d:`M21 4v5h-5`})]}),le?`扫描中…`:`重新扫描`]})]})]}),n.length?(0,I.jsx)(`ul`,{className:`mt-2 divide-y rounded-lg border ${V} ${H}`,children:n.map(e=>fe===e.id?(0,I.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-2.5 py-2`,children:[(0,I.jsx)(`input`,{className:`${G} w-28 shrink-0`,value:pe,onChange:e=>_(e.target.value),placeholder:`名称(留空用原名称)`,"aria-label":`修改名称 ${e.id}`}),(0,I.jsx)(`input`,{className:`${G} flex-1 font-mono`,value:me,onChange:e=>he(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ye(),e.key===`Escape`&&g(``)},placeholder:`命令`,"aria-label":`修改命令 ${e.id}`,spellCheck:!1}),(0,I.jsx)(`button`,{type:`button`,className:`h-8 shrink-0 rounded-lg bg-[#4176e6] px-2.5 text-xs text-white transition-colors hover:bg-[#3566d0]`,onClick:()=>void ye(),children:`保存`}),(0,I.jsx)(`button`,{type:`button`,className:`h-8 shrink-0 rounded-lg border px-2.5 text-xs ${H} ${U} transition-colors hover:bg-[var(--tw-session-hover-bg)]`,onClick:()=>g(``),children:`取消`})]},e.id):(0,I.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-1.5 ${yt}`,children:[(0,I.jsx)(`span`,{className:`w-24 shrink-0 truncate text-xs ${U}`,children:e.display||e.command}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] ${W}`,children:e.command}),e.edited?(0,I.jsx)(`span`,{className:`shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] text-amber-600`,children:`已改`}):e.hint?(0,I.jsx)(`span`,{className:`hidden max-w-[170px] shrink-0 truncate text-[11px] sm:block ${W}`,children:e.hint}):null,(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,I.jsx)(`button`,{type:`button`,className:`${xt} hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)]`,onClick:()=>ve(e),children:`修改`}),(0,I.jsx)(`button`,{type:`button`,className:`${xt} hover:bg-red-50 hover:text-red-600`,onClick:()=>void p(e.id),children:`删除`})]})]},e.id))}):(0,I.jsx)(`p`,{className:`mt-2 rounded-lg border border-dashed px-2.5 py-2 text-[11px] ${H} ${W}`,children:`没扫到可复用命令(项目里没有测试脚本 / Makefile 目标 / marker),只保留全量运行。`}),(0,I.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed ${W}`,children:`扫描来源:package.json 的 scripts、Makefile 目标、pytest markers、Maven profiles。改过的命令按原样用 shell 执行,不再追加框架参数。`})]})]}),o?(0,I.jsx)(`p`,{className:`shrink-0 border-t px-5 py-2 text-[11px] text-red-600 ${H}`,children:o}):null]})})]})}function Ct(e){return e.kind===`create`?{label:`新增`,className:`bg-emerald-50 text-emerald-600`}:e.kind===`merge`?{label:`追加`,className:`bg-sky-50 text-sky-600`}:{label:`修改`,className:`bg-amber-50 text-amber-600`}}function wt({changes:e,git:t,draft:n,loading:r,onReveal:i,onRefresh:a}){let[o,s]=(0,w.useState)(``),c=(0,w.useMemo)(()=>e.find(e=>e.path===o)??e[0]??null,[o,e]);return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-500`,children:[`本次写入 `,(0,I.jsx)(`span`,{className:`font-medium text-stone-700`,children:e.length}),` 个文件`]}),n?.draftRoot?(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[10px] text-stone-400`,children:n.draftRoot}):null,(0,I.jsxs)(`button`,{type:`button`,className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap text-[11px] text-[#3370ff] hover:underline disabled:opacity-40`,onClick:a,disabled:r,children:[`刷新`,(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-full border border-[#3370ff]/30 border-t-[#3370ff] ${r?`animate-spin`:`opacity-0`}`})]})]}),e.length===0?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-1 px-4 text-center`,children:(0,I.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`还没有写入项目。试跑通过后点「写入项目」,这里会出现精确到行的改动内容。`})}):(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex w-60 shrink-0 flex-col overflow-auto border-r border-stone-100`,children:[(0,I.jsx)(`div`,{className:`shrink-0`,children:e.map(e=>{let t=Ct(e),n=c?.path===e.path;return(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] transition-colors ${n?`bg-[#f2f6ff]`:`hover:bg-stone-50`}`,onClick:()=>s(e.path),children:[(0,I.jsx)(`span`,{className:`shrink-0 rounded px-1 text-[10px] leading-4 ${t.className}`,children:t.label}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-stone-700`,children:e.path}),(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-emerald-600`,children:[`+`,e.added]}),(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-red-500`,children:[`-`,e.removed]})]},e.path)})}),t?.ok&&t.entries.length?(0,I.jsxs)(`details`,{className:`mt-auto shrink-0 border-t border-stone-100 px-2.5 py-1.5`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:[`项目工作区其它改动 `,t.entries.length,t.truncated?`(截断)`:``]}),(0,I.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.entries.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-stone-500`,children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 text-[#3370ff]`,children:e.code}),(0,I.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left hover:underline`,onClick:()=>i(e.path),children:e.path})]},`${e.code}-${e.path}`))})]}):null]}),c?(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-stone-600`,children:c.path}),(0,I.jsx)(`button`,{type:`button`,className:`ml-auto shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>i(c.path),children:`打开文件`}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>{let e=c.path.lastIndexOf(`/`);i(e===-1?``:c.path.slice(0,e))},children:`打开目录`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/40`,children:[c.truncated?(0,I.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-stone-500`,children:c.message}):null,(c.hunks??[]).map((e,t)=>(0,I.jsxs)(`div`,{className:`border-b border-stone-100`,children:[(0,I.jsxs)(`div`,{className:`bg-stone-100/70 px-3 py-0.5 font-mono text-[10px] text-stone-500`,children:[`@@ -`,e.oldStart,`,`,e.oldLines,` +`,e.newStart,`,`,e.newLines,` @@`]}),(0,I.jsx)(`div`,{className:`py-1`,children:(()=>{let t=e.oldStart,n=e.newStart;return e.lines.map((e,r)=>{let i=e.type===`add`?`+`:e.type===`del`?`-`:` `,a=e.type===`add`?``:t,o=e.type===`del`?``:n;return e.type!==`add`&&(t+=1),e.type!==`del`&&(n+=1),(0,I.jsxs)(`div`,{className:`flex gap-2 px-2 font-mono text-[11px] leading-5 ${e.type===`add`?`bg-emerald-50 text-emerald-800`:e.type===`del`?`bg-red-50 text-red-700`:`text-stone-600`}`,children:[(0,I.jsx)(`span`,{className:`w-8 shrink-0 select-none text-right text-[10px] text-stone-400`,children:a}),(0,I.jsx)(`span`,{className:`w-8 shrink-0 select-none text-right text-[10px] text-stone-400`,children:o}),(0,I.jsx)(`span`,{className:`w-2 shrink-0 select-none text-stone-400`,children:i}),(0,I.jsx)(`span`,{className:`whitespace-pre`,children:e.text||` `})]},r)})})()})]},`${c.path}-${t}`)),!c.truncated&&(c.hunks??[]).length===0?(0,I.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-stone-400`,children:`内容没有变化`}):null]})]}):null]})]})}var Tt=[{value:`goto`,label:`打开页面`},{value:`click`,label:`点击`},{value:`fill`,label:`填写`},{value:`select`,label:`选择`},{value:`press`,label:`按键`},{value:`hover`,label:`悬停`},{value:`expect`,label:`断言元素`},{value:`expectUrl`,label:`断言地址`},{value:`wait`,label:`等待`}],Et=`h-7 w-full rounded-md border border-stone-200 bg-white px-2 text-[11px] text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,Dt={pending:{label:`待绑定`,className:`bg-stone-100 text-stone-500`},bound:{label:`已绑定`,className:`bg-emerald-50 text-emerald-600`},done:{label:`已完成`,className:`bg-emerald-50 text-emerald-600`},failed:{label:`没绑上`,className:`bg-red-50 text-red-600`}};function Ot(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`p${n}`);)n+=1;return`p${n}`}function kt({plan:e,disabled:t,onChange:n}){let r=(t,r)=>{n(e.map(e=>e.id===t?{...e,...r}:e))},i=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=e.slice(),[o]=a.splice(t,1);a.splice(i,0,o),n(a)},a=t=>n(e.filter(e=>e.id!==t)),o=()=>n([...e,{id:Ot(e),action:`click`,target:``,status:`pending`}]),s=e.filter(e=>e.status===`bound`||e.status===`done`).length;return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-1 pb-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium text-stone-600`,children:`步骤计划`}),e.length?(0,I.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[s,`/`,e.length,` 已绑定`]}):null]}),(0,I.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,I.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#3370ff] hover:underline disabled:opacity-40`,onClick:o,disabled:t||e.length>=40,children:`+ 添加`})})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-auto px-0.5`,children:[e.length===0?(0,I.jsxs)(`p`,{className:`rounded-lg border border-dashed border-stone-200 px-3 py-6 text-center text-[11px] leading-relaxed text-stone-400`,children:[`还没有步骤。`,(0,I.jsx)(`br`,{}),`输入需求后点「生成步骤」,这里会出来一份可以手动调整的计划。`]}):null,e.map((n,o)=>{let s=Dt[n.status]??Dt.pending,c=n.action===`fill`||n.action===`select`||n.action===`press`;return(0,I.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-white px-2 py-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 text-center font-mono text-[10px] text-stone-400`,children:o+1}),(0,I.jsx)(`div`,{className:`w-[88px] shrink-0`,children:(0,I.jsx)(re,{options:Tt,value:n.action,onChange:e=>r(n.id,{action:e}),disabled:t,unstyled:!0,ariaLabel:`步骤动作`,triggerClassName:`flex h-6 w-full items-center justify-between gap-1 rounded-md border border-stone-200 bg-white px-1 text-[10px] text-stone-600 outline-none transition-colors hover:border-stone-300 focus:border-[#3370ff] disabled:cursor-not-allowed disabled:opacity-50`,menuMinWidth:120})}),(0,I.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${s.className}`,children:s.label}),(0,I.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,I.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-stone-700 disabled:opacity-30`,onClick:()=>i(o,-1),disabled:t||o===0,"aria-label":`上移`,children:`↑`}),(0,I.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-stone-700 disabled:opacity-30`,onClick:()=>i(o,1),disabled:t||o===e.length-1,"aria-label":`下移`,children:`↓`}),(0,I.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-red-600 disabled:opacity-30`,onClick:()=>a(n.id),disabled:t,"aria-label":`删除`,children:`×`})]})]}),(0,I.jsx)(`input`,{className:`${Et} mt-1`,value:n.target,disabled:t,placeholder:n.action===`goto`?`打开哪个页面`:`目标描述,例如「登录按钮」`,onChange:e=>r(n.id,{target:e.target.value}),spellCheck:!1}),n.action===`goto`||n.action===`expectUrl`?(0,I.jsx)(`input`,{className:`${Et} mt-1 font-mono`,value:n.url??``,disabled:t,placeholder:`/login`,onChange:e=>r(n.id,{url:e.target.value}),spellCheck:!1}):null,c?(0,I.jsx)(`input`,{className:`${Et} mt-1 font-mono`,value:n.value??``,disabled:t,placeholder:n.action===`press`?`Enter`:"输入值 / 选项(${ENV} 占位)",onChange:e=>r(n.id,{value:e.target.value}),spellCheck:!1}):null,n.locator?(0,I.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-emerald-700`,children:it(n.locator)}):null,n.warning?(0,I.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-4 text-amber-600`,children:n.warning}):null]},n.id)})]})]})}var At=`inline-flex h-8 shrink-0 select-none items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-sm outline-none transition-[background-color,border-color,color,box-shadow,opacity,transform] duration-150 motion-safe:active:translate-y-px focus-visible:ring-2 focus-visible:ring-[#4176e6]/35 disabled:cursor-not-allowed disabled:motion-safe:active:translate-y-0`,jt=`${At} font-medium text-white shadow-[0_1px_2px_rgba(23,43,99,0.12),inset_0_1px_0_rgba(255,255,255,0.18)] bg-[#4176e6] hover:bg-[#3566d0] active:bg-[#2f5cbd] active:shadow-none disabled:opacity-40 disabled:shadow-none disabled:hover:bg-[#4176e6] disabled:active:bg-[#4176e6]`,Mt=`${At} border border-stone-200 text-stone-600 hover:border-stone-300 hover:bg-stone-50 disabled:opacity-40`,Nt=`${At} border border-red-200 bg-red-50 text-red-600 hover:opacity-90 active:opacity-80`,Pt=`inline-flex h-7 select-none items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-xs outline-none transition-[background-color,color,box-shadow,opacity,transform] duration-150 motion-safe:active:translate-y-px focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 disabled:cursor-not-allowed disabled:motion-safe:active:translate-y-0`,Ft=`${Pt} text-stone-600 hover:bg-stone-100 disabled:opacity-40`,It=`${Pt} bg-(--tw-accent-soft) text-[#4176e6]`,Lt=`text-[11px] text-[#3370ff] hover:underline disabled:opacity-40 disabled:no-underline`,Rt=`h-8 w-full rounded-lg border border-stone-200 bg-white px-2.5 text-xs text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,zt=3,Bt=`ui-auto.gen.panel`,Vt=160,Ht=260,Ut=36,Wt=60,Gt=`ui-auto.gen.side`,Kt=330,qt=560,Jt=380,Yt=`ui-auto.gen.top`,Xt=`ui-auto.gen.bottom`,Zt=`ui-auto.gen.target`,Qt=72,$t=420,en=Qt,tn=`ui-auto.gen.reqheight`,nn=[{value:`activity`,label:`探索活动`},{value:`code`,label:`代码`},{value:`changes`,label:`变更`}],rn=[{value:`console`,label:`控制台`},{value:`network`,label:`网络`},{value:`run`,label:`试跑`}];function an(e,t,n){let r=a(e);return t.includes(r)?r:n}var on=`ui-auto.requirement`;function sn(){let e=o(on,``);return typeof e==`string`&&e?e:a(on,``)}function cn(e,t,n,r){let i=Number(a(e));return!Number.isFinite(i)||i<t?r:Math.min(i,n)}function ln(e,t){let n=a(e);return n===`1`||n!==`0`&&t}var un=[{value:`1`,label:`有头(可围观)`},{value:`0`,label:`无头(更快)`}];function dn(e,t){let n=t.some(e=>e.endsWith(`.py`)),r=t.some(e=>/\.(ts|js|mjs|cjs|tsx|jsx)$/.test(e));return e===`pytest`||n&&!r?{options:[{value:`python`,label:`Python`}],fallback:`python`}:{options:[{value:`ts`,label:`TypeScript`},{value:`python`,label:`Python`}],fallback:`ts`}}var fn=new Set([`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`]);function pn(e){return e.filter(e=>fn.has(e.action))}function mn(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>{let t=n.get(e.id);return t?{...e,status:t.status,locator:t.locator,warning:t.warning}:e});for(let n of t)e.some(e=>e.id===n.id)||r.push(n);return pn(r)}function hn(e,t){if(!t)return``;if(e!==`ui_browser_fill`&&e!==`ui_browser_select`)return t.slice(0,240);try{let e=JSON.parse(t);for(let t of[`text`,`value`]){let n=e[t];typeof n==`string`&&!n.startsWith("${")&&(e[t]=n.replace(/[\s\S]/g,`•`))}return JSON.stringify(e).slice(0,240)}catch{return t.slice(0,240)}}function gn(e){window.dispatchEvent(new CustomEvent(`lantern:uiauto-changed`,{detail:{count:e}}))}function _n(e){return e.split(`/`).pop()||e}function vn(e){let t=e.split(`/`);return t.pop(),t.join(`/`)||`.`}function yn(e){return e===`page`?{label:`页面`,className:`bg-sky-50 text-sky-600`}:e===`fixture`?{label:`登录态`,className:`bg-violet-50 text-violet-600`}:{label:`用例`,className:`bg-emerald-50 text-emerald-600`}}function bn({project:e,promptFile:t,onError:o}){let[s,c]=(0,w.useState)(null),l=(0,w.useCallback)(async()=>h(t),[t]),u=(0,w.useCallback)(async()=>{let e=await l();return!e.plan.trim()&&!e.agent.trim()?(ue(`没有读到「提示词管理」里的「${e.file||`Playwright提示词.md`}」。本平台提示词以提示词管理为准,请先在「提示词管理」里写好(需包含「## 规划阶段」「## 探索阶段」)再生成。`,`error`),null):e},[l]),ee=(0,w.useMemo)(()=>dn(e.framework,e.specFiles??[]),[e.framework,e.specFiles]),[d,te]=(0,w.useState)(()=>{let{options:t,fallback:n}=dn(e.framework,e.specFiles??[]),r=a(Zt);return t.some(e=>e.value===r)?r:n}),[f,p]=(0,w.useState)(sn),ne=`ui-auto.baseurl.${e.id}`,[m,ae]=(0,w.useState)(()=>e.baseURL||a(ne)||e.detectedBaseURL||a(`ui-auto.baseurl`)||`http://localhost:5173`),[oe,fe]=(0,w.useState)(e.detectedBaseURL||``),g=`ui-auto.storage.${e.id}`,[_,me]=(0,w.useState)(()=>e.storageState||e.detectedStorageState||a(g)||``),[he,ge]=(0,w.useState)(e.detectedStorageState||``),[v,_e]=(0,w.useState)(()=>ln(`ui-auto.headed`,!0)),[ye,be]=(0,w.useState)(()=>cn(tn,Qt,$t,en)),[xe,Se]=(0,w.useState)(!1),Ce=(0,w.useRef)(null),[we,Te]=(0,w.useState)(()=>ln(`ui-auto.gen.address`,!1)),[Ee,De]=(0,w.useState)(()=>ln(`ui-auto.gen.accept`,!1)),[Oe,ke]=(0,w.useState)(!0),[y,b]=(0,w.useState)(`idle`),[Ae,x]=(0,w.useState)([]),[S,je]=(0,w.useState)(null),[C,Me]=(0,w.useState)([]),[Ne,T]=(0,w.useState)(!1),[Fe,Ie]=(0,w.useState)(!1),[E,D]=(0,w.useState)(``),[ze,Be]=(0,w.useState)(``),[j,M]=(0,w.useState)([]),[N,Ze]=(0,w.useState)(()=>a(`ui-auto.gen.file.${e.id}`)),[P,rt]=(0,w.useState)(()=>ln(`ui-auto.gen.force`,!1)),[it,F]=(0,w.useState)([]),[at,ut]=(0,w.useState)(()=>{let e=Number(a(Gt));return!Number.isFinite(e)||e<Kt?Jt:Math.min(e,qt)}),dt=(0,w.useRef)(null),[ft,mt]=(0,w.useState)(``),[L,ht]=(0,w.useState)(``),[gt,R]=(0,w.useState)(``),[_t,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(null),[H,vt]=(0,w.useState)(0),[U,W]=(0,w.useState)(()=>an(Xt,rn.map(e=>e.value),`run`)),[yt,G]=(0,w.useState)(()=>an(Yt,nn.map(e=>e.value),`activity`)),[bt,xt]=(0,w.useState)(()=>{let e=Number(a(Bt));return!Number.isFinite(e)||e<Ut||e<=Wt?Ht:Math.min(e,640)}),[St,Ct]=(0,w.useState)(()=>a(Bt)===`closed`),[Tt,Et]=(0,w.useState)(!1),Dt=(0,w.useRef)(null),[Ot,At]=(0,w.useState)([]),[Pt,fn]=(0,w.useState)([]),[bn,Tn]=(0,w.useState)([]),[En,Dn]=(0,w.useState)(null),[K,On]=(0,w.useState)(null),[kn,An]=(0,w.useState)(!1),[q,jn]=(0,w.useState)(null),[Mn,Nn]=(0,w.useState)(!1),[Pn,Fn]=(0,w.useState)(``),[In,Ln]=(0,w.useState)(null),[Rn,zn]=(0,w.useState)(!1),Bn=(0,w.useRef)(null),J=(0,w.useRef)(``),Vn=(0,w.useRef)(0),Hn=(0,w.useRef)([]),Un=(0,w.useRef)(null),Y=(0,w.useRef)(null),Wn=(0,w.useRef)(null),Gn=(0,w.useRef)([]);(0,w.useEffect)(()=>{Gn.current=C},[C]);let[Kn,qn]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let e=!0;n().then(()=>{e&&c(ce())});let t=se(()=>c(ce()));return()=>{e=!1,t()}},[]);let X=(0,w.useCallback)(e=>{Vn.current+=1;let t=Vn.current;return x(n=>[...n,{...e,id:t,at:e.at??new Date().toISOString()}]),t},[]),Jn=(0,w.useRef)(null),Yn=(0,w.useRef)(``);(0,w.useEffect)(()=>{let e=J.current;if(!e)return;let t=Ae.map(({kind:e,name:t,detail:n,status:r,at:i})=>({kind:e,name:t,detail:n,status:r,at:i})),n=JSON.stringify(t);n!==Yn.current&&(Yn.current=n,Jn.current&&window.clearTimeout(Jn.current),Jn.current=window.setTimeout(()=>{O({sessionId:e,activity:t}).catch(()=>void 0)},600))},[Ae]),(0,w.useEffect)(()=>{r(on,f)},[f]),(0,w.useEffect)(()=>{i(ne,m),i(`ui-auto.baseurl`,m)},[ne,m]);let Xn=(0,w.useRef)(null),Zn=(0,w.useRef)(m);(0,w.useEffect)(()=>{m!==Zn.current&&(Zn.current=m,Xn.current&&window.clearTimeout(Xn.current),Xn.current=window.setTimeout(()=>{ve({id:e.id,baseURL:m}).then(e=>fe(e.detectedBaseURL||``)).catch(()=>void 0)},600))},[m,e.id]),(0,w.useEffect)(()=>{i(g,_)},[g,_]);let Qn=(0,w.useRef)(null),$n=(0,w.useRef)(_);(0,w.useEffect)(()=>{_!==$n.current&&($n.current=_,Qn.current&&window.clearTimeout(Qn.current),Qn.current=window.setTimeout(()=>{ve({id:e.id,storageState:_}).then(e=>ge(e.detectedStorageState||``)).catch(()=>void 0)},600))},[_,e.id]),(0,w.useEffect)(()=>{i(`ui-auto.headed`,v?`1`:`0`)},[v]),(0,w.useEffect)(()=>{i(`ui-auto.gen.force`,P?`1`:`0`)},[P]),(0,w.useEffect)(()=>{i(`ui-auto.gen.address`,we?`1`:`0`)},[we]),(0,w.useEffect)(()=>{i(`ui-auto.gen.accept`,Ee?`1`:`0`)},[Ee]),(0,w.useEffect)(()=>{N&&i(`ui-auto.gen.file.${e.id}`,N)},[N,e.id]),(0,w.useEffect)(()=>{xe||i(tn,String(ye))},[ye,xe]);let er=(0,w.useCallback)(e=>{G(e),i(Yt,e)},[]),tr=(0,w.useCallback)(e=>{W(e),i(Xt,e),St&&(Ct(!1),i(Bt,String(bt)))},[St,bt]),nr=(0,w.useCallback)(()=>{Ct(e=>{let t=!e;return i(Bt,t?`closed`:String(bt)),t})},[bt]),Z=(0,w.useCallback)(async()=>{if(!J.current)Tn([]),Dn(null),On(null);else{An(!0);try{let e=await qe(J.current);Tn(e.changes),Dn(e.git),On(e.draft),e.changes.length&&gn(e.changes.length)}catch{}finally{An(!1)}}},[]),rr=(0,w.useCallback)(async(e,t,n=``)=>{if(!e?.steps?.length)return M([]),[];try{let r=await He(e,t,{testDir:n.includes(`/`)?n.replace(/\/[^/]+$/,``):`tests`});return M(r.files),Ze(e=>r.files.some(t=>t.path===e)?e:r.files[0]?.path??``),r.files}catch{return[]}},[]),ir=(0,w.useCallback)(async()=>{if(!J.current)return[];Ie(!0);try{let e=await A(J.current);return D(e.code),Be(e.suggestedPath),await rr(e.session.ir,e.session.target===`python`?`python`:`ts`,e.suggestedPath)}catch{return[]}finally{Ie(!1)}},[rr]);(0,w.useEffect)(()=>{let t=!0;return je(null),J.current=``,Me([]),D(``),V(null),ht(``),x([]),Tn([]),Dn(null),On(null),jn(null),Fn(``),Ln(null),ke(!0),We(e.id).then(async n=>{if(!t)return;let r=n.sessions[0];if(!r){let t=e.baseURL||e.detectedBaseURL||``;Zn.current=t,ae(t),fe(e.detectedBaseURL||``);let n=e.storageState||e.detectedStorageState||``;$n.current=n,me(n),ge(e.detectedStorageState||``);return}let i=await A(r.id);if(!t)return;je(i.session),J.current=i.session.id,Me(pn(i.session.plan??[])),D(i.code),Be(i.suggestedPath),M([]),Ze(a(`ui-auto.gen.file.${e.id}`)),rr(i.session.ir,i.session.target===`python`?`python`:`ts`,i.suggestedPath),te(i.session.target===`python`?`python`:`ts`);let o=e.baseURL||i.session.baseURL||e.detectedBaseURL||``;Zn.current=o,ae(o),fe(e.detectedBaseURL||``);let s=e.storageState||i.session.storageState||e.detectedStorageState||``;if($n.current=s,me(s),ge(e.detectedStorageState||``),p(e=>i.session.source||e),On(i.draft??null),Tn(i.changes??[]),i.session.lastVerify&&V({passed:i.session.lastVerify.passed,exitCode:i.session.lastVerify.exitCode,durationMs:i.session.lastVerify.durationMs,log:i.session.lastVerify.log}),Array.isArray(i.session.activity)&&i.session.activity.length){let e=i.session.activity.map(e=>{Vn.current+=1;let t=e.status===`running`?`failed`:e.status;return{id:Vn.current,kind:e.kind===`tool`||e.kind===`error`?e.kind:`info`,name:e.name,detail:e.detail,status:t,at:e.at}});Yn.current=JSON.stringify(e.map(({kind:e,name:t,detail:n,status:r,at:i})=>({kind:e,name:t,detail:n,status:r,at:i}))),x(e)}i.session.savedPath&&er(`changes`),z(`已载入上次生成的草稿`),await Z()}).catch(()=>void 0).finally(()=>{t&&ke(!1)}),()=>{t=!1}},[e.id,Z,rr,er]),(0,w.useEffect)(()=>{let{options:t,fallback:n}=dn(e.framework,e.specFiles??[]);t.some(e=>e.value===d)||te(n)},[e.framework,e.specFiles,d]),(0,w.useEffect)(()=>{Un.current?.scrollTo({top:Un.current.scrollHeight})},[Ae]),(0,w.useEffect)(()=>()=>{Y.current?.release(),Bn.current?.abort(),Wn.current&&window.clearTimeout(Wn.current),J.current&&(Ke(J.current).catch(()=>void 0),Ve(J.current).catch(()=>void 0))},[]),(0,w.useEffect)(()=>{if(!S?.id)return;let e=S.id;U===`console`?Le(e).then(e=>At(e.messages??[])).catch(()=>At([])):U===`network`&&Re(e).then(e=>fn(e.requests??[])).catch(()=>fn([]))},[U,S?.id]);let Q=y!==`idle`,ar=y===`exploring`||y===`verifying`||y===`repairing`,or=Q||!f.trim()||!C.length,sr=S?.status===`explored`||S?.status===`verified`||S?.status===`written`||S?.status===`failed`,cr=Q||!sr||!S?.ir?.steps?.length,lr=(0,w.useCallback)(()=>({sessionId:J.current,target:d,onPlan:e=>Me(t=>mn(t,e)),onShot:e=>mt(e),onCode:(e,t)=>{D(e),Be(t)},onIr:e=>{X({kind:`info`,name:`提交步骤`,detail:`${e.title} · ${e.steps.length} 步`,status:`done`})}}),[X,d]),ur=(0,w.useCallback)(async(e,t)=>{if(!s)throw le(`model`),Error(`请先配置模型`);let n=lr();for await(let r of ie(s,e,t,{tools:$e,maxToolRounds:40,runTool:async(e,t)=>{Y.current&&await Y.current.promise;let r=await nt(e,t,n);if(tt(r)){for(let e of Hn.current.splice(0))x(t=>t.map(t=>t.id===e?{...t,status:`failed`}:t));throw Error(et)}return r}}))if(r.type===`tool`){if(r.status===`running`){let e=X({kind:`tool`,name:r.name,detail:hn(r.name,r.args??``),status:`running`});Hn.current.push(e)}else{let e=Hn.current.pop();x(t=>t.map(t=>t.id===e?{...t,status:`done`,detail:(r.result??``).slice(0,240)}:t))}}else r.type===`content`&&ht(e=>e+r.delta)},[X,s,lr]),dr=(0,w.useCallback)(async(t=!1)=>{let n=await Pe({projectId:e.id,sessionId:J.current||void 0,title:f.trim().split(/\r?\n/)[0]?.slice(0,60)||`未命名流程`,target:d,baseURL:m,storageState:_,source:f.trim(),headed:v,reset:t,plan:Gn.current.length?Gn.current:void 0});return J.current=n.session.id,je(n.session),Be(n.suggestedPath),On(n.draft),t&&(D(``),M([]),V(null),Tn([]),jn(null),Ln(null)),n.session.storageState&&me(n.session.storageState),n},[m,v,e.id,f,_,d]),fr=(0,w.useCallback)(async(t,n)=>{if(!s)throw le(`model`),Error(`请先配置模型`);let r=lr(),i=await l(),a=[{role:`system`,content:st(e,d,i.plan)},{role:`user`,content:ct(t,m,d)}];for await(let e of ie(s,a,n,{tools:Qe,maxToolRounds:2,runTool:async(e,t)=>nt(e,t,r)}))e.type===`tool`&&e.status===`running`?X({kind:`info`,name:`规划步骤`,detail:`只做测试设计,不打开浏览器`,status:`done`}):e.type===`content`&&ht(t=>t+e.delta);let o=pn((await A(J.current)).session.plan??[]);return Me(o),o},[m,l,e,X,s,d,lr]),pr=(0,w.useCallback)(async()=>{let e=f.trim();if(!e||Q)return;if(!s){R(`还没有配置模型,请先在设置里填好 API Key`),le(`model`);return}if(!await u())return;r(on,e),i(`ui-auto.baseurl`,m),i(g,_),i(`ui-auto.headed`,v?`1`:`0`);let t=new AbortController;Bn.current=t,R(``),z(``),ht(``),b(`planning`);try{await dr(!0);let n=await fr(e,t.signal);z(n.length?`已生成 ${n.length} 步计划,可以手动调整后再探索`:`没有得到步骤,补充需求后再试`)}catch(e){if(t.signal.aborted)z(`已停止`);else{let t=e instanceof Error?e.message:String(e);R(t),o?.(t),X({kind:`error`,name:`规划失败`,detail:t,status:`failed`})}}finally{Bn.current=null,b(`idle`)}},[m,Q,dr,v,o,fr,X,u,f,s,_]),mr=(0,w.useCallback)(async(e,t)=>{let n=e;for(let e=0;e<=zt;e+=1){vt(e),b(`verifying`),tr(`run`);let r=X({kind:`info`,name:e?`第 ${e} 次修复后试跑`:`试跑`,detail:`写进 .lantern-ai 草稿并执行,失败保留现场`,status:`running`}),i=await k(J.current);if(V(i),jn(null),typeof i.code==`string`&&D(i.code),x(e=>e.map(e=>e.id===r?{...e,status:i.passed?`done`:`failed`,detail:i.passed?`通过 · ${Math.round((i.durationMs??0)/100)/10}s`:(i.log??i.error??``).slice(-800)}:e)),Z(),ir(),i.passed)return X({kind:`info`,name:`试跑通过`,detail:`${Math.round((i.durationMs??0)/100)/10}s · 草稿在 ${i.draftPath??``}`,status:`done`}),z(`试跑通过,可以打开草稿 / trace 调试,确认后写入项目`),je(e=>e&&{...e,status:`verified`}),b(`idle`),!0;if(e===zt)break;b(`repairing`),n=[...n,{role:`user`,content:[`第 ${e+1} 次试跑失败(exitCode=${i.exitCode??`?`})。日志尾部:`,"```",(i.log??i.error??``).slice(-3500),"```",`请先调用 ui_test_get_steps 看当前步骤,只修改步骤 IR(定位器 / 等待 / 断言),再 ui_test_verify 重跑。`,`如果是页面行为本身不符合需求,不要为了跑绿改断言,直接在回答里说明疑似缺陷。`].join(`
9
+ `)}],await ur(n,t)}return z(`自动修复 ${zt} 轮仍未通过,请看试跑日志 / 打开 trace`),b(`idle`),!1},[tr,X,Z,ir,ur]),hr=(0,w.useCallback)(async()=>{let t=f.trim();if(!t||Q)return;if(!s){R(`还没有配置模型,请先在设置里填好 API Key`),le(`model`);return}if(!await u())return;r(on,t),i(`ui-auto.baseurl`,m),i(g,_),i(`ui-auto.headed`,v?`1`:`0`);let n=new AbortController;Bn.current=n,R(``),z(``),D(``),V(null),mt(``),vt(0),M([]),F([]),Ln(null),jn(null),Fn(``),ht(e=>e.trim()?`${e.trimEnd()}\n\n---\n\n`:e),er(`activity`),b(`exploring`);let a=``;try{let r=await dr(!0);a=r.session.id,X({kind:`info`,name:`探索开始`,detail:`${v?`有头`:`无头`}浏览器 · ${e.name}`,status:`done`});let i=C;if(i.length||(X({kind:`info`,name:`先规划步骤`,detail:`还没有计划,先做一次测试设计`,status:`done`}),i=await fr(t,n.signal)),!i.length){z(`没有得到步骤计划,请补充需求后重试`),b(`idle`);return}await O({sessionId:r.session.id,plan:i});let o=await l(),s=[{role:`system`,content:ot(e,d,i,o.agent,o.code)},{role:`user`,content:lt(t,m,d,i)}];await ur(s,n.signal);let c=await A(r.session.id);if(c.code&&(D(c.code),Be(c.suggestedPath)),Me(e=>mn(e,c.session.plan??[])),!(c.session.ir?.steps?.length??0)){X({kind:`error`,name:`没有提交步骤`,detail:`探索结束了,但这轮没有可用的步骤 IR,代码与试跑保持为空`,status:`failed`}),z(`AI 没有提交步骤,请补充需求后重试`),await O({sessionId:r.session.id,status:`draft`}).catch(()=>void 0);return}let u=await rr(c.session.ir,d,c.suggestedPath);X({kind:`info`,name:`生成代码`,detail:u.length?`按步骤出了 ${u.length} 个文件(用例 / 页面对象 / 登录态)`:`步骤已就绪,代码页可点「重新出码」`,status:`done`}),await O({sessionId:r.session.id,status:`explored`}).catch(()=>void 0),je({...c.session,status:`explored`}),On(c.draft??null),Tn(c.changes??[]),z(`探索完成,可以点「生成代码」出码;出码后会进入代码页`)}catch(e){if(n.signal.aborted)z(`已停止`);else if(e instanceof Error&&e.message===`浏览器已被关闭,这一轮探索已结束`)z(`浏览器已关闭,这一轮探索结束;重新点「开始探索」会新开一个浏览器`),X({kind:`error`,name:`浏览器已关闭`,detail:`窗口被关闭,AI 停止操作;已提交的步骤与计划保留`,status:`failed`});else{let t=e instanceof Error?e.message:String(e);R(t),o?.(t),X({kind:`error`,name:`生成中断`,detail:t,status:`failed`})}a&&await O({sessionId:a,status:`draft`}).catch(()=>void 0)}finally{Y.current?.release(),Y.current=null,qn(!1),Bn.current=null,b(`idle`),Z()}},[m,Q,dr,er,v,l,o,C,fr,e,X,Z,rr,u,f,ur,s,_,d]),gr=(0,w.useCallback)(()=>{Y.current?.release(),Y.current=null,qn(!1),Bn.current?.abort(),J.current&&(Ke(J.current).catch(()=>void 0),Ve(J.current).catch(()=>void 0))},[]),_r=(0,w.useCallback)(()=>{if(Y.current){Y.current.release(),Y.current=null,qn(!1),X({kind:`info`,name:`继续探索`,detail:`已手动完成登录 / 验证码`,status:`done`});return}let e=()=>{},t=new Promise(t=>{e=t});Y.current={promise:t,release:e},qn(!0),X({kind:`info`,name:`暂停`,detail:`请在打开的浏览器窗口里完成登录,完成后点「我已登录,继续」`,status:`running`})},[X]),vr=(0,w.useRef)(C.length);(0,w.useEffect)(()=>{vr.current=C.length},[C.length]);let yr=(0,w.useCallback)(e=>{if(Me(e),!J.current)return;let t=e.length!==vr.current;vr.current=e.length,t&&pe(`ui-auto`);let n=()=>{let t=J.current;t&&(T(!0),O({sessionId:t,plan:e,allowEmptyPlan:!0}).catch(()=>void 0).finally(()=>T(!1)))};Wn.current&&window.clearTimeout(Wn.current),t?n():Wn.current=window.setTimeout(n,400)},[]),$=(0,w.useMemo)(()=>j.length?j:E?[{path:ze||(d===`python`?`tests/test_ai_generated.py`:`tests/ai-generated.spec.ts`),content:E,language:d,role:`spec`}]:[],[E,j,ze,d]),br=(0,w.useMemo)(()=>$.find(e=>e.path===N)??$[0]??null,[N,$]),xr=(0,w.useCallback)((e,t)=>{M(n=>n.map(n=>n.path===e?{...n,path:t}:n)),Ze(t)},[]),Sr=(0,w.useCallback)(async()=>{if(J.current&&$.length){R(``),F([]);try{let e=await Ue({sessionId:J.current,files:$.map(e=>({path:e.path,content:e.content,role:e.role})),force:P});if(!e.ok){R(e.error??`写入失败`),F((e.conflicts??[]).map(e=>e.path));return}let t=e.savedPaths?.length??e.paths?.length??1,n=e.summary?.merged??0,r=e.summary?.created??0,i=e.summary?.unchanged??0,a=[r?`新建 ${r}`:``,n?`合并 ${n}`:``,i?`无变化 ${i}`:``].filter(Boolean).join(`、`);z(`已写入 ${t} 个文件${a?`(${a})`:``}${e.path?`,主用例 ${e.path}`:``},可以按项目配置验收`),je(t=>t&&{...t,status:`written`,savedPath:e.path,savedPaths:e.savedPaths}),rt(!1),await Z(),er(`changes`)}catch(e){R(e instanceof Error?e.message:String(e))}}},[P,er,Z,$]),Cr=(0,w.useCallback)(async()=>{if(J.current&&!Rn){zn(!0),R(``),Ln(null);try{let e=await Ye(J.current,S?.savedPath||$.find(e=>e.role===`spec`)?.path||ze);Ln(e),X({kind:`info`,name:`按项目配置验收`,detail:e.ok?e.passed?`通过`:e.excluded?`被 testMatch 排除,没跑起来`:`失败(exit ${e.exitCode??`?`})`:e.error??`失败`,status:e.ok&&e.passed?`done`:`failed`})}catch(e){R(e instanceof Error?e.message:String(e))}finally{zn(!1)}}},[Rn,X,S?.savedPath,ze,$]),wr=(0,w.useCallback)(async()=>{if(!J.current||y!==`idle`)return;if(!S?.ir?.steps?.length){R(`还没有步骤,先「开始探索」把流程跑一遍`);return}let t=new AbortController;Bn.current=t,R(``);try{if(!s){b(`verifying`),tr(`run`);let e=X({kind:`info`,name:`试跑`,detail:`在 .lantern-ai 草稿里执行(未配置模型,不做自动修复)`,status:`running`}),t=await k(J.current);V(t),jn(null),typeof t.code==`string`&&D(t.code),x(n=>n.map(n=>n.id===e?{...n,status:t.passed?`done`:`failed`,detail:t.passed?`通过 · ${Math.round((t.durationMs??0)/100)/10}s`:(t.log??t.error??``).slice(-800)}:n)),z(t.passed?`试跑通过`:`试跑失败,草稿与 trace 已保留`),await Z(),await ir();return}let n=await l(),r=[{role:`system`,content:ot(e,d,C,n.agent,n.code)},{role:`user`,content:lt(f.trim()||S?.source||``,m,d,C)}];await mr(r,t.signal)}catch(e){t.signal.aborted?z(`已停止`):R(e instanceof Error?e.message:String(e))}finally{Bn.current=null,b(`idle`);let e=J.current;e&&A(e).then(e=>je(e.session)).catch(()=>void 0)}},[m,tr,l,y,C,e,X,Z,ir,f,mr,S?.ir?.steps?.length,S?.source,s,d]),Tr=(0,w.useCallback)(async e=>{if(J.current&&!Mn){Nn(!0),R(``);try{let t=await Ge(J.current,e);jn(t),t.url&&Fn(t.url),t.ok?e===`headed`&&typeof t.tracePath==`string`&&t.tracePath&&On(e=>e&&{...e,tracePath:t.tracePath??``}):R(t.error??`调试启动失败`),X({kind:`info`,name:e===`ui`?`Playwright UI`:`调试运行`,detail:t.ok?t.url||`exit ${t.exitCode??`?`} · ${t.tracePath||`无 trace`}`:t.error??`失败`,status:t.ok&&t.passed!==!1?`done`:`failed`})}catch(e){R(e instanceof Error?e.message:String(e))}finally{Nn(!1)}}},[Mn,X]),Er=(0,w.useCallback)(async()=>{J.current&&(await Ke(J.current).catch(()=>void 0),Fn(``),jn(null))},[]),Dr=(0,w.useCallback)(async()=>{if(Q||!J.current)return;R(``);let e=await ir();er(`code`),z(e.length?`已生成 ${e.length} 个文件,确认后到「试跑」里执行`:`当前没有可出码的步骤,先「开始探索」把流程跑一遍`)},[Q,er,ir]),Or=(0,w.useCallback)(async e=>{if(J.current)try{await Je({sessionId:J.current,path:e})}catch(e){R(e instanceof Error?e.message:String(e))}},[]),kr=(0,w.useCallback)(async()=>{if(J.current){Nn(!0);try{let e=await Xe(J.current);On(e.draft),jn(null),V(null),Fn(``),z(`草稿已清理`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{Nn(!1)}}},[]),Ar=(0,w.useCallback)(async e=>{if(te(e),i(Zt,e),J.current)try{let t=await O({sessionId:J.current,target:e});D(t.code),Be(t.suggestedPath),await rr(S?.ir??null,e,t.suggestedPath)}catch(e){R(e instanceof Error?e.message:String(e))}},[rr,S?.ir]),jr=(0,w.useCallback)(()=>{let e=br?.content??E;e&&navigator.clipboard.writeText(e).then(()=>z(`已复制当前文件`)).catch(()=>R(`复制失败,请手动选中`))},[br?.content,E]),Mr=(0,w.useMemo)(()=>Kn?`已暂停:请在浏览器窗口里完成登录,然后点「我已登录,继续」`:y===`planning`?`AI 正在拆解步骤计划…`:y===`exploring`?`AI 正在操作浏览器…`:y===`verifying`?`正在草稿里试跑生成的脚本…`:y===`repairing`?`试跑失败,正在修复(第 ${H} 轮)…`:``,[Kn,y,H]),Nr=y===`planning`,Pr=Fe,Fr=S?S.status===`verified`?`试跑通过`:S.status===`written`?`已写入项目`:S.status===`explored`?`已探索`:S.status===`failed`?`试跑失败`:`草稿`:``,Ir=q?.tracePath||K?.tracePath||B?.tracePath||``,Lr=q?.draftPath||B?.draftPath||``,Rr=!!(K?.hasSteps||(S?.ir?.steps?.length??0));return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden bg-stone-50/40`,"aria-busy":Oe?`true`:void 0,children:[(0,I.jsxs)(`aside`,{className:`flex min-h-0 min-w-0 shrink-0 flex-col gap-2 overflow-hidden bg-white px-2.5 py-2`,style:{width:at},children:[(0,I.jsxs)(`div`,{className:`flex min-h-[104px] shrink flex-col`,children:[(0,I.jsx)(`div`,{className:`mb-1 flex items-center`,children:(0,I.jsx)(`label`,{htmlFor:`ui-gen-req`,className:`text-xs font-medium text-stone-600`,children:`需求 / 步骤`})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-lg border border-stone-200 bg-white transition-colors focus-within:border-[#3370ff] ${xe?``:`transition-[height] duration-150`}`,style:{flexBasis:ye},children:(0,I.jsx)(`textarea`,{id:`ui-gen-req`,className:`block h-full w-full resize-none bg-transparent px-2.5 py-2 text-xs leading-relaxed text-stone-700 outline-none`,value:f,onChange:e=>p(e.target.value),placeholder:`例:登录后进入商品列表,把第一个商品加入购物车,断言购物车出现该商品`,spellCheck:!1})}),(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整需求框高度`,title:`拖动调整高度,双击恢复默认`,className:`group mt-1 flex h-2 cursor-row-resize touch-none items-center justify-center`,onPointerDown:e=>{Ce.current={startY:e.clientY,startHeight:ye},Se(!0),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=Ce.current;if(!t)return;let n=Math.max(Qt,Math.min($t,Math.round(window.innerHeight*.45)));be(Math.min(n,Math.max(Qt,t.startHeight+(e.clientY-t.startY))))},onPointerUp:e=>{Ce.current&&(Ce.current=null,Se(!1),e.currentTarget.releasePointerCapture(e.pointerId))},onDoubleClick:()=>be(en),onPointerCancel:()=>{Ce.current=null,Se(!1)},children:(0,I.jsx)(`span`,{className:`h-[3px] w-8 rounded-full transition-colors ${xe?`bg-[#4176e6]/70`:`bg-stone-200 group-hover:bg-[#4176e6]/50`}`})})]}),(0,I.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`span`,{className:`mb-1 block text-[11px] text-stone-500`,children:`目标语言`}),(0,I.jsx)(re,{options:ee.options,value:d,onChange:e=>void Ar(e),compact:!0,ariaLabel:`目标语言`,className:`w-full`})]}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`span`,{className:`mb-1 block text-[11px] text-stone-500`,children:`浏览器`}),(0,I.jsx)(re,{options:un,value:v?`1`:`0`,onChange:e=>_e(e===`1`),compact:!0,ariaLabel:`浏览器`,className:`w-full`})]})]}),(0,I.jsxs)(`details`,{className:`shrink-0 rounded-lg border border-stone-200 px-2 py-1.5`,open:we,onToggle:e=>Te(e.currentTarget.open),children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:`地址与登录态`}),(0,I.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,I.jsx)(`input`,{id:`ui-gen-base`,className:`${Rt} font-mono`,value:m,onChange:e=>ae(e.target.value),placeholder:`http://localhost:5173`,spellCheck:!1,"aria-label":`起始地址`}),oe?(0,I.jsxs)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:[`项目配置里读到:`,(0,I.jsx)(`button`,{type:`button`,className:`ml-1 font-mono text-[#3370ff] hover:underline`,onClick:()=>ae(oe),disabled:m===oe,children:oe})]}):null,(0,I.jsx)(`input`,{id:`ui-gen-storage`,className:`${Rt} font-mono`,value:_,onChange:e=>me(e.target.value),placeholder:`登录态文件,留空自动检测;填 - 不用`,spellCheck:!1,"aria-label":`登录态文件`}),he?(0,I.jsxs)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:[`项目里找到:`,(0,I.jsx)(`button`,{type:`button`,className:`ml-1 font-mono text-[#3370ff] hover:underline`,onClick:()=>me(he),disabled:_===he,children:he})]}):_===`-`?(0,I.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`按未登录身份跑,不加载 cookie`}):_?(0,I.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`项目里没找到这个文件,跑之前会再确认一次;找不到就按未登录身份跑`}):(0,I.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`项目里没找到登录态文件:会以未登录身份打开,探索中可以点「手动登录」`})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`inline-flex h-8 items-center rounded-lg border border-stone-200 bg-white p-0.5`,children:[(0,I.jsxs)(`button`,{type:`button`,className:Nr?It:Ft,onClick:()=>void pr(),disabled:Q||!f.trim(),"aria-busy":Nr||void 0,children:[Nr?(0,I.jsx)(Cn,{}):(0,I.jsx)(wn,{name:`steps`}),(0,I.jsx)(`span`,{className:`min-w-[52px] text-center`,children:Nr?`规划中…`:`生成步骤`})]}),(0,I.jsx)(`span`,{className:`mx-0.5 h-4 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,I.jsxs)(`button`,{type:`button`,className:Pr?It:Ft,onClick:()=>void Dr(),disabled:cr,"aria-busy":Pr||void 0,children:[Pr?(0,I.jsx)(Cn,{}):(0,I.jsx)(wn,{name:`code`}),(0,I.jsx)(`span`,{className:`min-w-[52px] text-center`,children:Pr?`出码中…`:`生成代码`})]})]}),(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,I.jsx)(`button`,{type:`button`,className:`${ar?Nt:jt} min-w-[104px] justify-center`,onClick:()=>ar?gr():void hr(),disabled:!ar&&or,"aria-busy":ar||void 0,children:ar?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Cn,{}),`停止`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(wn,{name:`play`}),`开始探索`]})})})]}),!C.length&&!Q&&!Oe?(0,I.jsx)(`p`,{className:`shrink-0 text-[11px] leading-relaxed text-stone-400`,children:`先「生成步骤」,确认计划后就能开始探索`}):null,(0,I.jsxs)(`div`,{className:`max-h-[96px] shrink-0 space-y-1 overflow-y-auto`,children:[Mr||Ne||y===`exploring`&&v?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[Mr?(0,I.jsx)(`p`,{className:`text-[11px] text-[#4176e6]`,children:Mr}):null,Ne?(0,I.jsx)(`p`,{className:`text-[10px] text-stone-400`,children:`保存中…`}):null,y===`exploring`&&v?(0,I.jsx)(`button`,{type:`button`,className:`text-[11px] font-medium text-[#4176e6] underline-offset-2 hover:underline`,onClick:_r,children:Kn?`我已登录,继续`:`手动登录`}):null]}):null,gt?(0,I.jsx)(`p`,{className:`rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed break-words text-red-600`,children:gt}):null,_t?(0,I.jsx)(`p`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-[11px] leading-relaxed break-words text-emerald-700`,children:_t}):null]}),(0,I.jsx)(`div`,{className:`flex min-h-[150px] min-w-0 flex-1 flex-col`,children:Oe?(0,I.jsx)(Sn,{}):(0,I.jsx)(kt,{plan:C,disabled:Q,onChange:yr})})]}),(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`调整左栏宽度`,className:`w-1 shrink-0 cursor-col-resize touch-none bg-stone-200/70 transition-colors hover:bg-[#4176e6]/40`,onPointerDown:e=>{dt.current={startX:e.clientX,startWidth:at},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=dt.current;t&&ut(Math.min(qt,Math.max(Kt,t.startWidth+(e.clientX-t.startX))))},onPointerUp:e=>{dt.current&&(dt.current=null,e.currentTarget.releasePointerCapture(e.pointerId),i(Gt,String(at)))},onPointerCancel:()=>{dt.current=null}}),(0,I.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,I.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b border-stone-100 px-3`,children:[nn.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-[11px] transition-colors ${yt===e.value?`bg-[#f2f6ff] text-[#3370ff]`:`text-stone-500 hover:bg-stone-50`}`,onClick:()=>er(e.value),children:e.value===`changes`&&bn.length?`${e.label} ${bn.length}`:e.label},e.value)),(0,I.jsxs)(`div`,{className:`ml-auto flex min-w-0 shrink items-center gap-2`,children:[yt===`activity`&&Ae.length?(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 text-[10px] text-stone-400 transition-colors hover:text-red-500`,onClick:()=>{x([]),J.current&&O({sessionId:J.current,activity:[],replaceActivity:!0}).catch(()=>void 0)},children:`清除活动日志`}):null,S?(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[10px] text-stone-400`,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:`会话`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,children:S.id})]}):null]})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[yt===`activity`?(0,I.jsx)(`div`,{ref:Un,className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:Oe?(0,I.jsx)(xn,{rows:4}):(0,I.jsxs)(I.Fragment,{children:[Ae.length===0?(0,I.jsx)(`p`,{className:`py-6 text-center text-xs leading-relaxed text-stone-400`,children:`生成时这里会显示每一步操作与探测结果`}):(0,I.jsx)(`ul`,{className:`space-y-1.5`,children:Ae.map(e=>(0,I.jsx)(`li`,{className:`text-[11px] leading-relaxed`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,I.jsx)(`span`,{className:`mt-1 h-1.5 w-1.5 shrink-0 rounded-full ${e.status===`running`?`animate-pulse bg-[#4176e6]`:e.status===`failed`?`bg-red-500`:`bg-emerald-500`}`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`font-mono text-stone-700`,children:e.name}),e.detail?(0,I.jsx)(`pre`,{className:`mt-0.5 max-h-24 overflow-hidden whitespace-pre-wrap break-all text-[11px] text-stone-400`,children:e.detail}):null]})]})},e.id))}),L?(0,I.jsx)(`div`,{className:`chat-md prose prose-sm prose-stone mt-3 max-w-none border-t border-stone-100 pt-2 text-stone-600`,style:{fontSize:11,lineHeight:1.7},onClick:e=>{let t=e.target;if(!t.closest(`[data-copy-code]`))return;let n=t.closest(`.code-block`)?.querySelector(`code`);n&&navigator.clipboard?.writeText(n.textContent??``).then(()=>ue(`已复制`,`success`),()=>ue(`复制失败`,`error`))},dangerouslySetInnerHTML:{__html:de(L)}}):null]})}):null,yt===`code`?Oe?(0,I.jsx)(xn,{rows:5}):$.length?(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col border-r border-stone-100`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-2.5 py-1.5`,children:[(0,I.jsxs)(`span`,{className:`text-[11px] font-medium text-stone-600`,children:[`待写入 `,$.length,` 个文件`]}),(0,I.jsx)(`button`,{type:`button`,className:`ml-auto rounded px-1 text-[11px] text-stone-400 hover:bg-stone-50 hover:text-stone-600`,onClick:()=>void ir(),disabled:!S?.ir||Fe,children:Fe?`出码中…`:`重新出码`})]}),(0,I.jsx)(`ul`,{className:`min-h-0 flex-1 overflow-auto p-1`,children:$.map(e=>{let t=br?.path===e.path;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-1.5 rounded-md px-1.5 py-1 text-left transition-colors ${t?`bg-[#f2f6ff]`:`hover:bg-stone-50`}`,onClick:()=>Ze(e.path),children:[(0,I.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded px-1 py-px text-[10px] leading-4 ${yn(e.role).className}`,children:yn(e.role).label}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-stone-700`,children:_n(e.path)}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[10px] leading-4 text-stone-400`,children:vn(e.path)})]})]})},e.path)})}),(0,I.jsxs)(`div`,{className:`shrink-0 space-y-1.5 border-t border-stone-100 px-2.5 py-2`,children:[(0,I.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[11px] text-stone-500`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>rt(e.target.checked)}),`整文件覆盖(默认与已有文件合并)`]}),(0,I.jsxs)(`button`,{type:`button`,className:`${jt} w-full justify-center`,onClick:()=>void Sr(),disabled:Q||!$.length,children:[`写入 `,$.length,` 个文件`]})]})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:`shrink-0 rounded bg-stone-100 px-1.5 py-0.5 text-[10px] text-stone-500`,children:d===`python`?`pytest`:`Playwright Test`}),(0,I.jsx)(`input`,{className:`${Rt} min-w-[180px] flex-1 font-mono`,value:br?.path??``,onChange:e=>{br&&xr(br.path,e.target.value)},placeholder:ze||`tests/xxx.spec.ts`,spellCheck:!1,"aria-label":`写入路径`}),(0,I.jsx)(`button`,{type:`button`,className:Mt,onClick:jr,children:`复制`}),(0,I.jsx)(pt,{compact:!0,disabled:!br||!S?.savedPaths?.length,onOpen:e=>{br&&Je({sessionId:J.current,path:br.path,app:e?.id}).catch(e=>R(e instanceof Error?e.message:String(e)))}})]}),it.length?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-amber-100 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-700`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`这些文件已存在:`,it.join(`、`)]}),(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 rounded border border-amber-300 px-1.5 py-0.5 text-amber-800 hover:bg-amber-100`,onClick:()=>{rt(!0),F([])},children:`勾选覆盖`})]}):null,(0,I.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre px-3 py-2 font-mono text-[11px] leading-relaxed text-stone-700`,children:br?.content||`生成后这里显示要写入的文件`})]})]}):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs leading-relaxed text-stone-400`,children:`生成步骤并试跑后,这里会列出要写入项目的 spec、页面对象与登录态文件`}):null,yt===`changes`?Oe?(0,I.jsx)(xn,{rows:4}):(0,I.jsx)(wt,{changes:bn,git:En,draft:K,loading:kn,onReveal:e=>void Or(e),onRefresh:()=>void Z()}):null]}),ft&&yt===`activity`?(0,I.jsx)(`div`,{className:`shrink-0 border-t border-stone-100 p-2`,children:(0,I.jsx)(`img`,{src:ft,alt:`最近一步截图`,className:`max-h-52 w-full rounded-md border border-stone-100 object-contain`})}):null]}),(0,I.jsxs)(`section`,{className:`relative flex shrink-0 flex-col overflow-hidden border-t border-stone-200 bg-white ${Tt?``:`transition-[height] duration-200 ease-out`}`,style:{height:St?Ut:bt},children:[St?null:(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整底部面板高度`,className:`h-1 shrink-0 cursor-row-resize touch-none bg-stone-100 transition-colors hover:bg-[#4176e6]/40`,onPointerDown:e=>{Dt.current={startY:e.clientY,startHeight:bt},Et(!0),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=Dt.current;if(!t)return;let n=Math.max(Vt,Math.round(window.innerHeight*.65));xt(Math.min(n,Math.max(Ut,t.startHeight+(t.startY-e.clientY))))},onPointerUp:e=>{let t=Dt.current;if(!t)return;Dt.current=null,Et(!1),e.currentTarget.releasePointerCapture(e.pointerId);let n=Math.max(Vt,Math.round(window.innerHeight*.65)),r=Math.min(n,Math.max(Ut,t.startHeight+(t.startY-e.clientY)));r<=Wt?(xt(Math.max(Vt,t.startHeight)),Ct(!0),i(Bt,`closed`)):(xt(r),i(Bt,String(r)))},onPointerCancel:()=>{Dt.current=null,Et(!1)}}),(0,I.jsxs)(`div`,{className:`relative flex h-9 shrink-0 items-center gap-1 border-b border-stone-100 px-2`,children:[rn.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-[11px] transition-colors ${U===e.value?`bg-[#f2f6ff] text-[#3370ff]`:`text-stone-500 hover:bg-stone-50`}`,onClick:()=>tr(e.value),children:e.label},e.value)),(0,I.jsx)(`span`,{className:`ml-2 min-w-0 truncate text-[10px] text-stone-400`,children:Fr}),(0,I.jsx)(`button`,{type:`button`,"aria-label":St?`展开底部面板`:`收起底部面板`,"aria-expanded":!St,className:`group absolute left-1/2 top-1/2 flex h-6 w-20 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 focus-visible:outline-none`,onClick:nr,children:(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 transition-transform duration-200 ${St?`rotate-180`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`m6 9 6 6 6-6`})})})]}),St?null:(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[U===`console`?(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:Ot.length?(0,I.jsx)(`ul`,{className:`space-y-1 font-mono text-[11px]`,children:Ot.slice(-80).map((e,t)=>(0,I.jsxs)(`li`,{className:e.type===`error`?`text-red-600`:`text-stone-600`,children:[(0,I.jsxs)(`span`,{className:`mr-1 text-stone-400`,children:[`[`,e.type,`]`]}),e.text]},t))}):(0,I.jsx)(`p`,{className:`py-6 text-center text-xs text-stone-400`,children:`暂无控制台错误 / 警告`})}):null,U===`network`?(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:Pt.length?(0,I.jsx)(`ul`,{className:`space-y-1 font-mono text-[11px]`,children:Pt.slice(-80).map((e,t)=>(0,I.jsxs)(`li`,{className:`text-stone-600`,children:[(0,I.jsx)(`span`,{className:`mr-1 text-red-500`,children:e.status}),(0,I.jsx)(`span`,{className:`mr-1 text-stone-400`,children:e.method}),(0,I.jsx)(`span`,{className:`break-all`,children:e.url})]},t))}):(0,I.jsx)(`p`,{className:`py-6 text-center text-xs text-stone-400`,children:`暂无失败请求`})}):null,U===`run`?(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-stone-100 px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-stone-500`,children:`最近一次试跑`}),(0,I.jsx)(`span`,{className:`text-[11px] font-medium ${B?B.passed?`text-emerald-600`:`text-red-600`:`text-stone-400`}`,children:B?B.passed?`通过`:`失败(exit ${B.exitCode??`?`})`:`未试跑`}),(0,I.jsxs)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:[`耗时 `,Math.round((B?.durationMs??0)/100)/10,`s`,B?.timedOut?` · 超时`:``]}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,className:jt,onClick:()=>void wr(),disabled:Q||!Rr,children:y===`verifying`?`试跑中…`:B?`重新试跑`:`试跑`}),(0,I.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Tr(`headed`),disabled:Mn||!Rr,children:`调试运行`}),(0,I.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Tr(`ui`),disabled:Mn||!Rr||d===`python`,children:`Playwright UI`}),Pn?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`a`,{className:Lt,href:Pn,target:`_blank`,rel:`noreferrer`,children:[`打开 `,Pn]}),(0,I.jsx)(`button`,{type:`button`,className:Lt,onClick:()=>void Er(),children:`结束 UI`})]}):null]})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all bg-stone-50/40 px-3 py-2 font-mono text-[11px] leading-relaxed text-stone-700`,children:B?.log||(B?`试跑没有输出`:`试跑后这里显示日志;失败时草稿与 trace 会保留,方便回看现场。`)}),(0,I.jsxs)(`div`,{className:`w-64 shrink-0 space-y-2 overflow-auto border-l border-stone-100 p-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[11px] text-stone-500`,children:`草稿工作区`}),(0,I.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] leading-4 text-stone-500`,children:K?.draftRoot||`还没有草稿,试跑后生成`}),(0,I.jsx)(`p`,{className:`break-all font-mono text-[10px] leading-4 text-stone-400`,children:Lr?`用例:${Lr}`:``}),(0,I.jsx)(`p`,{className:`break-all font-mono text-[10px] leading-4 text-stone-400`,children:Ir?`trace:${Ir}`:``}),(0,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:Lt,onClick:()=>void Or(Lr||K?.draftDir||``),disabled:!Lr&&!K?.draftDir,children:`打开草稿`}),(0,I.jsx)(`button`,{type:`button`,className:Lt,onClick:()=>void Or(K?.draftRoot??``),disabled:!K?.exists,children:`打开目录`}),(0,I.jsx)(`button`,{type:`button`,className:Lt,onClick:()=>void Or(Ir),disabled:!Ir,children:`打开 trace`}),(0,I.jsx)(`button`,{type:`button`,className:`${Lt} text-stone-400`,onClick:()=>void kr(),disabled:Mn||!K?.exists,children:`清理草稿`})]})]}),(0,I.jsxs)(`details`,{className:`rounded-lg border border-stone-200 px-2 py-1.5`,open:Ee,onToggle:e=>De(e.currentTarget.open),children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:`写入后验收`}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`用项目自己的配置跑正式文件`}),(0,I.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Cr(),disabled:Rn||!(S?.savedPath||$.find(e=>e.role===`spec`)?.path),children:Rn?`验收中…`:`开始验收`})]}),In?(0,I.jsxs)(`div`,{className:`mt-1.5`,children:[(0,I.jsx)(`p`,{className:`text-[11px] font-medium ${In.passed?`text-emerald-600`:`text-red-600`}`,children:In.ok?In.passed?`验收通过`:In.excluded?`没被项目配置识别为用例`:`失败(exit ${In.exitCode??`?`})`:In.error??`失败`}),In.note?(0,I.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-4 text-amber-600`,children:In.note}):null,In.log?(0,I.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-stone-50 p-2 font-mono text-[10px] leading-4 text-stone-600`,children:In.log}):null]}):null]}),q?(0,I.jsxs)(`div`,{className:`rounded-lg border border-stone-200 px-2 py-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-stone-500`,children:q.mode===`ui`?`Playwright UI`:`调试运行`}),(0,I.jsx)(`span`,{className:`text-[11px] ${q.ok&&q.passed!==!1?`text-emerald-600`:`text-red-600`}`,children:q.ok?q.mode===`ui`?q.ready?`已启动`:`启动较慢`:q.passed?`通过`:`失败(exit ${q.exitCode??`?`})`:q.error??`失败`})]}),q.url?(0,I.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] text-stone-500`,children:q.url}):null,q.log?(0,I.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-stone-50 p-2 font-mono text-[10px] leading-4 text-stone-600`,children:q.log}):null]}):null]})]})]}):null]})]})]})]})}function xn({rows:e=3}){return(0,I.jsx)(`div`,{className:`space-y-2 p-3`,"aria-hidden":`true`,children:Array.from({length:e}).map((e,t)=>(0,I.jsx)(`div`,{className:`h-3 animate-pulse rounded bg-stone-100`,style:{width:`${Math.max(40,92-t*14)}%`}},t))})}function Sn(){return(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1.5`,"aria-hidden":`true`,children:[0,1,2].map(e=>(0,I.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-stone-50`},e))})}function Cn(){return(0,I.jsxs)(`svg`,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,stroke:`currentColor`,strokeWidth:`2`,opacity:`0.25`}),(0,I.jsx)(`path`,{d:`M14 8a6 6 0 0 0-6-6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}function wn({name:e}){let t={width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`};return e===`play`?(0,I.jsx)(`svg`,{...t,fill:`currentColor`,stroke:`none`,children:(0,I.jsx)(`path`,{d:`M8 5.5v13l11-6.5Z`})}):e===`code`?(0,I.jsxs)(`svg`,{...t,children:[(0,I.jsx)(`path`,{d:`m9 8-4 4 4 4`}),(0,I.jsx)(`path`,{d:`m15 8 4 4-4 4`})]}):(0,I.jsxs)(`svg`,{...t,children:[(0,I.jsx)(`path`,{d:`M4 7h10`}),(0,I.jsx)(`path`,{d:`M4 12h7`}),(0,I.jsx)(`path`,{d:`M4 17h10`}),(0,I.jsx)(`path`,{d:`M17 12h3`}),(0,I.jsx)(`path`,{d:`m18 10 2 2-2 2`})]})}function Tn(e){if(e.kind===`full`)return`全量运行`;let t=e.display?.trim()??``;return!t||t===e.command?e.label||e.command:`${t}(${e.command})`}var En=[{value:`run`,label:`运行`},{value:`generate`,label:`生成`},{value:`history`,label:`历史`}],Dn=`ui-auto.project`,K=`ui-auto.tab`,On=`ui-auto.task`,kn=e=>`ui-auto.log-scroll.${e}`,An=e=>`${On}.${e}`,q=1e3,jn=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,Mn=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`,Nn=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-red-200 px-3 text-sm text-red-600 transition-colors hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40`;function Pn(){let{ready:e,on:t}=_(`uiAuto`),[n,s]=(0,w.useState)([]),[c,l]=(0,w.useState)([]),[u,p]=(0,w.useState)(()=>a(Dn)),[ie,se]=(0,w.useState)(!0),[ce,le]=(0,w.useState)(!0),[de,h]=(0,w.useState)(``),[pe,ke]=(0,w.useState)(()=>a(K)===`history`?`history`:a(K)===`generate`?`generate`:`run`),[Ne,T]=(0,w.useState)(()=>a(On)||`full`),[Pe,Fe]=(0,w.useState)(!1),[Ie,E]=(0,w.useState)(``),[D,Le]=(0,w.useState)([]),[Re,ze]=(0,w.useState)(!1),[Be,Ve]=(0,w.useState)(!1),[O,He]=(0,w.useState)([]),[k,Ue]=(0,w.useState)(null),[We,A]=(0,w.useState)(``),[Ge,Ke]=(0,w.useState)(!1),[qe,j]=(0,w.useState)(!1),M=(0,w.useRef)(0),Ye=(0,w.useRef)(null),Xe=(0,w.useRef)(!0),N=(0,w.useRef)(null),Ze=(0,w.useRef)(0),[Qe,$e]=(0,w.useState)(!1),[et,tt]=(0,w.useState)(``),[P,nt]=(0,w.useState)(null),[rt,it]=(0,w.useState)(``),[F,at]=(0,w.useState)(!1),[ot,st]=(0,w.useState)(null),[ct,lt]=(0,w.useState)(null),[ut,dt]=(0,w.useState)(!1),[ft,mt]=(0,w.useState)(()=>Date.now()),L=(0,w.useMemo)(()=>n.find(e=>e.id===u)??null,[n,u]),ht=(0,w.useMemo)(()=>{let e=L?.promptFile??``;return e&&D.some(t=>t.value===e)?e:g},[L?.promptFile,D]),gt=(0,w.useMemo)(()=>{if(!L||!Re||!D.length)return!1;let e=(L.promptFile??``).trim();return!e||!D.some(t=>t.value===e)},[L,Re,D]);(0,w.useEffect)(()=>{gt&&Ve(!0)},[gt]);let R=(0,w.useMemo)(()=>n.map(e=>({value:e.id,label:e.name,secondary:e.dir.replace(/^\/Users\/[^/]+/,`~`)})),[n]),_t=(0,w.useCallback)(e=>{ke(e),i(K,e)},[]),B=(0,w.useCallback)(async()=>{let e=async t=>{let{entries:n}=await ae(`prompts`,t),r=t===`.`?``:`${t}/`,i=n.filter(e=>e.type===`file`&&/\.md$/i.test(e.name)).map(e=>`${r}${e.name}`),a=await Promise.all(n.filter(e=>e.type===`dir`).map(t=>e(`${r}${t.name}`)));return[...i,...a.flat()]},t=(await e(`.`)).filter(e=>{let t=oe(e);return!t||t===`uiAuto`}).sort().map(e=>({value:e,label:e}));return Le(t),t},[]);(0,w.useEffect)(()=>{if(!t)return;B().catch(()=>void 0).finally(()=>ze(!0));let e=()=>{document.visibilityState===`visible`&&B().catch(()=>void 0)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t,B]);let V=(0,w.useCallback)(async()=>{let e=await Se();return s(e.projects),e.frameworks.length&&l(e.frameworks),e.projects},[]),H=(0,w.useCallback)(async e=>{let t=await S(e);return He(t),t},[]),vt=(0,w.useRef)(``);vt.current=k?.id??``;let U=(0,w.useCallback)(()=>{let e=Ye.current,t=vt.current;if(!e||!t)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight<40;r(kn(t),{top:e.scrollTop,stick:n})},[]),W=(0,w.useCallback)(async e=>{U();let t=await De(e,0);Ue(t.run),A(t.log),Ke(t.stopping),M.current=t.nextOffset;let n=o(kn(e),null),r=n&&typeof n.top==`number`&&!n.stick?n:null;N.current=r,Xe.current=!r},[U]);(0,w.useEffect)(()=>{if(!t)return;let e=!0;return fe(!0).catch(()=>void 0),se(!0),V().catch(t=>{e&&h(t instanceof Error?t.message:String(t))}).finally(()=>{e&&se(!1)}),()=>{e=!1}},[t,V]),(0,w.useEffect)(()=>{if(!n.length||n.some(e=>e.id===u))return;let e=n[0].id;p(e),i(Dn,e)},[n,u]),(0,w.useEffect)(()=>{if(!t||!u){He([]),Ue(null),A(``),t&&le(!1);return}let e=!0;return He([]),Ue(null),A(``),Ke(!1),M.current=0,N.current=null,T(a(An(u))||`full`),H(u).then(t=>{if(!e)return;let n=t.find(e=>e.status===`running`)??t[0];n&&W(n.id).catch(()=>void 0)}).catch(t=>{e&&h(t instanceof Error?t.message:String(t))}).finally(()=>{e&&le(!1)}),()=>{e=!1}},[t,u,H,W]);let yt=(0,w.useCallback)(async()=>{await V().catch(()=>null),u&&await H(u).catch(()=>null)},[V,H,u]),G=(0,w.useMemo)(()=>L?.runTasks??[],[L?.runTasks]),bt=(0,w.useMemo)(()=>G.find(e=>e.id===Ne)??G[0]??null,[G,Ne]),xt=(0,w.useMemo)(()=>[...G.length?G.map(e=>({value:e.id,label:Tn(e)})):[{value:`full`,label:`全量运行`}]],[G]),Ct=k?.status??``,wt=k?.id??``,Tt=k?.status===`running`;(0,w.useEffect)(()=>{if(!wt||!Tt)return;let e=!0,t=async()=>{try{let t=await De(wt,M.current);if(!e)return;t.reset?A(t.log):t.log&&A(e=>e+t.log),M.current=t.nextOffset,Ke(t.stopping),Ue(t.run),Oe(t.run.status)&&yt()}catch{}},n=window.setInterval(()=>void t(),q);return()=>{e=!1,window.clearInterval(n)}},[wt,Tt,yt]),(0,w.useEffect)(()=>{if(!Tt)return;let e=window.setInterval(()=>mt(Date.now()),1e3);return()=>window.clearInterval(e)},[Tt]),(0,w.useEffect)(()=>{if(Tt)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&(V().catch(()=>null),u&&H(u).catch(()=>null))},15e3);return()=>window.clearInterval(e)},[Tt,u,V,H]),(0,w.useEffect)(()=>{let e=Ye.current;if(!e)return;let t=N.current;t?(N.current=null,e.scrollTop=t.top):Xe.current&&(e.scrollTop=e.scrollHeight)},[We]),(0,w.useEffect)(()=>{let e=()=>U(),t=()=>{document.visibilityState===`hidden`&&U()};return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),window.clearTimeout(Ze.current)}},[U]);let Et=()=>{let e=Ye.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<40;Xe.current=t,window.clearTimeout(Ze.current),Ze.current=window.setTimeout(()=>U(),200)},Dt=(0,w.useCallback)(async(e={})=>{if(u){h(``),j(!0);try{let t=await Me(u,{taskId:bt?.id??`full`,...e});Ue(t),A(``),Ke(!1),M.current=0,N.current=null,Xe.current=!0,_t(`run`),await H(u).catch(()=>null),await V().catch(()=>null)}catch(e){h(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[u,bt,H,V,_t]),Ot=(e=null)=>{h(``),it(``),nt(e),tt(e?.dir??``),$e(!0)},kt=()=>{F||$e(!1)},At=(0,w.useCallback)(e=>{L&&Je({projectId:L.id,path:e.path,app:e.app}).catch(e=>h(e instanceof Error?e.message:String(e)))},[L]),jt=async()=>{at(!0),it(``);try{let e=await ye();e&&tt(e)}catch(e){it(`${e instanceof Error?e.message:String(e)}(可在下方直接填写目录路径)`)}finally{at(!1)}},Mt=async e=>{if(L){E(``);try{let t=await ve({id:L.id,customTasks:e.customTasks?.map(({id:e,name:t,command:n})=>({id:e,name:t,command:n})),taskOverrides:e.taskOverrides,hiddenTasks:e.hiddenTasks});s(e=>e.map(e=>e.id===t.id?t:e)),(t.runTasks??[]).some(e=>e.id===Ne)||(T(`full`),i(An(t.id),`full`))}catch(e){E(e instanceof Error?e.message:String(e))}}},Nt=e=>Mt({customTasks:e}),Pt=(0,w.useCallback)(async e=>{if(!L)return;let t=L.id;s(n=>n.map(n=>n.id===t?{...n,promptFile:e}:n));try{let n=await ve({id:t,promptFile:e});s(e=>e.map(e=>e.id===n.id?n:e)),Ve(!1),Te(),ue(e?`已挂载「${e}」`:`已取消挂载`,`success`)}catch(e){throw await V().catch(()=>void 0),e}},[L,V]),Ft=async(e,t,n)=>{if(!L)return;let r=(L.taskOverrides??[]).filter(t=>t.id!==e),i={id:e,name:t.trim(),command:n.trim()};(i.name||i.command)&&r.push(i),await Mt({taskOverrides:r})},It=async e=>{L&&await Mt({taskOverrides:(L.taskOverrides??[]).filter(t=>t.id!==e),hiddenTasks:[...new Set([...L.hiddenTasks??[],e])]})},Lt=async()=>{await Mt({taskOverrides:[],hiddenTasks:[]})},Rt=async(e,t)=>{if(!L)return;let n=t.trim();n?await Nt([...L.customTasks??[],{id:``,name:e,command:n}]):E(`先填要执行的命令`)},zt=async e=>{L&&await Nt((L.customTasks??[]).filter(t=>t.id!==e))},Bt=async()=>{let e=et.trim();if(!e)it(`请先选择或填写项目目录`);else{j(!0),it(``);try{let t;t=P?(await ve({id:P.id,dir:e})).id:(await Ae(e)).id,await V(),p(t),i(Dn,t),_t(`run`),$e(!1),nt(null),tt(``)}catch(t){let r=t instanceof Error?t.message:String(t),a=n.find(t=>t.dir===e);if(a&&/已经添加/.test(r)){p(a.id),i(Dn,a.id),_t(`run`),$e(!1),tt(``);return}it(r)}finally{j(!1)}}},Vt=async()=>{if(k){h(``);try{await xe(k.id),Ke(!0)}catch(e){h(e instanceof Error?e.message:String(e))}}},Ht=()=>{bt?.failureFlags?Dt({lastFailed:!0}):h(`当前运行任务不支持只跑失败用例,切到「全量运行」或 pytest 任务再试`)},Ut=async()=>{if(ct){h(``);try{await Ee(ct.id),k?.id===ct.id&&(Ue(null),A(``)),u&&await H(u),await V().catch(()=>null)}catch(e){h(e instanceof Error?e.message:String(e))}finally{lt(null)}}};if(!e||ce)return(0,I.jsx)(`div`,{className:`tw-hydrate-pending h-full w-full`,children:(0,I.jsx)(ge,{label:`加载自动化测试…`})});if(!t)return(0,I.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:`该插件未启用,到「我的插件」里打开「自动化测试」就能挂载 Playwright / pytest / Selenium 项目。`});let Wt=(0,I.jsxs)(`div`,{className:`border-b border-stone-100 bg-stone-50/60 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:P?`重新指定项目目录`:`挂载项目`}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`自动识别 Playwright / pytest / Selenium,只读取与运行,不改项目文件`})]}),(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`input`,{className:`h-8 min-w-[260px] flex-1 rounded-lg border border-stone-200 bg-white px-2.5 font-mono text-xs text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,value:et,onChange:e=>tt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Bt()},placeholder:`/path/to/your-test-project`,"aria-label":`项目目录`,spellCheck:!1}),(0,I.jsxs)(`button`,{type:`button`,className:Mn,onClick:()=>void jt(),disabled:F,children:[(0,I.jsx)(_e,{name:`folder`,size:13}),F?`选择中…`:`浏览…`]}),(0,I.jsx)(`button`,{type:`button`,className:jn,onClick:()=>void Bt(),disabled:qe||F||!et.trim(),children:qe?`挂载中…`:P?`保存目录`:`挂载`})]}),rt?(0,I.jsx)(`p`,{className:`mt-2 rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed text-red-600`,children:rt}):null]}),Gt=k?Tt?Math.max(0,ft-Date.parse(k.startedAt)):k.durationMs:0,Kt=Qe||!n.length;return(0,I.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-white`,children:[de?(0,I.jsx)(he,{message:de,onClose:()=>h(``)}):null,(0,I.jsxs)(`header`,{className:`relative z-20 flex h-12 shrink-0 items-center gap-3 border-b border-stone-200 px-4`,children:[(0,I.jsx)(`h1`,{className:`shrink-0 text-sm font-semibold text-stone-800`,children:`自动化测试`}),(0,I.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),L?(0,I.jsx)(`div`,{role:`tablist`,"aria-label":`自动化测试视图`,className:`flex h-full shrink-0 items-stretch`,children:En.map(e=>{let t=e.value===`history`?O.length:0,n=pe===e.value;return(0,I.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>_t(e.value),className:`relative flex h-full items-center gap-1.5 border-b-2 px-2.5 text-[13px] transition-colors ${n?`border-[#3370ff] font-medium text-stone-900`:`border-transparent text-stone-500 hover:text-stone-800`}`,children:[e.label,t?(0,I.jsx)(`span`,{className:`rounded-full px-1.5 text-[11px] leading-4 tabular-nums ${n?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:t}):null]},e.value)})}):(0,I.jsx)(`span`,{className:`truncate text-[11px] text-stone-400`,children:ie?`正在读取挂载列表…`:`还没有挂载项目`}),(0,I.jsxs)(`div`,{className:`ml-auto flex min-w-0 shrink-0 items-center gap-2`,children:[L?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-8 w-40 min-w-0 items-center rounded-lg border border-stone-200 bg-white px-2.5 text-left transition-colors hover:border-stone-300 focus:border-[#4176e6] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#4176e6]/30`,onClick:()=>Ve(!0),"aria-label":`挂载提示词`,children:(0,I.jsx)(m,{text:ht,className:`min-w-0 flex-1 truncate text-sm text-stone-700`})}),(0,I.jsx)(re,{options:R,value:L.id,onChange:e=>{p(e),i(Dn,e)},compact:!0,className:`w-48`,ariaLabel:`切换项目`,triggerClassName:L.exists?``:`text-amber-700`,hideTriggerHint:!0,renderOptionAction:e=>{let t=n.find(t=>t.id===e.value);return t?(0,I.jsx)(`button`,{type:`button`,disabled:qe,"aria-label":`移出 ${t.name}`,className:`rounded p-1 text-stone-400 opacity-0 transition-opacity hover:bg-red-50 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>st(t),children:(0,I.jsx)(_e,{name:`trash`,size:13})}):null}}),L.frameworkReady?(0,I.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11px] text-stone-500`,children:[c.find(e=>e.id===L.framework)?.label||L.framework,L.kind?b(L.kind):``].filter(Boolean).join(` · `)}):(0,I.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11px] text-amber-600`,children:`运行环境未就绪`}),(0,I.jsx)(pt,{onOpen:e=>At({path:``,app:e?.id}),disabled:!L.exists})]}):null,(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`${Mn} ${Qe?`border-[#4176e6] bg-[#f2f6ff] text-[#3566d0] hover:bg-[#eaf1ff]`:``}`,onClick:()=>Qe?kt():Ot(null),disabled:qe||F,"aria-expanded":Qe,children:[(0,I.jsx)(_e,{name:`plus`,size:13}),`挂载`]}),L?(0,I.jsxs)(te,{as:`div`,className:`relative shrink-0`,children:[(0,I.jsx)(f,{type:`button`,className:`flex h-8 w-8 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-700`,"aria-label":`更多操作`,children:(0,I.jsx)(_e,{name:`more`,size:16})}),(0,I.jsxs)(ee,{anchor:{to:`bottom end`,gap:4,padding:12},transition:!0,className:`tw-select-menu tw-menu-anim z-80 w-max min-w-[168px] space-y-0.5 rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[(0,I.jsx)(d,{children:(0,I.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-stone-700 data-[focus]:bg-stone-50`,onClick:()=>{(navigator.clipboard?.writeText(L.dir))?.then(()=>dt(!0)).catch(()=>void 0),window.setTimeout(()=>dt(!1),1200)},children:ut?`已复制路径`:`复制项目路径`})}),(0,I.jsx)(d,{children:(0,I.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-stone-700 data-[focus]:bg-stone-50`,onClick:()=>Ot(L),children:`重新指定目录`})}),(0,I.jsx)(`div`,{className:`my-1 h-px bg-stone-100`,"aria-hidden":`true`}),(0,I.jsx)(d,{children:(0,I.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-red-600 data-[focus]:bg-red-50`,onClick:()=>st(L),children:`移出项目`})})]})]}):null]})]})]}),!L&&!ie?(0,I.jsx)(`p`,{className:`shrink-0 border-b border-stone-100 bg-stone-50/60 px-4 py-1.5 text-[11px] text-stone-500`,children:`还没有挂载项目。点右上角「挂载」选一个 Playwright / pytest / Selenium 目录,自动识别框架。`}):null,(0,I.jsx)(`div`,{className:`grid shrink-0 transition-[grid-template-rows,opacity] duration-200 ease-out ${Kt?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`}`,"aria-hidden":!Kt,children:(0,I.jsx)(`div`,{className:`overflow-hidden`,inert:!Kt,children:Wt})}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:(0,I.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:L?(0,I.jsxs)(I.Fragment,{children:[pe===`run`?(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs text-stone-400`,children:`运行任务`}),(0,I.jsx)(re,{options:xt,value:bt?.id??`full`,onChange:e=>{T(e),L&&i(An(L.id),e)},compact:!0,className:`w-60`,ariaLabel:`运行任务`}),(0,I.jsxs)(`button`,{type:`button`,className:Mn,onClick:()=>{E(``),Fe(!0)},disabled:qe,"aria-label":`运行配置`,children:[(0,I.jsxs)(`svg`,{className:`h-3.5 w-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M4 7h10M18 7h2M4 17h4M12 17h8`}),(0,I.jsx)(`circle`,{cx:`16`,cy:`7`,r:`2`}),(0,I.jsx)(`circle`,{cx:`10`,cy:`17`,r:`2`})]}),`配置`]}),(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:Tt?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`${jn} cursor-default`,disabled:!0,children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-white/90`}),`运行中…`]}),(0,I.jsx)(`button`,{type:`button`,className:Nn,onClick:()=>void Vt(),disabled:Ge,children:Ge?`停止中…`:`停止`})]}):(0,I.jsxs)(`button`,{type:`button`,className:jn,onClick:()=>void Dt(),disabled:qe||!L.exists,children:[(0,I.jsx)(_e,{name:`play`,size:14}),qe?`启动中…`:Ct?`重新运行`:`运行`]})})]}),L.exists?L.frameworkReady?null:(0,I.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:L.readyHint||`运行环境未就绪,先按项目要求安装依赖后再运行。`}):(0,I.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:[`项目目录已不存在(换机器或被移动过),记录与历史报告不会丢。`,(0,I.jsx)(`button`,{type:`button`,className:`font-medium text-amber-800 underline underline-offset-2 hover:text-amber-900`,onClick:()=>Ot(L),children:`重新指定目录`})]}),k?(0,I.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-600`,children:[(0,I.jsx)(me,{tone:x[k.status].tone,children:x[k.status].label}),(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`耗时 `,we(Gt)]}),k.status===`running`?null:(0,I.jsx)(`span`,{className:`tabular-nums`,children:C(k)}),(0,I.jsx)(`span`,{className:k.command?`max-w-[360px] truncate font-mono text-[11px] text-stone-400`:`text-stone-400`,children:k.command?y(k.command):be(k.args,k.framework)}),k.reportRel?(0,I.jsxs)(`span`,{className:`max-w-[320px] truncate font-mono text-[11px] text-stone-400`,children:[`存储:`,k.reportRel.replace(/\/[^/]+$/,``)]}):null,(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k.reportUrl&&k.status!==`running`?(0,I.jsx)(`a`,{className:Mn,href:k.reportUrl,target:`_blank`,rel:`noreferrer`,children:`查看报告`}):null,k.failed>0&&k.status!==`running`?(0,I.jsx)(`button`,{type:`button`,className:Mn,onClick:Ht,disabled:qe||!L.exists,children:`重跑失败用例`}):null]})]}),k.error?(0,I.jsx)(`pre`,{className:`mt-2 max-h-24 overflow-auto whitespace-pre-wrap break-all rounded bg-red-50 px-2 py-1.5 text-[11px] leading-relaxed text-red-600`,children:k.error}):null]}):null,(0,I.jsxs)(`div`,{className:`flex min-h-[220px] flex-1 flex-col overflow-hidden rounded-lg border border-stone-200`,children:[(0,I.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-stone-100 bg-stone-50 px-3 text-xs text-stone-500`,children:[(0,I.jsx)(`span`,{children:`运行日志`}),Tt?(0,I.jsx)(`span`,{className:`text-[#3370ff]`,children:`实时`}):null,We?(0,I.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[We.length,` 字符`]}):null]}),(0,I.jsx)(`pre`,{ref:Ye,onScroll:Et,className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all bg-white p-3 font-mono text-[12px] leading-relaxed text-stone-700`,children:We||`运行后这里会显示实时输出…`})]})]}):null,pe===`generate`?(0,I.jsx)(bn,{project:L,promptFile:ht,onError:h},L.id):null,pe===`history`?(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:O.length===0?(0,I.jsx)(v,{children:`还没有运行记录`}):(0,I.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b border-stone-200 text-left text-xs text-stone-400`,children:[(0,I.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`开始时间`}),(0,I.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`框架`}),(0,I.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`结果`}),(0,I.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`用例`}),(0,I.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`耗时`}),(0,I.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`参数`}),(0,I.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`操作`})]})}),(0,I.jsx)(`tbody`,{children:O.map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-0`,children:[(0,I.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-600`,children:Ce(e.startedAt)}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-500`,children:c.find(t=>t.id===e.framework)?.label??e.framework}),(0,I.jsx)(`td`,{className:`px-2 py-2`,children:(0,I.jsx)(me,{tone:x[e.status].tone,children:x[e.status].label})}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:e.total?`${e.passed}/${e.total} 通过${e.failed?` · ${e.failed} 失败`:``}`:`—`}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:we(e.durationMs)}),(0,I.jsx)(`td`,{className:`max-w-[240px] truncate px-2 py-2 text-xs text-stone-500`,children:e.command?y(e.command):be(e.args,e.framework)}),(0,I.jsxs)(`td`,{className:`whitespace-nowrap px-2 py-2 text-right`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-xs text-[#3370ff] hover:underline`,onClick:()=>{_t(`run`),W(e.id).catch(e=>h(String(e)))},children:`日志`}),e.reportUrl?(0,I.jsx)(`a`,{className:`ml-3 text-xs text-[#3370ff] hover:underline`,href:e.reportUrl,target:`_blank`,rel:`noreferrer`,children:`报告`}):null,(0,I.jsx)(`button`,{type:`button`,className:`ml-3 text-xs text-red-500 hover:underline`,onClick:()=>lt(e),children:`删除`})]})]},e.id))})]})}):null]}):(0,I.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-1 px-6 py-10 text-center`,children:[(0,I.jsx)(`p`,{className:`text-sm text-stone-500`,children:`挂载一个项目后就能在这里运行用例`}),(0,I.jsx)(`p`,{className:`text-xs text-stone-400`,children:`移出项目只删除挂载记录,项目文件与历史报告都保留`})]})})}),(0,I.jsx)(z,{open:Be,prompts:D.map(e=>e.value),value:L?.promptFile&&D.some(e=>e.value===L.promptFile)?L.promptFile:``,force:gt,onClose:()=>Ve(!1),onMount:Pt}),(0,I.jsx)(St,{open:Pe,projectName:L?.name??``,detected:G.filter(e=>!e.custom&&e.kind!==`full`),customTasks:L?.customTasks??[],hiddenCount:L?.hiddenTasks?.length??0,editedCount:(L?.taskOverrides??[]).length,error:Ie,onClose:()=>{Fe(!1),E(``)},onAdd:(e,t)=>Rt(e,t),onRemove:e=>zt(e),onEdit:(e,t,n)=>Ft(e,t,n),onHide:e=>It(e),onReset:()=>Lt(),onRescan:()=>V().then(()=>void 0)}),(0,I.jsx)(ne,{open:!!ot,title:`移出项目`,message:`确定把「${ot?.name??``}」移出挂载列表吗?\n只删除挂载记录,项目文件与历史报告都保留;该项目挂载的提示词也会自动取消引用。`,confirmLabel:`移出`,danger:`outline`,onClose:()=>st(null),onConfirm:()=>{let e=ot;st(null),e&&je(e.id).then(async()=>{let t=await V();if(e.id===u){let e=t[0]?.id??``;p(e),i(Dn,e)}Te()}).catch(e=>h(e instanceof Error?e.message:String(e)))}}),(0,I.jsx)(ne,{open:!!ct,title:`删除运行记录`,message:`会同时删除该次运行的 HTML 报告与原始日志,确定删除吗?`,confirmLabel:`删除`,danger:`solid`,onClose:()=>lt(null),onConfirm:()=>void Ut()})]})}export{Pn as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{G as n,b as r,dt as i,ft as a}from"./portal.C0hAhXDF.js";var o=e(t(),1);function s(e,t,n,r){let i=a(n);(0,o.useEffect)(()=>{e??=window;function n(e){i.current(e)}return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)},[e,t,r])}function c(e,t){let n=(0,o.useRef)([]),r=i(e);(0,o.useEffect)(()=>{let e=[...n.current];for(let[i,a]of t.entries())if(n.current[i]!==a){let i=r(t,e);return n.current=t,i}},[r,...t])}function l(e){function t(){document.readyState!==`loading`&&(e(),document.removeEventListener(`DOMContentLoaded`,t))}typeof window<`u`&&typeof document<`u`&&(document.addEventListener(`DOMContentLoaded`,t),t())}var u=[];l(()=>{function e(e){if(!n(e.target)||e.target===document.body||u[0]===e.target)return;let t=e.target;t=t.closest(r),u.unshift(t??e.target),u=u.filter(e=>e!=null&&e.isConnected),u.splice(10)}window.addEventListener(`click`,e,{capture:!0}),window.addEventListener(`mousedown`,e,{capture:!0}),window.addEventListener(`focus`,e,{capture:!0}),document.body.addEventListener(`click`,e,{capture:!0}),document.body.addEventListener(`mousedown`,e,{capture:!0}),document.body.addEventListener(`focus`,e,{capture:!0})});export{c as n,s as r,u as t};
@@ -0,0 +1 @@
1
+ var e=[{id:`functional`,label:`功能测试`,casesFolder:`功能测试`,templateFolder:`功能测试用例`},{id:`api`,label:`接口测试`,casesFolder:`接口测试`,templateFolder:`接口测试用例`},{id:`performance`,label:`性能测试`,casesFolder:`性能测试`,templateFolder:`性能测试用例`},{id:`automation`,label:`自动化测试`,casesFolder:`自动化测试`,templateFolder:`自动化测试用例`}];function t(){return`ct_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function n(e){let t=e.trim()||`未命名类型`;return{casesFolder:t,templateFolder:`${t}用例`}}function r(e){if(!e||typeof e!=`object`)return null;let r=e,i=String(r.label??``).trim();if(!i)return null;let a=String(r.id??``).trim()||t(),o=n(i);return{id:a,label:i,casesFolder:typeof r.casesFolder==`string`&&r.casesFolder.trim()?r.casesFolder.trim():o.casesFolder,templateFolder:typeof r.templateFolder==`string`&&r.templateFolder.trim()?r.templateFolder.trim():o.templateFolder}}function i(t){if(!Array.isArray(t))return e.map(e=>({...e}));let n=[],i=new Set;for(let e of t){let t=r(e);t&&!i.has(t.id)&&(i.add(t.id),n.push(t))}return n.length?n:e.map(e=>({...e}))}function a(){return t()}var o=[`测试规范`,`方法论`,`环境约定`];function s(e){if(!Array.isArray(e))return[...o];let t=[],n=new Set;for(let r of e){let e=String(r??``).trim();!e||e.length>40||n.has(e)||(n.add(e),t.push(e))}return t.length?t:[...o]}var c=[{id:`case`,label:`用例生成提示词`,hint:`用于编写「用例生成」提示词:指导模型按需求与模板输出可入库用例;须约束 JSON 结构、字段对齐模板、步骤换行与覆盖策略,不要限定固定用例条数。`},{id:`general`,label:`通用提示词`,hint:`用于编写通用测试/工作台提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}];function l(){return`pk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function u(e){return`生成「${e.trim()||`自定义`}」类提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}function d(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.label??``).trim();if(!n)return null;let r=String(t.id??``).trim()||l(),i=typeof t.hint==`string`&&t.hint.trim()?t.hint.trim():u(n);return r===`case`&&i.includes(`「测试用例生成」`)&&(i=c[0].hint),{id:r,label:n,hint:i}}function f(e){if(!Array.isArray(e))return c.map(e=>({...e}));let t=[],n=new Set;for(let r of e){let e=d(r);e&&!n.has(e.id)&&(n.add(e.id),t.push(e))}return t.length?t:c.map(e=>({...e}))}function ee(){return l()}var p=[{id:`dashboard`,href:`dashboard/`,i18n:`nav.dashboard`,plugin:`dashboard`,match:`dashboard`},{id:`tasks`,href:`tasks/`,i18n:`nav.tasks`,plugin:`tasks`,match:`tasks`},{id:`todos`,href:`todos/`,i18n:`nav.todos`,plugin:`todos`,match:`todos`},{id:`projects`,href:`pm/projects/`,i18n:`nav.projects`,plugin:`projects`,match:`pm/projects`},{id:`iterations`,href:`pm/iterations/`,i18n:`nav.iterations`,plugin:`iterations`,match:`pm/iterations`},{id:`pmRequirements`,href:`pm/requirements/`,i18n:`nav.requirementsMgmt`,plugin:`pmRequirements`,match:`pm/requirements`},{id:`bugs`,href:`pm/bugs/`,i18n:`nav.bugs`,plugin:`bugs`,match:`pm/bugs`},{id:`reports`,href:`reports/`,i18n:`nav.reports`,plugin:`reports`,match:`reports`},{id:`testStats`,href:`test-stats/`,i18n:`nav.testStats`,plugin:`testStats`,match:`test-stats`},{id:`caseExec`,href:`case-exec/`,i18n:`nav.caseExec`,plugin:`caseExec`,match:`case-exec`},{id:`uiAuto`,href:`test-automation/`,i18n:`nav.uiAuto`,plugin:`uiAuto`,match:`test-automation`},{id:`cases`,href:`cases/library/`,i18n:`nav.caseManage`,plugin:`cases`,match:`cases`},{id:`prompts`,href:`prompts/`,i18n:`nav.prompts`,plugin:`prompts`,match:`prompts`},{id:`knowledgeLib`,href:`knowledge/`,i18n:`nav.knowledge`,plugin:`knowledgeLib`,match:`knowledge`},{id:`requirements`,href:`requirements/`,i18n:`nav.requirements`,plugin:`requirements`,match:`requirements`},{id:`templates`,href:`templates/`,i18n:`nav.templates`,plugin:`templates`,match:`templates`}],m=[],te=[`prompts`];function h(e){return te.includes(e)}var g=[`check`,`pencil`,`book`,`fileText`,`layers`,`list`,`folder`,`star`,`database`,`target`,`code`,`flask`,`home`,`clipboard`,`bug`,`calendar`,`chart`,`globe`,`link`,`users`,`terminal`,`tag`,`flag`,`zap`,`dashboard`],_={dashboard:`dashboard`,tasks:`clipboard`,todos:`list`,projects:`folder`,iterations:`calendar`,pmRequirements:`fileText`,bugs:`bug`,reports:`fileText`,testStats:`chart`,caseExec:`target`,uiAuto:`terminal`,cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`};function ne(e){return typeof e==`string`&&g.includes(e)}function v(e){let t={..._};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of p){let r=e[n.id];ne(r)&&(t[n.id]=r)}return t}var y=new Set(p.map(e=>e.id));function b(e){return typeof e==`string`&&y.has(e)}function re(e){return p.find(t=>t.id===e)}function ie(e,t=`/`){let n=t.replace(/\/$/,``),r=(n&&e.startsWith(n)?e.slice(n.length):e).replace(/^\/+/,``);return r?p.filter(e=>r===e.match||r.startsWith(`${e.match}/`)).sort((e,t)=>t.match.length-e.match.length)[0]??null:null}function x(e){return`item:${e}`}function S(e){return`group:${e}`}function C(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function w(){return m.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function T(e,t=!0){if(e==null||!Array.isArray(e))return t?w():[];let n=new Set,r=[],i=new Set;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,a=String(e.name??``).trim();if(!a)continue;let o=String(e.id??``).trim()||C();i.has(o)&&(o=C());let s=[];if(Array.isArray(e.items))for(let t of e.items)b(t)&&!n.has(t)&&(n.add(t),s.push(t));let c=String(e.parentId??``).trim()||void 0;i.add(o),r.push({id:o,name:a,items:s,parentId:c})}let a=new Set(r.map(e=>e.id)),o=r.map(e=>{let t=e.parentId;return(!t||t===e.id||!a.has(t))&&(t=void 0),t?{...e,parentId:t}:{id:e.id,name:e.name,items:e.items}}),s=new Map(o.map(e=>[e.id,e])),c=o.map(e=>{if(!e.parentId)return e;let t=s.get(e.parentId);if(t?.parentId){let n=t.parentId;return n&&n!==e.id&&a.has(n)?{...e,parentId:n}:{id:e.id,name:e.name,items:e.items}}return e}),l=new Set(c.map(e=>e.parentId).filter(e=>!!e));return c.filter(e=>e.items.length>0||l.has(e.id))}function E(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>b(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||C(),a=e.find(e=>e.id===i),o=t.parentId===void 0?a?.parentId:t.parentId.trim()||void 0;if(o===i&&(o=void 0),o){let t=e.find(e=>e.id===o);t?t.parentId&&(o=t.parentId):o=void 0}let s=new Set(r),c=e.filter(e=>e.id!==i).map(e=>({...e,items:e.items.filter(e=>!s.has(e))}));return c.push(o?{id:i,name:n,items:r,parentId:o}:{id:i,name:n,items:r}),{groups:T(c),id:i}}function ae(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function D(e,t){return e.filter(e=>e.parentId===t)}function oe(e,t){let n=e.find(e=>e.id===t);if(!n)return e;let r=e.filter(e=>e.id!==t);return n.parentId?r.map(e=>e.id===n.parentId?{...e,items:[...e.items,...n.items]}:e.parentId===t?{...e,parentId:n.parentId}:e):r.map(e=>e.parentId===t?{id:e.id,name:e.name,items:e.items}:e)}function se(e,t,n){let r=e.find(e=>e.id===t);return!r||!b(n)||r.items.includes(n)?e:E(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function ce(e,t){let n=e.find(e=>e.items.includes(t))??null;return n?{groups:e.map(e=>e.id===n.id?{...e,items:e.items.filter(e=>e!==t)}:e).filter(e=>e.items.length>0),owner:n}:{groups:e,owner:null}}function le(e,t,n,r){let i=x(t),a=S(n.id),o=r.some(e=>e.id===n.id),s=e.indexOf(a),c=e.filter(e=>e!==i&&(o||e!==a)),l=s<0?c.length:o?s+1:s;return c.splice(l,0,i),k(c,r)}function ue(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.parentId?t.get(r.parentId)??r:r;for(let t of r.items)n.set(t,e)}let r=new Set,i=[];for(let e of p){let t=n.get(e.id);if(t){if(r.has(t.id))continue;r.add(t.id),i.push({type:`group`,group:t})}else i.push({type:`item`,id:e.id})}return i}function O(e){let t=new Map;for(let n of e){if(!n.parentId)continue;let e=t.get(n.parentId);e?e.push(n):t.set(n.parentId,[n])}let n=[],r=new Set,i=e=>{if(!r.has(e.id)){r.add(e.id),n.push(S(e.id));for(let n of t.get(e.id)??[])i(n)}};for(let t of ue(e))t.type===`item`?n.push(x(t.id)):i(t.group);for(let t of e)i(t);return n}function de(e){let t=new Set,n=new Set;for(let r of e){n.add(S(r.id));for(let e of r.items)t.add(e)}for(let e of p)t.has(e.id)||n.add(x(e.id));return n}function k(e,t){let n=de(t),r=[],i=new Set;if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.has(t)&&!i.has(t)&&(i.add(t),r.push(t));for(let e of O(t))i.has(e)||r.push(e);return r}function fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=k(t,e),a=[];for(let e of i)if(e.startsWith(`group:`)){let t=n.get(e.slice(6));t&&!t.parentId&&a.push({type:`group`,group:t})}else if(e.startsWith(`item:`)){let t=e.slice(5);b(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function pe(e,t,n){let r=t.find(e=>e.id===n);if(!r)return k(e,t);let i=new Set(r.items.map(e=>x(e))),a=S(n);if(r.parentId){let n=e.filter(e=>e!==a),i=S(r.parentId),o=n.indexOf(i),s=[...n];return o<0?s.push(a):s.splice(o+1,0,a),k(s,t)}let o=[...e],s=o.length;for(let e=0;e<o.length;e++){let t=o[e];if(t===a||i.has(t)){s=o.slice(0,e).filter(e=>e!==a&&!i.has(e)).length;break}}let c=o.filter(e=>e!==a&&!i.has(e));return c.splice(s,0,a),k(c,t)}function me(e,t,n){let r=D(e,t);if(!n?.length||r.length<2)return r;let i=new Map;return n.forEach((e,t)=>{i.has(e)||i.set(e,t)}),r.map((e,t)=>({group:e,i:t,at:i.get(S(e.id))})).sort((e,t)=>{let n=e.at??1/0,r=t.at??1/0;return n===r?e.i-t.i:n-r}).map(e=>e.group)}function he(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=r.filter(e=>i.get(e)?.parentId===n),o=new Set(a.map(S)),s=e.filter(e=>!o.has(e)),c=S(n),l=s.indexOf(c),u=a.map(S),d=[...s];return l<0?d.push(...u):d.splice(l+1,0,...u),k(d,t)}function ge(e,t){if(!e.startsWith(`group:`))return!1;let n=e.slice(6);return t.some(e=>e.id===n&&!!e.parentId)}function _e(e,t,n,r=[]){if(t.parentId)return k(e,n);let i=S(t.id),a=[...r.map(e=>S(e)),...t.items.map(e=>x(e))],o=e.filter(e=>e!==i);return o.push(...a),k(o,n)}function ve(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return[...e];let a=[...e],[o]=a.splice(r,1);return o===void 0?[...e]:(a.splice(i,0,o),a)}var A=`tw.space.active-id`,ye=`tw.spaces.list.v1`;function j(e,t){try{return(e===`local`?localStorage:sessionStorage).getItem(t)?.trim()||``}catch{return``}}function M(e,t,n){try{(e===`local`?localStorage:sessionStorage).setItem(t,n)}catch{}}function N(e){let t=String(e||``).trim();t&&(M(`session`,A,t),M(`local`,A,t))}function P(){let e=j(`session`,A);if(e)return e;let t=j(`local`,A);if(t)return t;try{let e=sessionStorage.getItem(ye);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function F(e){let t=P();return t?`${e}::${t}`:e}var I=`/__tb_config`,L=`tw.app.config.v1`,R=`tw.app.apikey.v1`,z=`tw.app.model.v1`,B=!1,V=null,H=``,U=!1,be={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``};function W(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function xe(e){if(!e||typeof e!=`object`)return null;let t=String(e.name??``).trim()||`未命名提供商`,n=String(e.baseURL??``).trim(),r=String(e.model??``).trim();return{id:String(e.id??``).trim()||W(),name:t,baseURL:n,model:r,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}}function Se(e){let t=typeof e.baseURL==`string`?e.baseURL.trim():``,n=typeof e.model==`string`?e.model.trim():``;return!t&&!n&&!e.apiKey?[]:[{id:W(),name:`默认`,baseURL:t||`https://api.deepseek.com/v1`,model:n,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}]}function G(e){let t=e?.reasoningEffort===`low`||e?.reasoningEffort===`high`||e?.reasoningEffort===`max`?e.reasoningEffort:`high`,n=[];Array.isArray(e?.providers)&&e.providers.length?n=e.providers.map(e=>xe(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=Se(e));let r=typeof e?.activeId==`string`?e.activeId:``;return n.length&&!n.some(e=>e.id===r)&&(r=n[0].id),n.length||(r=``),{activeId:r,reasoningEffort:t,providers:n}}function K(){return{version:1,model:{activeId:``,reasoningEffort:`high`,providers:[]},access:`readonly`,general:{...be},plugins:{cases:!1,caseGen:!1,prompts:!0,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,knowledge:!1,memory:!1,pluginDev:!1,todos:!1,tasks:!1,projects:!1,iterations:!1,pmRequirements:!1,bugs:!1,reports:!1,testStats:!1,caseExec:!1,dashboard:!1},caseTypes:e.map(e=>({...e})),promptKinds:c.map(e=>({...e})),knowledgeCategories:[...o],navGroups:m.map(e=>({...e,items:[...e.items]})),navIcons:{..._},navOrder:O(m)}}function q(e){let t=K();if(!e||typeof e!=`object`)return t;let n=e.general&&typeof e.general==`object`?e.general:{},r={...t.plugins,...e.plugins??{}},a=T(e.navGroups);return{version:typeof e.version==`number`?e.version:1,model:G(e.model),access:e.access===`readwrite`||e.access===`full`||e.access===`readonly`?e.access:`readonly`,general:{language:n.language===`en`?`en`:`zh-CN`,appearance:n.appearance===`light`||n.appearance===`dark`||n.appearance===`system`?n.appearance:`system`,sessionFontSize:typeof n.sessionFontSize==`number`&&n.sessionFontSize>=12&&n.sessionFontSize<=22?Math.round(n.sessionFontSize):14,toolStepDetail:n.toolStepDetail===`concise`||n.toolStepDetail===`standard`||n.toolStepDetail===`detailed`||n.toolStepDetail===`full`?n.toolStepDetail:`standard`,busySendBehavior:n.busySendBehavior===`interrupt`?`interrupt`:`queue`,subagentModel:typeof n.subagentModel==`string`?n.subagentModel.trim():``},plugins:r,caseTypes:i(e.caseTypes),promptKinds:f(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:v(e.navIcons),navOrder:k(e.navOrder,a)}}function Ce(){try{let e=localStorage.getItem(z);if(e)return G(JSON.parse(e))}catch{}try{let e=localStorage.getItem(F(L));if(e){let t=JSON.parse(e);if(t?.model)return G(t.model)}}catch{}return null}function we(e){try{localStorage.setItem(z,JSON.stringify(e))}catch{}}function J(){try{let e=localStorage.getItem(F(L)),t=Ce();if(!e)return t?q({...K(),model:t}):null;let n=q(JSON.parse(e));return t&&(n.model=t),n}catch{return null}}function Y(e){try{let{model:t,...n}=e;localStorage.setItem(F(L),JSON.stringify(n)),we(t)}catch{}}function Te(){try{return localStorage.getItem(R)?.trim()||localStorage.getItem(F(R))?.trim()||``}catch{return``}}function Ee(e){try{e?localStorage.setItem(R,e):localStorage.removeItem(R),localStorage.removeItem(F(R))}catch{}}function De(){try{let e=K(),t=!1,n=localStorage.getItem(`tw-llm-settings`);if(n){let r=JSON.parse(n);e.model=G({providers:[{id:W(),name:r.name||`默认`,baseURL:r.baseURL||``,model:r.model||``,apiKey:r.apiKey,availableModels:r.availableModels}],reasoningEffort:r.reasoningEffort}),e.model.providers[0]&&(e.model.activeId=e.model.providers[0].id),t=!0}let r=localStorage.getItem(`tw-access-level`);(r===`readonly`||r===`readwrite`||r===`full`)&&(e.access=r,t=!0);let i=localStorage.getItem(`tw.general.prefs.v1`);i&&(e.general=q({general:JSON.parse(i)}).general,t=!0);let a=localStorage.getItem(`tw.plugins.enabled.v1`);if(a){let n=JSON.parse(a);e.plugins={...e.plugins,...n},t=!0}return t?e:null}catch{return null}}function X(e){let t=e.model.providers;return t.length?t.find(t=>t.id===e.model.activeId)??t[0]??null:null}function Oe(){return B}function ke(){return V||Z(),V??K()}function Z(){if(!U&&(U=!0,typeof window<`u`))try{let e=J();e&&(V=e)}catch{}}function Ae(){return H}function je(){return[...V?.model.providers??[]]}async function Me(){try{let e=await fetch(I,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();V=q(t.config);let n=X(V),r=String(t.apiKey??``).trim();return H=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(H=r),B=!0,Y(V),V}}catch{}B=!1;let e=J();return e||=De()??K(),V=e,H=X(e)?.apiKey?.trim()||Te(),Y(V),V}var Q=null;async function $(e){if(Y(e),B)try{await fetch(I,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e})})}catch{}}function Ne(e){let t=V??K(),n=q({...t,...e,model:e.model?{...t.model,...e.model,providers:e.model.providers??t.model.providers}:t.model,general:{...t.general,...e.general??{}},plugins:{...t.plugins,...e.plugins??{}},caseTypes:e.caseTypes??t.caseTypes,promptKinds:e.promptKinds??t.promptKinds,knowledgeCategories:e.knowledgeCategories??t.knowledgeCategories,navGroups:e.navGroups??t.navGroups,navIcons:e.navIcons??t.navIcons,navOrder:e.navOrder??t.navOrder});return V=n,H=X(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Pe(){return Q&&=(clearTimeout(Q),null),$(V??K())}function Fe(e){if(H=e.trim(),B||Ee(H),!V)return;let t=V.model.providers.map(e=>e.id===V.model.activeId?{...e,apiKey:H||void 0}:e);V=q({...V,model:{...V.model,providers:t}})}function Ie(){let e=V;if(!e)return null;let t=X(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||H).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function Le(){return W()}export{he as A,u as B,h as C,T as D,ie as E,ce as F,e as G,f as H,oe as I,i as J,n as K,ve as L,_e as M,pe as N,v as O,me as P,E as R,ge as S,D as T,o as U,ee as V,s as W,se as _,Oe as a,re as b,Fe as c,P as d,N as f,g,p as h,Me as i,le as j,k,Ie as l,_ as m,Ae as n,je as o,F as p,a as q,ke as r,Le as s,Pe as t,Ne as u,fe as v,x as w,S as x,ae as y,c as z};