lantern-harness 0.1.38 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/Base.CQ_XCsxM.css +1 -0
  4. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.C17uMscj.js → Base.astro_astro_type_script_index_0_lang.rrUCMnye.js} +1 -1
  5. package/dist/_astro/CaseExecBoard.1aCJ_MsC.js +1 -0
  6. package/dist/_astro/CaseGenerateApp.C9bJ0es1.js +10 -0
  7. package/dist/_astro/CasesLibrary.DBxhr8Z1.js +21 -0
  8. package/dist/_astro/ChatApp.CRCMwSjv.js +226 -0
  9. package/dist/_astro/{DashboardBoard.BTFyQf9w.js → DashboardBoard.B-EpZOnS.js} +1 -1
  10. package/dist/_astro/{DocsFileBrowser.9WTBumS5.js → DocsFileBrowser.DceJyP9V.js} +1 -1
  11. package/dist/_astro/{DocsPager.BS20yicJ.js → DocsPager.D0TMvJ67.js} +1 -1
  12. package/dist/_astro/{DrawerField.CiHAvXHQ.js → DrawerField.CWpOf3L_.js} +1 -1
  13. package/dist/_astro/{KnowledgeLibrary.CiBRybeE.js → KnowledgeLibrary.C-_UybI5.js} +1 -1
  14. package/dist/_astro/LifeKrTasksBoard.DktIT_uO.js +1 -0
  15. package/dist/_astro/LifeKrTodosBoard.DVUmgRmh.js +1 -0
  16. package/dist/_astro/LifeObjectivesBoard.Cjg3hCkJ.js +1 -0
  17. package/dist/_astro/LifePlanTypeSelect.C63oD8zZ.js +1 -0
  18. package/dist/_astro/{LifeReviewsBoard.Bn-uxMI5.js → LifeReviewsBoard.Bj4otl26.js} +1 -1
  19. package/dist/_astro/LifeShared.-pwCbSyP.js +3 -0
  20. package/dist/_astro/LifeStagesBoard.DJpc4f7A.js +1 -0
  21. package/dist/_astro/LifeYearCycleSelect.CObXQA5s.js +1 -0
  22. package/dist/_astro/{LifeYearPlansBoard.ChAoQUB5.js → LifeYearPlansBoard.Bt6Hc8M9.js} +1 -1
  23. package/dist/_astro/PluginsPage.BWrcEbFk.js +1 -0
  24. package/dist/_astro/PluginsPage.CMeKGbb1.js +17 -0
  25. package/dist/_astro/PmBugsBoard.NUiKlz46.js +1 -0
  26. package/dist/_astro/PmIterationsBoard.C8F55feg.js +1 -0
  27. package/dist/_astro/{PmProjectDetail.DH8Z3nHb.js → PmProjectDetail.CMiWhGxn.js} +1 -1
  28. package/dist/_astro/{PmProjectsBoard.Dokaj4V1.js → PmProjectsBoard.-g9KAiZJ.js} +1 -1
  29. package/dist/_astro/PmRequirementsBoard.C0_6ye63.js +1 -0
  30. package/dist/_astro/PmRequirementsBoard.C5_NcAzj.js +1 -0
  31. package/dist/_astro/{PmShared.BJpoEYvk.js → PmShared.D6iq_Z9g.js} +1 -1
  32. package/dist/_astro/{PromptsLibrary.CNLcQ66B.js → PromptsLibrary.BLEjapm6.js} +1 -1
  33. package/dist/_astro/ReportsPage.DFsDsjow.js +1 -0
  34. package/dist/_astro/ReqAnalysisBoard.C1ki8w9Z.js +39 -0
  35. package/dist/_astro/{RequirementsLibrary.BnY7_YXU.js → RequirementsLibrary.Dat8rP5c.js} +1 -1
  36. package/dist/_astro/{SearchableSelect.5SfNLwNW.js → SearchableSelect.DFZBUFIs.js} +1 -1
  37. package/dist/_astro/SelectDropdown.Dmk5n225.js +1 -0
  38. package/dist/_astro/{SettingsDialog.DFnXkw7a.js → SettingsDialog.D486FVZ4.js} +1 -1
  39. package/dist/_astro/{SpaceSwitcher.Cy4UrzbH.js → SpaceSwitcher.Bw13MkIw.js} +2 -2
  40. package/dist/_astro/TableFieldConfig.C_NeWm8L.js +1 -0
  41. package/dist/_astro/TasksBoard.wGJOOJpR.js +1 -0
  42. package/dist/_astro/TemplatesLibrary.YIgI089k.js +1 -0
  43. package/dist/_astro/TestStatsBoard.ETea2KcX.js +1 -0
  44. package/dist/_astro/TodosBoard.OfBeAGWO.js +1 -0
  45. package/dist/_astro/UiAutoBoard.Df2ky1Cs.js +9 -0
  46. package/dist/_astro/app-version.DaJuJwsd.js +1 -0
  47. package/dist/_astro/{export.joBT53eb.js → case-fields.CmePqYfh.js} +1 -1
  48. package/dist/_astro/case-gen-run.CxlmN4EC.js +22 -0
  49. package/dist/_astro/{case-review.s1w_mD4l.js → case-review.TdDs1WFM.js} +1 -1
  50. package/dist/_astro/case-template.C-GBxgBC.js +8 -0
  51. package/dist/_astro/{req-analysis.ilj0McI3.js → req-analysis.BAC_bd4R.js} +1 -1
  52. package/dist/_astro/{story-review.Bsm2JWdj.js → story-review.CCSxTgNL.js} +1 -1
  53. package/dist/_astro/tasks.DEyD8pmq.js +1 -0
  54. package/dist/case-exec/index.html +5 -5
  55. package/dist/cases/generate/index.html +5 -5
  56. package/dist/cases/library/index.html +5 -5
  57. package/dist/dashboard/index.html +5 -5
  58. package/dist/docs/changelog/index.html +69 -44
  59. package/dist/docs/install/index.html +4 -4
  60. package/dist/docs/manual/index.html +22 -21
  61. package/dist/knowledge/index.html +5 -5
  62. package/dist/life/kr-tasks/index.html +5 -5
  63. package/dist/life/kr-todos/index.html +5 -5
  64. package/dist/life/objectives/index.html +5 -5
  65. package/dist/life/reviews/index.html +5 -5
  66. package/dist/life/stages/index.html +5 -5
  67. package/dist/life/year-plans/index.html +5 -5
  68. package/dist/plugins/index.html +5 -5
  69. package/dist/pm/bugs/index.html +5 -5
  70. package/dist/pm/iterations/index.html +5 -5
  71. package/dist/pm/projects/detail/index.html +5 -5
  72. package/dist/pm/projects/index.html +5 -5
  73. package/dist/pm/requirements/index.html +5 -5
  74. package/dist/prompts/index.html +5 -5
  75. package/dist/reports/index.html +5 -5
  76. package/dist/requirement-analysis/index.html +5 -5
  77. package/dist/requirements/index.html +5 -5
  78. package/dist/tasks/index.html +5 -5
  79. package/dist/templates/index.html +5 -5
  80. package/dist/test-automation/index.html +5 -5
  81. package/dist/test-stats/index.html +5 -5
  82. package/dist/todos/index.html +5 -5
  83. package/dist/workbench/index.html +5 -5
  84. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +18 -17
  85. package/lh-plugins/lh-mcp.mjs +4 -1
  86. package/lh-plugins/lh-todos.mjs +27 -10
  87. package/package.json +1 -1
  88. package/dist/_astro/Base.B-G3Zgu4.css +0 -1
  89. package/dist/_astro/CaseExecBoard.BWxBjYPI.js +0 -1
  90. package/dist/_astro/CaseGenerateApp.fUXTG_NE.js +0 -10
  91. package/dist/_astro/CasesLibrary.CVPhAnFf.js +0 -24
  92. package/dist/_astro/ChatApp.KceL1TNg.js +0 -226
  93. package/dist/_astro/LifeKrTasksBoard.RENBU_z9.js +0 -1
  94. package/dist/_astro/LifeKrTodosBoard.CbNnGHSZ.js +0 -1
  95. package/dist/_astro/LifeObjectivesBoard.BTGFpny2.js +0 -1
  96. package/dist/_astro/LifePlanTypeSelect.BGtEEsL-.js +0 -1
  97. package/dist/_astro/LifeShared.SnLIiFdN.js +0 -3
  98. package/dist/_astro/LifeStagesBoard.DrbIVrCK.js +0 -1
  99. package/dist/_astro/LifeYearCycleSelect.CuiWO8Tc.js +0 -1
  100. package/dist/_astro/PluginsPage.BFEwg0vr.js +0 -17
  101. package/dist/_astro/PluginsPage.CPEoYrlx.js +0 -1
  102. package/dist/_astro/PmBugsBoard.Cu1uf0TC.js +0 -1
  103. package/dist/_astro/PmIterationsBoard.RzRKkAH0.js +0 -1
  104. package/dist/_astro/PmRequirementsBoard.DET5YIVX.js +0 -1
  105. package/dist/_astro/PmRequirementsBoard.i203nmYC.js +0 -1
  106. package/dist/_astro/ReportsPage.BU3GtBvl.js +0 -1
  107. package/dist/_astro/ReqAnalysisBoard.DaOV-2Z2.js +0 -39
  108. package/dist/_astro/SelectDropdown.TgxIOKMD.js +0 -1
  109. package/dist/_astro/TasksBoard.CWkx5cD1.js +0 -1
  110. package/dist/_astro/TemplatesLibrary.phzK5kho.js +0 -1
  111. package/dist/_astro/TestStatsBoard.Dp1TWEf7.js +0 -1
  112. package/dist/_astro/TodosBoard.ofiKHKcQ.js +0 -1
  113. package/dist/_astro/UiAutoBoard.Cpb_EF46.js +0 -9
  114. package/dist/_astro/app-version.BsRPDlqD.js +0 -1
  115. package/dist/_astro/case-fields.Dqkws1iX.js +0 -1
  116. package/dist/_astro/case-gen-run.BaUxa_BR.js +0 -22
  117. package/dist/_astro/case-template.F1Nv08GV.js +0 -5
  118. package/dist/_astro/tasks.DefXqRfI.js +0 -1
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{t as a}from"./OverflowHint.pvo2Xc8R.js";import{t as o}from"./SelectDropdown.TgxIOKMD.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{c,d as l,i as u,l as d,n as f,o as p,t as m}from"./ColumnResize.CkE59sGq.js";import{$ as h,A as g,B as _,C as v,E as ee,F as y,H as te,J as ne,K as re,L as ie,M as b,N as ae,P as oe,Q as se,S as ce,St as le,T as ue,U as de,V as fe,X as pe,Y as me,Z as he,_ as ge,b as x,c as _e,dt as S,et as ve,f as C,g as ye,k as be,pt as xe,ut as w,w as Se,x as Ce,y as we,z as T}from"./LifeShared.SnLIiFdN.js";import{c as E,l as D,n as O,r as k,s as A,t as j}from"./DrawerField.CiHAvXHQ.js";import{t as M}from"./LifePlanTypeSelect.BGtEEsL-.js";import{t as Te}from"./LifeYearCycleSelect.CuiWO8Tc.js";var N=e(t(),1),P=e(n(),1),F=r(),Ee=[{key:`select`,width:36,min:32},{key:`title`,width:220,min:160},{key:`yearCycle`,width:120,min:88},{key:`planType`,width:112,min:88},{key:`status`,width:104,min:76},{key:`objectives`,width:280,min:180},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[{key:`yearCycle`,label:`年度周期`},{key:`planType`,label:`计划类型`},{key:`status`,label:`状态`},{key:`objectives`,label:`关联 Objective`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Oe=`life.year-plans.fields`,ke=`life.year-plans.search`,Ae=`life.year-plans.group`,je=[`status`,`yearCycle`,`none`],I=w.map(e=>({value:e,label:S[e]})),Me={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,done:`bg-[#d9f5d2] text-[#1d7a12]`},Ne=[{value:`none`,label:`不分组`},{value:`status`,label:`按状态分组`},{value:`yearCycle`,label:`按年度分组`}];function L(e){return{title:``,yearCycle:e?.yearCycle??``,planType:e?.planType??``,status:e?.status??`in_progress`,objectiveIds:e?.objectiveIds??[]}}function Pe(e){let t=(0,N.useMemo)(()=>{let t=new Set(e.values);return e.objectives.filter(n=>t.has(n.id)||!!e.yearPlanId&&n.yearPlanId===e.yearPlanId)},[e.objectives,e.values,e.yearPlanId]),n=!e.yearCycle,r=t.length===0,i=n?`先选年度周期`:r?`暂无关联 Objective`:`已关联 ${t.length} 个目标`,[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)({left:0,top:0,width:280,openUp:!1}),u=(0,N.useRef)(null),d=(0,N.useRef)(null),f=n;(0,N.useEffect)(()=>{if(!o)return;function e(e){let t=e.target;u.current?.contains(t)||d.current?.contains(t)||s(!1)}function t(e){e.target instanceof Node&&d.current?.contains(e.target)||s(!1)}function n(){s(!1)}return document.addEventListener(`mousedown`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,n)}},[o]);function p(){if(f)return;if(o){s(!1);return}let e=u.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.max(t.width,260),r=Math.min(t.left,Math.max(8,window.innerWidth-n-8)),i=t.bottom+4,a=i+200>window.innerHeight&&t.top>200;l({left:r,top:a?t.top-4:i,width:n,openUp:a}),s(!0)}function m(n,r){r.stopPropagation(),e.onChange(t.filter(e=>e.id!==n).map(e=>e.id))}let h=f?`w-full min-h-8 flex items-center justify-start rounded-lg border border-stone-200 bg-stone-50 px-2.5 py-1.5 text-sm text-left text-stone-400 cursor-not-allowed`:e.flat?`tw-field-trigger w-full min-h-9 flex items-center justify-start rounded-lg border border-stone-200 bg-white px-3 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`:`tw-field-trigger w-full min-h-8 flex items-center justify-start rounded-lg border border-stone-200 bg-white px-2.5 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-1 focus:ring-[#3370ff]/30`,g=null;return o&&typeof document<`u`&&(g=(0,P.createPortal)((0,F.jsx)(`div`,{ref:d,className:`tw-select-menu tw-popover-anim fixed z-[1000] overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200`,style:{left:c.left,width:c.width,...c.openUp?{bottom:window.innerHeight-c.top}:{top:c.top}},children:(0,F.jsx)(`div`,{className:`tw-dsh-scroll max-h-[120px] overflow-y-auto bg-white px-2.5 py-2`,onWheel:e=>e.stopPropagation(),children:r?(0,F.jsx)(`p`,{className:`px-1 py-1 text-sm text-stone-400`,children:n?`先选年度周期`:`暂无关联 Objective,可在 Objective 里选年度计划`}):(0,F.jsx)(`div`,{className:`flex flex-wrap content-start gap-1.5`,children:t.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-full bg-[#e8f0fe] px-2.5 py-0.5 text-[12px] leading-5 text-[#1f4ec2]`,children:[(0,F.jsx)(`span`,{className:`min-w-0 break-words whitespace-pre-wrap`,children:e.title}),(0,F.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`移除 ${e.title}`,className:`shrink-0 rounded-full px-0.5 text-[#5b7fd4] hover:bg-[#d2e3fc] hover:text-[#1f4ec2]`,onClick:t=>m(e.id,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m(e.id,t))},children:`×`})]},e.id))})})}),document.body)),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`button`,{ref:u,type:`button`,disabled:f,"aria-expanded":o,onClick:p,className:h,children:r||f?(0,F.jsx)(`span`,{className:`text-stone-400`,children:i}):(0,F.jsx)(a,{text:t.map(e=>e.title).join(`、`),className:`block min-w-0 flex-1 truncate text-left text-stone-700`})}),g]})}function Fe(e){let t={},n=/(?:^|\|)status:([^|]+)/.exec(e)?.[1];n&&w.includes(n)&&(t.status=n);let r=/(?:^|\|)year:([^|]+)/.exec(e)?.[1];return r&&r!==`unset`&&(t.yearCycle=r),t}function Ie(e){let{open:t,item:n,yearCycles:r,yearCycleMutate:i,objectives:o,planTypes:s,planTypeMutate:c,isVisible:l,onClose:u,onSave:d}=e,[f,p]=(0,N.useState)(L()),[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(``);(0,N.useEffect)(()=>{t&&(_(``),h(!1),p({title:n.title,yearCycle:n.yearCycle,planType:n.planType||``,status:n.status,objectiveIds:n.objectiveIds??[]}))},[t,n]);async function v(){let e=f.title.trim();if(!e)_(`请填写计划标题`);else{h(!0);try{await d({...f,title:e,yearCycle:f.yearCycle,objectiveIds:f.objectiveIds},n.id),u()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,F.jsxs)(x,{open:t,title:`计划详情`,onClose:u,footer:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:u,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>void v(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:`保存`})]}),children:[g?(0,F.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:g}):null,(0,F.jsx)(O,{icon:(0,F.jsx)(D,{}),label:`标题`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:f.title,onChange:e=>p({...f,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),v())},placeholder:`请输入内容`,className:j})}),l(`yearCycle`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`年度周期`,children:(0,F.jsx)(Te,{flat:!0,className:`w-full`,yearCycles:r,value:f.yearCycle,onChange:e=>p({...f,yearCycle:e}),mutate:i,renderTrigger:(e,{empty:t})=>(0,F.jsx)(a,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,l(`planType`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`计划类型`,children:(0,F.jsx)(M,{flat:!0,className:`w-full`,planTypes:s,value:f.planType,onChange:e=>p({...f,planType:e}),mutate:c,renderTrigger:(e,{empty:t})=>(0,F.jsx)(a,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,l(`status`)?(0,F.jsx)(O,{icon:(0,F.jsx)(A,{}),label:`状态`,children:(0,F.jsx)(k,{ariaLabel:`计划状态`,options:I,value:f.status,onChange:e=>p({...f,status:e}),label:S[f.status],optionDotClassName:e=>y[e]})}):null,l(`objectives`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`关联 Objective`,children:(0,F.jsxs)(`div`,{className:`w-full px-0.5 py-0.5`,children:[(0,F.jsx)(Pe,{flat:!0,yearCycle:f.yearCycle,yearPlanId:n.id,objectives:o,values:f.objectiveIds,onChange:e=>p({...f,objectiveIds:e})}),(0,F.jsx)(`p`,{className:`mt-1 px-1.5 text-[11px] leading-4 text-stone-400`,children:`点击查看已关联目标;在 Objective 里选「年度计划」后会自动出现。`})]})}):null,l(`createdAt`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`创建日期`,children:(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:T(n.createdAt)})}):null,l(`updatedAt`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`修改日期`,children:(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:T(n.updatedAt)})}):null]})}function Le(){let e=se(),{store:t,live:n,error:r,setError:x,updateItem:E,createItems:D,deleteItems:O}=ve(e.ready&&e.on),k=(0,N.useMemo)(()=>({createItems:D,updateItem:E,deleteItems:O}),[D,E,O]),A=(0,N.useMemo)(()=>({createItems:D,updateItem:E,deleteItems:O}),[D,E,O]),j=me(Oe,De),P=(0,N.useMemo)(()=>ie(Ee,j.isVisible),[j.isVisible]),[L,Le]=he(ke),Re=de(),[R,ze]=ne(Ae,je,`none`),[Be,Ve]=(0,N.useState)({}),[z,B]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(null),[V,We]=(0,N.useState)(!1),[H,Ge]=(0,N.useState)(!1),[Ke,U]=(0,N.useState)({}),[W,G]=(0,N.useState)(null),K=d(`life.year-plans.cols.v13`,P),qe=l(`life.year-plans`),q=(0,N.useMemo)(()=>re(xe(t.yearPlans,L),w),[t.yearPlans,L]),J=(0,N.useMemo)(()=>{if(R===`none`)return[{key:`all`,label:`全部计划`,pill:`bg-stone-500 text-white`,items:q}];if(R===`yearCycle`){let e=le(t.yearCycles),n=new Set(e.map(e=>e.id)),r=e.map(e=>({key:`year:${e.id}`,label:e.name,pill:_(e.id),items:q.filter(t=>t.yearCycle===e.id)})).filter(e=>e.items.length>0),i=q.filter(e=>!e.yearCycle||!n.has(e.yearCycle));return i.length>0&&r.push({key:`year:unset`,label:ye,pill:_(``),items:i}),r}return w.map(e=>({key:`status:${e}`,label:S[e],pill:Me[e],items:q.filter(t=>t.status===e)}))},[R,q,t.yearCycles]),Y=(0,N.useMemo)(()=>{if(R===`status`)return J;let e=J.filter(e=>e.items.length>0);return e.length>0?e:R===`none`?J.length>0?J:[{key:`all`,label:`全部计划`,pill:`bg-stone-500 text-white`,items:[]}]:[{key:`year:unset`,label:ye,pill:`bg-stone-300 text-stone-600`,items:[]}]},[R,J]),Je=(0,N.useMemo)(()=>Y.flatMap(e=>e.items.map(e=>e.id)),[Y]),X=h(Je),{submit:Ye}=pe({row:W,setRow:G,submitting:H,isPristine:e=>!e.title.trim()&&e.yearCycle===e.baseYearCycle&&e.planType===e.basePlanType&&e.status===e.baseStatus&&e.objectiveIds.join(`|`)===e.baseObjectiveIds.join(`|`),onSubmit:async e=>{Ge(!0);try{await D(`yearPlans`,[{title:e.title,yearCycle:e.yearCycle,planType:e.planType,status:e.status,objectiveIds:e.objectiveIds}]),G(null),s(`已新增年度计划`,`success`),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),s(`新增失败:${t}`,`error`)}finally{Ge(!1)}}});function Xe(e,t){let n=t?.planType??``,r=t?.status??`in_progress`,i=t?.yearCycle??``;G({groupKey:e,title:``,yearCycle:i,planType:n,status:r,objectiveIds:[],baseYearCycle:i,basePlanType:n,baseStatus:r,baseObjectiveIds:[]}),Ve(t=>({...t,[e]:!1}))}async function Z(e,t){try{await E(`yearPlans`,e,t),U(t=>{let n={...t};return delete n[e],n}),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),s(`保存失败:${t}`,`error`)}}function Ze(e){return{...e,...Ke[e.id]}}function Qe(e,t){U(n=>({...n,[e]:{...n[e],...t}}))}async function $e(e){let t=Ke[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):x(`标题不能为空`)}async function et(e,t){await E(`yearPlans`,t,e),s(`已保存`,`success`)}function Q(){return W?(0,F.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:f,style:Re,children:(0,F.jsx)(`input`,{autoFocus:!0,disabled:H,value:W.title,placeholder:`输入计划名称,回车或点空白处保存`,onChange:e=>G(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ye()):e.key===`Escape`&&(e.preventDefault(),G(null))},className:_e})}),j.isVisible(`yearCycle`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Te,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:W.yearCycle,onChange:e=>G(t=>t&&{...t,yearCycle:e}),mutate:A})}):null,j.isVisible(`planType`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(M,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:W.planType,onChange:e=>G(t=>t&&{...t,planType:e}),mutate:k})}):null,j.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(o,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`计划状态`,menuMinWidth:120,options:I,value:W.status,onChange:e=>G(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${oe[W.status]}`,renderTrigger:()=>(0,F.jsx)(a,{text:S[W.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${y[e.value]}`})})}):null,j.isVisible(`objectives`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Pe,{yearCycle:W.yearCycle,objectives:t.objectives,values:W.objectiveIds,onChange:e=>G(t=>t&&{...t,objectiveIds:e})})}):null,j.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:`—`,muted:!0})}):null,j.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:`—`,muted:!0})}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:u})]}):null}async function tt(){let e=z;if(e?.length){B(null),We(!0);try{await O(`yearPlans`,e.map(e=>e.id)),X.clear(),s(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){x(e instanceof Error?e.message:String(e))}finally{We(!1)}}}function nt(e,n){let r=Ze(e);return(0,F.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(be,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0}),(0,F.jsx)(`td`,{className:f,style:Re,children:(0,F.jsx)(ae,{value:r.title,placeholder:`标题`,onChange:t=>Qe(e.id,{title:t}),onCommit:()=>void $e(e),onCancel:()=>U(t=>{let n={...t};return delete n[e.id],n})})}),j.isVisible(`yearCycle`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Te,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:r.yearCycle,onChange:t=>void Z(e.id,{yearCycle:t}),mutate:A})}):null,j.isVisible(`planType`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(M,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:r.planType,onChange:t=>void Z(e.id,{planType:t}),mutate:k})}):null,j.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(o,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`计划状态`,menuMinWidth:120,options:I,value:r.status,onChange:t=>void Z(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${oe[r.status]}`,renderTrigger:()=>(0,F.jsx)(a,{text:S[r.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${y[e.value]}`})})}):null,j.isVisible(`objectives`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Pe,{yearCycle:r.yearCycle,yearPlanId:e.id,objectives:t.objectives,values:r.objectiveIds??[],onChange:t=>void Z(e.id,{objectiveIds:t})})}):null,j.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:T(e.createdAt),muted:!e.createdAt})}):null,j.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:T(e.updatedAt),muted:!e.updatedAt})}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:u,children:(0,F.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,F.jsx)(ce,{label:`编辑 ${e.title}`,disabled:V,onClick:()=>Ue(e)}),(0,F.jsx)(we,{label:`删除 ${e.title}`,disabled:V,onClick:()=>B([e])})]})})]},e.id)}if(!e.ready)return(0,F.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,F.jsx)(ee,{children:fe()});if(n===null)return(0,F.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,F.jsx)(ee,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=P.length;return(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:t.yearPlans.length}),` 条`]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:L,onChange:e=>Le(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)(o,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ne,value:R,onChange:e=>ze(e)}),(0,F.jsx)(v,{fields:j.fields,isVisible:j.isVisible,onToggle:j.toggle}),(0,F.jsx)(`button`,{type:`button`,disabled:V||X.selectedIds.length===0,onClick:()=>B(t.yearPlans.filter(e=>X.selected[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:V||H,onClick:()=>{let e=Y[0];Xe(e?.key??`all`,e?Fe(e.key):void 0)},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:`+ 新建计划`})]})]}),(0,F.jsx)(Ce,{error:r,onDismiss:()=>x(``)}),(0,F.jsx)(`div`,{ref:qe,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,F.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:K.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:P.map(e=>(0,F.jsx)(`col`,{style:e.key===`select`?{width:te(!1)}:K.widthOf(e.key)?{width:K.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)(g,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible()}),(0,F.jsxs)(`th`,{className:`${p} text-xs text-stone-500`,style:Re,children:[`标题`,(0,F.jsx)(m,{...K.resizeProps(`title`)})]}),j.isVisible(`yearCycle`)?(0,F.jsxs)(`th`,{className:C,children:[`年度周期`,(0,F.jsx)(m,{...K.resizeProps(`yearCycle`)})]}):null,j.isVisible(`planType`)?(0,F.jsxs)(`th`,{className:C,children:[`计划类型`,(0,F.jsx)(m,{...K.resizeProps(`planType`)})]}):null,j.isVisible(`status`)?(0,F.jsxs)(`th`,{className:C,children:[`状态`,(0,F.jsx)(m,{...K.resizeProps(`status`)})]}):null,j.isVisible(`objectives`)?(0,F.jsxs)(`th`,{className:C,children:[`关联 Objective`,(0,F.jsx)(m,{...K.resizeProps(`objectives`)})]}):null,j.isVisible(`createdAt`)?(0,F.jsxs)(`th`,{className:C,children:[`创建日期`,(0,F.jsx)(m,{...K.resizeProps(`createdAt`)})]}):null,j.isVisible(`updatedAt`)?(0,F.jsxs)(`th`,{className:C,children:[`修改日期`,(0,F.jsx)(m,{...K.resizeProps(`updatedAt`)})]}):null,(0,F.jsx)(`th`,{"aria-hidden":`true`}),(0,F.jsx)(`th`,{className:c,children:`操作`})]})}),(0,F.jsx)(`tbody`,{children:q.length===0&&!W?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.yearPlans.length===0?`还没有年度计划`:`没有匹配的记录`})}):q.length===0&&W?Q():R===`none`?(0,F.jsxs)(F.Fragment,{children:[q.map((e,t)=>nt(e,t+1)),W?Q():(0,F.jsx)(ge,{colSpan:$,disabled:V||H,onClick:()=>Xe(`all`)})]}):Y.length===0?W?Q():null:Y.map(e=>{let t=!Be[e.key];return(0,F.jsxs)(N.Fragment,{children:[(0,F.jsx)(Se,{label:e.label,pill:e.pill,count:e.items.length,open:t,kind:`tag`,colSpan:$,onToggle:()=>Ve(t=>({...t,[e.key]:!t[e.key]}))}),t?(0,F.jsxs)(F.Fragment,{children:[e.items.map((e,t)=>nt(e,t+1)),W?.groupKey===e.key?Q():q.length>0?(0,F.jsx)(ge,{colSpan:$,disabled:V||H,onClick:()=>Xe(e.key,Fe(e.key))}):null]}):null]},e.key)})})]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`显示 `,q.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`关联 Objective:点击弹出胶囊框;在 Objective 选年度计划后自动带出`})]}),He?(0,F.jsx)(Ie,{open:!0,item:He,yearCycles:t.yearCycles,yearCycleMutate:A,objectives:t.objectives,planTypes:t.planTypes,planTypeMutate:k,isVisible:j.isVisible,onClose:()=>Ue(null),onSave:et}):null,(0,F.jsx)(i,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除年度计划`,message:z&&z.length>1?`删除选中的 ${z.length} 条计划?`:`删除「${z?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>B(null),onConfirm:()=>void tt()})]})}export{Le as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{t as a}from"./OverflowHint.pvo2Xc8R.js";import{t as o}from"./SelectDropdown.Dmk5n225.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{c,d as l,i as u,l as d,n as f,o as p,t as m}from"./ColumnResize.CkE59sGq.js";import{$ as h,A as g,B as _,C as v,E as ee,F as y,H as te,J as ne,K as re,L as ie,M as b,N as ae,P as oe,Q as se,S as ce,St as le,T as ue,U as de,V as fe,X as pe,Y as me,Z as he,_ as ge,b as x,c as _e,dt as S,et as ve,f as C,g as ye,k as be,pt as xe,ut as w,w as Se,x as Ce,y as we,z as T}from"./LifeShared.-pwCbSyP.js";import{c as E,l as D,n as O,r as k,s as A,t as j}from"./DrawerField.CWpOf3L_.js";import{t as M}from"./LifePlanTypeSelect.C63oD8zZ.js";import{t as Te}from"./LifeYearCycleSelect.CObXQA5s.js";var N=e(t(),1),P=e(n(),1),F=r(),Ee=[{key:`select`,width:36,min:32},{key:`title`,width:220,min:160},{key:`yearCycle`,width:120,min:88},{key:`planType`,width:112,min:88},{key:`status`,width:104,min:76},{key:`objectives`,width:280,min:180},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[{key:`yearCycle`,label:`年度周期`},{key:`planType`,label:`计划类型`},{key:`status`,label:`状态`},{key:`objectives`,label:`关联 Objective`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Oe=`life.year-plans.fields`,ke=`life.year-plans.search`,Ae=`life.year-plans.group`,je=[`status`,`yearCycle`,`none`],I=w.map(e=>({value:e,label:S[e]})),Me={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,done:`bg-[#d9f5d2] text-[#1d7a12]`},Ne=[{value:`none`,label:`不分组`},{value:`status`,label:`按状态分组`},{value:`yearCycle`,label:`按年度分组`}];function L(e){return{title:``,yearCycle:e?.yearCycle??``,planType:e?.planType??``,status:e?.status??`in_progress`,objectiveIds:e?.objectiveIds??[]}}function Pe(e){let t=(0,N.useMemo)(()=>{let t=new Set(e.values);return e.objectives.filter(n=>t.has(n.id)||!!e.yearPlanId&&n.yearPlanId===e.yearPlanId)},[e.objectives,e.values,e.yearPlanId]),n=!e.yearCycle,r=t.length===0,i=n?`先选年度周期`:r?`暂无关联 Objective`:`已关联 ${t.length} 个目标`,[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)({left:0,top:0,width:280,openUp:!1}),u=(0,N.useRef)(null),d=(0,N.useRef)(null),f=n;(0,N.useEffect)(()=>{if(!o)return;function e(e){let t=e.target;u.current?.contains(t)||d.current?.contains(t)||s(!1)}function t(e){e.target instanceof Node&&d.current?.contains(e.target)||s(!1)}function n(){s(!1)}return document.addEventListener(`mousedown`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,n)}},[o]);function p(){if(f)return;if(o){s(!1);return}let e=u.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.max(t.width,260),r=Math.min(t.left,Math.max(8,window.innerWidth-n-8)),i=t.bottom+4,a=i+200>window.innerHeight&&t.top>200;l({left:r,top:a?t.top-4:i,width:n,openUp:a}),s(!0)}function m(n,r){r.stopPropagation(),e.onChange(t.filter(e=>e.id!==n).map(e=>e.id))}let h=f?`w-full min-h-8 flex items-center justify-start rounded-lg border border-stone-200 bg-stone-50 px-2.5 py-1.5 text-sm text-left text-stone-400 cursor-not-allowed`:e.flat?`tw-field-trigger w-full min-h-9 flex items-center justify-start rounded-lg border border-stone-200 bg-white px-3 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`:`tw-field-trigger w-full min-h-8 flex items-center justify-start rounded-lg border border-stone-200 bg-white px-2.5 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-1 focus:ring-[#3370ff]/30`,g=null;return o&&typeof document<`u`&&(g=(0,P.createPortal)((0,F.jsx)(`div`,{ref:d,className:`tw-select-menu tw-popover-anim fixed z-[1000] overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200`,style:{left:c.left,width:c.width,...c.openUp?{bottom:window.innerHeight-c.top}:{top:c.top}},children:(0,F.jsx)(`div`,{className:`tw-dsh-scroll max-h-[120px] overflow-y-auto bg-white px-2.5 py-2`,onWheel:e=>e.stopPropagation(),children:r?(0,F.jsx)(`p`,{className:`px-1 py-1 text-sm text-stone-400`,children:n?`先选年度周期`:`暂无关联 Objective,可在 Objective 里选年度计划`}):(0,F.jsx)(`div`,{className:`flex flex-wrap content-start gap-1.5`,children:t.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-full bg-[#e8f0fe] px-2.5 py-0.5 text-[12px] leading-5 text-[#1f4ec2]`,children:[(0,F.jsx)(`span`,{className:`min-w-0 break-words whitespace-pre-wrap`,children:e.title}),(0,F.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`移除 ${e.title}`,className:`shrink-0 rounded-full px-0.5 text-[#5b7fd4] hover:bg-[#d2e3fc] hover:text-[#1f4ec2]`,onClick:t=>m(e.id,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m(e.id,t))},children:`×`})]},e.id))})})}),document.body)),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`button`,{ref:u,type:`button`,disabled:f,"aria-expanded":o,onClick:p,className:h,children:r||f?(0,F.jsx)(`span`,{className:`text-stone-400`,children:i}):(0,F.jsx)(a,{text:t.map(e=>e.title).join(`、`),className:`block min-w-0 flex-1 truncate text-left text-stone-700`})}),g]})}function Fe(e){let t={},n=/(?:^|\|)status:([^|]+)/.exec(e)?.[1];n&&w.includes(n)&&(t.status=n);let r=/(?:^|\|)year:([^|]+)/.exec(e)?.[1];return r&&r!==`unset`&&(t.yearCycle=r),t}function Ie(e){let{open:t,item:n,yearCycles:r,yearCycleMutate:i,objectives:o,planTypes:s,planTypeMutate:c,isVisible:l,onClose:u,onSave:d}=e,[f,p]=(0,N.useState)(L()),[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(``);(0,N.useEffect)(()=>{t&&(_(``),h(!1),p({title:n.title,yearCycle:n.yearCycle,planType:n.planType||``,status:n.status,objectiveIds:n.objectiveIds??[]}))},[t,n]);async function v(){let e=f.title.trim();if(!e)_(`请填写计划标题`);else{h(!0);try{await d({...f,title:e,yearCycle:f.yearCycle,objectiveIds:f.objectiveIds},n.id),u()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,F.jsxs)(x,{open:t,title:`计划详情`,onClose:u,footer:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:u,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>void v(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:`保存`})]}),children:[g?(0,F.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:g}):null,(0,F.jsx)(O,{icon:(0,F.jsx)(D,{}),label:`标题`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:f.title,onChange:e=>p({...f,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),v())},placeholder:`请输入内容`,className:j})}),l(`yearCycle`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`年度周期`,children:(0,F.jsx)(Te,{flat:!0,className:`w-full`,yearCycles:r,value:f.yearCycle,onChange:e=>p({...f,yearCycle:e}),mutate:i,renderTrigger:(e,{empty:t})=>(0,F.jsx)(a,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,l(`planType`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`计划类型`,children:(0,F.jsx)(M,{flat:!0,className:`w-full`,planTypes:s,value:f.planType,onChange:e=>p({...f,planType:e}),mutate:c,renderTrigger:(e,{empty:t})=>(0,F.jsx)(a,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,l(`status`)?(0,F.jsx)(O,{icon:(0,F.jsx)(A,{}),label:`状态`,children:(0,F.jsx)(k,{ariaLabel:`计划状态`,options:I,value:f.status,onChange:e=>p({...f,status:e}),label:S[f.status],optionDotClassName:e=>y[e]})}):null,l(`objectives`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`关联 Objective`,children:(0,F.jsxs)(`div`,{className:`w-full px-0.5 py-0.5`,children:[(0,F.jsx)(Pe,{flat:!0,yearCycle:f.yearCycle,yearPlanId:n.id,objectives:o,values:f.objectiveIds,onChange:e=>p({...f,objectiveIds:e})}),(0,F.jsx)(`p`,{className:`mt-1 px-1.5 text-[11px] leading-4 text-stone-400`,children:`点击查看已关联目标;在 Objective 里选「年度计划」后会自动出现。`})]})}):null,l(`createdAt`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`创建日期`,children:(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:T(n.createdAt)})}):null,l(`updatedAt`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`修改日期`,children:(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:T(n.updatedAt)})}):null]})}function Le(){let e=se(),{store:t,live:n,error:r,setError:x,updateItem:E,createItems:D,deleteItems:O}=ve(e.ready&&e.on),k=(0,N.useMemo)(()=>({createItems:D,updateItem:E,deleteItems:O}),[D,E,O]),A=(0,N.useMemo)(()=>({createItems:D,updateItem:E,deleteItems:O}),[D,E,O]),j=me(Oe,De),P=(0,N.useMemo)(()=>ie(Ee,j.isVisible),[j.isVisible]),[L,Le]=he(ke),Re=de(),[R,ze]=ne(Ae,je,`none`),[Be,Ve]=(0,N.useState)({}),[z,B]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(null),[V,We]=(0,N.useState)(!1),[H,Ge]=(0,N.useState)(!1),[Ke,U]=(0,N.useState)({}),[W,G]=(0,N.useState)(null),K=d(`life.year-plans.cols.v13`,P),qe=l(`life.year-plans`),q=(0,N.useMemo)(()=>re(xe(t.yearPlans,L),w),[t.yearPlans,L]),J=(0,N.useMemo)(()=>{if(R===`none`)return[{key:`all`,label:`全部计划`,pill:`bg-stone-500 text-white`,items:q}];if(R===`yearCycle`){let e=le(t.yearCycles),n=new Set(e.map(e=>e.id)),r=e.map(e=>({key:`year:${e.id}`,label:e.name,pill:_(e.id),items:q.filter(t=>t.yearCycle===e.id)})).filter(e=>e.items.length>0),i=q.filter(e=>!e.yearCycle||!n.has(e.yearCycle));return i.length>0&&r.push({key:`year:unset`,label:ye,pill:_(``),items:i}),r}return w.map(e=>({key:`status:${e}`,label:S[e],pill:Me[e],items:q.filter(t=>t.status===e)}))},[R,q,t.yearCycles]),Y=(0,N.useMemo)(()=>{if(R===`status`)return J;let e=J.filter(e=>e.items.length>0);return e.length>0?e:R===`none`?J.length>0?J:[{key:`all`,label:`全部计划`,pill:`bg-stone-500 text-white`,items:[]}]:[{key:`year:unset`,label:ye,pill:`bg-stone-300 text-stone-600`,items:[]}]},[R,J]),Je=(0,N.useMemo)(()=>Y.flatMap(e=>e.items.map(e=>e.id)),[Y]),X=h(Je),{submit:Ye}=pe({row:W,setRow:G,submitting:H,isPristine:e=>!e.title.trim()&&e.yearCycle===e.baseYearCycle&&e.planType===e.basePlanType&&e.status===e.baseStatus&&e.objectiveIds.join(`|`)===e.baseObjectiveIds.join(`|`),onSubmit:async e=>{Ge(!0);try{await D(`yearPlans`,[{title:e.title,yearCycle:e.yearCycle,planType:e.planType,status:e.status,objectiveIds:e.objectiveIds}]),G(null),s(`已新增年度计划`,`success`),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),s(`新增失败:${t}`,`error`)}finally{Ge(!1)}}});function Xe(e,t){let n=t?.planType??``,r=t?.status??`in_progress`,i=t?.yearCycle??``;G({groupKey:e,title:``,yearCycle:i,planType:n,status:r,objectiveIds:[],baseYearCycle:i,basePlanType:n,baseStatus:r,baseObjectiveIds:[]}),Ve(t=>({...t,[e]:!1}))}async function Z(e,t){try{await E(`yearPlans`,e,t),U(t=>{let n={...t};return delete n[e],n}),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),s(`保存失败:${t}`,`error`)}}function Ze(e){return{...e,...Ke[e.id]}}function Qe(e,t){U(n=>({...n,[e]:{...n[e],...t}}))}async function $e(e){let t=Ke[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):x(`标题不能为空`)}async function et(e,t){await E(`yearPlans`,t,e),s(`已保存`,`success`)}function Q(){return W?(0,F.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:f,style:Re,children:(0,F.jsx)(`input`,{autoFocus:!0,disabled:H,value:W.title,placeholder:`输入计划名称,回车或点空白处保存`,onChange:e=>G(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ye()):e.key===`Escape`&&(e.preventDefault(),G(null))},className:_e})}),j.isVisible(`yearCycle`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Te,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:W.yearCycle,onChange:e=>G(t=>t&&{...t,yearCycle:e}),mutate:A})}):null,j.isVisible(`planType`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(M,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:W.planType,onChange:e=>G(t=>t&&{...t,planType:e}),mutate:k})}):null,j.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(o,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`计划状态`,menuMinWidth:120,options:I,value:W.status,onChange:e=>G(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${oe[W.status]}`,renderTrigger:()=>(0,F.jsx)(a,{text:S[W.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${y[e.value]}`})})}):null,j.isVisible(`objectives`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Pe,{yearCycle:W.yearCycle,objectives:t.objectives,values:W.objectiveIds,onChange:e=>G(t=>t&&{...t,objectiveIds:e})})}):null,j.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:`—`,muted:!0})}):null,j.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:`—`,muted:!0})}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:u})]}):null}async function tt(){let e=z;if(e?.length){B(null),We(!0);try{await O(`yearPlans`,e.map(e=>e.id)),X.clear(),s(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){x(e instanceof Error?e.message:String(e))}finally{We(!1)}}}function nt(e,n){let r=Ze(e);return(0,F.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(be,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0}),(0,F.jsx)(`td`,{className:f,style:Re,children:(0,F.jsx)(ae,{value:r.title,placeholder:`标题`,onChange:t=>Qe(e.id,{title:t}),onCommit:()=>void $e(e),onCancel:()=>U(t=>{let n={...t};return delete n[e.id],n})})}),j.isVisible(`yearCycle`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Te,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:r.yearCycle,onChange:t=>void Z(e.id,{yearCycle:t}),mutate:A})}):null,j.isVisible(`planType`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(M,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:r.planType,onChange:t=>void Z(e.id,{planType:t}),mutate:k})}):null,j.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(o,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`计划状态`,menuMinWidth:120,options:I,value:r.status,onChange:t=>void Z(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${oe[r.status]}`,renderTrigger:()=>(0,F.jsx)(a,{text:S[r.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${y[e.value]}`})})}):null,j.isVisible(`objectives`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Pe,{yearCycle:r.yearCycle,yearPlanId:e.id,objectives:t.objectives,values:r.objectiveIds??[],onChange:t=>void Z(e.id,{objectiveIds:t})})}):null,j.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:T(e.createdAt),muted:!e.createdAt})}):null,j.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:T(e.updatedAt),muted:!e.updatedAt})}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:u,children:(0,F.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,F.jsx)(ce,{label:`编辑 ${e.title}`,disabled:V,onClick:()=>Ue(e)}),(0,F.jsx)(we,{label:`删除 ${e.title}`,disabled:V,onClick:()=>B([e])})]})})]},e.id)}if(!e.ready)return(0,F.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,F.jsx)(ee,{children:fe()});if(n===null)return(0,F.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,F.jsx)(ee,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=P.length;return(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:t.yearPlans.length}),` 条`]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:L,onChange:e=>Le(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)(o,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ne,value:R,onChange:e=>ze(e)}),(0,F.jsx)(v,{fields:j.fields,isVisible:j.isVisible,onToggle:j.toggle}),(0,F.jsx)(`button`,{type:`button`,disabled:V||X.selectedIds.length===0,onClick:()=>B(t.yearPlans.filter(e=>X.selected[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:V||H,onClick:()=>{let e=Y[0];Xe(e?.key??`all`,e?Fe(e.key):void 0)},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:`+ 新建计划`})]})]}),(0,F.jsx)(Ce,{error:r,onDismiss:()=>x(``)}),(0,F.jsx)(`div`,{ref:qe,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,F.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:K.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:P.map(e=>(0,F.jsx)(`col`,{style:e.key===`select`?{width:te(!1)}:K.widthOf(e.key)?{width:K.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)(g,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible()}),(0,F.jsxs)(`th`,{className:`${p} text-xs text-stone-500`,style:Re,children:[`标题`,(0,F.jsx)(m,{...K.resizeProps(`title`)})]}),j.isVisible(`yearCycle`)?(0,F.jsxs)(`th`,{className:C,children:[`年度周期`,(0,F.jsx)(m,{...K.resizeProps(`yearCycle`)})]}):null,j.isVisible(`planType`)?(0,F.jsxs)(`th`,{className:C,children:[`计划类型`,(0,F.jsx)(m,{...K.resizeProps(`planType`)})]}):null,j.isVisible(`status`)?(0,F.jsxs)(`th`,{className:C,children:[`状态`,(0,F.jsx)(m,{...K.resizeProps(`status`)})]}):null,j.isVisible(`objectives`)?(0,F.jsxs)(`th`,{className:C,children:[`关联 Objective`,(0,F.jsx)(m,{...K.resizeProps(`objectives`)})]}):null,j.isVisible(`createdAt`)?(0,F.jsxs)(`th`,{className:C,children:[`创建日期`,(0,F.jsx)(m,{...K.resizeProps(`createdAt`)})]}):null,j.isVisible(`updatedAt`)?(0,F.jsxs)(`th`,{className:C,children:[`修改日期`,(0,F.jsx)(m,{...K.resizeProps(`updatedAt`)})]}):null,(0,F.jsx)(`th`,{"aria-hidden":`true`}),(0,F.jsx)(`th`,{className:c,children:`操作`})]})}),(0,F.jsx)(`tbody`,{children:q.length===0&&!W?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.yearPlans.length===0?`还没有年度计划`:`没有匹配的记录`})}):q.length===0&&W?Q():R===`none`?(0,F.jsxs)(F.Fragment,{children:[q.map((e,t)=>nt(e,t+1)),W?Q():(0,F.jsx)(ge,{colSpan:$,disabled:V||H,onClick:()=>Xe(`all`)})]}):Y.length===0?W?Q():null:Y.map(e=>{let t=!Be[e.key];return(0,F.jsxs)(N.Fragment,{children:[(0,F.jsx)(Se,{label:e.label,pill:e.pill,count:e.items.length,open:t,kind:`tag`,colSpan:$,onToggle:()=>Ve(t=>({...t,[e.key]:!t[e.key]}))}),t?(0,F.jsxs)(F.Fragment,{children:[e.items.map((e,t)=>nt(e,t+1)),W?.groupKey===e.key?Q():q.length>0?(0,F.jsx)(ge,{colSpan:$,disabled:V||H,onClick:()=>Xe(e.key,Fe(e.key))}):null]}):null]},e.key)})})]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`显示 `,q.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`关联 Objective:点击弹出胶囊框;在 Objective 选年度计划后自动带出`})]}),He?(0,F.jsx)(Ie,{open:!0,item:He,yearCycles:t.yearCycles,yearCycleMutate:A,objectives:t.objectives,planTypes:t.planTypes,planTypeMutate:k,isVisible:j.isVisible,onClose:()=>Ue(null),onSave:et}):null,(0,F.jsx)(i,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除年度计划`,message:z&&z.length>1?`删除选中的 ${z.length} 条计划?`:`删除「${z?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>B(null),onConfirm:()=>void tt()})]})}export{Le as default};
@@ -0,0 +1 @@
1
+ export{t as default}from"./PluginsPage.CMeKGbb1.js";
@@ -0,0 +1,17 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.C4rpn1Ix.js";import{a as i,l as a,o,r as s,t as c}from"./plugins.C0NrHGZv.js";import{f as l}from"./case-exec.BMNk9OyF.js";import{n as u,o as d}from"./view-prefs.8MPl3A7e.js";import{i as f,n as p,r as m,t as h}from"./dialog.DZHZCe_T.js";import{t as g}from"./jsx-runtime.DUg_B_vD.js";import{t as _}from"./OverflowHint.pvo2Xc8R.js";import{I as v,v as y}from"./pm.BXmOiFfW.js";import{showToast as b}from"./Toast.BO2NFckG.js";import"./settings.NTeTjmxg.js";import{at as x}from"./req-analysis.BAC_bd4R.js";import{F as S,I as C}from"./case-review.TdDs1WFM.js";import{s as w}from"./fs-tools.3F9MFrLf.js";import{s as T,w as E}from"./tasks.DEyD8pmq.js";import{l as D}from"./report-prompt.B9C4cv84.js";import{a as O}from"./test-stats.Cf3_L4wu.js";import{a as k}from"./ui-auto-prompt.l_EXfDs5.js";import{s as ee,y as A}from"./story-review.CCSxTgNL.js";var j=e(t(),1),M=`/__tb_memory`,N=3e3,P=`你可以使用跨会话长期记忆(本机五轨:user / memory / key / project / daily):
2
+ - 系统可能已在 <memory_snapshot> 注入用户档案、全局事实与项目关键记忆;优先参考。
3
+ - 查历史进展:memory_search 或 memory_read(project / daily 不自动注入)。
4
+ - 用户明确要求记住偏好/全局事实/项目约定:调用 memory_suggest(进待确认,确认后才注入)。
5
+ - 回合进展写入:memory_append 到 project 或 daily(无需确认)。
6
+ - 不要把寒暄、一次性闲聊写入记忆。`,te=[{type:`function`,function:{name:`memory_search`,description:`在五轨记忆中按关键词搜索条目。`,parameters:{type:`object`,properties:{query:{type:`string`,description:`搜索关键词`}},required:[`query`]}}},{type:`function`,function:{name:`memory_read`,description:`读取某一轨的全部条目。target: user|memory|key|project|daily`,parameters:{type:`object`,properties:{target:{type:`string`,enum:[`user`,`memory`,`key`,`project`,`daily`]}},required:[`target`]}}},{type:`function`,function:{name:`memory_suggest`,description:`提议写入用户档案/全局事实/项目关键(user|memory|key)。写入待确认队列,用户采纳后才生效。`,parameters:{type:`object`,properties:{target:{type:`string`,enum:[`user`,`memory`,`key`]},content:{type:`string`,description:`要记住的事实(简洁)`},reason:{type:`string`,description:`为何值得记住`}},required:[`target`,`content`]}}},{type:`function`,function:{name:`memory_append`,description:`向项目日志或每日日志追加进展(直写,无需确认)。`,parameters:{type:`object`,properties:{target:{type:`string`,enum:[`project`,`daily`]},content:{type:`string`}},required:[`target`,`content`]}}}];async function F(e,t={},n){let r=await fetch(`${M}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:n}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);return i}async function I(e){let t=await fetch(`${M}${e}`),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`HTTP ${t.status}`);return n}async function L(){try{let e=await fetch(`${M}/health`,{signal:AbortSignal.timeout(1500)});return e.ok?await e.json():null}catch{return null}}async function R(){try{return(await I(`/config`)).config??null}catch{return null}}async function z(e){return(await F(`/config`,e)).config}async function B(e=``){try{let t=await F(`/snapshot`,{cwd:e},AbortSignal.timeout(N));return typeof t.text==`string`?t.text:``}catch{return``}}async function ne(e=``,t=`all`){let n=await F(`/tracks`,{cwd:e,target:t});return t===`all`?{tracks:n.tracks??{},projectId:n.projectId}:{tracks:{[t]:{entries:n.entries??[],path:n.path,target:t}},projectId:n.projectId}}async function V(){return(await I(`/suggestions`)).suggestions??[]}async function re(e){await F(`/suggestions/approve`,{id:e})}async function ie(e){await F(`/suggestions/reject`,{id:e})}async function H(e,t,n=``){await F(`/archive`,{target:e,index:t,cwd:n})}async function U(e,t,n=``){await F(`/delete`,{target:e,index:t,cwd:n})}async function ae(e,t,n=``){await F(`/archives/delete`,{target:e,index:t,cwd:n})}async function oe(e,t=``){return(await F(`/archives`,{target:e,cwd:t})).entries??[]}async function se(e,t,n=``){await F(`/promote`,{target:e,index:t,cwd:n})}async function ce(e,t,n=``){await F(`/manual-add`,{target:e,content:t,cwd:n})}async function le(e,t){let n=t?.cwd??``,r=t?.maxChars??8e3;try{let e=await B(n);return e.length>r&&(e=`${e.slice(0,r-20)}\n…\n</memory_snapshot>`),{context:e,hits:[]}}catch{return{context:``,hits:[]}}}var ue=/记住|记下|别忘了|以后都|请记得|我喜欢|我的偏好|默认用|默认显示|默认城市|约定|不要再|以后默认/;async function de(e,t=``){let n=e.trim();if(!n||n.length<4||!ue.test(n))return!1;let r=n.length>400?`${n.slice(0,400)}…`:n;try{return await F(`/suggest`,{cwd:t,target:/偏好|喜欢|习惯|称呼|默认/.test(n)?`user`:`memory`,content:r,reason:`用户话术触发自动沉淀`}),!0}catch{return!1}}async function fe(e,t,n=``){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}try{switch(e){case`memory_search`:{let e=await F(`/search`,{query:r.query,cwd:n});return JSON.stringify(e)}case`memory_read`:{let e=await F(`/tracks`,{target:r.target,cwd:n});return JSON.stringify(e)}case`memory_suggest`:{let e=await F(`/suggest`,{target:r.target,content:r.content,reason:r.reason,cwd:n});return JSON.stringify(e)}case`memory_append`:{let e=await F(`/append`,{target:r.target,content:r.content,cwd:n});return JSON.stringify(e)}case`memory_create_entities`:case`memory_add_observations`:{let e=Array.isArray(r.entities)?r.entities:[],t=Array.isArray(r.observations)?r.observations:[],i=[];for(let t of e){let e=t,n=(e.observations??[]).join(`;`);i.push(n?`${e.name}: ${n}`:String(e.name??``))}for(let e of t){let t=e;i.push(`${t.entityName}: ${(t.contents??[]).join(`;`)}`)}let a=i.filter(Boolean).join(`
7
+ `);if(!a)return JSON.stringify({error:`empty`});let o=await F(`/suggest`,{target:`memory`,content:a,reason:`兼容旧工具调用`,cwd:n});return JSON.stringify(o)}case`memory_create_relations`:return JSON.stringify({ok:!0,skipped:!0,note:`五轨模式不使用关系图`});case`memory_open_nodes`:{let e=await F(`/search`,{query:Array.isArray(r.names)?r.names.join(` `):``,cwd:n});return JSON.stringify(e)}default:return JSON.stringify({error:`unknown tool: ${e}`})}}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}async function pe(e){}var W=`/__tb_mcp`,me="你可以使用 MCP 工具(名称形如 mcp__服务器__工具名)。它们来自当前数据空间 `.lantern/local/mcp.json` 配置的外部 MCP 服务。",G={name:`tencent-docs`,transport:`http`,url:`https://docs.qq.com/openapi/mcp`};function K(e){let t=e.name.trim()||`mcp`,n=e.transport===`stdio`?{command:e.command||``,args:e.args||[],...e.env&&Object.keys(e.env).length?{env:e.env}:{env:{}}}:{url:e.url||``,...e.headers&&Object.keys(e.headers).length?{headers:e.headers}:{}};return`${JSON.stringify({mcpServers:{[t]:n}},null,2)}\n`}function q(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`JSON 无法解析`}}if(!t||typeof t!=`object`)return{ok:!1,error:`JSON 必须是对象`};let n=t,r=[];if(n.mcpServers&&typeof n.mcpServers==`object`&&!Array.isArray(n.mcpServers))for(let[e,t]of Object.entries(n.mcpServers))t&&typeof t==`object`&&r.push({name:e,...t});else if(Array.isArray(n.servers))r=n.servers.filter(e=>e&&typeof e==`object`);else if(Array.isArray(t))r=t.filter(e=>e&&typeof e==`object`);else if(`command`in n||`url`in n||`transport`in n)r=[n];else return{ok:!1,error:`未识别的格式,请使用 mcpServers 或 servers[]`};let i=[];for(let e of r){let t=String(e.name||``).trim();if(!t)return{ok:!1,error:`缺少 name`};let n=String(e.transport||(e.url?`http`:`stdio`)).trim().toLowerCase();if(n===`stdio`||!e.url&&e.command){let n=String(e.command||``).trim();if(!n)return{ok:!1,error:`「${t}」缺少 command`};i.push({name:t,transport:`stdio`,command:n,args:Array.isArray(e.args)?e.args.map(e=>String(e)):[],env:e.env&&typeof e.env==`object`?Object.fromEntries(Object.entries(e.env).filter(([,e])=>typeof e==`string`)):void 0})}else if(n===`http`||n===`streamable-http`||n===`sse`){let n=String(e.url||``).trim();if(!n)return{ok:!1,error:`「${t}」缺少 url`};i.push({name:t,transport:`http`,url:n,headers:e.headers&&typeof e.headers==`object`?Object.fromEntries(Object.entries(e.headers).filter(([,e])=>typeof e==`string`)):void 0})}else return{ok:!1,error:`「${t}」不支持的 transport`}}return i.length?{ok:!0,servers:i}:{ok:!1,error:`没有有效的服务器配置`}}async function J(){try{let e=await fetch(`${W}/health`,{signal:AbortSignal.timeout(2e3)});return e.ok?await e.json():null}catch{return null}}async function he(){try{let e=await fetch(`${W}/servers`,{signal:AbortSignal.timeout(2e4)}),t=await e.json();return e.ok?{ok:!0,path:t.path,servers:Array.isArray(t.servers)?t.servers:[],connected:t.connected,errors:t.errors}:{ok:!1,servers:[],error:t.error||`HTTP ${e.status}`}}catch(e){return{ok:!1,servers:[],error:e instanceof Error?e.message:String(e)}}}async function ge(e,t){try{let n=await fetch(`${W}/servers`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({server:e,previousName:t}),signal:AbortSignal.timeout(3e4)}),r=await n.json();return n.ok?{ok:!0,path:r.path,servers:Array.isArray(r.servers)?r.servers:[]}:{ok:!1,servers:[],error:r.error||`HTTP ${n.status}`}}catch(e){return{ok:!1,servers:[],error:e instanceof Error?e.message:String(e)}}}async function _e(e){try{let t=await fetch(`${W}/servers`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e}),signal:AbortSignal.timeout(2e4)}),n=await t.json();return t.ok?{ok:!0,path:n.path,servers:Array.isArray(n.servers)?n.servers:[]}:{ok:!1,servers:[],error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,servers:[],error:e instanceof Error?e.message:String(e)}}}async function ve(e){try{let t=await fetch(`${W}/reload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{name:e}:{}),signal:AbortSignal.timeout(3e4)}),n=await t.json();return t.ok?{ok:!0,connected:n.connected,errors:n.errors}:{ok:!1,error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function ye(){try{let e=await fetch(`${W}/tools`,{signal:AbortSignal.timeout(15e3)});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.tools)?t.tools:[]}catch{return[]}}function be(e){return e.map(e=>({type:`function`,function:{name:e.name,description:e.description||e.name,parameters:e.inputSchema&&typeof e.inputSchema==`object`?e.inputSchema:{type:`object`,properties:{}}}}))}async function xe(e,t){let n={};try{n=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}try{let t=await(await fetch(`${W}/call`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,arguments:n}),signal:AbortSignal.timeout(6e4)})).json();return t.error&&!t.text?JSON.stringify({error:t.error}):t.text??JSON.stringify(t,null,2)}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}var Y=g(),Se=`mcp.list.cache`;function Ce(){try{let e=sessionStorage.getItem(r(Se));if(!e)return null;let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function we(e){try{sessionStorage.setItem(r(Se),JSON.stringify(e))}catch{}}function Te(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
8
+ `):``}function Ee(e){let t={};for(let n of e.split(`
9
+ `)){let e=n.trim();if(!e||e.startsWith(`#`))continue;let r=e.indexOf(`=`);r<=0||(t[e.slice(0,r).trim()]=e.slice(r+1).trim())}return Object.keys(t).length?t:void 0}function X(e){let t={};return e.authHeader.trim()&&(t.Authorization=e.authHeader.trim()),{name:e.name.trim()||(e.mode===`tencent`?G.name:`mcp`),transport:e.transport,command:e.command,args:e.argsText.trim().split(/\s+/).filter(Boolean),env:Ee(e.envText),url:e.url,headers:Object.keys(t).length?t:void 0}}function Z(e=`create`){let t=e===`tencent`?{mode:e,view:`form`,name:G.name,transport:`http`,url:G.url,command:``,argsText:``,authHeader:``,envText:``,jsonText:``}:{mode:e,view:`form`,name:``,transport:`http`,url:``,command:``,argsText:``,authHeader:``,envText:``,jsonText:``};return{...t,jsonText:K(X(t))}}function De(e){let t={mode:`edit`,view:`form`,previousName:e.name,name:e.name,transport:e.transport===`stdio`?`stdio`:`http`,url:e.url||``,command:e.command||``,argsText:Array.isArray(e.args)?e.args.join(` `):``,authHeader:e.headers?.Authorization||e.headers?.authorization||``,envText:Te(e.env),jsonText:``};return t.jsonText=K(X(t)),t}function Oe(e,t){return{...e,name:t.name,transport:t.transport,command:t.command||``,argsText:Array.isArray(t.args)?t.args.join(` `):``,envText:Te(t.env),url:t.url||``,authHeader:t.headers?.Authorization||t.headers?.authorization||``}}function ke({onServersChange:e}){let[t,n]=(0,j.useState)(()=>Ce()),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),[d,g]=(0,j.useState)(null),[_,v]=(0,j.useState)(null),y=(0,j.useRef)(null);_&&(y.current=_);let x=_??y.current,[S,C]=(0,j.useState)(null),w=(0,j.useRef)(null);S&&(w.current=S);let T=S??w.current,E=(0,j.useRef)(!1),D=(0,j.useCallback)(async()=>{E.current&&c(!0);try{let e=await he();n(e.servers),we(e.servers),i(e.path||``),o(e.errors||(e.error?[e.error]:[])),E.current=!0}finally{c(!1)}},[]);(0,j.useEffect)(()=>{D()},[D]);function O(e){if(!_||_.view===e)return;if(e===`json`){v({..._,view:`json`,jsonText:K(X(_))});return}let t=q(_.jsonText);t.ok?t.servers.length>1&&_.mode===`edit`?b(`编辑时 JSON 里请只保留一台服务器`,`error`):v({...Oe(_,t.servers[0]),view:`form`,jsonText:_.jsonText}):b(t.error,`error`)}async function k(){if(_){u(!0);try{let e;if(_.view===`json`){let t=q(_.jsonText);if(!t.ok){b(t.error,`error`);return}if(t.servers.length>1&&_.mode===`edit`){b(`编辑时 JSON 里请只保留一台服务器`,`error`);return}e=t.servers}else{let t=X(_),n=t.name.trim();if(!n){b(`请填写名称`,`error`);return}if(_.mode===`tencent`&&!_.authHeader.trim()){b(`请粘贴腾讯文档 MCP Token`,`error`);return}if(t.transport===`stdio`&&!t.command.trim()){b(`stdio 需要填写 command`,`error`);return}if(t.transport===`http`&&!t.url.trim()){b(`HTTP 需要填写 URL`,`error`);return}e=[t.transport===`stdio`?{name:n,transport:`stdio`,command:t.command.trim(),args:t.args,env:t.env}:{name:n,transport:`http`,url:t.url.trim(),headers:t.headers}]}let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=await ge(r,_.mode===`edit`&&n===0?_.previousName:void 0);if(!i.ok){t=i.error||`保存失败`;break}}if(t){b(t,`error`),await D();return}v(null),b(e.length>1?`已保存 ${e.length} 台并重新连接`:`已保存并重新连接`,`success`),await D()}finally{u(!1)}}}async function ee(e){u(!0);try{let t=await _e(e);if(!t.ok){b(t.error||`删除失败`,`error`);return}n(t=>{let n=(t??[]).filter(t=>t.name!==e);return we(n),n}),C(null),b(`已删除`,`success`),await D()}finally{u(!1)}}async function A(e){e?g(e):u(!0);try{let t=await ve(e);if(!t.ok){b(t.error||`连接失败`,`error`);return}let n=t.errors?.find(t=>!e||t.startsWith(`${e}:`));if(n)b(n,`error`);else if(e){let n=t.connected?.includes(e);b(n?`「${e}」已连接`:`「${e}」未连上`,n?`success`:`error`)}else t.errors?.length?b(t.errors[0],`error`):b(e?`已重新连接`:`刷新成功`,`success`);await D()}finally{g(null),u(!1)}}let M=(0,j.useMemo)(()=>{if(t===null)return[{name:G.name,displayName:`腾讯文档`,transport:`http`,url:G.url,booting:!0,connected:!1,toolCount:0}];let e=t.some(e=>e.name===G.name),n=t.filter(e=>e.name!==G.name);return[e?{...t.find(e=>e.name===G.name),displayName:`腾讯文档`}:{name:G.name,displayName:`腾讯文档`,transport:`http`,url:G.url,pending:!0,connected:!1,toolCount:0},...n]},[t]);return(0,j.useEffect)(()=>{e?.(M.length)},[M.length,e]),(0,Y.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l||s,onClick:()=>v(Z(`create`)),className:`h-8 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white hover:bg-[#3566cc] disabled:opacity-60`,children:`添加 MCP`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l||s,onClick:()=>void A(),className:`h-8 rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-600 hover:bg-stone-50 disabled:opacity-60`,children:s&&!d?`刷新中…`:`刷新连接`}),r?(0,Y.jsx)(`span`,{className:`ml-auto max-w-full truncate font-mono text-[11px] text-stone-400`,title:r,children:r}):null]}),a.length?(0,Y.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800`,children:a.map(e=>(0,Y.jsx)(`p`,{children:e},e))}):null,(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-stone-200 bg-white`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-[640px] border-collapse text-left text-[13px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-stone-100 bg-stone-50/80 text-[12px] text-stone-500`,children:[(0,Y.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`名称`}),(0,Y.jsx)(`th`,{className:`w-20 px-3 py-2.5 font-medium`,children:`类型`}),(0,Y.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`地址 / 命令`}),(0,Y.jsx)(`th`,{className:`w-16 px-3 py-2.5 font-medium tabular-nums`,children:`工具`}),(0,Y.jsx)(`th`,{className:`w-24 px-3 py-2.5 font-medium`,children:`状态`}),(0,Y.jsx)(`th`,{className:`w-32 px-3 py-2.5 font-medium text-right`,children:`操作`})]})}),(0,Y.jsx)(`tbody`,{children:M.map(e=>{let t=e.transport===`stdio`?[e.command,...e.args||[]].filter(Boolean).join(` `):e.url||``;return(0,Y.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-b-0 hover:bg-stone-50/70`,children:[(0,Y.jsxs)(`td`,{className:`max-w-[10rem] px-3 py-2.5`,children:[(0,Y.jsx)(`div`,{className:`truncate font-medium text-stone-900`,children:e.displayName||e.name}),(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-stone-400`,children:[e.name,e.booting?``:e.pending?` · 待配置`:e.hasSecrets?` · 已配置密钥`:``]})]}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Y.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] uppercase text-stone-400`,children:e.transport})}),(0,Y.jsx)(`td`,{className:`max-w-[18rem] px-3 py-2.5`,children:(0,Y.jsx)(`span`,{className:`block truncate font-mono text-[12px] text-stone-500`,title:t,children:t||`—`})}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5 tabular-nums text-stone-600`,children:e.pending||e.booting?`—`:e.toolCount??0}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5`,children:e.booting?(0,Y.jsx)(`span`,{className:`rounded-md bg-stone-100 px-2 py-0.5 text-[12px] text-stone-500`,children:`同步中…`}):e.pending?(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>v(Z(`tencent`)),className:`rounded-md bg-amber-50 px-2 py-0.5 text-[12px] text-amber-700 hover:bg-amber-100`,children:`需配置`}):(0,Y.jsx)(`button`,{type:`button`,disabled:l||d!==null||s,onClick:()=>void A(e.name),className:`rounded-md px-2 py-0.5 text-[12px] transition-colors ${d===e.name?`bg-sky-50 text-sky-700`:e.connected?`bg-emerald-50 text-emerald-700 hover:bg-emerald-100`:`bg-stone-100 text-stone-600 hover:bg-[#4176e6]/10 hover:text-[#4176e6]`} disabled:opacity-60`,children:d===e.name?`连接中…`:e.connected?`已连接`:`连接`})}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l||!!e.booting,onClick:()=>v(e.pending?Z(`tencent`):De(e)),className:`text-[13px] text-[#4176e6] hover:underline disabled:opacity-60`,children:e.pending?`配置`:`编辑`}),e.pending||e.booting?null:(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>C(e.name),className:`text-[13px] text-rose-600 hover:underline disabled:opacity-60`,children:`删除`})]})})]},e.name)})})]})}),(0,Y.jsxs)(m,{open:!!_,onClose:()=>{l||v(null)},className:`relative z-110`,children:[(0,Y.jsx)(h,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Y.jsx)(f,{transition:!0,className:`tw-dialog-panel-anim flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:x?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(p,{className:`text-[15px] font-semibold text-stone-900`,children:x.mode===`tencent`?`配置腾讯文档 MCP`:x.mode===`edit`?`编辑 MCP`:`添加 MCP`}),x.mode===`tencent`?(0,Y.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-5 text-stone-500`,children:`在腾讯文档空间菜单「使用 MCP」复制 Token,粘贴到下方。Token 约一年有效,有日调用限额。`}):x.view===`json`?(0,Y.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-5 text-stone-500`,children:`可粘贴 Trae / Claude Desktop 的 mcpServers JSON,也支持灵光 servers[]。`}):null]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-pills shrink-0`,role:`group`,"aria-label":`编辑方式`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.view===`form`,onClick:()=>O(`form`),children:`表单`}),(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.view===`json`,onClick:()=>O(`json`),children:`JSON`})]})]}),x.view===`json`?(0,Y.jsx)(`div`,{className:`mt-4 min-h-0 flex-1`,children:(0,Y.jsx)(`textarea`,{value:x.jsonText,onChange:e=>_&&v({..._,jsonText:e.target.value}),spellCheck:!1,className:`h-72 w-full resize-y rounded-lg border border-stone-200 bg-stone-50 px-3 py-2 font-mono text-[12px] leading-5 text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`{
10
+ "mcpServers": {
11
+ "demo": {
12
+ "command": "npx",
13
+ "args": ["-y", "some-mcp-server"],
14
+ "env": {}
15
+ }
16
+ }
17
+ }`})}):(0,Y.jsxs)(`div`,{className:`mt-4 space-y-3 overflow-y-auto`,children:[(0,Y.jsx)(Q,{label:`名称`,children:(0,Y.jsx)(`input`,{value:x.name,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,name:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`tencent-docs`})}),x.mode===`tencent`?null:(0,Y.jsx)(Q,{label:`传输`,children:(0,Y.jsx)(`div`,{className:`flex gap-2`,children:[`http`,`stdio`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.transport===e,onClick:()=>_&&v({..._,transport:e}),className:`h-8 rounded-md border px-3 text-[12px] ${x.transport===e?`border-[#4176e6] bg-[#4176e6]/10 text-[#4176e6]`:`border-stone-200 text-stone-600`}`,children:e},e))})}),x.transport===`http`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`URL`,children:(0,Y.jsx)(`input`,{value:x.url,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,url:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`https://…`})}),(0,Y.jsx)(Q,{label:x.mode===`tencent`?`MCP Token(Authorization)`:`Authorization`,children:(0,Y.jsx)(`input`,{value:x.authHeader,onChange:e=>_&&v({..._,authHeader:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:x.mode===`edit`&&x.authHeader.startsWith(`••••`)?`留脱敏值表示不改密钥`:`粘贴 Token`,autoComplete:`off`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`command`,children:(0,Y.jsx)(`input`,{value:x.command,onChange:e=>_&&v({..._,command:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`npx`})}),(0,Y.jsx)(Q,{label:`args(空格分隔)`,children:(0,Y.jsx)(`input`,{value:x.argsText,onChange:e=>_&&v({..._,argsText:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`-y some-mcp-server`})}),(0,Y.jsx)(Q,{label:`env(每行 KEY=VALUE)`,children:(0,Y.jsx)(`textarea`,{value:x.envText,onChange:e=>_&&v({..._,envText:e.target.value}),spellCheck:!1,rows:3,className:`w-full resize-y rounded-lg border border-stone-200 bg-white px-3 py-2 font-mono text-[12px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`TAVILY_API_KEY=…`})})]})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>v(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void k(),className:`h-9 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:l?`保存中…`:`保存`})]})]}):null})})]}),(0,Y.jsxs)(m,{open:!!S,onClose:()=>{l||C(null)},className:`relative z-110`,children:[(0,Y.jsx)(h,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Y.jsxs)(f,{transition:!0,className:`tw-dialog-panel-anim w-full max-w-sm rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Y.jsx)(p,{className:`text-[15px] font-semibold text-stone-900`,children:`删除 MCP?`}),(0,Y.jsxs)(`p`,{className:`mt-2 text-[13px] text-stone-500`,children:[`将从当前空间配置中移除「`,T,`」,对话里对应工具会立即消失。`]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>C(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l||!T,onClick:()=>T&&void ee(T),className:`h-9 rounded-lg bg-rose-600 px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:`删除`})]})]})})]})]})}function Q({label:e,children:t}){return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-[12px] text-stone-500`,children:e}),t]})}var Ae=[`extensions`,`mcp`],je=[{id:`extensions`,label:`扩展插件`},{id:`mcp`,label:`MCP`}],Me={tasks:`侧栏「任务管理」按状态列出任务;工作台可直接增删改`,todos:`侧栏「待办事项」按状态 / 紧急程度分组;工作台可直接增删改`,projects:`侧栏「项目列表」管理项目并汇总迭代 / 需求 / 缺陷;工作台可直接增删改`,iterations:`侧栏「迭代管理」按项目维护迭代周期、进度与逾期;工作台可直接增删改`,pmRequirements:`侧栏「需求管理」维护需求编号 / 优先级 / 状态与验收标准;工作台可直接增删改`,bugs:`侧栏「缺陷管理」记录严重程度 / 重现步骤与修复状态;工作台可直接增删改`,testStats:`侧栏「测试统计」按维度记录每天的统计数量`,caseExec:`侧栏「用例执行统计」按项目记录用例执行情况`,dashboard:`侧栏「仪表盘」聚合待办 / 任务 / 测试统计;卡片可拖动排序、拖角改宽高,右上角编辑组件`},$={tasks:T,todos:E,projects:y,iterations:y,pmRequirements:y,bugs:y,testStats:O,caseExec:l,dashboard:E},Ne=[{id:`all`,label:`全部`},{id:`on`,label:`已启用`},{id:`off`,label:`未启用`}],Pe=s();function Fe({embedded:e=!1}){let[t,r]=(0,j.useState)(()=>u(`plugins.pageTab`,Ae,`extensions`)),[s,l]=(0,j.useState)(()=>i()),[f,p]=(0,j.useState)(null),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[y,T]=(0,j.useState)(!0),[E,O]=(0,j.useState)(``),[M,N]=(0,j.useState)(`all`),[P,te]=(0,j.useState)(null),[F,I]=(0,j.useState)({}),[R,z]=(0,j.useState)(null);function B(e){r(e),d(`plugins.pageTab`,e)}async function ne(){T(!0);try{let[e,t,n,r,i,a,o,s,c,l,u]=await Promise.all([L(),w(),$.tasks(),$.todos(),$.projects(),$.iterations(),$.pmRequirements(),$.bugs(),$.testStats(),$.caseExec(),$.dashboard()]);p(e),h(t),_({tasks:n,todos:r,projects:i,iterations:a,pmRequirements:o,bugs:s,testStats:c,caseExec:l,dashboard:u})}finally{T(!1)}}(0,j.useEffect)(()=>{let e=o(e=>l(e));return n().then(()=>{l(i()),ne()}),J().then(e=>{e?.ok&&z(e.serversConfigured??0)}),()=>{e()}},[]),(0,j.useEffect)(()=>{t===`mcp`&&J().then(e=>{e?.ok&&z(e.serversConfigured??0)})},[t]);function V(e){if(e===`cases`)return{available:!0,detail:`侧栏「用例管理」浏览与维护本空间用例库`};if(e===`caseGen`)return s.cases?{available:!0,detail:`对话输入 / 打开配置面板,生成用例并写入用例库`}:{available:!1,detail:`需先启用「用例管理」,生成结果才能写入用例列表`};if(e===`prompts`)return{available:!0,detail:`侧栏「提示词管理」浏览与维护本空间提示词库`};if(e===`promptGen`)return s.prompts?{available:!0,detail:`对话输入 / 打开配置面板,生成提示词并写入提示词库`}:{available:!1,detail:`需先启用「提示词管理」,生成结果才能写入提示词列表`};if(e===`knowledgeLib`)return{available:!0,detail:`侧栏「知识库管理」浏览与维护本空间知识库`};if(e===`requirements`)return{available:!0,detail:`侧栏「需求文档库」浏览与维护本空间需求文档`};if(e===`templates`)return{available:!0,detail:`侧栏「测试模板库」浏览与维护本空间用例模板`};if(e===`reports`)return{available:!0,detail:`侧栏「工作汇报」按日报 / 周报 / 月报列出汇报文件`};if(e===`tasks`||e===`todos`||e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`||e===`testStats`||e===`caseExec`||e===`dashboard`){let t=g?.[e];return t===void 0?{available:y?null:!1,detail:y?`探测中…`:`需本地服务`}:t?{available:!0,detail:Me[e]}:{available:!1,detail:`需本地服务(npm run dev / lantern web)`}}return e===`knowledgeGen`?s.knowledgeLib?{available:!0,detail:`对话输入 / 打开配置面板,生成文档并写入知识库`}:{available:!1,detail:`需先启用「知识库管理」,生成结果才能写入知识库列表`}:e===`memory`?y&&f===null?{available:null,detail:`探测中…`}:f?.ok?{available:!0,detail:`已连接 · ${f.entryCount??f.entityCount??0} 条记忆 / 待确认 ${f.suggestionCount??0}`}:{available:!1,detail:`本地记忆服务未就绪`}:e===`knowledge`?{available:!0,detail:`对话输入 @ 可引用知识库与模板文档`}:e===`pluginDev`?y&&m===null?{available:null,detail:`探测中…`}:m?.ok?{available:!0,detail:`固定提示词开发扩展插件;先评估确认,再改代码并入「扩展插件」`}:{available:!1,detail:`需本地文件服务:开发要读写项目源码`}:{available:!1,detail:`未知`}}function re(e){let t=a(e,!s[e]),n=!!t[e],r=c.find(t=>t.id===e)?.name??e;l(t),b(n?`已启用「${r}」`:`已停用「${r}」`,`success`),e===`reports`&&D(!!t.reports).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`工作汇报提示词没生成成功:${t}`,`error`)}),e===`uiAuto`&&k(!!t.uiAuto).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`UI自动化测试提示词没生成成功:${t}`,`error`)}),e===`reqAnalysis`&&x(!!t.reqAnalysis).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`需求分析提示词没生成成功:${t}`,`error`)}),e===`storyReview`&&ee(!!t.storyReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用户故事审查提示词没生成成功:${t}`,`error`)}),e===`testPoints`&&A(!!t.testPoints).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`测试点生成提示词没生成成功:${t}`,`error`)}),(e===`caseReview`||e===`cases`)&&C(!!t.caseReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用例质量评审提示词没生成成功:${t}`,`error`)}),(e===`caseBlindspot`||e===`cases`)&&S(!!t.caseBlindspot).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`场景遗漏补全提示词没生成成功:${t}`,`error`)}),(e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`)&&t[e]&&v().catch(e=>{console.warn(`[pm] 同步项目管理数据目录失败`,e)})}let ie=(0,j.useMemo)(()=>c.filter(e=>s[e.id]).length,[s]),H=E.trim().toLowerCase(),U=(0,j.useMemo)(()=>Pe.map(e=>({...e,items:e.items.filter(e=>{let t=!H||e.name.toLowerCase().includes(H)||e.id.toLowerCase().includes(H)||e.description.toLowerCase().includes(H),n=M===`all`||(M===`on`?s[e.id]:!s[e.id]);return t&&n})})).filter(e=>e.items.length>0),[s,H,M]);return(0,Y.jsx)(`div`,{className:`tw-plugins-page overflow-y-auto ${e?`h-full min-h-0 flex-1`:`min-h-screen`}`,children:(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-[1320px] ${e?`px-4 py-5`:`px-4 py-7 sm:px-5`}`,children:[(0,Y.jsxs)(`header`,{className:`tw-plugins-head`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-[20px] font-semibold tracking-tight text-stone-900`,children:`我的插件`}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-6 text-stone-500`,children:t===`extensions`?(0,Y.jsxs)(Y.Fragment,{children:[`按用途分组的扩展能力,开关保存在本机;会话 / 全局内置能力在`,(0,Y.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 text-[12px] text-stone-600`,children:`设置 → 内置插件`}),`里查看。`]}):(0,Y.jsxs)(Y.Fragment,{children:[`管理当前数据空间的外接 MCP(写入`,(0,Y.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 font-mono text-[12px] text-stone-600`,children:`.lantern/local/mcp.json`}),`),对话里会出现对应工具。`]})})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stats`,"aria-label":`插件概览`,children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:c.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个插件`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num is-on`,children:ie}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`已启用`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:Pe.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个分类`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:R??`—`}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`MCP`})]})]})]}),(0,Y.jsx)(`div`,{className:`tw-plugins-tabs`,role:`tablist`,"aria-label":`插件页分类`,children:je.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:t===e.id?`is-active`:void 0,onClick:()=>B(e.id),children:[e.label,(0,Y.jsx)(`span`,{className:`tw-plugins-tab-count`,children:e.id===`extensions`?c.length:R??`—`})]},e.id))}),(0,Y.jsx)(`div`,{className:`tw-plugins-tab-panel`,children:t===`mcp`?(0,Y.jsx)(ke,{onServersChange:z}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-toolbar`,children:[(0,Y.jsxs)(`label`,{className:`relative block w-full max-w-72`,children:[(0,Y.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,Y.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,Y.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,Y.jsx)(`input`,{value:E,onChange:e=>O(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-9 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-[13px] text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]}),(0,Y.jsx)(`div`,{className:`tw-plugins-pills`,role:`group`,"aria-label":`按状态筛选`,children:Ne.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":M===e.id,onClick:()=>N(e.id),children:e.label},e.id))})]}),(0,Y.jsxs)(`div`,{className:`mt-4 space-y-6`,children:[U.map(e=>{let t=!!F[e.category],n=e.items.filter(e=>s[e.id]).length;return(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":!t,onClick:()=>I(n=>({...n,[e.category]:!t})),className:`mb-2.5 flex w-full items-center gap-2 text-left`,children:[(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform ${t?`-rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-stone-800`,children:e.category}),(0,Y.jsxs)(`span`,{className:`rounded-full bg-stone-100 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-500`,children:[n,`/`,e.items.length]}),(0,Y.jsx)(`span`,{className:`ml-1 h-px flex-1 bg-stone-200/70`,"aria-hidden":`true`})]}),t?null:(0,Y.jsx)(`ul`,{className:`tw-anim-list tw-plugin-grid`,children:e.items.map(e=>{let t=s[e.id],n=V(e.id),r=P===`ext:${e.id}`;return(0,Y.jsx)(`li`,{className:`relative z-0 min-w-0 overflow-visible hover:z-40 focus-within:z-40${r?` z-40`:``}`,children:(0,Y.jsx)(Ie,{open:r,onToggleOpen:()=>te(r?null:`ext:${e.id}`),title:e.name,subtitle:e.description,badge:(0,Y.jsxs)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-400`,children:[`v`,e.version]}),trailing:e.alwaysOn?(0,Y.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] text-stone-500`,children:`内置`}):(0,Y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`${t?`关闭`:`打开`} ${e.name}`,onClick:()=>re(e.id),className:`tw-toggle`,children:(0,Y.jsx)(`span`,{className:`tw-toggle-knob`})}),fullName:`@lh-plugins/${e.id}`,configLabel:e.alwaysOn?`内置常开`:t?`已启用`:`未启用`,runLabel:t&&n.available===!0?`运行中`:`已停用`,extra:n.detail})},e.id)})})]},e.category)}),U.length?null:(0,Y.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-white/60 px-4 py-12 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-stone-600`,children:`没有匹配的插件`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`换个关键词,或把状态筛选切回「全部」。`})]})]})]})},t)]})})}function Ie(e){let{open:t,onToggleOpen:n,title:r,subtitle:i,badge:a,trailing:o,fullName:s,configLabel:c,runLabel:l,extra:u}=e;return(0,Y.jsxs)(`div`,{className:`tw-plugin-card group/card relative z-0 self-start w-full overflow-visible rounded-xl border bg-white transition-colors hover:z-40 focus-within:z-40 ${t?`z-40 border-[#4176e6]/50 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,Y.jsxs)(`div`,{className:`relative flex h-17 items-start gap-3 overflow-visible px-4 py-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`relative h-full min-w-0 flex-1 overflow-visible text-left outline-none focus:outline-none`,"aria-expanded":t,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-medium text-stone-900`,children:r}),a,(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-300 ease-out ${t?`rotate-180`:``}`})]}),(0,Y.jsx)(_,{text:i,className:`mt-1 block min-w-0 truncate text-[13px] leading-5 text-stone-500`,disabled:t})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 self-start pt-0.5`,children:o})]}),(0,Y.jsx)(`div`,{className:`tw-collapse ${t?`is-open`:``}`,"aria-hidden":!t,children:(0,Y.jsx)(`div`,{className:`tw-collapse-inner`,children:(0,Y.jsx)(`div`,{className:`border-t border-stone-100 px-4 pb-3 pt-0`,children:(0,Y.jsxs)(`dl`,{className:`mt-2.5 space-y-1.5 text-[13px]`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`完整名称`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px] text-stone-700`,children:s})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`配置状态`}),(0,Y.jsx)(`dd`,{className:`text-stone-700`,children:c})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`运行状态`}),(0,Y.jsx)(`dd`,{className:l===`运行中`?`text-emerald-600`:`text-stone-500`,children:l})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`简介`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:i})]}),u?(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`说明`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:u})]}):null]})})})})]})}function Le({className:e}){return(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:e,"aria-hidden":!0,children:(0,Y.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}export{fe as C,ie as S,V as _,xe as a,se as b,re as c,U as d,pe as f,ne as g,L as h,be as i,H as l,R as m,me as n,P as o,oe as p,ye as r,te as s,Fe as t,ae as u,ce as v,z as w,le as x,de as y};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.C4rpn1Ix.js";import{s as r}from"./plugins.C0NrHGZv.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{n as te,t as ne}from"./DocsPager.D0TMvJ67.js";import{t as a}from"./SelectDropdown.Dmk5n225.js";import{A as re,D as ie,N as ae,P as oe,R as o,b as se,g as ce,h as le,i as ue,j as de,m as s,n as fe,p as pe,r as c,t as l,x as me,z as he}from"./pm.BXmOiFfW.js";import{A as ge,C as _e,D as ve,E as u,O as ye,S as be,_ as d,a as xe,c as Se,d as Ce,f,g as we,h as Te,j as Ee,k as p,l as De,m,n as Oe,p as ke,s as Ae,t as je,u as Me,y as h}from"./PmShared.D6iq_Z9g.js";import{n as Ne,r as Pe,t as Fe}from"./TableFieldConfig.C_NeWm8L.js";import{showToast as g}from"./Toast.BO2NFckG.js";import{c as Ie,d as Le,i as Re,l as ze,n as Be,o as Ve,r as He,s as Ue,t as _}from"./ColumnResize.CkE59sGq.js";var v=e(t(),1),y=i(),b=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],We={key:`project`,width:140,min:100},Ge=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ke=new Set([`id`,`title`,`filler`,`action`]),qe=[{key:`severity`,label:`严重程度`},{key:`status`,label:`缺陷状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Je=`pm.bugs.fields`,Ye=20,Xe=`tw.pm-bugs.page-size.v1`,Ze=[`all`,...c],Qe=[`all`,...l],$e=`pm.bugs.project`,et=`pm.bugs.iteration`,tt=`pm.bugs.status`,nt=`pm.bugs.severity`,rt=`pm.bugs.keyword`,it=l.map(e=>({value:e,label:fe[e]})),at=c.map(e=>({value:e,label:ue[e]}));function x(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function S(){return n(`pm.bugs.create-draft.v1`)}function ot(e){return!!(e.reproduceSteps.trim()||e.attachment.trim()||e.remark.trim()||e.iterationId||e.requirementId||e.expectedResult.trim()||e.actualResult.trim()||e.environment.trim()||e.githubIssue.trim())}function C(){try{let e=sessionStorage.getItem(S());if(!e)return null;let t=JSON.parse(e);return!t||typeof t!=`object`||t.id?null:{...x(),...t,id:void 0}}catch{return null}}function w(e){try{let t=S();if(!e||e.id||!ot(e)){sessionStorage.removeItem(t);return}sessionStorage.setItem(t,JSON.stringify({...e,id:void 0}))}catch{}}function st(e){let t=C();return t?e&&t.projectId!==e?{...t,projectId:e,iterationId:``,requirementId:``}:t:x(e)}function T({scopeProjectId:e=``}={}){let t=!!e,n=ge(`bugs`),{store:i,live:c,loading:l,error:x,setError:S,reload:C}=Ee(),[T,E]=p($e,`all`),D=e||T,[O,k]=p(et,`all`),[A,ct]=ye(tt,Ze,`all`),[j,lt]=ye(nt,Qe,`all`),[M,ut]=p(rt),[dt,N]=(0,v.useState)(1),[P,ft]=te(Ye,Xe),[F,I]=(0,v.useState)(null),[L,R]=(0,v.useState)(!1),[z,pt]=(0,v.useState)(!1),B=(0,v.useRef)(null),V=(0,v.useRef)(new Set),[H,U]=(0,v.useState)(null),[mt,W]=(0,v.useState)(null),G=(0,v.useMemo)(()=>de(F?.attachment??``),[F?.attachment]),ht=(0,v.useMemo)(()=>t?qe:[{key:`project`,label:`所属项目`},...qe],[t]),K=Pe(Je,ht,Ke),gt=(0,v.useMemo)(()=>t?[...b,...Ge]:[...b,We,...Ge],[t]),q=(0,v.useMemo)(()=>Ne(gt,K.isVisible),[gt,K.isVisible]),J=ze(t?`pm.bugs.cols.scoped.v2`:`pm.bugs.cols.v2`,q),_t=Le(t?`pm.bugs.scroll.scoped`:`pm.bugs.scroll`),vt=J.widthOf(`id`)??88;(0,v.useEffect)(()=>{for(let e of G)V.current.add(e.url)},[G]);let yt=(0,v.useMemo)(()=>[{value:`all`,label:`全部项目`},...i.projects.map(e=>({value:e.id,label:e.name}))],[i.projects]),bt=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...i.iterations.filter(e=>D===`all`||e.projectId===D).map(e=>({value:e.id,label:e.name}))],[i.iterations,D]),xt=(0,v.useMemo)(()=>{let e=new Map(i.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[i.projects]),St=(0,v.useMemo)(()=>{let e=new Map(i.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[i.iterations]),Y=(0,v.useMemo)(()=>ae(me(i.bugs,{projectId:D,iterationId:O,status:A,severity:j,keyword:M})),[i.bugs,D,O,A,j,M]),X=t?i.bugs.filter(e=>e.projectId===D).length:i.bugs.length,Ct=Math.max(1,Math.ceil(Y.length/P)),Z=Math.min(dt,Ct),wt=Y.slice((Z-1)*P,Z*P);(0,v.useEffect)(()=>{t||c===!0&&T!==`all`&&!i.projects.some(e=>e.id===T)&&E(`all`)},[c,i.projects,T,E,t]),(0,v.useEffect)(()=>{c===!0&&O!==`all`&&!i.iterations.some(e=>e.id===O&&(D===`all`||e.projectId===D))&&k(`all`)},[c,i.iterations,D,O,k]);let Tt=F?oe(i.iterations.filter(e=>e.projectId===F.projectId)):[],Et=F?i.requirements.filter(e=>e.projectId===F.projectId):[];async function Dt(){if(!F)return;if(!F.projectId){S(`请先选择所属项目`);return}let e=F.reproduceSteps.trim();if(!e){S(`缺陷描述不能为空`);return}let t=pe(e);R(!0);try{let n={projectId:F.projectId,iterationId:F.iterationId,requirementId:F.requirementId,title:t,severity:F.severity,status:F.status,reproduceSteps:e,expectedResult:F.expectedResult,actualResult:F.actualResult,environment:F.environment,githubIssue:F.githubIssue,attachment:F.attachment,remark:F.remark};F.id?await o(`bugs`,F.id,n):await le(`bugs`,[n]);let r=!!F.id;r||w(null),I(null),V.current.clear(),S(``),await C(!0),g(r?`已保存缺陷`:`已新建缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`保存缺陷失败:${t}`,`error`)}finally{R(!1)}}let Q=(0,v.useCallback)(async e=>{if(e&&e.length){pt(!0);try{let t=await he(Array.from(e));I(e=>{if(!e)return e;let n=de(e.attachment);return{...e,attachment:re([...n,...t])}}),S(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{pt(!1),B.current&&(B.current.value=``)}}},[S]),Ot=F!==null;(0,v.useEffect)(()=>{if(!Ot)return;let e=e=>{let t=se(e.clipboardData);t.length&&(e.preventDefault(),Q(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Ot,Q]);async function kt(e){if(!F)return;let t=re(G.filter(t=>t.url!==e));if(F.id)try{await o(`bugs`,F.id,{attachment:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e));return}I(e=>{if(!e)return e;let n={...e,attachment:t};return n.id||w(n),n}),s([e],F.id??``)}function At(){if(F&&!F.id){if(w(F),V.current.clear(),I(null),!ot(F)){let e=G.map(e=>e.url);e.length&&s(e)}return}let e=[...V.current,...G.map(e=>e.url)];V.current.clear(),I(null),e.length&&s(e)}function $(){I(st(D===`all`?``:D))}async function jt(e,t){R(!0);try{await o(`bugs`,e.id,{status:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{R(!1)}}async function Mt(){let e=H;if(e){U(null),R(!0);try{await ce(`bugs`,[e.id]),await C(!0),g(`已删除缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`删除缺陷失败:${t}`,`error`)}finally{R(!1)}}}if(!n.ready)return(0,y.jsx)(we,{label:`正在读取插件开关`});if(!n.on)return(0,y.jsx)(d,{children:r(`bugs`)});if(c===null)return(0,y.jsx)(we,{label:`正在连接项目管理服务`});if(!c)return(0,y.jsx)(d,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(i.projects.length===0&&!l&&!t)return(0,y.jsx)(d,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let Nt=[{value:`all`,label:`全部`},...at];return(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-600`,children:X}),` 条缺陷`,Y.length===X?``:` · 筛选出 ${Y.length} 条`]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:yt,value:T,onChange:e=>{E(e),k(`all`),N(1)}}),(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:bt,value:O,onChange:e=>{k(e),N(1)}}),(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...it],value:j,onChange:e=>{lt(e),N(1)}}),(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(m,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,y.jsx)(`input`,{value:M,onChange:e=>{ut(e.target.value),N(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,y.jsx)(Fe,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,y.jsxs)(`button`,{type:`button`,disabled:L,onClick:$,className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,y.jsx)(m,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,y.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,y.jsx)(ke,{ariaLabel:`按状态筛选缺陷`,options:Nt,value:A,onChange:e=>{ct(e),N(1)}})}),x?(0,y.jsx)(Ce,{message:x,onClose:()=>S(``)}):null,(0,y.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsx)(`div`,{ref:_t,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,y.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:J.tableStyle,children:[(0,y.jsx)(`colgroup`,{children:q.map(e=>(0,y.jsx)(`col`,{style:J.widthOf(e.key)?{width:J.widthOf(e.key)}:void 0},e.key))}),(0,y.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsxs)(`th`,{className:`${Ue} relative`,children:[`ID`,(0,y.jsx)(_,{...J.resizeProps(`id`)})]}),(0,y.jsxs)(`th`,{className:Ve,style:{"--tw-sticky-left":`${vt}px`},children:[`缺陷标题`,(0,y.jsx)(_,{...J.resizeProps(`title`)})]}),K.isVisible(`severity`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`严重程度`,(0,y.jsx)(_,{...J.resizeProps(`severity`)})]}):null,K.isVisible(`status`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`缺陷状态`,(0,y.jsx)(_,{...J.resizeProps(`status`)})]}):null,!t&&K.isVisible(`project`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,y.jsx)(_,{...J.resizeProps(`project`)})]}):null,K.isVisible(`iteration`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,y.jsx)(_,{...J.resizeProps(`iteration`)})]}):null,K.isVisible(`createdAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,y.jsx)(_,{...J.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,y.jsx)(_,{...J.resizeProps(`updatedAt`)})]}):null,(0,y.jsx)(`th`,{"aria-hidden":`true`}),(0,y.jsx)(`th`,{className:Ie,children:`操作`})]})}),(0,y.jsxs)(`tbody`,{children:[l&&!i.bugs.length?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,className:`px-4 py-16 text-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):wt.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,children:X?(0,y.jsx)(De,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(Me,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,y.jsxs)(`button`,{type:`button`,onClick:$,className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,y.jsx)(m,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,wt.map(e=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,y.jsx)(`td`,{className:`${He} font-mono text-xs text-stone-400`,children:e.autoId}),(0,y.jsx)(`td`,{className:Be,style:{"--tw-sticky-left":`${vt}px`},children:(0,y.jsx)(_e,{text:e.title,onClick:()=>I({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark})})}),K.isVisible(`severity`)?(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(be,{tone:je[e.severity],children:fe[e.severity]})}):null,K.isVisible(`status`)?(0,y.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,y.jsx)(a,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:L,options:at,value:e.status,onChange:t=>void jt(e,t),renderOptionPrefix:e=>(0,y.jsx)(Ae,{tone:Oe[e.value]}),renderTrigger:()=>(0,y.jsx)(be,{tone:Oe[e.status],children:ue[e.status]})})}):null,!t&&K.isVisible(`project`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,y.jsx)(`a`,{href:ve(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:xt(e.projectId)})}):null,K.isVisible(`iteration`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:St(e.iterationId)}):null,K.isVisible(`createdAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.updatedAt)}):null,(0,y.jsx)(`td`,{"aria-hidden":`true`}),(0,y.jsx)(`td`,{className:Re,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:L,onClick:()=>U(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,y.jsx)(m,{name:`trash`,size:15})})})]},e.id))]})]})}),Y.length>0?(0,y.jsx)(ne,{page:Z,totalPages:Ct,pageSize:P,busy:L,onPage:N,onPageSize:e=>{ft(e),N(1)}}):null]}),(0,y.jsx)(Se,{open:F!==null,title:F?.id?`编辑缺陷`:`新建缺陷`,busy:L,submitLabel:F?.id?`保存`:`创建`,onClose:At,onSubmit:()=>void Dt(),children:F?(0,y.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,y.jsx)(f,{label:`所属项目`,required:!0,children:(0,y.jsx)(h,{ariaLabel:`所属项目`,options:i.projects.map(e=>({value:e.id,label:e.name})),value:F.projectId,onChange:e=>I({...F,projectId:e,iterationId:``,requirementId:``})})}),(0,y.jsx)(f,{label:`所属迭代`,children:(0,y.jsx)(h,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Tt.map(e=>({value:e.id,label:e.name}))],value:F.iterationId,onChange:e=>I({...F,iterationId:e}),disabled:Tt.length===0})}),(0,y.jsx)(f,{label:`关联需求`,children:(0,y.jsx)(h,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...Et.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:F.requirementId,onChange:e=>I({...F,requirementId:e}),disabled:Et.length===0})}),(0,y.jsx)(f,{label:`缺陷描述`,required:!0,children:(0,y.jsx)(`textarea`,{autoFocus:!0,value:F.reproduceSteps,onChange:e=>I({...F,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:xe})}),(0,y.jsx)(f,{label:`严重程度`,children:(0,y.jsx)(h,{ariaLabel:`严重程度`,options:it,value:F.severity,onChange:e=>I({...F,severity:e}),renderOptionPrefix:e=>(0,y.jsx)(Ae,{tone:je[e.value]})})}),(0,y.jsx)(f,{label:`附件`,children:(0,y.jsxs)(`div`,{className:`space-y-2`,children:[G.length?(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:G.map(e=>{let t=ie(e.url);return(0,y.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,y.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,y.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,y.jsx)(m,{name:`file`,size:15})}),t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>kt(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url)})}):null,(0,y.jsx)(`input`,{ref:B,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void Q(e.target.files)}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>B.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,y.jsx)(m,{name:z?`file`:`plus`,size:13}),z?`上传中…`:`上传文件 / 图片`]}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,y.jsx)(f,{label:`备注`,children:(0,y.jsx)(`textarea`,{value:F.remark,onChange:e=>I({...F,remark:e.target.value}),rows:2,className:xe})}),F.id?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{label:`创建日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(i.bugs.find(e=>e.id===F.id)?.createdAt)})}),(0,y.jsx)(f,{label:`修改日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(i.bugs.find(e=>e.id===F.id)?.updatedAt)})})]}):null]}):null}),(0,y.jsx)(ee,{open:H!==null,title:`删除缺陷`,message:`确定删除「${H?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>U(null),onConfirm:()=>void Mt()}),(0,y.jsx)(Te,{file:mt,onClose:()=>W(null)})]})}export{T as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{t as a}from"./DatePicker.Bkl71M49.js";import{t as o}from"./SelectDropdown.Dmk5n225.js";import{L as s,O as ee,P as te,R as c,S as l,a as u,g as ne,h as re,k as ie,o as d}from"./pm.BXmOiFfW.js";import{A as ae,D as oe,O as se,S as f,_ as p,a as ce,c as le,d as ue,f as m,g as h,i as g,j as _,k as v,l as de,m as y,r as b,s as fe,u as pe,v as x,y as S}from"./PmShared.D6iq_Z9g.js";import{showToast as C}from"./Toast.BO2NFckG.js";var w=e(t(),1),T=r(),E=10,me=[`all`,...u],he=`pm.iterations.project`,ge=`pm.iterations.status`,_e=`pm.iterations.keyword`,D=u.map(e=>({value:e,label:d[e]}));function O(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function k({scopeProjectId:e=``}={}){let t=!!e,r=ae(`iterations`),{store:u,live:k,loading:A,error:j,setError:M,reload:N}=_(),[P,F]=v(he,`all`),I=e||P,[L,ve]=se(ge,me,`all`),[R,ye]=v(_e),[be,z]=(0,w.useState)(1),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),K=s(),q=(0,w.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[u.projects]),xe=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),J=(0,w.useMemo)(()=>te(l(u.iterations,{projectId:I,status:L,keyword:R})),[u.iterations,I,L,R]),Y=t?u.iterations.filter(e=>e.projectId===I).length:u.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(be,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||k===!0&&P!==`all`&&!u.projects.some(e=>e.id===P)&&F(`all`)},[k,u.projects,P,F,t]);async function Se(){if(!B)return;if(!B.projectId){M(`请先选择所属项目`);return}let e=B.name.trim();if(!e)M(`迭代名称不能为空`);else if(B.startDate&&B.endDate&&B.endDate<B.startDate)M(`迭代结束日期不能早于开始日期`);else{U(!0);try{let t={projectId:B.projectId,name:e,startDate:B.startDate,endDate:B.endDate,status:B.status,remark:B.remark};B.id?await c(`iterations`,B.id,t):await re(`iterations`,[t]),V(null),M(``),await N(!0),C(B.id?`已保存迭代`:`已新建迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`保存迭代失败:${t}`,`error`)}finally{U(!1)}}}async function $(e,t){U(!0);try{await c(`iterations`,e.id,{status:t}),await N(!0),C(`已更新迭代状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`更新迭代失败:${t}`,`error`)}finally{U(!1)}}async function Ce(){let e=W;if(e){G(null),U(!0);try{await ne(`iterations`,[e.id]),await N(!0),C(`已删除迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`删除迭代失败:${t}`,`error`)}finally{U(!1)}}}return r.ready?r.on?k===null?(0,T.jsx)(h,{label:`正在连接项目管理服务`}):k?u.projects.length===0&&!A&&!t?(0,T.jsx)(p,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:xe,value:P,onChange:e=>{F(e),z(1)}}),(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...D],value:L,onChange:e=>{ve(e),z(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(y,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:R,onChange:e=>{ye(e.target.value),z(1)},placeholder:`搜索迭代名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>V(O(I===`all`?``:I)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`plus`,size:14}),`新建迭代`]})]})]}),j?(0,T.jsx)(ue,{message:j,onClose:()=>M(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:A&&!u.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(de,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(pe,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(O(I===`all`?``:I)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(y,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=ie(e,K),r=ee(e,K),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${K}T00:00:00`))/864e5):null;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3.5 transition-[border-color,box-shadow] hover:border-[#ddd6fe] hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-[15px] font-medium text-stone-800`,children:e.name}),(0,T.jsx)(f,{tone:b[e.status],children:d[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:oe(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:q(e.projectId)}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`})]}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[e.startDate||`—`,` → `,e.endDate||`—`]}),r===null?i!==null&&i>=0&&e.endDate?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[`还剩 `,i,` 天`]}):null:(0,T.jsxs)(`span`,{className:`text-red-500`,children:[`逾期 `,r,` 天`]})]}),e.remark?(0,T.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-stone-400`,children:e.remark}):null]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status===`planning`?(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>void $(e,`in_progress`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`play`,size:12}),`开始`]}):null,e.status===`in_progress`?(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>void $(e,`done`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`check`,size:12}),`完成`]}):null,(0,T.jsx)(`button`,{type:`button`,"aria-label":`编辑 ${e.name}`,onClick:()=>V({id:e.id,projectId:e.projectId,name:e.name,startDate:e.startDate,endDate:e.endDate,status:e.status,remark:e.remark}),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(y,{name:`pencil`,size:15})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.name}`,disabled:H,onClick:()=>G(e),className:`tw-icon-danger flex h-8 w-8 items-center justify-center rounded-lg`,children:(0,T.jsx)(y,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(x,{page:Z,totalPages:X,busy:H,onPage:z}):null,(0,T.jsx)(le,{open:B!==null,title:B?.id?`编辑迭代`:`新建迭代`,busy:H,submitLabel:B?.id?`保存`:`创建`,onClose:()=>V(null),onSubmit:()=>void Se(),children:B?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(m,{label:`所属项目`,required:!0,children:(0,T.jsx)(S,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:B.projectId,onChange:e=>V({...B,projectId:e}),disabled:u.projects.length===0})}),(0,T.jsx)(m,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:B.name,onChange:e=>V({...B,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:g})}),(0,T.jsx)(m,{label:`开始日期`,children:(0,T.jsx)(a,{value:B.startDate,onChange:e=>V({...B,startDate:e}),placeholder:`选择开始日期`,className:`${g} tabular-nums`})}),(0,T.jsx)(m,{label:`截止日期`,children:(0,T.jsx)(a,{value:B.endDate,onChange:e=>V({...B,endDate:e}),placeholder:`选择截止日期`,className:`${g} tabular-nums`})}),(0,T.jsx)(m,{label:`状态`,children:(0,T.jsx)(S,{ariaLabel:`迭代状态`,options:D,value:B.status,onChange:e=>V({...B,status:e}),renderOptionPrefix:e=>(0,T.jsx)(fe,{tone:b[e.value]})})}),(0,T.jsx)(m,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:B.remark,onChange:e=>V({...B,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:ce})})]}):null}),(0,T.jsx)(i,{open:W!==null,title:`删除迭代`,message:`确定删除「${W?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void Ce()})]}):(0,T.jsx)(p,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(p,{children:n(`iterations`)}):(0,T.jsx)(h,{label:`正在读取插件开关`})}export{k as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{M as i,c as a}from"./pm.BXmOiFfW.js";import{A as o,D as s,S as c,_ as l,b as u,g as d,k as f,m as p,o as m,u as h,x as g}from"./PmShared.BJpoEYvk.js";import _ from"./PmBugsBoard.Cu1uf0TC.js";import v from"./PmIterationsBoard.RzRKkAH0.js";import{t as y}from"./PmRequirementsBoard.DET5YIVX.js";var b=e(t(),1),x=r(),S=[`iterations`,`requirements`,`bugs`],C=`pm.project.tab`,w=`/pm/projects/`;function T(){let e=f(`projects`);return e.ready?e.on?(0,x.jsx)(u,{children:(0,x.jsx)(E,{})}):(0,x.jsx)(l,{children:n(`projects`)}):(0,x.jsx)(d,{label:`正在读取插件开关`})}function E(){let{store:e,live:t,loading:n}=o(),[r,u]=(0,b.useState)(``),[f,T]=s(C,S,`iterations`);(0,b.useEffect)(()=>{u(new URLSearchParams(window.location.search).get(`id`)??``)},[]);let E=(0,b.useMemo)(()=>e.projects.find(e=>e.id===r),[e.projects,r]),O=(0,b.useMemo)(()=>i(e),[e]);if(t===null)return(0,x.jsx)(d,{label:`正在连接项目管理服务`});if(!t)return(0,x.jsx)(l,{children:`项目详情需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(!E)return n&&!e.projects.length?(0,x.jsx)(d,{label:`正在读取项目`}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(D,{}),(0,x.jsx)(h,{icon:`folder`,title:`没有找到这个项目`,hint:`它可能已被删除,或链接里的项目 id 不正确。`})]});let k=O[E.id],A=[{value:`iterations`,label:`迭代`,count:k?.iterations??0},{value:`requirements`,label:`需求`,count:k?.requirements??0},{value:`bugs`,label:`缺陷`,count:k?.bugs??0}];return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3`,children:[(0,x.jsx)(`a`,{href:w,"aria-label":`返回项目列表`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-stone-500 transition-colors hover:bg-stone-100 hover:text-stone-800`,children:(0,x.jsx)(p,{name:`arrowLeft`,size:18})}),(0,x.jsx)(`span`,{className:`tw-pm-tile flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-bold`,children:E.name.slice(0,1)}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`truncate text-lg font-semibold text-stone-800`,children:E.name}),(0,x.jsx)(c,{tone:m[E.status],children:a[E.status]})]}),(0,x.jsx)(`p`,{className:`mt-0.5 text-xs ${E.description?`text-stone-400`:`text-stone-300 italic`}`,children:E.description||`暂无描述`})]})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(g,{tabs:A,value:f,onChange:T,ariaLabel:`项目二级菜单`}),(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`需求完成 `,k?.requirementPercent??0,`% · 缺陷完成 `,k?.bugClosedPercent??100,`%`]})]}),(0,x.jsxs)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:[f===`iterations`?(0,x.jsx)(v,{scopeProjectId:E.id}):null,f===`requirements`?(0,x.jsx)(y,{scopeProjectId:E.id}):null,f===`bugs`?(0,x.jsx)(_,{scopeProjectId:E.id}):null]})]})}function D(){return(0,x.jsxs)(`a`,{href:w,className:`mb-2 inline-flex w-fit items-center gap-1.5 text-sm text-stone-500 transition-colors hover:text-stone-800`,children:[(0,x.jsx)(p,{name:`arrowLeft`,size:16}),`返回项目列表`]})}export{T as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{M as i,c as a}from"./pm.BXmOiFfW.js";import{A as o,O as s,S as c,_ as l,b as u,g as d,j as f,m as p,o as m,u as h,x as g}from"./PmShared.D6iq_Z9g.js";import _ from"./PmBugsBoard.NUiKlz46.js";import v from"./PmIterationsBoard.C8F55feg.js";import{t as y}from"./PmRequirementsBoard.C5_NcAzj.js";var b=e(t(),1),x=r(),S=[`iterations`,`requirements`,`bugs`],C=`pm.project.tab`,w=`/pm/projects/`;function T(){let e=o(`projects`);return e.ready?e.on?(0,x.jsx)(u,{children:(0,x.jsx)(E,{})}):(0,x.jsx)(l,{children:n(`projects`)}):(0,x.jsx)(d,{label:`正在读取插件开关`})}function E(){let{store:e,live:t,loading:n}=f(),[r,o]=(0,b.useState)(``),[u,T]=s(C,S,`iterations`);(0,b.useEffect)(()=>{o(new URLSearchParams(window.location.search).get(`id`)??``)},[]);let E=(0,b.useMemo)(()=>e.projects.find(e=>e.id===r),[e.projects,r]),O=(0,b.useMemo)(()=>i(e),[e]);if(t===null)return(0,x.jsx)(d,{label:`正在连接项目管理服务`});if(!t)return(0,x.jsx)(l,{children:`项目详情需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(!E)return n&&!e.projects.length?(0,x.jsx)(d,{label:`正在读取项目`}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(D,{}),(0,x.jsx)(h,{icon:`folder`,title:`没有找到这个项目`,hint:`它可能已被删除,或链接里的项目 id 不正确。`})]});let k=O[E.id],A=[{value:`iterations`,label:`迭代`,count:k?.iterations??0},{value:`requirements`,label:`需求`,count:k?.requirements??0},{value:`bugs`,label:`缺陷`,count:k?.bugs??0}];return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3`,children:[(0,x.jsx)(`a`,{href:w,"aria-label":`返回项目列表`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-stone-500 transition-colors hover:bg-stone-100 hover:text-stone-800`,children:(0,x.jsx)(p,{name:`arrowLeft`,size:18})}),(0,x.jsx)(`span`,{className:`tw-pm-tile flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-bold`,children:E.name.slice(0,1)}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`truncate text-lg font-semibold text-stone-800`,children:E.name}),(0,x.jsx)(c,{tone:m[E.status],children:a[E.status]})]}),(0,x.jsx)(`p`,{className:`mt-0.5 text-xs ${E.description?`text-stone-400`:`text-stone-300 italic`}`,children:E.description||`暂无描述`})]})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(g,{tabs:A,value:u,onChange:T,ariaLabel:`项目二级菜单`}),(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`需求完成 `,k?.requirementPercent??0,`% · 缺陷完成 `,k?.bugClosedPercent??100,`%`]})]}),(0,x.jsxs)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:[u===`iterations`?(0,x.jsx)(v,{scopeProjectId:E.id}):null,u===`requirements`?(0,x.jsx)(y,{scopeProjectId:E.id}):null,u===`bugs`?(0,x.jsx)(_,{scopeProjectId:E.id}):null]})]})}function D(){return(0,x.jsxs)(`a`,{href:w,className:`mb-2 inline-flex w-fit items-center gap-1.5 text-sm text-stone-500 transition-colors hover:text-stone-800`,children:[(0,x.jsx)(p,{name:`arrowLeft`,size:16}),`返回项目列表`]})}export{T as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.C0NrHGZv.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as te}from"./SelectDropdown.TgxIOKMD.js";import{showToast as i}from"./Toast.BO2NFckG.js";import{C as a,M as o,R as s,c,g as ne,h as re,s as l}from"./pm.BXmOiFfW.js";import{A as ie,D as u,E as d,O as f,S as p,_ as m,a as h,c as g,d as _,f as v,g as y,i as b,k as x,l as ae,m as S,o as C,s as oe,u as se,v as ce,y as le}from"./PmShared.BJpoEYvk.js";var w=e(t(),1),T=n(),E=10,D=l.map(e=>({value:e,label:c[e]})),O=[`all`,...l],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=x(`projects`),{store:t,live:n,loading:l,error:M,setError:N,reload:P}=ie(),[F,I]=u(k,O,`all`),[L,R]=f(A),[z,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(null),Y=(0,w.useRef)(null),ue=(0,w.useMemo)(()=>o(t),[t]),X=(0,w.useMemo)(()=>a(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await s(`projects`,V.id,{name:e,description:V.description,status:V.status}):await re(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),i(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),i(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await s(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),i(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),i(`更新项目失败:${t}`,`error`)}finally{W(!1)}}async function pe(){let e=G;if(e){K(null),W(!0);try{await ne(`projects`,[e.id]),await P(!0),i(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),i(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?n===null?(0,T.jsx)(y,{label:`正在连接项目管理服务`}):n?(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-stone-400`,children:t.projects.length?(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:t.projects.length}),` 个项目`,X.length===t.projects.length?``:` · 筛选出 ${X.length} 个`]}):`暂无项目`}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(te,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选项目`,className:`w-32`,options:[{value:`all`,label:`全部状态`},...D],value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(S,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(S,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(_,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:l&&!t.projects.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):$.length===0?t.projects.length?(0,T.jsx)(ae,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(se,{icon:`folder`,title:`暂无项目`,hint:`创建第一个项目开始吧`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(j()),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(S,{name:`plus`,size:13}),`新建项目`]})}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>{let t=ue[e.id];return(0,T.jsxs)(`article`,{className:`tw-pm-card group relative rounded-2xl border border-stone-200 bg-white`,children:[(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-0 overflow-hidden rounded-2xl`,"aria-hidden":`true`,children:(0,T.jsx)(`span`,{className:`tw-pm-card-accent absolute -right-6 -top-6 h-20 w-20 rounded-full bg-[#f1edff]`})}),(0,T.jsx)(`a`,{href:d(e.id),"aria-label":`打开项目 ${e.name}`,className:`absolute inset-0 z-0 rounded-2xl`}),(0,T.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex h-full flex-col p-5`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,T.jsx)(`span`,{className:`tw-pm-tile flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-xs font-bold`,children:e.name.slice(0,1)}),(0,T.jsx)(`h3`,{className:`truncate text-[15px] font-semibold text-stone-800`,children:e.name})]}),(0,T.jsx)(p,{tone:C[e.status],children:c[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(S,{name:`more`,size:18})}),q===e.id?(0,T.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-9 z-30 w-36 overflow-hidden rounded-lg border border-stone-200 bg-white py-1 shadow-lg`,children:[(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),H({id:e.id,name:e.name,description:e.description,status:e.status})},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(S,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void fe(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(S,{name:`folder`,size:14}),e.status===`archived`?`取消归档`:`归档`]}),(0,T.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),K(e)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-red-600 hover:bg-red-50`,children:[(0,T.jsx)(S,{name:`trash`,size:14}),`删除`]})]}):null]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-stone-400`,children:[`需求完成 `,t?.requirementPercent??0,`%`,(0,T.jsx)(S,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(ce,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(g,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void de(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(v,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:b})}),(0,T.jsx)(v,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:h})}),(0,T.jsx)(v,{label:`状态`,children:(0,T.jsx)(le,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(oe,{tone:C[e.value]})})})]}):null}),(0,T.jsx)(r,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void pe()})]}):(0,T.jsx)(m,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(m,{children:ee(`projects`)}):(0,T.jsx)(y,{label:`正在读取插件开关`})}export{M as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{t as te}from"./SelectDropdown.Dmk5n225.js";import{C as i,M as a,R as o,c as s,g as ne,h as re,s as c}from"./pm.BXmOiFfW.js";import{A as ie,D as ae,O as l,S as u,_ as d,a as f,c as p,d as m,f as h,g,i as _,j as v,k as y,l as b,m as x,o as S,s as oe,u as se,v as ce,y as le}from"./PmShared.D6iq_Z9g.js";import{showToast as C}from"./Toast.BO2NFckG.js";var w=e(t(),1),T=r(),E=10,D=c.map(e=>({value:e,label:s[e]})),O=[`all`,...c],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=ie(`projects`),{store:t,live:r,loading:c,error:M,setError:N,reload:P}=v(),[F,I]=l(k,O,`all`),[L,R]=y(A),[z,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(null),Y=(0,w.useRef)(null),ue=(0,w.useMemo)(()=>a(t),[t]),X=(0,w.useMemo)(()=>i(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await o(`projects`,V.id,{name:e,description:V.description,status:V.status}):await re(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),C(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await o(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),C(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`更新项目失败:${t}`,`error`)}finally{W(!1)}}async function pe(){let e=G;if(e){K(null),W(!0);try{await ne(`projects`,[e.id]),await P(!0),C(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?r===null?(0,T.jsx)(g,{label:`正在连接项目管理服务`}):r?(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-stone-400`,children:t.projects.length?(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:t.projects.length}),` 个项目`,X.length===t.projects.length?``:` · 筛选出 ${X.length} 个`]}):`暂无项目`}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(te,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选项目`,className:`w-32`,options:[{value:`all`,label:`全部状态`},...D],value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(x,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(x,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(m,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:c&&!t.projects.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):$.length===0?t.projects.length?(0,T.jsx)(b,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(se,{icon:`folder`,title:`暂无项目`,hint:`创建第一个项目开始吧`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(j()),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(x,{name:`plus`,size:13}),`新建项目`]})}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>{let t=ue[e.id];return(0,T.jsxs)(`article`,{className:`tw-pm-card group relative rounded-2xl border border-stone-200 bg-white`,children:[(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-0 overflow-hidden rounded-2xl`,"aria-hidden":`true`,children:(0,T.jsx)(`span`,{className:`tw-pm-card-accent absolute -right-6 -top-6 h-20 w-20 rounded-full bg-[#f1edff]`})}),(0,T.jsx)(`a`,{href:ae(e.id),"aria-label":`打开项目 ${e.name}`,className:`absolute inset-0 z-0 rounded-2xl`}),(0,T.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex h-full flex-col p-5`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,T.jsx)(`span`,{className:`tw-pm-tile flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-xs font-bold`,children:e.name.slice(0,1)}),(0,T.jsx)(`h3`,{className:`truncate text-[15px] font-semibold text-stone-800`,children:e.name})]}),(0,T.jsx)(u,{tone:S[e.status],children:s[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(x,{name:`more`,size:18})}),q===e.id?(0,T.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-9 z-30 w-36 overflow-hidden rounded-lg border border-stone-200 bg-white py-1 shadow-lg`,children:[(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),H({id:e.id,name:e.name,description:e.description,status:e.status})},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(x,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void fe(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(x,{name:`folder`,size:14}),e.status===`archived`?`取消归档`:`归档`]}),(0,T.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),K(e)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-red-600 hover:bg-red-50`,children:[(0,T.jsx)(x,{name:`trash`,size:14}),`删除`]})]}):null]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-stone-400`,children:[`需求完成 `,t?.requirementPercent??0,`%`,(0,T.jsx)(x,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(ce,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(p,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void de(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(h,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:_})}),(0,T.jsx)(h,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:f})}),(0,T.jsx)(h,{label:`状态`,children:(0,T.jsx)(le,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(oe,{tone:S[e.value]})})})]}):null}),(0,T.jsx)(ee,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void pe()})]}):(0,T.jsx)(d,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(d,{children:n(`projects`)}):(0,T.jsx)(g,{label:`正在读取插件开关`})}export{M as default};
@@ -0,0 +1 @@
1
+ export{t as default}from"./PmRequirementsBoard.C5_NcAzj.js";
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{n as a,t as ee}from"./DocsPager.D0TMvJ67.js";import{t as o}from"./SelectDropdown.Dmk5n225.js";import{A as s,D as c,F as l,P as u,R as d,b as f,d as p,f as m,g as te,h,j as g,l as _,m as ne,u as v,w as re,z as y}from"./pm.BXmOiFfW.js";import{A as ie,C as ae,D as oe,E as b,O as se,S as ce,T as x,_ as S,a as le,c as ue,d as de,f as C,g as fe,h as w,j as pe,k as T,l as me,m as E,p as he,s as D,u as ge,w as _e,y as O}from"./PmShared.D6iq_Z9g.js";import{n as ve,r as ye,t as be}from"./TableFieldConfig.C_NeWm8L.js";import{showToast as k}from"./Toast.BO2NFckG.js";import{c as xe,d as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as A}from"./ColumnResize.CkE59sGq.js";var j=e(t(),1),M=r();function ke({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=g(e),[l,u]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[te,h]=(0,j.useState)(null),_=(0,j.useRef)(null);(0,j.useEffect)(()=>{for(let t of g(e))i.current.add(t.url)},[e,i]);let v=(0,j.useCallback)(async n=>{if(n&&n.length){u(!0);try{let r=await y(Array.from(n));t(s([...g(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{u(!1),_.current&&(_.current.value=``)}}},[t,a,e]);(0,j.useEffect)(()=>{let e=e=>{let t=f(e.clipboardData);t.length&&(e.preventDefault(),v(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[v]);async function re(e){let i=s(o.filter(t=>t.url!==e));if(r)try{await d(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),ne([e],r)}return(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),v(e.dataTransfer?.files??null)},children:[o.length?(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,M.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,M.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,M.jsx)(E,{name:`file`,size:15})}),c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,M.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void re(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url))}):null,(0,M.jsx)(`input`,{ref:_,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void v(e.target.files)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>_.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,M.jsx)(E,{name:l?`file`:`plus`,size:13}),l?`上传中…`:`上传文件 / 图片`]}),(0,M.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,M.jsx)(w,{file:te,onClose:()=>h(null)})]})}var Ae=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],je={key:`project`,width:140,min:100},Me=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ne=new Set([`id`,`title`,`filler`,`action`]),Pe=[{key:`priority`,label:`优先级`},{key:`status`,label:`需求状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Fe=`pm.requirements.fields`,Ie=20,Le=`tw.pm-requirements.page-size.v1`,Re=[`all`,...p],ze=[`all`,..._],Be=`pm.requirements.project`,Ve=`pm.requirements.iteration`,He=`pm.requirements.status`,Ue=`pm.requirements.priority`,We=`pm.requirements.keyword`,Ge=_.map(e=>({value:e,label:v[e]})),N=p.map(e=>({value:e,label:m[e]}));function Ke(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ie(`pmRequirements`),{store:s,live:c,loading:f,error:p,setError:_,reload:y}=pe(),[w,P]=T(Be,`all`),F=e||w,[I,L]=T(Ve,`all`),[R,qe]=se(He,Re,`all`),[z,Je]=se(Ue,ze,`all`),[B,Ye]=T(We),[Xe,V]=(0,j.useState)(1),[H,Ze]=a(Ie,Le),[U,W]=(0,j.useState)(null),[G,K]=(0,j.useState)(!1),[q,J]=(0,j.useState)(null),Y=(0,j.useRef)(new Set),Qe=(0,j.useMemo)(()=>t?Pe:[{key:`project`,label:`所属项目`},...Pe],[t]),X=ye(Fe,Qe,Ne),$e=(0,j.useMemo)(()=>t?[...Ae,...Me]:[...Ae,je,...Me],[t]),Z=(0,j.useMemo)(()=>ve($e,X.isVisible),[$e,X.isVisible]),Q=we(t?`pm.requirements.cols.scoped.v2`:`pm.requirements.cols.v2`,Z),et=Se(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),tt=Q.widthOf(`id`)??88,nt=(0,j.useMemo)(()=>[{value:`all`,label:`全部项目`},...s.projects.map(e=>({value:e.id,label:e.name}))],[s.projects]),rt=(0,j.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u(s.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[s.iterations,F]),it=(0,j.useMemo)(()=>{let e=new Map(s.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[s.projects]),at=(0,j.useMemo)(()=>{let e=new Map(s.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[s.iterations]),$=(0,j.useMemo)(()=>l(re(s.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[s.requirements,F,I,R,z,B]),ot=t?s.requirements.filter(e=>e.projectId===F).length:s.requirements.length,st=Math.max(1,Math.ceil($.length/H)),ct=Math.min(Xe,st),lt=$.slice((ct-1)*H,ct*H);(0,j.useEffect)(()=>{t||c===!0&&w!==`all`&&!s.projects.some(e=>e.id===w)&&P(`all`)},[c,s.projects,w,P,t]),(0,j.useEffect)(()=>{c===!0&&I!==`all`&&!s.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[c,s.iterations,F,I,L]);let ut=U?u(s.iterations.filter(e=>e.projectId===U.projectId)):[];async function dt(){if(!U)return;if(!U.projectId){_(`请先选择所属项目`);return}let e=U.title.trim();if(!e)_(`需求描述不能为空`);else{K(!0);try{let t={projectId:U.projectId,iterationId:U.iterationId,title:e,priority:U.priority,status:U.status,description:U.description,acceptanceCriteria:U.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:U.githubIssue,attachment:U.attachment};U.id?await d(`requirements`,U.id,t):await h(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),_(``),await y(!0),k(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function ft(){let e=[...Y.current,...g(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&ne(e)}async function pt(e,t){K(!0);try{await d(`requirements`,e.id,{status:t}),await y(!0),k(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function mt(){let e=q;if(e){J(null),K(!0);try{await te(`requirements`,[e.id]),await y(!0),k(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!r.ready)return(0,M.jsx)(fe,{label:`正在读取插件开关`});if(!r.on)return(0,M.jsx)(S,{children:n(`pmRequirements`)});if(c===null)return(0,M.jsx)(fe,{label:`正在连接项目管理服务`});if(!c)return(0,M.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(s.projects.length===0&&!f&&!t)return(0,M.jsx)(S,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let ht=[{value:`all`,label:`全部`},...N];return(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:ot}),` 条需求`,$.length===ot?``:` · 筛选出 ${$.length} 条`]}),(0,M.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:nt,value:w,onChange:e=>{P(e),L(`all`),V(1)}}),(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:rt,value:I,onChange:e=>{L(e),V(1)}}),(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...Ge],value:z,onChange:e=>{Je(e),V(1)}}),(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(E,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:B,onChange:e=>{Ye(e.target.value),V(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsx)(be,{fields:X.fields,isVisible:X.isVisible,onToggle:X.toggle}),(0,M.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,M.jsx)(E,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,M.jsx)(he,{ariaLabel:`按状态筛选需求`,options:ht,value:R,onChange:e=>{qe(e),V(1)}})}),p?(0,M.jsx)(de,{message:p,onClose:()=>_(``)}):null,(0,M.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{ref:et,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,M.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Q.tableStyle,children:[(0,M.jsx)(`colgroup`,{children:Z.map(e=>(0,M.jsx)(`col`,{style:Q.widthOf(e.key)?{width:Q.widthOf(e.key)}:void 0},e.key))}),(0,M.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,M.jsxs)(`tr`,{children:[(0,M.jsxs)(`th`,{className:`${Oe} relative`,children:[`ID`,(0,M.jsx)(A,{...Q.resizeProps(`id`)})]}),(0,M.jsxs)(`th`,{className:Ee,style:{"--tw-sticky-left":`${tt}px`},children:[`需求描述`,(0,M.jsx)(A,{...Q.resizeProps(`title`)})]}),X.isVisible(`priority`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,M.jsx)(A,{...Q.resizeProps(`priority`)})]}):null,X.isVisible(`status`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,M.jsx)(A,{...Q.resizeProps(`status`)})]}):null,!t&&X.isVisible(`project`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,M.jsx)(A,{...Q.resizeProps(`project`)})]}):null,X.isVisible(`iteration`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,M.jsx)(A,{...Q.resizeProps(`iteration`)})]}):null,X.isVisible(`createdAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,M.jsx)(A,{...Q.resizeProps(`createdAt`)})]}):null,X.isVisible(`updatedAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,M.jsx)(A,{...Q.resizeProps(`updatedAt`)})]}):null,(0,M.jsx)(`th`,{"aria-hidden":`true`}),(0,M.jsx)(`th`,{className:xe,children:`操作`})]})}),(0,M.jsxs)(`tbody`,{children:[f&&!s.requirements.length?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,className:`px-4 py-16 text-center`,children:(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):lt.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,children:ot?(0,M.jsx)(me,{children:`没有符合筛选条件的需求。`}):(0,M.jsx)(ge,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(E,{name:`plus`,size:13}),`新建需求`]})})})}):null,lt.map(e=>(0,M.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,M.jsx)(`td`,{className:`${De} font-mono text-xs text-stone-400`,children:e.autoId}),(0,M.jsx)(`td`,{className:Te,style:{"--tw-sticky-left":`${tt}px`},children:(0,M.jsx)(ae,{text:e.title,onClick:()=>W({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment})})}),X.isVisible(`priority`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,M.jsx)(ce,{tone:_e[e.priority],children:v[e.priority]})}):null,X.isVisible(`status`)?(0,M.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,M.jsx)(o,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:G,options:N,value:e.status,onChange:t=>void pt(e,t),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]}),renderTrigger:()=>(0,M.jsx)(ce,{tone:x[e.status],children:m[e.status]})})}):null,!t&&X.isVisible(`project`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,M.jsx)(`a`,{href:oe(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:it(e.projectId)})}):null,X.isVisible(`iteration`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:at(e.iterationId)}):null,X.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.createdAt)}):null,X.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.updatedAt)}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:Ce,children:(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:G,onClick:()=>J(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,M.jsx)(E,{name:`trash`,size:15})})})]},e.id))]})]})}),$.length>0?(0,M.jsx)(ee,{page:ct,totalPages:st,pageSize:H,busy:G,onPage:V,onPageSize:e=>{Ze(e),V(1)}}):null]}),(0,M.jsx)(ue,{open:U!==null,title:U?.id?`编辑需求`:`新建需求`,busy:G,submitLabel:U?.id?`保存`:`创建`,onClose:()=>ft(),onSubmit:()=>void dt(),children:U?(0,M.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,M.jsx)(C,{label:`所属项目`,required:!0,children:(0,M.jsx)(O,{ariaLabel:`所属项目`,options:s.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=s.iterations.some(t=>t.id===U.iterationId&&t.projectId===e);W({...U,projectId:e,iterationId:t?U.iterationId:``})}})}),(0,M.jsx)(C,{label:`所属迭代`,children:(0,M.jsx)(O,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...ut.map(e=>({value:e.id,label:e.name}))],value:U.iterationId,onChange:e=>W({...U,iterationId:e}),disabled:ut.length===0})}),(0,M.jsx)(C,{label:`需求描述`,required:!0,children:(0,M.jsx)(`textarea`,{autoFocus:!0,value:U.title,onChange:e=>W({...U,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:le})}),(0,M.jsx)(C,{label:`优先级`,children:(0,M.jsx)(O,{ariaLabel:`优先级`,options:Ge,value:U.priority,onChange:e=>W({...U,priority:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:_e[e.value]})})}),(0,M.jsx)(C,{label:`需求状态`,children:(0,M.jsx)(O,{ariaLabel:`需求状态`,options:N,value:U.status,onChange:e=>W({...U,status:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]})})}),(0,M.jsx)(C,{label:`附件`,children:(0,M.jsx)(ke,{value:U.attachment,onChange:e=>W(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:U.id??``,seenUrls:Y,onError:_,onPersisted:()=>void y(!0)})}),(0,M.jsx)(C,{label:`备注`,children:(0,M.jsx)(`textarea`,{value:U.description,onChange:e=>W({...U,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:le})}),U.id?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(s.requirements.find(e=>e.id===U.id)?.createdAt)})}),(0,M.jsx)(C,{label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(s.requirements.find(e=>e.id===U.id)?.updatedAt)})})]}):null]}):null}),(0,M.jsx)(i,{open:q!==null,title:`删除需求`,message:`确定删除「${q?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>J(null),onConfirm:()=>void mt()})]})}export{P as t};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i}from"./plugins.C0NrHGZv.js";import{n as a,o,r as s,s as c}from"./view-prefs.8MPl3A7e.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.TgxIOKMD.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}function ne({text:e,onClick:t}){let n=(0,y.jsx)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{D as A,ne as C,x as D,H as E,S as O,ee as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,C as k,Y as l,R as m,P as n,k as o,B as p,A as r,I as s,N as t,V as u,K as v,j as w,z as x,G as y};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i}from"./plugins.C0NrHGZv.js";import{n as a,o,r as s,s as c}from"./view-prefs.8MPl3A7e.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.Dmk5n225.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}function ne(e){let t=(e??``).trim();if(!t)return`—`;let n=Date.parse(t);if(!Number.isFinite(n)){let e=t.slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.replace(/-/g,`/`):`—`}let r=new Date(n);return`${r.getFullYear()}/${String(r.getMonth()+1).padStart(2,`0`)}/${String(r.getDate()).padStart(2,`0`)} ${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`}function re({text:e,onClick:t}){let n=(0,y.jsx)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{C as A,re as C,H as D,ne as E,x as O,ee as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,D as j,S as k,Y as l,R as m,P as n,k as o,B as p,A as r,I as s,N as t,V as u,K as v,j as w,z as x,G as y};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.C4rpn1Ix.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.C0NrHGZv.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{showToast as u}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.CprZTsyX.js";import{a as ne,at as re,c as ie}from"./req-analysis.ilj0McI3.js";import{c as d,d as f,h as ae,n as p,p as oe,r as se,u as ce,v as le}from"./project-docs.DAw9bzgk.js";import{n as ue}from"./doc-roots.DAJP9Svr.js";import{a as m,c as h,d as de,i as g,l as _,o as v,s as y,u as b}from"./prompts-meta.Dnmq-SnF.js";import{i as fe,n as pe,r as me,t as he}from"./DocsFileBrowser.9WTBumS5.js";import{d as ge,t as _e}from"./open-docs-in-session.5cTowYAC.js";import{F as ve,I as ye,i as be,r as xe}from"./case-review.s1w_mD4l.js";import{t as x}from"./NamePromptDialog.Csfnh5eM.js";import{m as S}from"./PmShared.BJpoEYvk.js";import{i as Se}from"./report-prompt.B9C4cv84.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{f as Te,s as Ee,t as De,y as Oe}from"./story-review.Bsm2JWdj.js";var C=e(t(),1),w=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(w));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Ae(e){try{sessionStorage.setItem(r(w),JSON.stringify(e))}catch{}}var T=l(),je=10;async function E(e=`.`){let{entries:t}=await d(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await E(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=b(e,n);if(!r)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=v(e,n);return(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,T.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function D(){let e=me(`prompts`),[t,r]=(0,C.useState)(!1),[l,d]=(0,C.useState)(!0),[v,w]=(0,C.useState)(e?!0:null),[D,Ne]=(0,C.useState)(()=>e??[]),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)({}),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(()=>i()),[R,Pe]=(0,C.useState)(()=>ke()),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),G=pe(D,je,`prompts`),K=(0,C.useRef)(!1),q=(0,C.useRef)(!1),Fe=(0,C.useRef)(!1),J=(0,C.useRef)(!1),Ie=(0,C.useRef)(!1),Y=(0,C.useCallback)(async()=>{k(null);try{let e=await E(`.`);Ne(e),fe(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e))}},[]);(0,C.useEffect)(()=>{if(!v||I.reqAnalysis!==!0||K.current)return;let e=new Set(D.map(e=>e.name));e.has(`需求分析提示词.md`)&&e.has(`原文结构提示词.md`)||(K.current=!0,re(!0).then(()=>Y()).catch(()=>void 0))},[v,I.reqAnalysis,D,Y]),(0,C.useEffect)(()=>{v&&I.storyReview===!0&&!q.current&&(D.some(e=>e.name===`用户故事审查提示词.md`)||(q.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.storyReview,D,Y]),(0,C.useEffect)(()=>{v&&I.testPoints===!0&&!Fe.current&&(D.some(e=>e.name===`测试点生成提示词.md`)||(Fe.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.testPoints,D,Y]),(0,C.useEffect)(()=>{v&&I.caseReview===!0&&!J.current&&(D.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.caseReview,D,Y]),(0,C.useEffect)(()=>{v&&I.caseBlindspot===!0&&!Ie.current&&(D.some(e=>e.name===`场景遗漏补全提示词.md`)||(Ie.current=!0,ve(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.caseBlindspot,D,Y]),(0,C.useEffect)(()=>{let e=s(e=>{d(!!e.prompts),L(e)});return n().then(()=>{d(a(`prompts`)),L(i()),r(!0)}),e},[]),(0,C.useEffect)(()=>{t&&l&&(async()=>{await se(`prompts`)?(await ge().catch(()=>null),await Y(),w(!0)):w(!1)})()},[t,l,Y]);let X=(0,C.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[h(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[h(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(I.reqAnalysis&&(i[h(ne)]=`reqAnalysis`,i[h(ie)]=`reqAnalysis`),I.storyReview&&(i[h(De)]=`storyReview`),I.testPoints&&(i[h(Te)]=`testPoints`),I.caseReview&&(i[h(be)]=`caseReview`),I.caseBlindspot&&(i[h(xe)]=`caseBlindspot`),I.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(i[h(t)]=`caseGen`)}return Ae(i),i})},[I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen]);(0,C.useEffect)(()=>{if(!t||!l)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,I.uiAuto,I.reports,I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen,X]);let Z=(0,C.useMemo)(()=>Object.keys(M).filter(e=>M[e]),[M]),Q=(0,C.useCallback)(e=>{let t=b(e,R);return!t||t===`system`||de(e)?``:I[t]===!0?t:``},[R,I]);async function Le(e){j(!0),k(null);try{await ce(`prompts`,e.path)}catch(e){k(e instanceof Error?e.message:String(e))}finally{j(!1)}}async function Re(e){j(!0),k(null);try{await _e(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e)),j(!1)}}function ze(e){if(y(e.path)){k(`默认提示词不可删除`);return}if(g(e.path,I)){k(_(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else F({kind:`one`,entry:e})}function Be(e){if(y(e.path)){k(`默认提示词不可改名`);return}if(g(e.path,I)){k(_(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else B(e),W(``)}function Ve(e){H(e),W(``)}async function He(){let e=P;if(e){F(null),j(!0),k(null);try{if(e.kind===`one`)await p(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)y(n)||g(n,I)||Q(n)?t+=1:await p(`prompts`,n);t&&k(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),N({})}await Y(),u(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),u(`删除失败:${t}`,`error`)}finally{j(!1)}}}function Ue(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:k(c(`promptGen`))}let $=(0,C.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=D.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[D]);async function We(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){B(null),W(``);return}let r=$(f(t.path),n,t.path);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{await ae(`prompts`,t.path,n),B(null),await Y(),u(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),u(`重命名失败:${t}`,`error`)}finally{j(!1)}}}async function Ge(e){let t=V;if(!t)return;let n=e.trim();if(!n)return;let r=$(f(t.path),n);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{let{content:e}=await oe(`prompts`,t.path);await le(`prompts`,f(t.path)===`.`?n:`${f(t.path)}/${n}`,e),H(null),await Y(),u(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),u(`复制失败:${t}`,`error`)}finally{j(!1)}}}let Ke=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${ue(`prompts`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?v===null?(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):v?(0,T.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,T.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[G.query.trim()?(0,T.jsxs)(T.Fragment,{children:[`匹配 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.filtered.length}),` 个`,(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),Z.length>0?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,T.jsx)(`button`,{type:`button`,disabled:A||Z.length===0,onClick:()=>F({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:Ue,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),O?(0,T.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:O}):null,(0,T.jsx)(he,{resizeKey:`docs:prompts:cols:v1`,files:D,filtered:G.filtered,pageFiles:G.pageFiles,query:G.query,onQuery:G.setQuery,sortBy:G.sortBy,onSortBy:G.setSortBy,page:G.page,totalPages:G.totalPages,pageSize:G.pageSize,onPage:G.setPage,onPageSize:G.setPageSize,busy:A,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!m(e.path,I)&&!Q(e.path),selected:M,onToggleRow:e=>N(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>N(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Le(e),extraColumn:{header:`关联插件`,render:e=>(0,T.jsx)(Me,{path:e.path,enabled:I,mounted:R})},renderNameAction:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`重命名 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(S,{name:`pencil`,size:12})}),(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`复制 ${e.name}`,onClick:()=>Ve(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(S,{name:`copy`,size:12})})]}),renderActions:e=>{let t=m(e.path,I)||!!Q(e.path);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>void Re(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,T.jsx)(`button`,{type:`button`,disabled:A||t,"aria-label":`删除 ${e.name}`,onClick:()=>ze(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,T.jsx)(S,{name:`trash`,size:12})})]})}}),(0,T.jsx)(x,{open:z!=null,title:`重命名提示词`,label:`文件名称`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,error:U,onClose:()=>{B(null),W(``)},onConfirm:e=>void We(e)}),(0,T.jsx)(x,{open:V!=null,title:`复制提示词`,label:`新文件名称`,initialValue:V?V.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:U,onClose:()=>{H(null),W(``)},onConfirm:e=>void Ge(e)}),(0,T.jsx)(ee,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除提示词`,message:Ke,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void He()})]}):(0,T.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,T.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:c(`prompts`)}):(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{D as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.C4rpn1Ix.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.C0NrHGZv.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{m as u}from"./PmShared.D6iq_Z9g.js";import{showToast as d}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.CprZTsyX.js";import{c as f,d as p,h as ne,n as m,p as re,r as ie,u as ae,v as oe}from"./project-docs.DAw9bzgk.js";import{a as se,at as ce,c as le}from"./req-analysis.BAC_bd4R.js";import{n as ue}from"./doc-roots.DAJP9Svr.js";import{a as h,c as g,d as de,i as _,l as v,o as y,s as b,u as x}from"./prompts-meta.Dnmq-SnF.js";import{i as fe,n as pe,r as me,t as he}from"./DocsFileBrowser.DceJyP9V.js";import{d as ge,t as _e}from"./open-docs-in-session.5cTowYAC.js";import{F as ve,I as ye,i as be,r as xe}from"./case-review.TdDs1WFM.js";import{t as S}from"./NamePromptDialog.Csfnh5eM.js";import{i as Se}from"./report-prompt.B9C4cv84.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{f as Te,s as Ee,t as De,y as Oe}from"./story-review.CCSxTgNL.js";var C=e(t(),1),w=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(w));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Ae(e){try{sessionStorage.setItem(r(w),JSON.stringify(e))}catch{}}var T=l(),je=10;async function E(e=`.`){let{entries:t}=await f(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await E(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=x(e,n);if(!r)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=y(e,n);return(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,T.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function D(){let e=me(`prompts`),[t,r]=(0,C.useState)(!1),[l,f]=(0,C.useState)(!0),[y,w]=(0,C.useState)(e?!0:null),[D,Ne]=(0,C.useState)(()=>e??[]),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)({}),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(()=>i()),[R,Pe]=(0,C.useState)(()=>ke()),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),G=pe(D,je,`prompts`),K=(0,C.useRef)(!1),q=(0,C.useRef)(!1),Fe=(0,C.useRef)(!1),J=(0,C.useRef)(!1),Ie=(0,C.useRef)(!1),Y=(0,C.useCallback)(async()=>{k(null);try{let e=await E(`.`);Ne(e),fe(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e))}},[]);(0,C.useEffect)(()=>{if(!y||I.reqAnalysis!==!0||K.current)return;let e=new Set(D.map(e=>e.name));e.has(`需求分析提示词.md`)&&e.has(`原文结构提示词.md`)||(K.current=!0,ce(!0).then(()=>Y()).catch(()=>void 0))},[y,I.reqAnalysis,D,Y]),(0,C.useEffect)(()=>{y&&I.storyReview===!0&&!q.current&&(D.some(e=>e.name===`用户故事审查提示词.md`)||(q.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.storyReview,D,Y]),(0,C.useEffect)(()=>{y&&I.testPoints===!0&&!Fe.current&&(D.some(e=>e.name===`测试点生成提示词.md`)||(Fe.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.testPoints,D,Y]),(0,C.useEffect)(()=>{y&&I.caseReview===!0&&!J.current&&(D.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.caseReview,D,Y]),(0,C.useEffect)(()=>{y&&I.caseBlindspot===!0&&!Ie.current&&(D.some(e=>e.name===`场景遗漏补全提示词.md`)||(Ie.current=!0,ve(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.caseBlindspot,D,Y]),(0,C.useEffect)(()=>{let e=s(e=>{f(!!e.prompts),L(e)});return n().then(()=>{f(a(`prompts`)),L(i()),r(!0)}),e},[]),(0,C.useEffect)(()=>{t&&l&&(async()=>{await ie(`prompts`)?(await ge().catch(()=>null),await Y(),w(!0)):w(!1)})()},[t,l,Y]);let X=(0,C.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[g(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[g(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(I.reqAnalysis&&(i[g(se)]=`reqAnalysis`,i[g(le)]=`reqAnalysis`),I.storyReview&&(i[g(De)]=`storyReview`),I.testPoints&&(i[g(Te)]=`testPoints`),I.caseReview&&(i[g(be)]=`caseReview`),I.caseBlindspot&&(i[g(xe)]=`caseBlindspot`),I.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(i[g(t)]=`caseGen`)}return Ae(i),i})},[I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen]);(0,C.useEffect)(()=>{if(!t||!l)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,I.uiAuto,I.reports,I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen,X]);let Z=(0,C.useMemo)(()=>Object.keys(M).filter(e=>M[e]),[M]),Q=(0,C.useCallback)(e=>{let t=x(e,R);return!t||t===`system`||de(e)?``:I[t]===!0?t:``},[R,I]);async function Le(e){j(!0),k(null);try{await ae(`prompts`,e.path)}catch(e){k(e instanceof Error?e.message:String(e))}finally{j(!1)}}async function Re(e){j(!0),k(null);try{await _e(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e)),j(!1)}}function ze(e){if(b(e.path)){k(`默认提示词不可删除`);return}if(_(e.path,I)){k(v(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else F({kind:`one`,entry:e})}function Be(e){if(b(e.path)){k(`默认提示词不可改名`);return}if(_(e.path,I)){k(v(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else B(e),W(``)}function Ve(e){H(e),W(``)}async function He(){let e=P;if(e){F(null),j(!0),k(null);try{if(e.kind===`one`)await m(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)b(n)||_(n,I)||Q(n)?t+=1:await m(`prompts`,n);t&&k(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),N({})}await Y(),d(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),d(`删除失败:${t}`,`error`)}finally{j(!1)}}}function Ue(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:k(c(`promptGen`))}let $=(0,C.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=D.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[D]);async function We(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){B(null),W(``);return}let r=$(p(t.path),n,t.path);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{await ne(`prompts`,t.path,n),B(null),await Y(),d(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),d(`重命名失败:${t}`,`error`)}finally{j(!1)}}}async function Ge(e){let t=V;if(!t)return;let n=e.trim();if(!n)return;let r=$(p(t.path),n);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{let{content:e}=await re(`prompts`,t.path);await oe(`prompts`,p(t.path)===`.`?n:`${p(t.path)}/${n}`,e),H(null),await Y(),d(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),d(`复制失败:${t}`,`error`)}finally{j(!1)}}}let Ke=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${ue(`prompts`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?y===null?(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):y?(0,T.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,T.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[G.query.trim()?(0,T.jsxs)(T.Fragment,{children:[`匹配 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.filtered.length}),` 个`,(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),Z.length>0?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,T.jsx)(`button`,{type:`button`,disabled:A||Z.length===0,onClick:()=>F({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:Ue,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),O?(0,T.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:O}):null,(0,T.jsx)(he,{resizeKey:`docs:prompts:cols:v1`,files:D,filtered:G.filtered,pageFiles:G.pageFiles,query:G.query,onQuery:G.setQuery,sortBy:G.sortBy,onSortBy:G.setSortBy,page:G.page,totalPages:G.totalPages,pageSize:G.pageSize,onPage:G.setPage,onPageSize:G.setPageSize,busy:A,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!h(e.path,I)&&!Q(e.path),selected:M,onToggleRow:e=>N(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>N(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Le(e),extraColumn:{header:`关联插件`,render:e=>(0,T.jsx)(Me,{path:e.path,enabled:I,mounted:R})},renderNameAction:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`重命名 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(u,{name:`pencil`,size:12})}),(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`复制 ${e.name}`,onClick:()=>Ve(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(u,{name:`copy`,size:12})})]}),renderActions:e=>{let t=h(e.path,I)||!!Q(e.path);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>void Re(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,T.jsx)(`button`,{type:`button`,disabled:A||t,"aria-label":`删除 ${e.name}`,onClick:()=>ze(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,T.jsx)(u,{name:`trash`,size:12})})]})}}),(0,T.jsx)(S,{open:z!=null,title:`重命名提示词`,label:`文件名称`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,error:U,onClose:()=>{B(null),W(``)},onConfirm:e=>void We(e)}),(0,T.jsx)(S,{open:V!=null,title:`复制提示词`,label:`新文件名称`,initialValue:V?V.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:U,onClose:()=>{H(null),W(``)},onConfirm:e=>void Ge(e)}),(0,T.jsx)(ee,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除提示词`,message:Ke,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void He()})]}):(0,T.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,T.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:c(`prompts`)}):(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{D as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.C4rpn1Ix.js";import{i,o as ee,s as te}from"./plugins.C0NrHGZv.js";import{t as a}from"./jsx-runtime.DUg_B_vD.js";import{t as o}from"./ConfirmDialog.D5qXeML0.js";import{n as s,t as ne}from"./DocsPager.D0TMvJ67.js";import{t as re}from"./SelectDropdown.Dmk5n225.js";import{showToast as c}from"./Toast.BO2NFckG.js";import{a as ie,c as ae,l as oe,n as se,o as ce,s as le,t as l}from"./report-prompt.B9C4cv84.js";var u=e(t(),1),d=`tw.reports.kind.v1`,f=Object.keys(l);function p(e){return typeof e==`string`&&f.includes(e)}function ue(e=`day`){try{let t=localStorage.getItem(r(d));return p(t)?t:e}catch{return e}}function de(e){if(p(e))try{localStorage.setItem(r(d),e)}catch{}}var m=a(),fe=[`day`,`week`,`month`],pe=20,h=`tw.reports.page-size.v1`;function me(e){return e.replace(/\.(md|markdown|txt)$/i,``)}function g(e){return e.replace(/\.(md|markdown|txt|html?)$/i,``)}function _(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}/${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function he(e){return!Number.isFinite(e)||e<=0?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var ge={day:`日`,week:`周`,month:`月`};function _e(e){let t=!!e.indeterminate&&!e.checked;return(0,m.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e.checked,"aria-label":e.label,disabled:e.disabled,onClick:t=>{t.stopPropagation(),!e.disabled&&e.onChange()},className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-[5px] border transition-colors disabled:opacity-40 ${e.checked||t?`border-[#3370ff] bg-[#3370ff] text-white`:`border-stone-300 bg-white text-transparent hover:border-[#3370ff]/70`}`,children:t?(0,m.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`10`,height:`10`,"aria-hidden":`true`,children:(0,m.jsx)(`path`,{d:`M3.5 8h9`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})}):(0,m.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`10`,height:`10`,"aria-hidden":`true`,children:(0,m.jsx)(`path`,{d:`m3.5 8.2 2.8 2.8 6.2-6.4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function v(){let[e,t]=(0,u.useState)(!1),[r,a]=(0,u.useState)(!0),[d,f]=(0,u.useState)(()=>ue()),p=(0,u.useRef)(d),[v,y]=(0,u.useState)([]),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(!1),[w,T]=(0,u.useState)(null),[E,D]=(0,u.useState)(``),[O,k]=(0,u.useState)([]),[A,j]=(0,u.useState)(``),[M,N]=(0,u.useState)(!1),[P,F]=(0,u.useState)(1),[I,ve]=s(pe,h),[L,R]=(0,u.useState)({}),[z,B]=(0,u.useState)(null),[V,H]=(0,u.useState)(!1),U=(0,u.useCallback)(async(e,t)=>{C(!0),T(null);try{if(t?.ensure)try{await oe(!0)}catch{}let n=await ce(e);y(n.items),x(n.dir)}catch(e){let t=e instanceof Error?e.message:String(e);T(t.includes(`404`)?`工作汇报需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`:t),y([])}finally{C(!1)}},[]);(0,u.useEffect)(()=>{let e=ee(e=>a(!!e.reports));return n().then(()=>{a(i(`reports`)),t(!0)}),e},[]);let W=(0,u.useCallback)(async()=>{try{let e=await ie();k(e.items),j(e.promptFile),e.promptFile||c(`没有读到「提示词管理」里的工作汇报提示词,写汇报前请先在提示词管理里补一份。`,`error`)}catch(e){let t=e instanceof Error?e.message:String(e);c(`读取工作汇报提示词失败:${t}`,`error`)}},[]);(0,u.useEffect)(()=>{e&&r&&(async()=>{await U(p.current,{ensure:!0}),await W()})()},[e,r,U,W]);function ye(e){de(e),e!==d&&(f(e),F(1),R({}),y([]),U(e))}async function be(e){if(e&&e!==A){N(!0),T(null);try{let t=await ae(e);j(t),k(e=>e.map(e=>({...e,selected:e.name===t})))}catch(e){let t=e instanceof Error?e.message:String(e);T(t),c(`切换提示词失败:${t}`,`error`)}finally{N(!1)}}}let xe=(0,u.useMemo)(()=>O.length?O.map(e=>({value:e.name,label:me(e.name)})):[{value:``,label:`暂无提示词`}],[O]),G=(0,u.useMemo)(()=>[...v].sort((e,t)=>t.generatedAt-e.generatedAt),[v]),K=Math.max(1,Math.ceil(G.length/I)),q=Math.min(P,K),J=(0,u.useMemo)(()=>G.slice((q-1)*I,q*I),[G,q,I]),Y=(0,u.useMemo)(()=>Object.keys(L).filter(e=>L[e]&&v.some(t=>t.name===e)),[L,v]),X=J.length>0&&J.every(e=>!!L[e.name]),Se=J.some(e=>!!L[e.name])&&!X,Ce=`/workbench/?report=${d}`;function Z(e){R(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function Q(){R(e=>{let t={...e};if(X)for(let e of J)delete t[e.name];else for(let e of J)t[e.name]=!0;return t})}async function we(e){if(!(E||V)){D(e.name),T(null);try{await le(e.kind,e.name)}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(``)}}}async function Te(){let e=z;if(e?.length){H(!0),T(null);try{let t=await se(d,e);B(null),R(e=>{let n={...e};for(let e of t.deleted)delete n[e];return n}),c(t.deleted.length>1?`已删除 ${t.deleted.length} 篇${l[d]}`:`已删除「${g(t.deleted[0]||e[0]||``)}」`,`success`),t.missing.length&&c(`${t.missing.length} 篇未找到或已删除`,`error`),await U(d)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),c(`删除失败:${t}`,`error`)}finally{H(!1)}}}if(!e)return(0,m.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex items-center justify-center min-h-[220px]`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!r)return(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:te(`reports`)});let $=G[0];return(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:fe.map(e=>(0,m.jsx)(`button`,{type:`button`,onClick:()=>ye(e),className:`h-8 rounded-md px-3 text-sm transition-colors ${d===e?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:l[e]},e))}),(0,m.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[v.length>0?(0,m.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,m.jsx)(_e,{checked:X,indeterminate:Se,disabled:J.length===0||V,label:`全选本页汇报`,onChange:Q}),(0,m.jsx)(`button`,{type:`button`,disabled:J.length===0||V,onClick:()=>Q(),className:`disabled:opacity-40`,children:`全选本页`})]}):null,(0,m.jsxs)(`button`,{type:`button`,disabled:V||Y.length===0,onClick:()=>B(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:[`批量删除`,Y.length?` (${Y.length})`:``]}),(0,m.jsx)(re,{className:`w-[172px]`,flat:!0,options:xe,value:A,onChange:e=>void be(e),disabled:!O.length||M,ariaLabel:`选择工作汇报提示词`,menuMinWidth:200}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{await U(d),await W()})(),disabled:S||V,"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800 disabled:opacity-40`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,m.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,m.jsx)(`a`,{href:Ce,className:`inline-flex h-9 items-center whitespace-nowrap rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9]`,children:`去工作台写汇报`})]})]}),(0,m.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-400`,children:[(0,m.jsxs)(`span`,{children:[l[d],` · 共 `,v.length,` 篇`,Y.length?` · 已选 ${Y.length}`:``]}),$?(0,m.jsxs)(`span`,{className:`tabular-nums`,children:[`最近生成 `,_($.generatedAt)]}):null,(0,m.jsx)(`span`,{className:`min-w-0 truncate`,children:b||`—`}),(0,m.jsx)(`span`,{className:`ml-auto hidden shrink-0 sm:inline`,children:`单击选中 · 双击打开`})]})]}),w?(0,m.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,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:w}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>T(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,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/60 p-3 sm:p-4`,children:S&&v.length===0?(0,m.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center`,"aria-busy":`true`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):v.length===0?(0,m.jsxs)(`div`,{className:`flex min-h-[260px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-stone-300 px-6 py-10 text-center`,children:[(0,m.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-stone-100 text-stone-400`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,m.jsx)(`path`,{d:`M14 3v5h5`}),(0,m.jsx)(`path`,{d:`M9 13h6M9 17h4`})]})}),(0,m.jsxs)(`div`,{className:`text-sm font-medium text-stone-700`,children:[`还没有`,l[d]]}),(0,m.jsxs)(`p`,{className:`max-w-md text-xs leading-5 text-stone-400`,children:[`保存到 `,b||`工作汇报/${l[d]}`,` 后会自动出现在这里。`]})]}):(0,m.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,380px),1fr))] gap-2.5`,children:J.map(e=>{let t=!!L[e.name],n=!!E||V,r=t||Y.length>0,i=!r||t;return(0,m.jsx)(`li`,{children:(0,m.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":t,"aria-label":`${t?`取消选中`:`选中`} ${g(e.name)},双击打开`,onClick:()=>{n||Z(e.name)},onDoubleClick:t=>{t.preventDefault(),!n&&we(e)},onKeyDown:t=>{n||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Z(e.name))},className:`group relative flex w-full cursor-pointer items-center gap-3 overflow-hidden rounded-xl border bg-white px-3.5 py-3 text-left transition-colors select-none ${t?`border-[#3370ff] shadow-[0_0_0_1px_rgba(51,112,255,0.12)]`:i?`border-stone-200 hover:border-[#3370ff]/45`:`border-stone-200`} ${n?`opacity-60`:``}`,children:[(0,m.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-0 bg-[#3370ff]/[0.07] transition-opacity ${t?`opacity-100`:`opacity-0`}`}),(0,m.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,"aria-label":`选择 ${g(e.name)}`,disabled:V,onClick:t=>{t.stopPropagation(),V||Z(e.name)},className:`absolute left-0 top-0 z-10 h-[22px] w-[22px] disabled:opacity-40 ${t||r?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:[(0,m.jsxs)(`svg`,{viewBox:`0 0 22 22`,className:`absolute inset-0 h-full w-full`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M0 0h22L0 22z`,fill:`#3370ff`}),t?null:(0,m.jsx)(`path`,{d:`M0 0h22L0 22z`,fill:`#fff`,fillOpacity:.45})]}),(0,m.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`9`,height:`9`,className:`absolute left-[3px] top-[3px] text-white ${t?`opacity-100`:`opacity-70`}`,"aria-hidden":`true`,children:(0,m.jsx)(`path`,{d:`m3.4 8 2.8 2.8 6.2-6.4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,m.jsx)(`span`,{className:`relative z-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-[13px] font-semibold text-stone-600`,children:ge[e.kind]}),(0,m.jsxs)(`span`,{className:`relative z-1 min-w-0 flex-1`,children:[(0,m.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800 transition-colors ${i?`group-hover:text-[#3370ff]`:``}`,children:g(e.name)}),(0,m.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-stone-400 tabular-nums`,children:[_(e.generatedAt),` · `,he(e.size),E===e.name?` · 打开中…`:``]})]}),(0,m.jsx)(`button`,{type:`button`,"aria-label":`删除 ${g(e.name)}`,disabled:V,onClick:t=>{t.stopPropagation(),B([e.name])},className:`relative z-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-40`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})},e.name)})})}),v.length>0?(0,m.jsx)(ne,{page:q,totalPages:K,pageSize:I,busy:S||V,onPage:F,onPageSize:e=>{ve(e),F(1)}}):(0,m.jsx)(`div`,{className:`pb-2.5`}),(0,m.jsx)(o,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除汇报`,message:z&&z.length>1?`确认删除已选中的 ${z.length} 篇${l[d]}?此操作不可恢复。`:`删除「${g(z?.[0]||``)}」?此操作不可恢复。`,confirmLabel:V?`删除中…`:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>{V||B(null)},onConfirm:()=>void Te()})]})}export{v as default};