@runfusion/fusion 0.71.0 → 0.72.0

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 (93) hide show
  1. package/dist/bin.js +2251 -2176
  2. package/dist/child-process-worker.js +1545 -1485
  3. package/dist/client/.vite/manifest.json +244 -244
  4. package/dist/client/assets/{AgentDetailView-BvY24zNh.js → AgentDetailView-Bq6qfKGR.js} +5 -5
  5. package/dist/client/assets/{AgentPermissionPolicyEditor-CYvJw48-.js → AgentPermissionPolicyEditor-Dah1P8IX.js} +2 -2
  6. package/dist/client/assets/{AgentsView-BWkWEfNs.js → AgentsView-Bu8h0vGY.js} +4 -4
  7. package/dist/client/assets/{ChatView-BhlVq9Re.js → ChatView-BTE8fIib.js} +1 -1
  8. package/dist/client/assets/{CommandCenter-DingokjC.js → CommandCenter-l4no66mI.js} +1 -1
  9. package/dist/client/assets/{DevServerView-kfNJk83M.js → DevServerView-Cuxhgjdv.js} +1 -1
  10. package/dist/client/assets/DirectoryPicker-tm1SS2jF.js +1 -0
  11. package/dist/client/assets/{DocumentsView-Bwc5HSg7.js → DocumentsView-Dg8lFF7X.js} +2 -2
  12. package/dist/client/assets/{EvalsView-BEr_MhJ4.js → EvalsView-TccfkTNy.js} +1 -1
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-CZK-KtFP.js → ExperimentalAgentOnboardingModal-2qAtocIG.js} +1 -1
  14. package/dist/client/assets/{GoalsView-B_Qrm8po.js → GoalsView-Du_jIEn2.js} +1 -1
  15. package/dist/client/assets/{InsightsView-BfbclBHM.js → InsightsView-BxJ327Tj.js} +2 -2
  16. package/dist/client/assets/{MemoryView-V9Y08BtR.js → MemoryView-Blv0YUWC.js} +2 -2
  17. package/dist/client/assets/{PiExtensionsManager-B7fl5l3O.js → PiExtensionsManager-BUS_ZKwO.js} +2 -2
  18. package/dist/client/assets/{PluginManager-H32X557C.js → PluginManager-DM5-rNen.js} +1 -1
  19. package/dist/client/assets/{PullRequestView-Dhz86tnJ.js → PullRequestView-D7ozwDrc.js} +2 -2
  20. package/dist/client/assets/{ResearchView-DEObk9J2.js → ResearchView-CRGaOkBH.js} +1 -1
  21. package/dist/client/assets/{SecretsView-DFEWUbXI.js → SecretsView-Nwc-7xGn.js} +1 -1
  22. package/dist/client/assets/{SessionTerminal-CwfTrmor.js → SessionTerminal-gC7X57E6.js} +1 -1
  23. package/dist/client/assets/{SettingsModal-H1TNebmF.js → SettingsModal-CuEXiFb_.js} +4 -4
  24. package/dist/client/assets/{SettingsModal-2mlwjfVZ.js → SettingsModal-q_D1o7T-.js} +1 -1
  25. package/dist/client/assets/{SettingsTextareaRow-ByeSU4Pi.js → SettingsTextareaRow-DnsWtbkh.js} +1 -1
  26. package/dist/client/assets/SetupWizardModal-3-mXX0VJ.js +2 -0
  27. package/dist/client/assets/{SkillsView-DScNdDRz.js → SkillsView-Dw8m0G-9.js} +1 -1
  28. package/dist/client/assets/{ThemeDropdown-BKl0kouU.js → ThemeDropdown-C7qybW7w.js} +1 -1
  29. package/dist/client/assets/{TodoView-_HojIE_Y.js → TodoView-r_qHhO28.js} +2 -2
  30. package/dist/client/assets/{WorkflowNodeEditor-CoQYdUYX.js → WorkflowNodeEditor-B0TGhu5B.js} +1 -1
  31. package/dist/client/assets/{architectureDiagram-3BPJPVTR-vIoH_tGm.js → architectureDiagram-3BPJPVTR-9REjGWnr.js} +1 -1
  32. package/dist/client/assets/{blockDiagram-GPEHLZMM-BqjSE9AM.js → blockDiagram-GPEHLZMM-OATfTc06.js} +1 -1
  33. package/dist/client/assets/{c4Diagram-AAUBKEIU-TWEWVE4T.js → c4Diagram-AAUBKEIU-B-nq1avj.js} +1 -1
  34. package/dist/client/assets/channel-BW-0I-xJ.js +1 -0
  35. package/dist/client/assets/{chunk-2J33WTMH-CJM3p9Fh.js → chunk-2J33WTMH-Dds2A4Un.js} +1 -1
  36. package/dist/client/assets/{chunk-4BX2VUAB-Bf_1wJ7O.js → chunk-4BX2VUAB-Dc-jRxxZ.js} +1 -1
  37. package/dist/client/assets/{chunk-55IACEB6-CI4ThikJ.js → chunk-55IACEB6-CKtwSOvQ.js} +1 -1
  38. package/dist/client/assets/{chunk-727SXJPM-C2TasaKk.js → chunk-727SXJPM-DbRZhQCr.js} +1 -1
  39. package/dist/client/assets/{chunk-AQP2D5EJ-BqKUxt3g.js → chunk-AQP2D5EJ-Dq_cSIeh.js} +1 -1
  40. package/dist/client/assets/{chunk-FMBD7UC4-CdK77AxG.js → chunk-FMBD7UC4-BmnvYNOo.js} +1 -1
  41. package/dist/client/assets/{chunk-ND2GUHAM-TE8zbIZ3.js → chunk-ND2GUHAM-D6nyZn0C.js} +1 -1
  42. package/dist/client/assets/{chunk-QZHKN3VN-7lgttGIx.js → chunk-QZHKN3VN-FFojVCmd.js} +1 -1
  43. package/dist/client/assets/classDiagram-4FO5ZUOK-DfBIljo4.js +1 -0
  44. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DfBIljo4.js +1 -0
  45. package/dist/client/assets/{cose-bilkent-S5V4N54A-DsK8EBeo.js → cose-bilkent-S5V4N54A-DysS3-yZ.js} +1 -1
  46. package/dist/client/assets/{dagre-BM42HDAG-COza1ss6.js → dagre-BM42HDAG-DgL7uNq4.js} +1 -1
  47. package/dist/client/assets/{dashboard-view-ILJ_vnYK.js → dashboard-view-Bu_nB-cd.js} +1 -1
  48. package/dist/client/assets/{dashboard-view-D_etacMS.js → dashboard-view-DlxD_dta.js} +1 -1
  49. package/dist/client/assets/{dashboard-view-JEFD-Zgw.js → dashboard-view-ln6_a3ZY.js} +1 -1
  50. package/dist/client/assets/{diagram-2AECGRRQ-Co_F0-vp.js → diagram-2AECGRRQ-DTACb17z.js} +1 -1
  51. package/dist/client/assets/{diagram-5GNKFQAL-BD_n7vU0.js → diagram-5GNKFQAL-DqdKDR_d.js} +1 -1
  52. package/dist/client/assets/{diagram-KO2AKTUF-SFnuzet_.js → diagram-KO2AKTUF-CCKa3iUW.js} +1 -1
  53. package/dist/client/assets/{diagram-LMA3HP47-CFYeR0mH.js → diagram-LMA3HP47-C2SLmXdM.js} +1 -1
  54. package/dist/client/assets/{diagram-OG6HWLK6-DOVfqKgw.js → diagram-OG6HWLK6-Dz9wXgRN.js} +1 -1
  55. package/dist/client/assets/{erDiagram-TEJ5UH35-DkeW3bDN.js → erDiagram-TEJ5UH35-GGHapzlB.js} +1 -1
  56. package/dist/client/assets/{flowDiagram-I6XJVG4X-CVaNMQl_.js → flowDiagram-I6XJVG4X-B3SLxAlP.js} +1 -1
  57. package/dist/client/assets/{folder-open-BY1Gp9Wf.js → folder-open-BWBZSyO2.js} +1 -1
  58. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BQJ0x5Hq.js → ganttDiagram-6RSMTGT7-DYveq-32.js} +1 -1
  59. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CIt0P2Lg.js → gitGraphDiagram-PVQCEYII-Bxh-7IFt.js} +1 -1
  60. package/dist/client/assets/{index-GJLKrqhe.css → index-CiqkhNwQ.css} +1 -1
  61. package/dist/client/assets/{index-ClPjlOHJ.js → index-D8sgsB8q.js} +268 -268
  62. package/dist/client/assets/{infoDiagram-5YYISTIA-B1KKCn80.js → infoDiagram-5YYISTIA-B3_g2TQW.js} +1 -1
  63. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-CzG1cEeg.js → ishikawaDiagram-YF4QCWOH-CExRn4qZ.js} +1 -1
  64. package/dist/client/assets/{journeyDiagram-JHISSGLW-CNB7oM4Q.js → journeyDiagram-JHISSGLW-Dgck68vd.js} +1 -1
  65. package/dist/client/assets/{kanban-definition-UN3LZRKU-D8vXTzfs.js → kanban-definition-UN3LZRKU-B258_39Z.js} +1 -1
  66. package/dist/client/assets/{mermaid.core-BUhJJv1M.js → mermaid.core-uCT9za93.js} +4 -4
  67. package/dist/client/assets/{mindmap-definition-RKZ34NQL-y_XyU0Us.js → mindmap-definition-RKZ34NQL-DHevd0he.js} +1 -1
  68. package/dist/client/assets/{pieDiagram-4H26LBE5-MB9aZtTc.js → pieDiagram-4H26LBE5-rTbXqg0x.js} +1 -1
  69. package/dist/client/assets/{puzzle-CE00Ce2g.js → puzzle-D7NHfczg.js} +1 -1
  70. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-hF7q33gK.js → quadrantDiagram-W4KKPZXB-C-N3JbLv.js} +1 -1
  71. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BIOIzbEd.js → requirementDiagram-4Y6WPE33-DNINb6LP.js} +1 -1
  72. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BpLzUxJ8.js → sankeyDiagram-5OEKKPKP-UI7SyvRN.js} +1 -1
  73. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-CLXamQhZ.js → sequenceDiagram-3UESZ5HK-pc1RDjwM.js} +1 -1
  74. package/dist/client/assets/{shield-alert-BhLVV0rp.js → shield-alert-c_--H0ce.js} +1 -1
  75. package/dist/client/assets/{standing-instructions-template-96KSNan7.js → standing-instructions-template-aTeHy5lT.js} +1 -1
  76. package/dist/client/assets/{stateDiagram-AJRCARHV-CPRWhQtZ.js → stateDiagram-AJRCARHV-CEiZfKWc.js} +1 -1
  77. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-8GvpOVMc.js → stateDiagram-v2-BHNVJYJU-B7aNz5OD.js} +1 -1
  78. package/dist/client/assets/{timeline-definition-PNZ67QCA-BAAldJMW.js → timeline-definition-PNZ67QCA-DyE71jn0.js} +1 -1
  79. package/dist/client/assets/{upload-DbKZcYCW.js → upload-YGrA50-5.js} +1 -1
  80. package/dist/client/assets/{users-ccVe3aKQ.js → users-fxiLvP6C.js} +1 -1
  81. package/dist/client/assets/{vennDiagram-CIIHVFJN-DGSAcrfx.js → vennDiagram-CIIHVFJN-DX-6Y82D.js} +1 -1
  82. package/dist/client/assets/{wardley-L42UT6IY-CLGvNiAx.js → wardley-L42UT6IY-ew7KQxeH.js} +1 -1
  83. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-BhU8FLGx.js → wardleyDiagram-YWT4CUSO-DqSCrJdO.js} +1 -1
  84. package/dist/client/assets/{xychartDiagram-2RQKCTM6-BQ6AzTfE.js → xychartDiagram-2RQKCTM6-CEtZEj45.js} +1 -1
  85. package/dist/client/index.html +2 -2
  86. package/dist/client/version.json +1 -1
  87. package/dist/extension.js +1767 -1707
  88. package/package.json +1 -1
  89. package/dist/client/assets/DirectoryPicker-Cluyep4u.js +0 -1
  90. package/dist/client/assets/SetupWizardModal-BFZnVJX1.js +0 -2
  91. package/dist/client/assets/channel-hhQEu5zM.js +0 -1
  92. package/dist/client/assets/classDiagram-4FO5ZUOK-C2Thhy7D.js +0 -1
  93. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C2Thhy7D.js +0 -1
@@ -1 +1 @@
1
- import{r}from"./vendor-react-SZ_qB27O.js";import{Y as n,aS as s}from"./index-ClPjlOHJ.js";function x(e){return n(s("/memory/files",e))}function C(e,t){const c=`path=${encodeURIComponent(e)}`;return n(s(`/memory/file?${c}`,t))}function F(e,t,c){return n(s("/memory/file",c),{method:"PUT",body:JSON.stringify({path:e,content:t})})}function J(e,t){return n(s("/memory/compact",t),{method:"POST",body:JSON.stringify(e?{path:e}:{})})}function N(e){return n(s("/memory/dream",e),{method:"POST"})}function W(e){return n(s("/memory/insights",e))}function j(e,t){return n(s("/memory/insights",t),{method:"PUT",body:JSON.stringify({content:e})})}function q(e){return n(s("/memory/extract",e),{method:"POST"})}function D(e){return n(s("/memory/audit",e))}function w(e){return n(s("/memory/backend",e))}function L(e){return n(s("/memory/install-qmd",e),{method:"POST"})}function $(e,t){return n(s("/memory/test",t),{method:"POST",body:JSON.stringify({query:e})})}function Q(e={}){const{projectId:t,pollInterval:c=6e4,autoRefresh:p=!1,enabled:a=!0}=e,[g,y]=r.useState(null),[S,m]=r.useState(a),[M,d]=r.useState(null),[k,v]=r.useState(null),o=r.useRef(null),u=r.useRef(null),l=r.useRef(!0),i=r.useCallback(async()=>{if(!a){m(!1),d(null),y(null);return}o.current&&o.current.abort(),o.current=new AbortController,m(!0),d(null),y(null);try{const f=await w(t);if(!l.current)return;y(f),d(null),v(new Date),m(!1)}catch(f){if(f instanceof Error&&f.name==="AbortError"||!l.current)return;const B=f instanceof Error?f.message:"Failed to fetch memory backend status";d(B),m(!1)}},[a,t]);r.useEffect(()=>(l.current=!0,a?(i(),()=>{l.current=!1}):(o.current&&o.current.abort(),y(null),d(null),m(!1),()=>{l.current=!1})),[a,i]),r.useEffect(()=>{if(!(!a||!p))return u.current=setInterval(()=>{i()},c),()=>{u.current&&(clearInterval(u.current),u.current=null)}},[a,p,c,i]),r.useEffect(()=>()=>{l.current=!1,o.current&&o.current.abort(),u.current&&(clearInterval(u.current),u.current=null)},[]);const I=r.useCallback(()=>i(),[i]),b=S?null:g,R=b?.currentBackend??null,h=b?.capabilities??null,E=b?.availableBackends??[],O=h?.readable??!1,P=h?.writable??!1,T=h?.supportsAtomicWrite??!1;return{status:b,currentBackend:R,capabilities:h,availableBackends:E,isReadable:O,isWritable:P,supportsAtomicWrite:T,loading:S,error:M,lastUpdated:k,refresh:I}}export{x as a,D as b,W as c,j as d,q as e,C as f,N as g,J as h,L as i,F as s,$ as t,Q as u};
1
+ import{r}from"./vendor-react-SZ_qB27O.js";import{Y as n,aU as s}from"./index-D8sgsB8q.js";function x(e){return n(s("/memory/files",e))}function C(e,t){const c=`path=${encodeURIComponent(e)}`;return n(s(`/memory/file?${c}`,t))}function F(e,t,c){return n(s("/memory/file",c),{method:"PUT",body:JSON.stringify({path:e,content:t})})}function J(e,t){return n(s("/memory/compact",t),{method:"POST",body:JSON.stringify(e?{path:e}:{})})}function N(e){return n(s("/memory/dream",e),{method:"POST"})}function W(e){return n(s("/memory/insights",e))}function j(e,t){return n(s("/memory/insights",t),{method:"PUT",body:JSON.stringify({content:e})})}function q(e){return n(s("/memory/extract",e),{method:"POST"})}function D(e){return n(s("/memory/audit",e))}function U(e){return n(s("/memory/backend",e))}function L(e){return n(s("/memory/install-qmd",e),{method:"POST"})}function $(e,t){return n(s("/memory/test",t),{method:"POST",body:JSON.stringify({query:e})})}function Q(e={}){const{projectId:t,pollInterval:c=6e4,autoRefresh:p=!1,enabled:a=!0}=e,[S,y]=r.useState(null),[g,m]=r.useState(a),[M,d]=r.useState(null),[k,v]=r.useState(null),o=r.useRef(null),u=r.useRef(null),l=r.useRef(!0),i=r.useCallback(async()=>{if(!a){m(!1),d(null),y(null);return}o.current&&o.current.abort(),o.current=new AbortController,m(!0),d(null),y(null);try{const f=await U(t);if(!l.current)return;y(f),d(null),v(new Date),m(!1)}catch(f){if(f instanceof Error&&f.name==="AbortError"||!l.current)return;const B=f instanceof Error?f.message:"Failed to fetch memory backend status";d(B),m(!1)}},[a,t]);r.useEffect(()=>(l.current=!0,a?(i(),()=>{l.current=!1}):(o.current&&o.current.abort(),y(null),d(null),m(!1),()=>{l.current=!1})),[a,i]),r.useEffect(()=>{if(!(!a||!p))return u.current=setInterval(()=>{i()},c),()=>{u.current&&(clearInterval(u.current),u.current=null)}},[a,p,c,i]),r.useEffect(()=>()=>{l.current=!1,o.current&&o.current.abort(),u.current&&(clearInterval(u.current),u.current=null)},[]);const I=r.useCallback(()=>i(),[i]),b=g?null:S,R=b?.currentBackend??null,h=b?.capabilities??null,E=b?.availableBackends??[],O=h?.readable??!1,P=h?.writable??!1,T=h?.supportsAtomicWrite??!1;return{status:b,currentBackend:R,capabilities:h,availableBackends:E,isReadable:O,isWritable:P,supportsAtomicWrite:T,loading:g,error:M,lastUpdated:k,refresh:I}}export{x as a,D as b,W as c,j as d,q as e,C as f,N as g,J as h,L as i,F as s,$ as t,Q as u};
@@ -1 +1 @@
1
- import{r as h,j as e}from"./vendor-react-SZ_qB27O.js";import{u as j}from"./vendor-i18n-GF3RlKbq.js";import{dm as S,a9 as E}from"./index-ClPjlOHJ.js";const b="fusion:settings-help-open";function y({children:s,settingKey:l}){const{t:n}=j("app"),[c,o]=h.useState(!1),a=h.useRef(null),p=h.useId(),d=`settings-help-${l??p}`;h.useEffect(()=>{const t=i=>{i.detail!==d&&o(!1)};return document.addEventListener(b,t),()=>document.removeEventListener(b,t)},[d]);const u=()=>{o(t=>{const i=!t;return i&&document.dispatchEvent(new CustomEvent(b,{detail:d})),i})};return h.useEffect(()=>{if(!c)return;const t=r=>{a.current?.contains(r.target)||o(!1)},i=r=>{r.key==="Escape"&&(r.stopPropagation(),o(!1))};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",i,!0)}},[c]),e.jsxs("span",{className:"settings-help","data-open":c?"true":"false",ref:a,children:[e.jsx("button",{type:"button",className:"settings-help-trigger","aria-label":n("settings.help.show","Show help"),"aria-expanded":c,"aria-describedby":d,"data-testid":l?`settings-help-${l}`:void 0,onClick:u,children:e.jsx(S,{size:13,"aria-hidden":!0})}),e.jsx("span",{id:d,role:"note",className:"settings-help-bubble",children:s})]})}const N=h.createContext({highlightedKey:null});function L({highlightedKey:s,children:l}){const n=h.useMemo(()=>({highlightedKey:s}),[s]);return e.jsx(N.Provider,{value:n,children:l})}function k(s){const{highlightedKey:l}=h.useContext(N);return s!==void 0&&s===l}function f({htmlFor:s,label:l,help:n,error:c,scope:o,disabled:a,clearable:p,onClear:d,inlineControl:u,children:t}){const{t:i}=j("app"),r=k(s),g=e.jsxs("div",{className:"settings-field-row-control",children:[t,p&&e.jsx("button",{type:"button",className:"settings-field-row-clear","aria-label":i("settings.clearToDefault","Reset to default"),title:i("settings.clearToDefault","Reset to default"),disabled:a,onClick:d,children:e.jsx(E,{size:13,"aria-hidden":!0})})]}),m=e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"settings-field-row-label",htmlFor:s,children:l}),o&&e.jsx("span",{className:`settings-field-row-scope settings-field-row-scope--${o}`,"data-testid":"settings-field-row-scope",children:o}),n&&e.jsx(y,{settingKey:s,children:n})]});return e.jsxs("div",{className:`settings-field-row${u?" settings-field-row--inline":""}${a?" is-disabled":""}${r?" is-search-match":""}`,"data-settings-key":s,children:[e.jsxs("div",{className:"settings-field-row-head",children:[u&&g,e.jsx("div",{className:"settings-field-row-labelgroup",children:m})]}),!u&&g,c&&e.jsx("p",{className:"settings-field-row-error",role:"alert",children:c})]})}function P({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t}=s;return e.jsx(f,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),inlineControl:!0,children:e.jsx("label",{className:"settings-toggle",children:e.jsx("input",{id:a,type:"checkbox",checked:l===!0,disabled:t,onChange:i=>n(i.target.checked)})})})}function $({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,options:i}=s;return e.jsx(f,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("select",{id:a,className:"select settings-select",value:l??"",disabled:t,onChange:r=>n(r.target.value),children:i.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})})}function H({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,min:i,max:r,step:g,placeholder:m}=s;return e.jsx(f,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("input",{id:a,className:"input settings-number",type:"number",value:l??"",min:i,max:r,step:g,placeholder:m,disabled:t,onChange:x=>{const v=x.target.value;if(v==="")return n(null);const w=Number(v);Number.isNaN(w)||n(w)}})})}function I({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,placeholder:i,type:r,autoComplete:g}=s,m=g??(r==="password"?"off":void 0);return e.jsx(f,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("input",{id:a,className:"input settings-text",type:r??"text",autoComplete:m,value:l??"",placeholder:i,disabled:t,onChange:x=>n(x.target.value)})})}function D({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,placeholder:i}=s;return e.jsx(f,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("textarea",{id:a,className:"input settings-textarea",value:l??"",placeholder:i,disabled:t,rows:3,onChange:r=>n(r.target.value)})})}export{f as S,I as a,D as b,$ as c,H as d,P as e,y as f,L as g};
1
+ import{r as h,j as e}from"./vendor-react-SZ_qB27O.js";import{u as j}from"./vendor-i18n-GF3RlKbq.js";import{dn as S,a9 as E}from"./index-D8sgsB8q.js";const b="fusion:settings-help-open";function y({children:s,settingKey:l}){const{t:n}=j("app"),[c,o]=h.useState(!1),a=h.useRef(null),p=h.useId(),d=`settings-help-${l??p}`;h.useEffect(()=>{const t=i=>{i.detail!==d&&o(!1)};return document.addEventListener(b,t),()=>document.removeEventListener(b,t)},[d]);const u=()=>{o(t=>{const i=!t;return i&&document.dispatchEvent(new CustomEvent(b,{detail:d})),i})};return h.useEffect(()=>{if(!c)return;const t=r=>{a.current?.contains(r.target)||o(!1)},i=r=>{r.key==="Escape"&&(r.stopPropagation(),o(!1))};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",i,!0)}},[c]),e.jsxs("span",{className:"settings-help","data-open":c?"true":"false",ref:a,children:[e.jsx("button",{type:"button",className:"settings-help-trigger","aria-label":n("settings.help.show","Show help"),"aria-expanded":c,"aria-describedby":d,"data-testid":l?`settings-help-${l}`:void 0,onClick:u,children:e.jsx(S,{size:13,"aria-hidden":!0})}),e.jsx("span",{id:d,role:"note",className:"settings-help-bubble",children:s})]})}const N=h.createContext({highlightedKey:null});function L({highlightedKey:s,children:l}){const n=h.useMemo(()=>({highlightedKey:s}),[s]);return e.jsx(N.Provider,{value:n,children:l})}function k(s){const{highlightedKey:l}=h.useContext(N);return s!==void 0&&s===l}function m({htmlFor:s,label:l,help:n,error:c,scope:o,disabled:a,clearable:p,onClear:d,inlineControl:u,children:t}){const{t:i}=j("app"),r=k(s),g=e.jsxs("div",{className:"settings-field-row-control",children:[t,p&&e.jsx("button",{type:"button",className:"settings-field-row-clear","aria-label":i("settings.clearToDefault","Reset to default"),title:i("settings.clearToDefault","Reset to default"),disabled:a,onClick:d,children:e.jsx(E,{size:13,"aria-hidden":!0})})]}),f=e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"settings-field-row-label",htmlFor:s,children:l}),o&&e.jsx("span",{className:`settings-field-row-scope settings-field-row-scope--${o}`,"data-testid":"settings-field-row-scope",children:o}),n&&e.jsx(y,{settingKey:s,children:n})]});return e.jsxs("div",{className:`settings-field-row${u?" settings-field-row--inline":""}${a?" is-disabled":""}${r?" is-search-match":""}`,"data-settings-key":s,children:[e.jsxs("div",{className:"settings-field-row-head",children:[u&&g,e.jsx("div",{className:"settings-field-row-labelgroup",children:f})]}),!u&&g,c&&e.jsx("p",{className:"settings-field-row-error",role:"alert",children:c})]})}function P({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t}=s;return e.jsx(m,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),inlineControl:!0,children:e.jsx("label",{className:"settings-toggle",children:e.jsx("input",{id:a,type:"checkbox",checked:l===!0,disabled:t,onChange:i=>n(i.target.checked)})})})}function $({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,options:i}=s;return e.jsx(m,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("select",{id:a,className:"select settings-select",value:l??"",disabled:t,onChange:r=>n(r.target.value),children:i.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})})}function H({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,min:i,max:r,step:g,placeholder:f}=s;return e.jsx(m,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("input",{id:a,className:"input settings-number",type:"number",value:l??"",min:i,max:r,step:g,placeholder:f,disabled:t,onChange:x=>{const v=x.target.value;if(v==="")return n(null);const w=Number(v);Number.isNaN(w)||n(w)}})})}function I({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,placeholder:i,type:r,autoComplete:g}=s,f=g??(r==="password"?"off":void 0);return e.jsx(m,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("input",{id:a,className:"input settings-text",type:r??"text",autoComplete:f,value:l??"",placeholder:i,disabled:t,onChange:x=>n(x.target.value)})})}function D({descriptor:s,value:l,onChange:n,error:c,clearable:o}){const{key:a,label:p,help:d,scope:u,disabled:t,placeholder:i}=s;return e.jsx(m,{htmlFor:a,label:p,help:d,error:c,scope:u,disabled:t,clearable:o,onClear:()=>n(null),children:e.jsx("textarea",{id:a,className:"input settings-textarea",value:l??"",placeholder:i,disabled:t,rows:3,onChange:r=>n(r.target.value)})})}export{m as S,I as a,D as b,$ as c,H as d,P as e,y as f,L as g};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ExperimentalAgentOnboardingModal-2qAtocIG.js","assets/vendor-react-SZ_qB27O.js","assets/index-D8sgsB8q.js","assets/vendor-i18n-GF3RlKbq.js","assets/vendor-reactflow-9C3XTE7_.js","assets/vendor-reactflow-C5ap-Sga.css","assets/vendor-codemirror-jBKmHyH0.js","assets/vendor-xterm-BNq00GSj.js","assets/vendor-xterm-LZoznX6r.css","assets/index-CiqkhNwQ.css","assets/ExperimentalAgentOnboardingModal-3ZEFv8sr.css"])))=>i.map(i=>d[i]);
2
+ import{a1 as de,v as x,aq as R,ar as L,as as pe,at as ue,au as me,av as G,aw as ge,ax as he,ay as xe,az as fe,X as je,L as M,e as we,aA as W,S as ye,aB as O,aC as Ne,_ as be}from"./index-D8sgsB8q.js";import{r as o,j as e}from"./vendor-react-SZ_qB27O.js";import{D as ke}from"./DirectoryPicker-tm1SS2jF.js";import{s as D}from"./projectDetection-G3XuxD2X.js";import{u as Ce}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";import"./folder-open-BWBZSyO2.js";function H(c){return c.filter(p=>p.type!=="local")}function ve(c){return H(c).length>0}function S(c){const p=c.replace(/[^a-zA-Z]/g,"").toUpperCase();return p.length>=2&&p.length<=4?p:p.length>4?p.slice(0,4):"FN"}const Pe=o.lazy(()=>be(()=>import("./ExperimentalAgentOnboardingModal-2qAtocIG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(c=>({default:c.ExperimentalAgentOnboardingModal})));function Te({onProjectRegistered:c,onClose:p,agentOnboardingEnabled:F=!1,includeAgentStep:f=!0}){const{t:s}=Ce("app"),{confirmWithChoice:b}=de(),_="https://discord.gg/ksrfuy7WYR",k=o.useMemo(()=>R("ceo")??x[0],[]),[B,Y]=o.useState(!0),[t,n]=o.useState(()=>({step:"manual",manualMode:"existing",manualPath:"",manualCloneUrl:"",manualName:"",manualIsolationMode:"in-process",manualNodeId:"",manualTaskPrefix:"",detectedRepos:[],workspaceMode:!1,isDetectingWorkspace:!1,registeredProject:null,selectedPresetId:k.id,agentDraft:L(k),isCreatingAgent:!1,isRegistering:!1,error:null,agentError:null,agentOutcome:null})),[E,$]=o.useState(!1),[T,C]=o.useState(!1),U=o.useRef(null),{nodes:v,loading:q}=pe(),K=v.find(a=>a.type==="local")?.id,P=o.useCallback(()=>{Y(!1),p?.()},[p]),Z=o.useCallback(()=>{if(t.registeredProject){c(t.registeredProject);return}P()},[P,c,t.registeredProject]);o.useEffect(()=>{t.agentError&&U.current?.focus()},[t.agentError]);const j=o.useRef(0),w=o.useRef(!1),V=o.useCallback(a=>{if(n(i=>{const r={manualPath:a,detectedRepos:[],workspaceMode:!1,error:null};a&&(!i.manualName||i.manualName===D(i.manualPath))&&(r.manualName=D(a));const d=r.manualName??i.manualName;return d&&(!i.manualTaskPrefix||i.manualTaskPrefix===S(D(i.manualPath)))&&(r.manualTaskPrefix=S(d)),{...i,...r}}),t.manualMode==="existing"&&a.trim()&&a.trim()!=="/"){const i=++j.current;n(r=>({...r,isDetectingWorkspace:!0})),ue(a.trim()).then(r=>{i===j.current&&n(d=>({...d,isDetectingWorkspace:!1,detectedRepos:r.repos,workspaceMode:r.isWorkspace}))}).catch(()=>{i===j.current&&n(r=>({...r,isDetectingWorkspace:!1}))})}},[t.manualMode]),z=o.useCallback(a=>{n(i=>({...i,manualMode:a,manualCloneUrl:a==="clone"?i.manualCloneUrl:"",detectedRepos:a==="existing"?i.detectedRepos:[],workspaceMode:a==="existing"?i.workspaceMode:!1,isDetectingWorkspace:!1,error:null})),j.current+=1},[]),X=o.useCallback(async()=>{const a=t.manualPath.trim(),i=t.manualName.trim(),r=t.manualCloneUrl.trim();if(!a||!i||t.manualMode==="clone"&&!r||w.current||t.isRegistering)return;w.current=!0,n(l=>({...l,isRegistering:!0,error:null}));const d=()=>{w.current=!1,n(l=>({...l,isRegistering:!1}))};let m=!1;try{const{gitCli:l}=await me();if(l&&!l.available){if(t.manualMode==="clone"){await b({title:s("setup.gitMissingTitle","Git is not installed"),message:s("setup.gitMissingCloneMessage","Cloning a repository requires Git on the Fusion host, and Git was not found. Install Git, then try again — Fusion picks it up without a restart."),confirmLabel:s("setup.gitMissingOpenDownloads","Open Git downloads"),cancelLabel:s("setup.cancel","Cancel"),alwaysAsk:!0})==="primary"&&G(l.installUrl??"https://git-scm.com/downloads"),d();return}const g=await b({title:s("setup.gitMissingTitle","Git is not installed"),message:s("setup.gitMissingMessage","Git was not found on the Fusion host. Fusion projects normally live in a git repository so agents can branch, commit, and merge work. You can install Git first (Fusion picks it up without a restart), or create the project anyway without a git repository."),confirmLabel:s("setup.gitMissingCreateAnyway","Create anyway without Git"),tertiaryLabel:s("setup.gitMissingOpenDownloads","Open Git downloads"),cancelLabel:s("setup.cancel","Cancel"),alwaysAsk:!0});if(g==="tertiary"){G(l.installUrl??"https://git-scm.com/downloads"),d();return}if(g!=="primary"){d();return}m=!0}}catch{}try{const l={name:i,path:a,isolationMode:t.manualIsolationMode,nodeId:t.manualNodeId||void 0,gitSetupMode:t.manualMode,cloneUrl:t.manualMode==="clone"?r:void 0,workspaceMode:t.manualMode==="existing"?t.workspaceMode:!1,taskPrefix:t.manualTaskPrefix.trim()||void 0,skipGitInit:m||void 0},g=await ge(l);if(!f){n(N=>({...N,isRegistering:!1})),c(g);return}n(N=>({...N,step:"agent",registeredProject:g,isRegistering:!1}))}catch(l){n(g=>({...g,isRegistering:!1,error:l instanceof Error?l.message:"Failed to register project"}))}finally{w.current=!1}},[f,c,t.manualPath,t.manualName,t.manualCloneUrl,t.manualMode,t.manualIsolationMode,t.manualNodeId,t.workspaceMode,t.manualTaskPrefix,b,s]),I=o.useCallback(a=>{const i=R(a);i&&n(r=>({...r,selectedPresetId:i.id,agentDraft:L(i),agentError:null}))},[]),J=o.useCallback((a,i)=>{const r=x.findIndex(g=>g.id===i);if(r<0)return;const d=x.length-1;let m=null;if(a.key==="ArrowDown"||a.key==="ArrowRight"?m=r===d?0:r+1:a.key==="ArrowUp"||a.key==="ArrowLeft"?m=r===0?d:r-1:a.key==="Home"?m=0:a.key==="End"&&(m=d),m===null)return;a.preventDefault();const l=x[m];I(l.id),requestAnimationFrame(()=>{document.querySelector(`[data-agent-preset-id="${l.id}"]`)?.focus()})},[I]),Q=o.useCallback(a=>{n(i=>({...i,selectedPresetId:"",agentDraft:he(a),agentError:null}))},[]),ee=o.useCallback(async()=>{if(!(!t.registeredProject||!t.agentDraft.name.trim())){n(a=>({...a,isCreatingAgent:!0,agentError:null}));try{await xe(fe(t.agentDraft),t.registeredProject.id),n(a=>({...a,step:"complete",isCreatingAgent:!1,agentOutcome:"created"}))}catch(a){if(a instanceof Error&&/already exists/i.test(a.message)){n(i=>({...i,step:"complete",isCreatingAgent:!1,agentOutcome:"created"}));return}n(i=>({...i,isCreatingAgent:!1,agentError:a instanceof Error?a.message:s("setup.firstAgentCreateError","Failed to create agent")}))}}},[t.agentDraft,t.registeredProject,s]),te=o.useCallback(()=>{n(a=>({...a,step:"complete",agentError:null,agentOutcome:"skipped"}))},[]);if(!B)return null;const A=t.manualMode==="existing",h=t.manualMode==="init",u=t.manualMode==="clone",se=u?s("setup.cloneAndRegisterProject","Clone and Register Project"):h?s("setup.initializeAndRegisterProject","Initialize and Register Project"):s("setup.registerProject","Register Project"),ae=t.manualPath.trim().length>0,ie=t.manualName.trim().length>0,ne=t.manualCloneUrl.trim().length>0,re=t.isRegistering||!ae||!ie||u&&!ne,oe=t.selectedPresetId?R(t.selectedPresetId):void 0,y=t.isCreatingAgent,le=t.selectedPresetId||k.id,ce=`modal setup-wizard-modal${t.step==="agent"?" setup-wizard-modal--agent":""}`;return e.jsxs("div",{className:"modal-overlay open setup-wizard-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"wizard-title",children:[e.jsxs("div",{className:ce,children:[e.jsxs("div",{className:"setup-wizard-header",children:[e.jsxs("div",{className:"setup-wizard-heading",children:[e.jsxs("div",{className:"setup-wizard-brand","aria-label":s("setup.brandName","Fusion"),children:[e.jsxs("svg",{className:"setup-wizard-brand-logo",width:28,height:28,viewBox:"0 0 128 128",fill:"none","aria-label":s("setup.brandLogo","Fusion logo"),role:"img",children:[e.jsx("circle",{cx:"64",cy:"64",r:"52",stroke:"currentColor",strokeWidth:"8"}),e.jsx("path",{d:"M26 101C44 82 62 64 82 45C90 37 98 30 104 24C96 35 89 47 81 60C70 79 57 95 43 108C38 112 32 108 26 101Z",fill:"currentColor"})]}),e.jsx("span",{className:"setup-wizard-brand-name",children:s("setup.brandName","Fusion")})]}),!f&&t.step==="manual"&&e.jsx("span",{className:"setup-wizard-step-context",children:s("setup.projectStepContext","Step 3 of 5 — Project · Fusion setup")}),e.jsxs("h2",{id:"wizard-title",className:"setup-wizard-title",children:[t.step==="manual"&&(f?s("setup.welcomeToFusion","Welcome to Fusion"):s("setup.titleSetUpProject","Set Up Your Project")),t.step==="agent"&&s("setup.firstAgentTitle","Create your first agent"),t.step==="complete"&&s("setup.setupCompleteTitle","Setup Complete!")]})]}),t.step!=="complete"&&t.step!=="agent"&&e.jsx("button",{className:"modal-close",onClick:P,"aria-label":s("setup.closeWizard","Close wizard"),children:e.jsx(je,{size:20})})]}),e.jsxs("div",{className:"setup-wizard-content",children:[t.step==="manual"&&e.jsxs("div",{className:"setup-wizard-manual",children:[e.jsxs("section",{className:"setup-wizard-repository-section","aria-labelledby":"setup-repository-mode-title",children:[e.jsxs("div",{className:"setup-wizard-section-heading",children:[e.jsx("h3",{id:"setup-repository-mode-title",children:s("setup.repositorySetupTitle","Repository setup")}),e.jsx("p",{children:s("setup.repositorySetupDescription","Choose how Fusion should prepare the project directory before registration.")})]}),e.jsxs("fieldset",{className:"setup-wizard-mode-switch","aria-label":s("setup.projectSetupModeAriaLabel","Project setup mode"),children:[e.jsx("legend",{children:s("setup.setupMode","Setup Mode")}),e.jsxs("label",{className:`setup-wizard-mode-option${A?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"existing","aria-label":s("setup.useExistingDirectory","Use Existing Directory"),checked:A,onChange:()=>z("existing")}),e.jsxs("span",{className:"setup-wizard-mode-option-copy",children:[e.jsx("strong",{children:s("setup.useExistingDirectory","Use Existing Directory")}),e.jsx("span",{children:s("setup.useExistingDirectoryHint","Register a folder that is already a git repository or workspace root.")})]})]}),e.jsxs("label",{className:`setup-wizard-mode-option${h?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"init","aria-label":s("setup.initializeNewRepository","Initialize New Repository"),checked:h,onChange:()=>z("init")}),e.jsxs("span",{className:"setup-wizard-mode-option-copy",children:[e.jsx("strong",{children:s("setup.initializeNewRepository","Initialize New Repository")}),e.jsx("span",{children:s("setup.initializeNewRepositoryHint","Register a selected non-git folder and let Fusion run git init on the server.")})]})]}),e.jsxs("label",{className:`setup-wizard-mode-option${u?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"clone","aria-label":s("setup.cloneGitRepository","Clone Git Repository"),checked:u,onChange:()=>z("clone")}),e.jsxs("span",{className:"setup-wizard-mode-option-copy",children:[e.jsx("strong",{children:s("setup.cloneGitRepository","Clone Git Repository")}),e.jsx("span",{children:s("setup.cloneGitRepositoryHint","Clone a remote repository into an empty or absent destination folder.")})]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-path",children:u?s("setup.destinationDirectory","Destination Directory"):h?s("setup.newRepositoryDirectory","New Repository Directory"):s("setup.projectDirectory","Project Directory")}),e.jsx(ke,{value:t.manualPath,onChange:V,nodeId:t.manualNodeId||void 0,localNodeId:K,selectCreatedDirectory:!0,placeholder:u?s("setup.clonePathPlaceholder","/path/for/new-clone"):h?s("setup.initPathPlaceholder","/path/to/new-project"):s("setup.projectPathPlaceholder","/path/to/your/project")}),e.jsx("p",{className:"form-hint",children:u?s("setup.clonePathHint","Select or type an absolute destination path. Fusion will clone into this directory. The destination must be empty or absent."):h?s("setup.initPathHint","Select or type an absolute path to an empty or non-git folder. Fusion will run git init during registration."):s("setup.projectPathHint","Select or type the absolute path to an existing git repository or workspace root.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-name",children:s("setup.projectName","Project Name")}),e.jsx("input",{id:"project-name",type:"text",value:t.manualName,onChange:a=>n(i=>({...i,manualName:a.target.value})),placeholder:s("setup.projectNamePlaceholder","my-project")}),e.jsx("p",{className:"form-hint",children:u?s("setup.projectNameHintClone","By default this follows the destination folder name unless you edit it."):h?s("setup.projectNameHintInit","By default this follows the folder name Fusion will initialize unless you edit it."):s("setup.projectNameHintExisting","By default this follows the selected directory name unless you edit it.")})]}),u&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-clone-url",children:s("setup.repositoryUrl","Repository URL")}),e.jsx("input",{id:"project-clone-url",type:"text",value:t.manualCloneUrl,onChange:a=>n(i=>({...i,manualCloneUrl:a.target.value,error:null})),placeholder:s("setup.repositoryUrlPlaceholder","https://github.com/owner/repo.git")}),e.jsx("p",{className:"form-hint",children:s("setup.cloneGitHint","Fusion will run git clone into the destination directory, then register that cloned folder.")})]}),A&&t.manualPath.trim()&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"workspace-mode",className:"checkbox-label",children:[e.jsx("input",{id:"workspace-mode",type:"checkbox",checked:t.workspaceMode,onChange:a=>n(i=>({...i,workspaceMode:a.target.checked}))}),s("setup.workspaceMode","Workspace mode (multi-repo)")]}),t.isDetectingWorkspace&&e.jsxs("p",{className:"form-hint",children:[e.jsx(M,{size:12,className:"animate-spin setup-wizard-inline-spinner"}),s("setup.detectingWorkspace","Detecting sub-repositories...")]}),!t.isDetectingWorkspace&&t.detectedRepos.length>0&&e.jsxs("p",{className:"form-hint",children:[s("setup.detectedRepos","Found {{count}} repositories:",{count:t.detectedRepos.length})," ",t.detectedRepos.join(", ")]}),!t.isDetectingWorkspace&&t.detectedRepos.length===0&&t.workspaceMode===!1&&t.manualPath.trim()&&e.jsx("p",{className:"form-hint",children:s("setup.noSubReposDetected","No sub-repositories detected. Enable if this is a multi-repo workspace.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"task-prefix",children:s("setup.taskPrefix","Task Prefix")}),e.jsx("input",{id:"task-prefix",type:"text",value:t.manualTaskPrefix,onChange:a=>n(i=>({...i,manualTaskPrefix:a.target.value.toUpperCase()})),placeholder:S(t.manualName||"FN"),maxLength:5}),e.jsx("p",{className:"form-hint",children:s("setup.taskPrefixHint",'Used for task IDs (e.g. "{{prefix}}-1"). Derived from project name.',{prefix:t.manualTaskPrefix||"FN"})})]}),e.jsxs("div",{className:"setup-wizard-advanced",children:[e.jsxs("button",{type:"button",className:"setup-wizard-advanced-toggle","aria-expanded":E,onClick:()=>$(a=>!a),children:[e.jsx(we,{size:16,className:"setup-wizard-advanced-chevron"}),e.jsx("span",{children:s("setup.advancedSettings","Advanced settings")})]}),E&&e.jsxs("div",{className:"setup-wizard-advanced-panel",children:[ve(v)&&e.jsxs("div",{className:"form-group",children:[e.jsxs("div",{className:"project-node-selector",children:[e.jsx("span",{className:"project-node-selector__label",children:s("setup.runtimeNode","Runtime Node")}),e.jsxs("select",{value:t.manualNodeId,onChange:a=>n(i=>({...i,manualNodeId:a.target.value})),disabled:q||t.isRegistering,children:[e.jsx("option",{value:"",children:s("setup.localNode","Local node")}),H(v).map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.type,")"]},a.id))]})]}),e.jsx("p",{className:"form-hint",children:s("setup.runtimeNodeHint",`A runtime node is the machine where this project's tasks run. "Local node" is this computer; pick a remote node to run tasks elsewhere.`)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("setup.isolationMode","Isolation Mode")}),e.jsxs("div",{className:"setup-wizard-isolation-options",children:[e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="in-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"in-process",checked:t.manualIsolationMode==="in-process",onChange:()=>n(a=>({...a,manualIsolationMode:"in-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.inProcess","In-Process")}),e.jsx("span",{children:s("setup.inProcessDesc","Lower overhead, shared memory. Best for most projects.")}),e.jsx("span",{className:"wizard-option-recommended",children:s("setup.recommended","Recommended")})]})]}),e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="child-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"child-process",checked:t.manualIsolationMode==="child-process",onChange:()=>n(a=>({...a,manualIsolationMode:"child-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.childProcess","Child-Process")}),e.jsx("span",{children:s("setup.childProcessDesc","Isolated execution with crash containment.")})]})]})]})]})]})]}),t.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:t.error})]}),t.step==="agent"&&e.jsxs("div",{className:"setup-wizard-agent-step",children:[e.jsx("p",{className:"setup-wizard-agent-intro",children:s("setup.firstAgentIntro","Agents are optional. Fusion can build tasks without one by starting temporary agents for planning, coding, review, and merge. Create an agent only if you want help coordinating tasks and direction.")}),e.jsxs("div",{className:"setup-wizard-agent-layout",children:[e.jsxs("section",{className:"setup-wizard-agent-presets","aria-labelledby":"setup-first-agent-presets-heading",children:[e.jsx("div",{className:"setup-wizard-agent-section-heading",id:"setup-first-agent-presets-heading",children:s("setup.firstAgentTemplates","Templates")}),e.jsx("div",{className:"setup-wizard-agent-preset-list",role:"radiogroup","aria-label":s("setup.firstAgentTemplates","Templates"),children:x.map(a=>{const i=t.selectedPresetId===a.id;return e.jsxs("button",{type:"button",className:`setup-wizard-agent-preset${i?" selected":""}`,role:"radio","aria-checked":i,"aria-label":i?s("setup.selectedAgentTemplate","{{name}} selected",{name:a.name}):a.name,tabIndex:a.id===le?0:-1,"data-agent-preset-id":a.id,disabled:y,onClick:()=>I(a.id),onKeyDown:r=>J(r,a.id),children:[e.jsx(W,{agent:{id:a.id,icon:a.icon,name:a.name},size:28}),e.jsxs("span",{className:"setup-wizard-agent-preset-copy",children:[e.jsxs("span",{className:"setup-wizard-agent-preset-name",children:[a.name,a.id==="ceo"&&e.jsx("span",{className:"wizard-option-recommended",children:s("setup.recommended","Recommended")})]}),e.jsx("span",{className:"setup-wizard-agent-preset-description",children:a.description})]})]},a.id)})})]}),e.jsxs("section",{className:"setup-wizard-agent-preview","aria-labelledby":"setup-first-agent-preview-heading",children:[e.jsx("div",{className:"setup-wizard-agent-section-heading",id:"setup-first-agent-preview-heading",children:s("setup.firstAgentPreview","Preview")}),e.jsxs("div",{className:"setup-wizard-agent-preview-card",children:[e.jsxs("div",{className:"setup-wizard-agent-preview-title-row",children:[e.jsx(W,{agent:{id:t.selectedPresetId||"draft",icon:t.agentDraft.icon,name:t.agentDraft.name},size:36}),e.jsxs("div",{children:[e.jsx("h3",{children:t.agentDraft.name||s("setup.firstAgentDraftName","Draft agent")}),e.jsx("p",{children:t.agentDraft.title||oe?.title||s("setup.firstAgentCustomDraft","Custom agent draft")})]})]}),e.jsxs("dl",{className:"setup-wizard-agent-preview-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:s("agents.fieldRole","Role")}),e.jsx("dd",{children:t.agentDraft.role})]}),e.jsxs("div",{children:[e.jsx("dt",{children:s("agents.fieldInstructionsText","Inline Instructions")}),e.jsx("dd",{children:t.agentDraft.instructionsText||s("setup.firstAgentNoInstructions","No inline instructions yet")})]})]}),F&&e.jsxs("button",{type:"button",className:"btn setup-wizard-agent-ai-btn",onClick:()=>C(!0),disabled:y,children:[e.jsx(ye,{size:16}),e.jsx("span",{children:s("agents.aiInterview","AI Interview")})]})]})]})]}),t.agentError&&e.jsx("div",{className:"wizard-error",role:"alert",tabIndex:-1,ref:U,children:t.agentError})]}),t.step==="complete"&&e.jsxs("div",{className:"setup-wizard-complete",children:[e.jsxs("div",{className:"setup-wizard-success-streak","aria-hidden":"true",children:[e.jsx("div",{className:"setup-wizard-success-streak-core"}),e.jsx("div",{className:"setup-wizard-success-streak-glow"})]}),e.jsx(O,{size:64,className:"success-icon"}),e.jsx("h3",{children:s("setup.allSet","All Set!")}),e.jsx("p",{children:t.agentOutcome==="created"?s("setup.firstAgentCreatedSuccess","Your project is registered and your first agent is ready."):s("setup.projectRegisteredSuccess","Your project has been registered successfully.")}),e.jsx("p",{children:t.agentOutcome==="skipped"?s("setup.firstAgentSkippedHint","You can create agents later from the Agents view."):s("setup.addMoreProjectsHint","You can add more projects anytime from the project overview.")})]})]}),e.jsxs("div",{className:"setup-wizard-footer",children:[e.jsx("a",{className:"btn setup-wizard-help-link",href:_,target:"_blank",rel:"noopener noreferrer",children:s("setup.needHelp","Need help?")}),t.step==="manual"&&e.jsx("button",{className:"btn btn-primary",onClick:X,disabled:re,children:t.isRegistering?e.jsxs(e.Fragment,{children:[e.jsx(M,{size:16,className:"animate-spin"}),e.jsx("span",{children:s("setup.registering","Registering...")})]}):e.jsx("span",{children:se})}),t.step==="agent"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:te,disabled:y,children:s("setup.skipFirstAgent","Skip for now")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void ee(),disabled:y||!t.agentDraft.name.trim(),"aria-busy":t.isCreatingAgent,children:t.isCreatingAgent?e.jsxs(e.Fragment,{children:[e.jsx(M,{size:16,className:"animate-spin"}),e.jsx("span",{children:s("setup.creatingFirstAgent","Creating agent...")})]}):e.jsx("span",{children:s("setup.createFirstAgent","Create Agent")})})]}),t.step==="complete"&&e.jsxs("button",{className:"btn btn-primary",onClick:Z,children:[e.jsx(O,{size:16}),e.jsx("span",{children:s("setup.getStarted","Get Started")})]})]})]}),F&&T&&e.jsx(Ne,{level:"modal",fallback:e.jsxs("div",{className:"wizard-error setup-wizard-agent-interview-error",role:"alert",children:[e.jsx("span",{children:s("setup.firstAgentInterviewLoadError","AI interview could not load. You can still create an agent from a template or skip this step.")}),e.jsx("button",{type:"button",className:"btn",onClick:()=>C(!1),children:s("setup.firstAgentContinueWithTemplates","Continue with templates")})]}),children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"wizard-error setup-wizard-agent-interview-error",role:"status",children:s("setup.firstAgentInterviewLoading","Loading AI Interview...")}),children:e.jsx(Pe,{isOpen:T,onClose:()=>C(!1),onUseDraft:Q,projectId:t.registeredProject?.id,existingAgents:[],mode:"create"})})})]})}export{Te as SetupWizardModal};
@@ -1 +1 @@
1
- import{r as a,j as s}from"./vendor-react-SZ_qB27O.js";import{f as ms,a as us,t as vs,i as hs,b as gs,d as bs,V as ws,Z as xs,X as H,R as fs,C as js,e as ps,L as A,A as q,g as G,M as J}from"./index-ClPjlOHJ.js";import{u as Ns}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const Ss=new Set([".md",".markdown",".mdx"]);function Cs(r){const d=r.toLowerCase(),j=d.lastIndexOf(".");return j<0?!1:Ss.has(d.slice(j))}function zs({projectId:r,addToast:d,onClose:j}){const{t:e}=Ns("app"),[k,p]=a.useState([]),[F,T]=a.useState(!0),[Y,V]=a.useState(!1),[I,D]=a.useState(null),[_,ss]=a.useState([]),[g,ls]=a.useState(""),[M,B]=a.useState(null),[c,N]=a.useState(null),[b,S]=a.useState(null),[es,K]=a.useState(!1),[Q,C]=a.useState(null),[y,w]=a.useState(null),[u,v]=a.useState(null),[is,z]=a.useState(!1),[$,h]=a.useState(null),m=a.useRef(null),[P,as]=a.useState(""),O=g.trim()?k.filter(l=>l.name.toLowerCase().includes(g.toLowerCase())||l.relativePath.toLowerCase().includes(g.toLowerCase())):k,x=a.useCallback(async()=>{T(!0);try{const l=await ms(r);p(l)}catch(l){const t=l instanceof Error?l.message:e("skills.loadDiscoveredError","Failed to load discovered skills");d(t,"error")}finally{T(!1)}},[r,d]),f=a.useCallback(async l=>{const t=i=>{if(!i||typeof i!="object")return!1;const n=i;if(typeof n.status=="number"&&n.status>=500)return!0;if(n.details&&typeof n.details=="object"){const L=n.details;if(typeof L.code=="string"&&L.code.startsWith("upstream_"))return!0}const o=i;return typeof o.error=="string"&&typeof o.code=="string"};V(!0),D(null);try{const i=await us(l,20,r);ss(i.entries)}catch(i){if(t(i))D(e("skills.catalogUnavailable","Catalog is temporarily unavailable. Please try again later."));else{const n=i instanceof Error?i.message:e("skills.loadCatalogError","Failed to load catalog");D(n)}}finally{V(!1)}},[r]);a.useEffect(()=>{x(),f("")},[x,f]);const ts=a.useCallback(l=>{ls(l),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{as(l),m.current=null},300)},[]);a.useEffect(()=>()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),a.useEffect(()=>{f(P)},[P,f]);const ns=a.useCallback(async(l,t)=>{const i=!t;p(n=>n.map(o=>o.id===l?{...o,toggling:!0}:o));try{await vs(l,i,r),p(n=>n.map(o=>o.id===l?{...o,enabled:i,toggling:!1}:o)),d(e(`skills.${i?"enabled":"disabled"}`,i?"Skill enabled":"Skill disabled"),"success")}catch(n){p(L=>L.map(R=>R.id===l?{...R,toggling:!1}:R));const o=n instanceof Error?n.message:e("skills.toggleError","Failed to toggle skill");d(e("skills.toggleFailed","Failed to toggle skill: {{message}}",{message:o}),"error")}},[r,d]),cs=a.useCallback(async l=>{const t=l.repo?.trim();if(!(!t||M===l.id)){B(l.id);try{await hs(t,l.slug||l.name,r),d(e("skills.installSuccess","Installed {{name}}",{name:l.name}),"success"),await x()}catch(i){const n=i instanceof Error?i.message:e("skills.installError","Failed to install skill");d(e("skills.installFailed","Failed to install {{name}}: {{message}}",{name:l.name,message:n}),"error")}finally{B(i=>i===l.id?null:i)}}},[d,M,x,r]),E=a.useCallback(async l=>{K(!0),C(null),S(null),w(null),v(null),h(null);try{const t=await gs(l,r);S(t)}catch(t){const i=t instanceof Error?t.message:e("skills.loadContentError","Failed to load skill content");C(i)}finally{K(!1)}},[r]),U=a.useCallback((l,t)=>{if(!(t&&t.target.closest(".skills-view-item-toggle"))){if(c===l){N(null),S(null),C(null),w(null),v(null),h(null);return}N(l),E(l)}},[c,E]),os=a.useCallback(l=>{c!==l&&N(l),E(l)},[E,c]),W=a.useCallback(async(l,t)=>{w(t),v(null),h(null),z(!0);try{const i=await bs(l,t,r);v(i)}catch(i){const n=i instanceof Error?i.message:e("skills.loadFileError","Failed to load file");h(n)}finally{z(!1)}},[r]),rs=a.useCallback(()=>{w(null),v(null),h(null),z(!1)},[]),X=a.useCallback(()=>{N(null),S(null),C(null),w(null),v(null),h(null)},[]),ds=a.useMemo(()=>k.find(l=>l.id===c)??null,[k,c]),Z=()=>!b||b.files.length===0?null:s.jsxs("div",{className:"skills-view-detail-files","data-testid":"skill-files",children:[s.jsxs("span",{className:"skills-view-detail-files-label",children:[e("skills.filesLabel","Files"),":"]}),b.files.map(l=>{if(l.type==="directory")return s.jsxs("span",{className:"badge badge--sm skills-view-detail-file--dir",children:[l.name,"/"]},l.relativePath);const t=y===l.relativePath;return s.jsx("button",{type:"button","data-testid":"skill-file-item",className:`badge badge--sm skills-view-detail-file${t?" skills-view-detail-file--active":""}`,onClick:()=>c&&void W(c,l.relativePath),"aria-pressed":t,"aria-label":e("skills.viewFile","View {{name}}",{name:l.name}),children:l.name},l.relativePath)})]}),ks=()=>c?es?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingContent","Loading skill content...")]}):Q?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:Q}),s.jsx("button",{className:"btn btn-sm",onClick:()=>os(c),children:e("common.retry","Retry")})]}):b?y!==null?s.jsxs("div",{className:"skills-view-file-viewer","data-testid":"skill-file-viewer",children:[s.jsxs("div",{className:"skills-view-file-viewer-bar",children:[s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-file-back",onClick:rs,"data-testid":"skill-file-back","aria-label":e("skills.backToSkillMd","Back to SKILL.md"),children:[s.jsx(q,{size:14}),e("skills.backToSkillMd","Back to SKILL.md")]}),s.jsx("span",{className:"skills-view-file-viewer-name",children:y})]}),is?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingFile","Loading file...")]}):$?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:$}),s.jsx("button",{className:"btn btn-sm",onClick:()=>c&&void W(c,y),children:e("common.retry","Retry")})]}):u&&!u.isText?s.jsx("div",{className:"skills-view-detail-empty",children:e("skills.fileNotPreviewable","This file cannot be previewed.")}):u?Cs(u.relativePath)?s.jsx(J,{content:u.content||e("skills.emptyFile","(Empty file)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}):s.jsx("pre",{className:"skills-view-detail-content",children:u.content||e("skills.emptyFile","(Empty file)")}):null,Z()]}):s.jsxs(s.Fragment,{children:[s.jsx(J,{content:b.skillMd||e("skills.noSkillMd","(No SKILL.md found)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}),Z()]}):null:s.jsx("div",{className:"skills-view-detail-placeholder","data-testid":"skills-detail-empty",children:e("skills.selectASkill","Select a skill to view its details")});return s.jsxs("div",{className:"skills-view","data-testid":"skills-view","data-selected":c?"true":"false",children:[s.jsx(ws,{icon:xs,title:e("skills.title","Skills"),actions:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"skills-view-count","aria-label":e("skills.discoveredCount","{{count}} discovered skills",{count:k.length}),children:[k.length," ",e("skills.discovered","discovered")]}),s.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:j,"aria-label":e("skills.closeView","Close skills view"),children:s.jsx(H,{size:16})}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>void x(),disabled:F,children:[s.jsx(fs,{size:14,className:F?"spin":""}),e("common.refresh","Refresh")]})]})}),s.jsxs("div",{className:"skills-view-body",children:[s.jsx("div",{className:"skills-view__list","data-testid":"skills-list",children:s.jsxs("div",{className:"skills-view-content",children:[s.jsx("div",{className:"skills-view-search",children:s.jsx("input",{type:"text",className:"form-input",placeholder:e("skills.searchPlaceholder","Search skills..."),value:g,onChange:l=>ts(l.target.value),"aria-label":e("skills.searchLabel","Search skills")})}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[s.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:e("skills.discoveredSection","Discovered Skills")}),F?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingDiscovered","Loading discovered skills...")]}):k.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noDiscovered","No skills discovered in this project.")})}):O.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noMatchingDiscovered","No discovered skills match your search.")})}):s.jsx("div",{className:"skills-view-list",children:O.map(l=>{const t=c===l.id;return s.jsx("div",{children:s.jsxs("div",{className:`skills-view-item${t?" skills-view-item--selected":""}`,onClick:i=>U(l.id,i),role:"button",tabIndex:0,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),U(l.id))},"aria-expanded":t,"aria-label":e("skills.viewDetails","View details for {{name}}",{name:l.name}),children:[s.jsxs("div",{className:"skills-view-item-info",children:[s.jsxs("span",{className:"skills-view-item-name",children:[t?s.jsx(js,{size:14}):s.jsx(ps,{size:14}),s.jsx("span",{className:"skills-view-item-name-text",children:l.name})]}),s.jsx("span",{className:"skills-view-item-path",children:l.relativePath}),s.jsx("span",{className:"skills-view-item-source",children:l.metadata.source})]}),s.jsxs("label",{className:"skills-view-item-toggle",onClick:i=>i.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:l.enabled,disabled:l.toggling,onChange:()=>void ns(l.id,l.enabled),"aria-label":e(`skills.${l.enabled?"disable":"enable"}Skill`,l.enabled?"Disable {{name}}":"Enable {{name}}",{name:l.name})}),s.jsx("span",{className:"skills-view-toggle-slider"})]})]})},l.id)})})]}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[s.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:e("skills.catalogSection","Skills Catalog")}),I?s.jsxs("div",{className:"skills-view-error",children:[s.jsx("p",{children:I}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void f(P),children:e("common.tryAgain","Try Again")})]}):Y?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingCatalog","Loading catalog...")]}):_.length===0?s.jsx("div",{className:"skills-view-empty",children:g?s.jsx("p",{children:e("skills.noMatchingSearch","No skills match your search.")}):s.jsx("p",{children:e("skills.noCatalogAvailable","No skills available in the catalog.")})}):s.jsx("div",{className:"skills-view-grid",children:_.map(l=>{const i=!!l.repo?.trim(),n=M===l.id;return s.jsxs("div",{className:"skills-view-card",children:[s.jsxs("div",{className:"skills-view-card-header",children:[s.jsx("h4",{className:"skills-view-card-title",children:l.name}),i?s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-card-install",onClick:()=>void cs(l),disabled:n,"aria-label":e("skills.installSkill","Install {{name}}",{name:l.name}),children:[n?s.jsx(A,{size:14,className:"spin"}):null,n?e("skills.installing","Installing…"):e("skills.install","Install")]}):null]}),l.description&&s.jsx("p",{className:"skills-view-card-description",children:l.description}),l.tags&&l.tags.length>0&&s.jsx("div",{className:"skills-view-card-tags",children:l.tags.map(o=>s.jsx("span",{className:"badge badge--sm",children:o},o))}),l.installs!==void 0&&s.jsx("span",{className:"skills-view-card-installs",children:e("skills.installsCount","{{value}} installs",{value:l.installs.toLocaleString()})})]},l.id)})})]})]})}),s.jsxs("div",{className:"skills-view__detail","data-testid":"skill-detail",children:[s.jsxs("div",{className:"skills-view-detail-header",children:[s.jsx("button",{type:"button",className:"btn btn-sm btn-icon skills-view-detail-back",onClick:X,"aria-label":e("skills.backToList","Back to skills"),title:e("skills.backToList","Back to skills"),"data-testid":"skills-detail-back",children:s.jsx(q,{size:14})}),s.jsx("span",{className:"skills-view-detail-title",children:ds?.name??e("skills.detailTitle","Skill")}),s.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:X,disabled:!c,"aria-label":e("skills.closeDetail","Close skill detail"),children:[s.jsx(H,{size:14}),e("common.close","Close")]})]}),s.jsx("div",{className:"skills-view-detail-body",children:ks()})]})]})]})}export{zs as SkillsView};
1
+ import{r as a,j as s}from"./vendor-react-SZ_qB27O.js";import{f as ms,a as us,t as vs,i as hs,b as gs,d as bs,V as ws,Z as xs,X as H,R as fs,C as js,e as ps,L as A,A as q,g as G,M as J}from"./index-D8sgsB8q.js";import{u as Ns}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const Ss=new Set([".md",".markdown",".mdx"]);function Cs(r){const d=r.toLowerCase(),j=d.lastIndexOf(".");return j<0?!1:Ss.has(d.slice(j))}function zs({projectId:r,addToast:d,onClose:j}){const{t:e}=Ns("app"),[k,p]=a.useState([]),[F,T]=a.useState(!0),[Y,V]=a.useState(!1),[I,D]=a.useState(null),[_,ss]=a.useState([]),[g,ls]=a.useState(""),[M,B]=a.useState(null),[c,N]=a.useState(null),[b,S]=a.useState(null),[es,K]=a.useState(!1),[Q,C]=a.useState(null),[y,w]=a.useState(null),[u,v]=a.useState(null),[is,z]=a.useState(!1),[$,h]=a.useState(null),m=a.useRef(null),[P,as]=a.useState(""),O=g.trim()?k.filter(l=>l.name.toLowerCase().includes(g.toLowerCase())||l.relativePath.toLowerCase().includes(g.toLowerCase())):k,x=a.useCallback(async()=>{T(!0);try{const l=await ms(r);p(l)}catch(l){const t=l instanceof Error?l.message:e("skills.loadDiscoveredError","Failed to load discovered skills");d(t,"error")}finally{T(!1)}},[r,d]),f=a.useCallback(async l=>{const t=i=>{if(!i||typeof i!="object")return!1;const n=i;if(typeof n.status=="number"&&n.status>=500)return!0;if(n.details&&typeof n.details=="object"){const L=n.details;if(typeof L.code=="string"&&L.code.startsWith("upstream_"))return!0}const o=i;return typeof o.error=="string"&&typeof o.code=="string"};V(!0),D(null);try{const i=await us(l,20,r);ss(i.entries)}catch(i){if(t(i))D(e("skills.catalogUnavailable","Catalog is temporarily unavailable. Please try again later."));else{const n=i instanceof Error?i.message:e("skills.loadCatalogError","Failed to load catalog");D(n)}}finally{V(!1)}},[r]);a.useEffect(()=>{x(),f("")},[x,f]);const ts=a.useCallback(l=>{ls(l),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{as(l),m.current=null},300)},[]);a.useEffect(()=>()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),a.useEffect(()=>{f(P)},[P,f]);const ns=a.useCallback(async(l,t)=>{const i=!t;p(n=>n.map(o=>o.id===l?{...o,toggling:!0}:o));try{await vs(l,i,r),p(n=>n.map(o=>o.id===l?{...o,enabled:i,toggling:!1}:o)),d(e(`skills.${i?"enabled":"disabled"}`,i?"Skill enabled":"Skill disabled"),"success")}catch(n){p(L=>L.map(R=>R.id===l?{...R,toggling:!1}:R));const o=n instanceof Error?n.message:e("skills.toggleError","Failed to toggle skill");d(e("skills.toggleFailed","Failed to toggle skill: {{message}}",{message:o}),"error")}},[r,d]),cs=a.useCallback(async l=>{const t=l.repo?.trim();if(!(!t||M===l.id)){B(l.id);try{await hs(t,l.slug||l.name,r),d(e("skills.installSuccess","Installed {{name}}",{name:l.name}),"success"),await x()}catch(i){const n=i instanceof Error?i.message:e("skills.installError","Failed to install skill");d(e("skills.installFailed","Failed to install {{name}}: {{message}}",{name:l.name,message:n}),"error")}finally{B(i=>i===l.id?null:i)}}},[d,M,x,r]),E=a.useCallback(async l=>{K(!0),C(null),S(null),w(null),v(null),h(null);try{const t=await gs(l,r);S(t)}catch(t){const i=t instanceof Error?t.message:e("skills.loadContentError","Failed to load skill content");C(i)}finally{K(!1)}},[r]),U=a.useCallback((l,t)=>{if(!(t&&t.target.closest(".skills-view-item-toggle"))){if(c===l){N(null),S(null),C(null),w(null),v(null),h(null);return}N(l),E(l)}},[c,E]),os=a.useCallback(l=>{c!==l&&N(l),E(l)},[E,c]),W=a.useCallback(async(l,t)=>{w(t),v(null),h(null),z(!0);try{const i=await bs(l,t,r);v(i)}catch(i){const n=i instanceof Error?i.message:e("skills.loadFileError","Failed to load file");h(n)}finally{z(!1)}},[r]),rs=a.useCallback(()=>{w(null),v(null),h(null),z(!1)},[]),X=a.useCallback(()=>{N(null),S(null),C(null),w(null),v(null),h(null)},[]),ds=a.useMemo(()=>k.find(l=>l.id===c)??null,[k,c]),Z=()=>!b||b.files.length===0?null:s.jsxs("div",{className:"skills-view-detail-files","data-testid":"skill-files",children:[s.jsxs("span",{className:"skills-view-detail-files-label",children:[e("skills.filesLabel","Files"),":"]}),b.files.map(l=>{if(l.type==="directory")return s.jsxs("span",{className:"badge badge--sm skills-view-detail-file--dir",children:[l.name,"/"]},l.relativePath);const t=y===l.relativePath;return s.jsx("button",{type:"button","data-testid":"skill-file-item",className:`badge badge--sm skills-view-detail-file${t?" skills-view-detail-file--active":""}`,onClick:()=>c&&void W(c,l.relativePath),"aria-pressed":t,"aria-label":e("skills.viewFile","View {{name}}",{name:l.name}),children:l.name},l.relativePath)})]}),ks=()=>c?es?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingContent","Loading skill content...")]}):Q?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:Q}),s.jsx("button",{className:"btn btn-sm",onClick:()=>os(c),children:e("common.retry","Retry")})]}):b?y!==null?s.jsxs("div",{className:"skills-view-file-viewer","data-testid":"skill-file-viewer",children:[s.jsxs("div",{className:"skills-view-file-viewer-bar",children:[s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-file-back",onClick:rs,"data-testid":"skill-file-back","aria-label":e("skills.backToSkillMd","Back to SKILL.md"),children:[s.jsx(q,{size:14}),e("skills.backToSkillMd","Back to SKILL.md")]}),s.jsx("span",{className:"skills-view-file-viewer-name",children:y})]}),is?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingFile","Loading file...")]}):$?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:$}),s.jsx("button",{className:"btn btn-sm",onClick:()=>c&&void W(c,y),children:e("common.retry","Retry")})]}):u&&!u.isText?s.jsx("div",{className:"skills-view-detail-empty",children:e("skills.fileNotPreviewable","This file cannot be previewed.")}):u?Cs(u.relativePath)?s.jsx(J,{content:u.content||e("skills.emptyFile","(Empty file)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}):s.jsx("pre",{className:"skills-view-detail-content",children:u.content||e("skills.emptyFile","(Empty file)")}):null,Z()]}):s.jsxs(s.Fragment,{children:[s.jsx(J,{content:b.skillMd||e("skills.noSkillMd","(No SKILL.md found)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}),Z()]}):null:s.jsx("div",{className:"skills-view-detail-placeholder","data-testid":"skills-detail-empty",children:e("skills.selectASkill","Select a skill to view its details")});return s.jsxs("div",{className:"skills-view","data-testid":"skills-view","data-selected":c?"true":"false",children:[s.jsx(ws,{icon:xs,title:e("skills.title","Skills"),actions:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"skills-view-count","aria-label":e("skills.discoveredCount","{{count}} discovered skills",{count:k.length}),children:[k.length," ",e("skills.discovered","discovered")]}),s.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:j,"aria-label":e("skills.closeView","Close skills view"),children:s.jsx(H,{size:16})}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>void x(),disabled:F,children:[s.jsx(fs,{size:14,className:F?"spin":""}),e("common.refresh","Refresh")]})]})}),s.jsxs("div",{className:"skills-view-body",children:[s.jsx("div",{className:"skills-view__list","data-testid":"skills-list",children:s.jsxs("div",{className:"skills-view-content",children:[s.jsx("div",{className:"skills-view-search",children:s.jsx("input",{type:"text",className:"form-input",placeholder:e("skills.searchPlaceholder","Search skills..."),value:g,onChange:l=>ts(l.target.value),"aria-label":e("skills.searchLabel","Search skills")})}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[s.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:e("skills.discoveredSection","Discovered Skills")}),F?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingDiscovered","Loading discovered skills...")]}):k.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noDiscovered","No skills discovered in this project.")})}):O.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noMatchingDiscovered","No discovered skills match your search.")})}):s.jsx("div",{className:"skills-view-list",children:O.map(l=>{const t=c===l.id;return s.jsx("div",{children:s.jsxs("div",{className:`skills-view-item${t?" skills-view-item--selected":""}`,onClick:i=>U(l.id,i),role:"button",tabIndex:0,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),U(l.id))},"aria-expanded":t,"aria-label":e("skills.viewDetails","View details for {{name}}",{name:l.name}),children:[s.jsxs("div",{className:"skills-view-item-info",children:[s.jsxs("span",{className:"skills-view-item-name",children:[t?s.jsx(js,{size:14}):s.jsx(ps,{size:14}),s.jsx("span",{className:"skills-view-item-name-text",children:l.name})]}),s.jsx("span",{className:"skills-view-item-path",children:l.relativePath}),s.jsx("span",{className:"skills-view-item-source",children:l.metadata.source})]}),s.jsxs("label",{className:"skills-view-item-toggle",onClick:i=>i.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:l.enabled,disabled:l.toggling,onChange:()=>void ns(l.id,l.enabled),"aria-label":e(`skills.${l.enabled?"disable":"enable"}Skill`,l.enabled?"Disable {{name}}":"Enable {{name}}",{name:l.name})}),s.jsx("span",{className:"skills-view-toggle-slider"})]})]})},l.id)})})]}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[s.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:e("skills.catalogSection","Skills Catalog")}),I?s.jsxs("div",{className:"skills-view-error",children:[s.jsx("p",{children:I}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void f(P),children:e("common.tryAgain","Try Again")})]}):Y?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingCatalog","Loading catalog...")]}):_.length===0?s.jsx("div",{className:"skills-view-empty",children:g?s.jsx("p",{children:e("skills.noMatchingSearch","No skills match your search.")}):s.jsx("p",{children:e("skills.noCatalogAvailable","No skills available in the catalog.")})}):s.jsx("div",{className:"skills-view-grid",children:_.map(l=>{const i=!!l.repo?.trim(),n=M===l.id;return s.jsxs("div",{className:"skills-view-card",children:[s.jsxs("div",{className:"skills-view-card-header",children:[s.jsx("h4",{className:"skills-view-card-title",children:l.name}),i?s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-card-install",onClick:()=>void cs(l),disabled:n,"aria-label":e("skills.installSkill","Install {{name}}",{name:l.name}),children:[n?s.jsx(A,{size:14,className:"spin"}):null,n?e("skills.installing","Installing…"):e("skills.install","Install")]}):null]}),l.description&&s.jsx("p",{className:"skills-view-card-description",children:l.description}),l.tags&&l.tags.length>0&&s.jsx("div",{className:"skills-view-card-tags",children:l.tags.map(o=>s.jsx("span",{className:"badge badge--sm",children:o},o))}),l.installs!==void 0&&s.jsx("span",{className:"skills-view-card-installs",children:e("skills.installsCount","{{value}} installs",{value:l.installs.toLocaleString()})})]},l.id)})})]})]})}),s.jsxs("div",{className:"skills-view__detail","data-testid":"skill-detail",children:[s.jsxs("div",{className:"skills-view-detail-header",children:[s.jsx("button",{type:"button",className:"btn btn-sm btn-icon skills-view-detail-back",onClick:X,"aria-label":e("skills.backToList","Back to skills"),title:e("skills.backToList","Back to skills"),"data-testid":"skills-detail-back",children:s.jsx(q,{size:14})}),s.jsx("span",{className:"skills-view-detail-title",children:ds?.name??e("skills.detailTitle","Skill")}),s.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:X,disabled:!c,"aria-label":e("skills.closeDetail","Close skill detail"),children:[s.jsx(H,{size:14}),e("common.close","Close")]})]}),s.jsx("div",{className:"skills-view-detail-body",children:ks()})]})]})]})}export{zs as SkillsView};
@@ -1,4 +1,4 @@
1
- import{r as h,j as e}from"./vendor-react-SZ_qB27O.js";import{c as O,dh as F,dj as E,ap as G,C as T,dk as _,dl as B,o as H}from"./index-ClPjlOHJ.js";import{u as L}from"./vendor-i18n-GF3RlKbq.js";/**
1
+ import{r as h,j as e}from"./vendor-react-SZ_qB27O.js";import{c as O,di as F,dk as E,ap as G,C as T,dl as _,dm as B,o as H}from"./index-D8sgsB8q.js";import{u as L}from"./vendor-i18n-GF3RlKbq.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,6 +1,6 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Kt,aB as Lt,aC as yt,aD as Bt,b1 as Ht,b2 as Vt,b3 as Xt,b4 as Gt,b5 as Wt,b6 as qt,b7 as zt,b8 as Yt,aG as Jt,a1 as Qt,b9 as Zt,ba as nt,bb as te,bc as jt,L as ee,P as It,o as at,X as it,bd as kt,q as Ct,s as wt,be as se,n as oe,E as ne,ap as ae,C as ie,bf as de,bg as Nt,a8 as le,bh as re}from"./index-ClPjlOHJ.js";import{u as At}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Kt,aD as Lt,aE as yt,aF as Ht,b3 as Bt,b4 as Vt,b5 as Xt,b6 as Wt,b7 as qt,b8 as zt,b9 as Gt,ba as Yt,aI as Jt,a1 as Qt,bb as Zt,bc as nt,bd as te,be as jt,L as ee,P as It,o as at,X as it,bf as kt,q as wt,s as Ct,bg as se,n as oe,E as ne,ap as ae,C as ie,bh as de,bi as Nt,a8 as le,bj as re}from"./index-D8sgsB8q.js";import{u as At}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],me=Kt("circle-plus",ce);function ue(x){const{items:r,...f}=x;return f}function St(x){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${x}-${crypto.randomUUID()}`:`${x}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function be(x={}){const{t:r}=At("app"),{projectId:f,addToast:L}=x,o=`${Bt.TODO_LISTS_PREFIX}${f??"global"}`,[w,k]=l.useState(()=>{const s=Lt(o,{maxAgeMs:yt});return Array.isArray(s)?s:[]}),[N,C]=l.useState([]),[E,K]=l.useState(()=>w.length===0),[Q,j]=l.useState(null),[M,R]=l.useState(null),[I,h]=l.useState([]),A=l.useRef(M);A.current=M,l.useEffect(()=>{let s=!1;const c=Lt(o,{maxAgeMs:yt}),u=Array.isArray(c)&&c.length>0;u?(k(c),K(!1)):(k([]),K(!0));async function b(){u||K(!0),j(null);try{const a=await Yt(f);if(s)return;h(a);const n=a.map(ue);k(n),Jt(o,n,{maxBytes:5e5});const i=A.current&&a.some(d=>d.id===A.current)?A.current:a[0]?.id??null;R(i),C(i?a.find(d=>d.id===i)?.items??[]:[])}catch(a){if(s)return;h([]),k([]),C([]),R(null),j(a instanceof Error?a.message:r("todo.failedLoadLists","Failed to load todo lists"))}finally{s||K(!1)}}return b(),()=>{s=!0}},[o,f]),l.useEffect(()=>{if(!M){C([]);return}const s=I.find(c=>c.id===M);C(s?.items??[])},[I,M]);const Z=l.useCallback(async s=>{const c=w,u=I,b=new Date().toISOString(),a={id:St("temp-list"),projectId:f??"",title:s,createdAt:b,updatedAt:b};j(null),k(n=>[...n,a]),h(n=>[...n,{...a,items:[]}]);try{const n=await Ht(s,f);k(i=>i.map(d=>d.id===a.id?n:d)),h(i=>i.map(d=>d.id===a.id?{...n,items:[]}:d)),A.current||R(n.id)}catch(n){k(c),h(u),j(n instanceof Error?n.message:r("todo.failedCreateList","Failed to create list")),L?.(r("todo.failedCreateListToast","Failed to create todo list"),"error")}},[L,I,w,f,r]),B=l.useCallback(async(s,c)=>{const u=w,b=I;j(null),k(a=>a.map(n=>n.id===s?{...n,title:c}:n)),h(a=>a.map(n=>n.id===s?{...n,title:c}:n));try{const a=await Vt(s,c,f);k(n=>n.map(i=>i.id===s?a:i)),h(n=>n.map(i=>i.id===s?{...a,items:i.items}:i))}catch(a){k(u),h(b),j(a instanceof Error?a.message:r("todo.failedRenameList","Failed to rename list")),L?.(r("todo.failedRenameListToast","Failed to rename todo list"),"error")}},[L,I,w,f,r]),D=l.useCallback(async s=>{const c=w,u=I,b=A.current,a=b===s?w.find(n=>n.id!==s)?.id??null:b;j(null),k(n=>n.filter(i=>i.id!==s)),h(n=>n.filter(i=>i.id!==s)),b===s&&R(a);try{await Xt(s,f)}catch(n){k(c),h(u),R(b),j(n instanceof Error?n.message:r("todo.failedDeleteList","Failed to delete list")),L?.(r("todo.failedDeleteListToast","Failed to delete todo list"),"error")}},[L,I,w,f,r]),W=l.useCallback(async s=>{const c=A.current;if(!c)return;const u=N,b=I,a=new Date().toISOString(),n=N.reduce((d,p)=>Math.max(d,p.sortOrder),-1),i={id:St("temp-item"),listId:c,text:s,completed:!1,completedAt:null,createdAt:a,updatedAt:a,sortOrder:n+1};j(null),C(d=>[...d,i]),h(d=>d.map(p=>p.id===c?{...p,items:[...p.items,i]}:p));try{const d=await Gt(c,s,f);C(p=>p.map(v=>v.id===i.id?d:v)),h(p=>p.map(v=>v.id===c?{...v,items:v.items.map(_=>_.id===i.id?d:_)}:v))}catch(d){C(u),h(b),j(d instanceof Error?d.message:r("todo.failedCreateItem","Failed to create item")),L?.(r("todo.failedCreateItemToast","Failed to create todo item"),"error")}},[L,N,I,f,r]),S=l.useCallback(async(s,c)=>{const u=N.find(d=>d.id===s);if(!u)return;const b=N,a=I,n=c.completed??u.completed,i={...u,...c,completed:n,completedAt:n?u.completedAt??new Date().toISOString():null,updatedAt:new Date().toISOString()};j(null),C(d=>d.map(p=>p.id===s?i:p)),h(d=>d.map(p=>p.id===i.listId?{...p,items:p.items.map(v=>v.id===s?i:v)}:p));try{const d=await Wt(s,c,f);C(p=>p.map(v=>v.id===s?d:v)),h(p=>p.map(v=>v.id===d.listId?{...v,items:v.items.map(_=>_.id===s?d:_)}:v))}catch(d){C(b),h(a),j(d instanceof Error?d.message:r("todo.failedUpdateItem","Failed to update item")),L?.(r("todo.failedUpdateItemToast","Failed to update todo item"),"error")}},[L,N,I,f,r]),H=l.useCallback(async s=>{const c=N.find(u=>u.id===s);c&&await S(s,{completed:!c.completed})},[N,S]),O=l.useCallback(async s=>{const c=N,u=I;j(null),C(b=>b.filter(a=>a.id!==s)),h(b=>b.map(a=>({...a,items:a.items.filter(n=>n.id!==s)})));try{await qt(s,f)}catch(b){C(c),h(u),j(b instanceof Error?b.message:r("todo.failedDeleteItem","Failed to delete item")),L?.(r("todo.failedDeleteItemToast","Failed to delete todo item"),"error")}},[L,N,I,f,r]),q=l.useCallback(async s=>{const c=A.current;if(!c)return;const u=N,b=I,a=new Map(N.map(i=>[i.id,i])),n=s.map((i,d)=>{const p=a.get(i);return p?{...p,sortOrder:d}:null}).filter(i=>i!==null);j(null),C(n),h(i=>i.map(d=>d.id===c?{...d,items:n}:d));try{await zt(c,s,f)}catch(i){C(u),h(b),j(i instanceof Error?i.message:r("todo.failedReorderItems","Failed to reorder items")),L?.(r("todo.failedReorderItemsToast","Failed to reorder todo items"),"error")}},[L,N,I,f,r]);return{lists:w,items:N,loading:E,error:Q,selectedListId:M,setSelectedListId:R,createList:Z,renameList:B,deleteList:D,createItem:W,updateItem:S,toggleItem:H,deleteItem:O,reorderItems:q}}function pe(x){return[...x].sort((r,f)=>r.sortOrder-f.sortOrder)}function fe(x){try{const r=re("kb-dashboard-todo-hide-done",x);if(r!==null)return r==="true"}catch{}return!1}function je({projectId:x,addToast:r,onPlanningMode:f,onTaskCreated:L}){const{t:o}=At("app"),{lists:w,items:k,loading:N,error:C,selectedListId:E,setSelectedListId:K,createList:Q,renameList:j,deleteList:M,createItem:R,updateItem:I,toggleItem:h,deleteItem:A,reorderItems:Z}=be({projectId:x,addToast:(t,m)=>{if(m==="success"||m==="error"||m==="info"||m===void 0){r(t,m);return}r(t,"info")}}),[B,D]=l.useState(null),[W,S]=l.useState(""),[H,O]=l.useState(null),[q,s]=l.useState(""),[c,u]=l.useState(""),[b,a]=l.useState(!1),[n,i]=l.useState(""),[d,p]=l.useState([]),[v,_]=l.useState(!1),[tt,V]=l.useState(!1),[dt,X]=l.useState(null),[P,Et]=l.useState(()=>fe(x)),et=l.useRef(null),{confirm:Dt}=Qt(),[Tt,lt]=l.useState("list"),z=l.useMemo(()=>w.find(t=>t.id===E)??null,[w,E]),U=l.useMemo(()=>pe(k.filter(t=>t.listId===E)),[k,E]),Y=l.useMemo(()=>P?U.filter(t=>!t.completed):U,[P,U]),rt=l.useMemo(()=>{const t=new Map;for(const m of w)t.set(m.id,{total:0,completed:0});for(const m of k){const y=t.get(m.listId)??{total:0,completed:0};y.total+=1,m.completed&&(y.completed+=1),t.set(m.listId,y)}return t},[k,w]),st=z?rt.get(z.id)??{total:U.length,completed:U.filter(t=>t.completed).length}:null;function ct(){D(null),S(""),u(""),a(!1)}function J(){O(null),s(""),i("")}function Ft(t){ct(),J(),K(t),lt("detail")}function $t(){lt("list")}const Mt=l.useCallback(async()=>{_(!0);try{const t=await Zt(void 0,x);p(t),V(!0)}catch(t){r(o("todo.failedToLoadAgents","Failed to load agents: {{error}}",{error:nt(t)}),"error"),V(!1),X(null)}finally{_(!1)}},[x,r,o]);l.useEffect(()=>{D(null),S(""),u(""),a(!1),O(null),s(""),i(""),V(!1),X(null)},[E]),l.useEffect(()=>{typeof window<"u"&&te("kb-dashboard-todo-hide-done",P.toString(),x)},[P,x]),l.useEffect(()=>{if(!tt)return;const t=m=>{et.current&&!et.current.contains(m.target)&&(V(!1),X(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[tt]);function Rt(t){J(),D(t.id),S(t.title),a(!1)}async function mt(){if(!B)return;const t=W.trim();if(!t){D(null),S("");return}await j(B,t),D(null),S("")}function ut(){D(null),S("")}function bt(t){ct(),O(t.id),s(t.text)}async function pt(){if(!H)return;const t=q.trim();if(!t){O(null),s("");return}await I(H,{text:t}),O(null),s("")}function ft(){O(null),s("")}async function ht(){const t=c.trim();t&&(await Q(t),u(""),a(!1))}async function xt(){if(!E)return;const t=n.trim();t&&(await R(t),i(""))}async function Ot(t){await Dt({title:o("todo.deleteListTitle","Delete List"),message:o("todo.deleteListConfirm","Delete this list and all its items?"),danger:!0})&&await M(t)}async function _t(t){await A(t)}async function gt(t,m){const y=Y.map($=>$.id),g=y.findIndex($=>$===t);if(g<0)return;const T=m==="up"?g-1:g+1;if(T<0||T>=y.length)return;const F=U.map($=>$.id),G=F.findIndex($=>$===t),ot=F.findIndex($=>$===y[T]);G<0||ot<0||([F[G],F[ot]]=[F[ot],F[G]],await Z(F))}const Pt=l.useCallback(async t=>{try{const m={description:t.text,source:{sourceType:"dashboard_ui"}},y=await jt(m,x);L?.(y),r(o("todo.taskCreatedFromTodo","Created {{id}} from todo",{id:y.id}),"success")}catch(m){r(o("todo.failedToCreateTask","Failed to create task: {{error}}",{error:nt(m)}),"error")}},[x,r,L,o]),Ut=l.useCallback(async(t,m)=>{try{const y={description:t.text,assignedAgentId:m,source:{sourceType:"dashboard_ui"}},g=await jt(y,x);L?.(g);const F=d.find(G=>G.id===m)?.name??m;r(o("todo.taskCreatedAndAssigned","Created {{id}} and assigned to {{agent}}",{id:g.id,agent:F}),"success"),V(!1),X(null)}catch(y){r(o("todo.failedToCreateAndAssign","Failed to create and assign task: {{error}}",{error:nt(y)}),"error")}},[x,r,d,L,o]),vt=null;return N?e.jsxs("div",{className:"todo-view","data-testid":"todo-view-root",children:[vt,e.jsxs("div",{className:"todo-loading",children:[e.jsx(ee,{className:"todo-loading-icon","aria-hidden":"true"}),e.jsx("p",{children:o("todo.loading","Loading todos...")})]})]}):e.jsxs("div",{className:"todo-view","data-testid":"todo-view-root",children:[vt,e.jsxs("div",{className:"todo-view-layout","data-mobile-stack-view":Tt,children:[e.jsxs("aside",{className:"todo-view-sidebar","aria-label":o("todo.listsLabel","Todo lists sidebar"),children:[e.jsxs("div",{className:"todo-sidebar-header",children:[e.jsx("h3",{className:"todo-sidebar-title",children:o("todo.lists","Lists")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-add-list-btn",onClick:()=>{J(),a(!0),D(null)},"aria-label":o("todo.addList","Add list"),"data-testid":"add-list-button",children:e.jsx(It,{})})]}),b&&e.jsxs("div",{className:"todo-list-item",children:[e.jsx("input",{className:"input todo-inline-edit-input",placeholder:o("todo.newListTitle","New list title"),value:c,onChange:t=>u(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ht(),t.key==="Escape"&&(u(""),a(!1))},autoFocus:!0,"data-testid":"new-list-input"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{ht()},"aria-label":o("todo.saveList","Save list"),children:e.jsx(at,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{u(""),a(!1)},"aria-label":o("todo.cancelList","Cancel list"),children:e.jsx(it,{})})]}),w.length===0&&!b?e.jsxs("div",{className:"todo-empty-state",children:[e.jsx(kt,{"aria-hidden":"true"}),e.jsx("p",{children:o("todo.noListsEmpty","No todo lists yet. Create one to get started.")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>{J(),a(!0)},children:o("todo.createList","Create List")})]}):e.jsx("div",{className:"todo-list-items",role:"list","aria-label":o("todo.todoListsLabel","Todo lists"),children:w.map(t=>{const m=t.id===E,y=t.id===B,g=rt.get(t.id)??{total:0,completed:0};return e.jsx("div",{className:`todo-list-item${m?" todo-list-item--active":""}`,role:"listitem",children:y?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"input todo-inline-edit-input",value:W,onChange:T=>S(T.target.value),onKeyDown:T=>{T.key==="Enter"&&mt(),T.key==="Escape"&&ut()},autoFocus:!0,"data-testid":`rename-list-input-${t.id}`}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{mt()},"aria-label":o("todo.saveListRename","Save list rename"),children:e.jsx(at,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:ut,"aria-label":o("todo.cancelListRename","Cancel list rename"),children:e.jsx(it,{})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"todo-list-select-btn",onClick:()=>Ft(t.id),"aria-label":o("todo.selectList","Select list {{title}}",{title:t.title}),"aria-current":m?"true":void 0,"data-testid":`todo-list-${t.id}`,children:[e.jsx("span",{className:"todo-list-item-name",children:t.title}),e.jsxs("span",{className:"todo-list-item-count",children:[g.completed,"/",g.total]})]}),e.jsxs("div",{className:"todo-list-item-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{Rt(t)},"aria-label":o("todo.renameList","Rename {{title}}",{title:t.title}),"data-testid":`rename-list-button-${t.id}`,children:e.jsx(Ct,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{Ot(t.id)},"aria-label":o("todo.deleteList","Delete {{title}}",{title:t.title}),"data-testid":`delete-list-button-${t.id}`,children:e.jsx(wt,{})})]})]})},t.id)})})]}),e.jsxs("section",{className:"todo-view-main","aria-label":o("todo.itemsLabel","Todo items"),children:[C&&e.jsxs("div",{className:"todo-error-banner",role:"alert",children:[e.jsx("span",{className:"todo-error-message",children:C}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>window.location.reload(),children:o("actions.retry","Retry")})]}),z?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"todo-items-header",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn todo-mobile-back-btn",onClick:$t,"aria-label":o("todo.backToLists","Back to lists"),"data-testid":"todo-mobile-back-button",children:e.jsx(se,{})}),e.jsxs("div",{className:"todo-items-heading",children:[e.jsx("h3",{children:z.title}),st&&e.jsx("span",{className:"todo-items-progress",children:o("todo.completedCount","{{completed}}/{{total}} complete",{completed:st.completed,total:st.total})})]}),e.jsxs("button",{type:"button",className:"btn btn-sm todo-hide-done-toggle","aria-pressed":P,onClick:()=>Et(t=>!t),"data-testid":"todo-hide-done-toggle",children:[P?e.jsx(oe,{"aria-hidden":"true"}):e.jsx(ne,{"aria-hidden":"true"}),P?o("todo.showDone","Show done"):o("todo.hideDone","Hide done")]})]}),e.jsxs("div",{className:"todo-add-item-row",children:[e.jsx("input",{className:"input",placeholder:o("todo.addItemPlaceholder","Add a todo item"),value:n,onChange:t=>i(t.target.value),onKeyDown:t=>{t.key==="Enter"&&xt(),t.key==="Escape"&&i("")},"data-testid":"new-item-input"}),e.jsxs("button",{type:"button",className:"btn btn-primary",onClick:()=>{xt()},children:[e.jsx(It,{size:14}),o("actions.add","Add")]})]}),U.length===0?e.jsx("div",{className:"todo-empty-state",children:e.jsx("p",{children:o("todo.noItemsEmpty","No items in this list. Add one above.")})}):Y.length===0?e.jsx("div",{className:"todo-empty-state","data-testid":"todo-all-done-hidden-empty",children:e.jsx("p",{children:o("todo.allDoneHidden","All items are complete. Choose Show done to view them.")})}):e.jsx("div",{className:"todo-items-list",children:Y.map((t,m)=>{const y=t.id===H;return e.jsxs("div",{className:"todo-item","data-testid":`todo-item-${t.id}`,children:[e.jsxs("div",{className:"todo-item-main-row",children:[e.jsx("input",{type:"checkbox",checked:t.completed,onChange:()=>{h(t.id)},className:"todo-item-checkbox","aria-label":`Toggle ${t.text}`,"data-testid":`toggle-item-${t.id}`}),y?e.jsx("input",{className:"input todo-inline-edit-input",value:q,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&pt(),g.key==="Escape"&&ft()},autoFocus:!0,"data-testid":`edit-item-input-${t.id}`}):e.jsx("button",{type:"button",className:`todo-item-text${t.completed?" todo-item-text--completed":""}`,onClick:()=>bt(t),children:t.text})]}),e.jsx("div",{className:"todo-item-actions","data-testid":`todo-item-actions-${t.id}`,children:y?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{pt()},"aria-label":o("todo.saveItemEdit","Save item edit"),children:e.jsx(at,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:ft,"aria-label":o("todo.cancelItemEdit","Cancel item edit"),children:e.jsx(it,{})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"todo-item-reorder-btns",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{gt(t.id,"up")},disabled:m===0,"aria-label":o("todo.moveItemUp","Move {{text}} up",{text:t.text}),"data-testid":`move-up-${t.id}`,children:e.jsx(ae,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{gt(t.id,"down")},disabled:m===Y.length-1,"aria-label":o("todo.moveItemDown","Move {{text}} down",{text:t.text}),"data-testid":`move-down-${t.id}`,children:e.jsx(ie,{})})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{f?.(t.text)},"aria-label":o("todo.startPlanning","Start planning from {{text}}",{text:t.text}),"data-testid":`planning-from-${t.id}`,children:e.jsx(de,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{Pt(t)},"aria-label":o("todo.createTaskFrom","Create task from {{text}}",{text:t.text}),"data-testid":`create-task-from-${t.id}`,children:e.jsx(me,{})}),e.jsxs("div",{className:"todo-agent-picker-trigger",ref:dt===t.id?et:void 0,children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{X(t.id),Mt()},"aria-label":o("todo.assignAgent","Assign {{text}} to agent",{text:t.text}),"data-testid":`assign-agent-for-${t.id}`,children:e.jsx(Nt,{})}),tt&&dt===t.id&&e.jsx("div",{className:"todo-agent-picker-dropdown",onMouseDown:g=>{g.preventDefault()},children:v?e.jsx("div",{className:"todo-agent-picker-loading",children:e.jsx(le,{label:o("todo.loadingAgents","Loading agents...")})}):d.length>0?d.map(g=>e.jsxs("button",{type:"button",className:"todo-agent-picker-item",onClick:()=>{Ut(t,g.id)},children:[e.jsx(Nt,{}),e.jsx("span",{children:g.name}),e.jsx("span",{className:"todo-agent-picker-role",children:g.role})]},g.id)):e.jsx("div",{className:"todo-agent-picker-empty",children:o("todo.noAgentsAvailable","No agents available")})})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>bt(t),"aria-label":o("todo.editItem","Edit {{text}}",{text:t.text}),"data-testid":`edit-item-${t.id}`,children:e.jsx(Ct,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{_t(t.id)},"aria-label":o("todo.deleteItem","Delete {{text}}",{text:t.text}),"data-testid":`delete-item-${t.id}`,children:e.jsx(wt,{})})]})})]},t.id)})})]}):e.jsxs("div",{className:"todo-empty-state",children:[e.jsx(kt,{"aria-hidden":"true"}),e.jsx("p",{children:o("todo.selectListEmpty","Select a list from the sidebar")})]})]})]})]})}export{je as TodoView};
6
+ */const ce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],me=Kt("circle-plus",ce);function ue(x){const{items:r,...f}=x;return f}function St(x){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${x}-${crypto.randomUUID()}`:`${x}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function be(x={}){const{t:r}=At("app"),{projectId:f,addToast:L}=x,o=`${Ht.TODO_LISTS_PREFIX}${f??"global"}`,[C,k]=l.useState(()=>{const s=Lt(o,{maxAgeMs:yt});return Array.isArray(s)?s:[]}),[N,w]=l.useState([]),[E,K]=l.useState(()=>C.length===0),[Q,j]=l.useState(null),[M,R]=l.useState(null),[I,h]=l.useState([]),A=l.useRef(M);A.current=M,l.useEffect(()=>{let s=!1;const c=Lt(o,{maxAgeMs:yt}),u=Array.isArray(c)&&c.length>0;u?(k(c),K(!1)):(k([]),K(!0));async function b(){u||K(!0),j(null);try{const a=await Yt(f);if(s)return;h(a);const n=a.map(ue);k(n),Jt(o,n,{maxBytes:5e5});const i=A.current&&a.some(d=>d.id===A.current)?A.current:a[0]?.id??null;R(i),w(i?a.find(d=>d.id===i)?.items??[]:[])}catch(a){if(s)return;h([]),k([]),w([]),R(null),j(a instanceof Error?a.message:r("todo.failedLoadLists","Failed to load todo lists"))}finally{s||K(!1)}}return b(),()=>{s=!0}},[o,f]),l.useEffect(()=>{if(!M){w([]);return}const s=I.find(c=>c.id===M);w(s?.items??[])},[I,M]);const Z=l.useCallback(async s=>{const c=C,u=I,b=new Date().toISOString(),a={id:St("temp-list"),projectId:f??"",title:s,createdAt:b,updatedAt:b};j(null),k(n=>[...n,a]),h(n=>[...n,{...a,items:[]}]);try{const n=await Bt(s,f);k(i=>i.map(d=>d.id===a.id?n:d)),h(i=>i.map(d=>d.id===a.id?{...n,items:[]}:d)),A.current||R(n.id)}catch(n){k(c),h(u),j(n instanceof Error?n.message:r("todo.failedCreateList","Failed to create list")),L?.(r("todo.failedCreateListToast","Failed to create todo list"),"error")}},[L,I,C,f,r]),H=l.useCallback(async(s,c)=>{const u=C,b=I;j(null),k(a=>a.map(n=>n.id===s?{...n,title:c}:n)),h(a=>a.map(n=>n.id===s?{...n,title:c}:n));try{const a=await Vt(s,c,f);k(n=>n.map(i=>i.id===s?a:i)),h(n=>n.map(i=>i.id===s?{...a,items:i.items}:i))}catch(a){k(u),h(b),j(a instanceof Error?a.message:r("todo.failedRenameList","Failed to rename list")),L?.(r("todo.failedRenameListToast","Failed to rename todo list"),"error")}},[L,I,C,f,r]),D=l.useCallback(async s=>{const c=C,u=I,b=A.current,a=b===s?C.find(n=>n.id!==s)?.id??null:b;j(null),k(n=>n.filter(i=>i.id!==s)),h(n=>n.filter(i=>i.id!==s)),b===s&&R(a);try{await Xt(s,f)}catch(n){k(c),h(u),R(b),j(n instanceof Error?n.message:r("todo.failedDeleteList","Failed to delete list")),L?.(r("todo.failedDeleteListToast","Failed to delete todo list"),"error")}},[L,I,C,f,r]),q=l.useCallback(async s=>{const c=A.current;if(!c)return;const u=N,b=I,a=new Date().toISOString(),n=N.reduce((d,p)=>Math.max(d,p.sortOrder),-1),i={id:St("temp-item"),listId:c,text:s,completed:!1,completedAt:null,createdAt:a,updatedAt:a,sortOrder:n+1};j(null),w(d=>[...d,i]),h(d=>d.map(p=>p.id===c?{...p,items:[...p.items,i]}:p));try{const d=await Wt(c,s,f);w(p=>p.map(v=>v.id===i.id?d:v)),h(p=>p.map(v=>v.id===c?{...v,items:v.items.map(_=>_.id===i.id?d:_)}:v))}catch(d){w(u),h(b),j(d instanceof Error?d.message:r("todo.failedCreateItem","Failed to create item")),L?.(r("todo.failedCreateItemToast","Failed to create todo item"),"error")}},[L,N,I,f,r]),S=l.useCallback(async(s,c)=>{const u=N.find(d=>d.id===s);if(!u)return;const b=N,a=I,n=c.completed??u.completed,i={...u,...c,completed:n,completedAt:n?u.completedAt??new Date().toISOString():null,updatedAt:new Date().toISOString()};j(null),w(d=>d.map(p=>p.id===s?i:p)),h(d=>d.map(p=>p.id===i.listId?{...p,items:p.items.map(v=>v.id===s?i:v)}:p));try{const d=await qt(s,c,f);w(p=>p.map(v=>v.id===s?d:v)),h(p=>p.map(v=>v.id===d.listId?{...v,items:v.items.map(_=>_.id===s?d:_)}:v))}catch(d){w(b),h(a),j(d instanceof Error?d.message:r("todo.failedUpdateItem","Failed to update item")),L?.(r("todo.failedUpdateItemToast","Failed to update todo item"),"error")}},[L,N,I,f,r]),B=l.useCallback(async s=>{const c=N.find(u=>u.id===s);c&&await S(s,{completed:!c.completed})},[N,S]),O=l.useCallback(async s=>{const c=N,u=I;j(null),w(b=>b.filter(a=>a.id!==s)),h(b=>b.map(a=>({...a,items:a.items.filter(n=>n.id!==s)})));try{await zt(s,f)}catch(b){w(c),h(u),j(b instanceof Error?b.message:r("todo.failedDeleteItem","Failed to delete item")),L?.(r("todo.failedDeleteItemToast","Failed to delete todo item"),"error")}},[L,N,I,f,r]),z=l.useCallback(async s=>{const c=A.current;if(!c)return;const u=N,b=I,a=new Map(N.map(i=>[i.id,i])),n=s.map((i,d)=>{const p=a.get(i);return p?{...p,sortOrder:d}:null}).filter(i=>i!==null);j(null),w(n),h(i=>i.map(d=>d.id===c?{...d,items:n}:d));try{await Gt(c,s,f)}catch(i){w(u),h(b),j(i instanceof Error?i.message:r("todo.failedReorderItems","Failed to reorder items")),L?.(r("todo.failedReorderItemsToast","Failed to reorder todo items"),"error")}},[L,N,I,f,r]);return{lists:C,items:N,loading:E,error:Q,selectedListId:M,setSelectedListId:R,createList:Z,renameList:H,deleteList:D,createItem:q,updateItem:S,toggleItem:B,deleteItem:O,reorderItems:z}}function pe(x){return[...x].sort((r,f)=>r.sortOrder-f.sortOrder)}function fe(x){try{const r=re("kb-dashboard-todo-hide-done",x);if(r!==null)return r==="true"}catch{}return!1}function je({projectId:x,addToast:r,onPlanningMode:f,onTaskCreated:L}){const{t:o}=At("app"),{lists:C,items:k,loading:N,error:w,selectedListId:E,setSelectedListId:K,createList:Q,renameList:j,deleteList:M,createItem:R,updateItem:I,toggleItem:h,deleteItem:A,reorderItems:Z}=be({projectId:x,addToast:(t,m)=>{if(m==="success"||m==="error"||m==="info"||m===void 0){r(t,m);return}r(t,"info")}}),[H,D]=l.useState(null),[q,S]=l.useState(""),[B,O]=l.useState(null),[z,s]=l.useState(""),[c,u]=l.useState(""),[b,a]=l.useState(!1),[n,i]=l.useState(""),[d,p]=l.useState([]),[v,_]=l.useState(!1),[tt,V]=l.useState(!1),[dt,X]=l.useState(null),[P,Et]=l.useState(()=>fe(x)),et=l.useRef(null),{confirm:Dt}=Qt(),[Tt,lt]=l.useState("list"),G=l.useMemo(()=>C.find(t=>t.id===E)??null,[C,E]),U=l.useMemo(()=>pe(k.filter(t=>t.listId===E)),[k,E]),Y=l.useMemo(()=>P?U.filter(t=>!t.completed):U,[P,U]),rt=l.useMemo(()=>{const t=new Map;for(const m of C)t.set(m.id,{total:0,completed:0});for(const m of k){const y=t.get(m.listId)??{total:0,completed:0};y.total+=1,m.completed&&(y.completed+=1),t.set(m.listId,y)}return t},[k,C]),st=G?rt.get(G.id)??{total:U.length,completed:U.filter(t=>t.completed).length}:null;function ct(){D(null),S(""),u(""),a(!1)}function J(){O(null),s(""),i("")}function Ft(t){ct(),J(),K(t),lt("detail")}function $t(){lt("list")}const Mt=l.useCallback(async()=>{_(!0);try{const t=await Zt(void 0,x);p(t),V(!0)}catch(t){r(o("todo.failedToLoadAgents","Failed to load agents: {{error}}",{error:nt(t)}),"error"),V(!1),X(null)}finally{_(!1)}},[x,r,o]);l.useEffect(()=>{D(null),S(""),u(""),a(!1),O(null),s(""),i(""),V(!1),X(null)},[E]),l.useEffect(()=>{typeof window<"u"&&te("kb-dashboard-todo-hide-done",P.toString(),x)},[P,x]),l.useEffect(()=>{if(!tt)return;const t=m=>{et.current&&!et.current.contains(m.target)&&(V(!1),X(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[tt]);function Rt(t){J(),D(t.id),S(t.title),a(!1)}async function mt(){if(!H)return;const t=q.trim();if(!t){D(null),S("");return}await j(H,t),D(null),S("")}function ut(){D(null),S("")}function bt(t){ct(),O(t.id),s(t.text)}async function pt(){if(!B)return;const t=z.trim();if(!t){O(null),s("");return}await I(B,{text:t}),O(null),s("")}function ft(){O(null),s("")}async function ht(){const t=c.trim();t&&(await Q(t),u(""),a(!1))}async function xt(){if(!E)return;const t=n.trim();t&&(await R(t),i(""))}async function Ot(t){await Dt({title:o("todo.deleteListTitle","Delete List"),message:o("todo.deleteListConfirm","Delete this list and all its items?"),danger:!0})&&await M(t)}async function _t(t){await A(t)}async function gt(t,m){const y=Y.map($=>$.id),g=y.findIndex($=>$===t);if(g<0)return;const T=m==="up"?g-1:g+1;if(T<0||T>=y.length)return;const F=U.map($=>$.id),W=F.findIndex($=>$===t),ot=F.findIndex($=>$===y[T]);W<0||ot<0||([F[W],F[ot]]=[F[ot],F[W]],await Z(F))}const Pt=l.useCallback(async t=>{try{const m={description:t.text,source:{sourceType:"dashboard_ui"}},y=await jt(m,x);L?.(y),r(o("todo.taskCreatedFromTodo","Created {{id}} from todo",{id:y.id}),"success")}catch(m){r(o("todo.failedToCreateTask","Failed to create task: {{error}}",{error:nt(m)}),"error")}},[x,r,L,o]),Ut=l.useCallback(async(t,m)=>{try{const y={description:t.text,assignedAgentId:m,source:{sourceType:"dashboard_ui"}},g=await jt(y,x);L?.(g);const F=d.find(W=>W.id===m)?.name??m;r(o("todo.taskCreatedAndAssigned","Created {{id}} and assigned to {{agent}}",{id:g.id,agent:F}),"success"),V(!1),X(null)}catch(y){r(o("todo.failedToCreateAndAssign","Failed to create and assign task: {{error}}",{error:nt(y)}),"error")}},[x,r,d,L,o]),vt=null;return N?e.jsxs("div",{className:"todo-view","data-testid":"todo-view-root",children:[vt,e.jsxs("div",{className:"todo-loading",children:[e.jsx(ee,{className:"todo-loading-icon","aria-hidden":"true"}),e.jsx("p",{children:o("todo.loading","Loading todos...")})]})]}):e.jsxs("div",{className:"todo-view","data-testid":"todo-view-root",children:[vt,e.jsxs("div",{className:"todo-view-layout","data-mobile-stack-view":Tt,children:[e.jsxs("aside",{className:"todo-view-sidebar","aria-label":o("todo.listsLabel","Todo lists sidebar"),children:[e.jsxs("div",{className:"todo-sidebar-header",children:[e.jsx("h3",{className:"todo-sidebar-title",children:o("todo.lists","Lists")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-add-list-btn",onClick:()=>{J(),a(!0),D(null)},"aria-label":o("todo.addList","Add list"),"data-testid":"add-list-button",children:e.jsx(It,{})})]}),b&&e.jsxs("div",{className:"todo-list-item",children:[e.jsx("input",{className:"input todo-inline-edit-input",placeholder:o("todo.newListTitle","New list title"),value:c,onChange:t=>u(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ht(),t.key==="Escape"&&(u(""),a(!1))},autoFocus:!0,"data-testid":"new-list-input"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{ht()},"aria-label":o("todo.saveList","Save list"),children:e.jsx(at,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{u(""),a(!1)},"aria-label":o("todo.cancelList","Cancel list"),children:e.jsx(it,{})})]}),C.length===0&&!b?e.jsxs("div",{className:"todo-empty-state",children:[e.jsx(kt,{"aria-hidden":"true"}),e.jsx("p",{children:o("todo.noListsEmpty","No todo lists yet. Create one to get started.")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>{J(),a(!0)},children:o("todo.createList","Create List")})]}):e.jsx("div",{className:"todo-list-items",role:"list","aria-label":o("todo.todoListsLabel","Todo lists"),children:C.map(t=>{const m=t.id===E,y=t.id===H,g=rt.get(t.id)??{total:0,completed:0};return e.jsx("div",{className:`todo-list-item${m?" todo-list-item--active":""}`,role:"listitem",children:y?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"input todo-inline-edit-input",value:q,onChange:T=>S(T.target.value),onKeyDown:T=>{T.key==="Enter"&&mt(),T.key==="Escape"&&ut()},autoFocus:!0,"data-testid":`rename-list-input-${t.id}`}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{mt()},"aria-label":o("todo.saveListRename","Save list rename"),children:e.jsx(at,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:ut,"aria-label":o("todo.cancelListRename","Cancel list rename"),children:e.jsx(it,{})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"todo-list-select-btn",onClick:()=>Ft(t.id),"aria-label":o("todo.selectList","Select list {{title}}",{title:t.title}),"aria-current":m?"true":void 0,"data-testid":`todo-list-${t.id}`,children:[e.jsx("span",{className:"todo-list-item-name",children:t.title}),e.jsxs("span",{className:"todo-list-item-count",children:[g.completed,"/",g.total]})]}),e.jsxs("div",{className:"todo-list-item-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{Rt(t)},"aria-label":o("todo.renameList","Rename {{title}}",{title:t.title}),"data-testid":`rename-list-button-${t.id}`,children:e.jsx(wt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{Ot(t.id)},"aria-label":o("todo.deleteList","Delete {{title}}",{title:t.title}),"data-testid":`delete-list-button-${t.id}`,children:e.jsx(Ct,{})})]})]})},t.id)})})]}),e.jsxs("section",{className:"todo-view-main","aria-label":o("todo.itemsLabel","Todo items"),children:[w&&e.jsxs("div",{className:"todo-error-banner",role:"alert",children:[e.jsx("span",{className:"todo-error-message",children:w}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>window.location.reload(),children:o("actions.retry","Retry")})]}),G?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"todo-items-header",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn todo-mobile-back-btn",onClick:$t,"aria-label":o("todo.backToLists","Back to lists"),"data-testid":"todo-mobile-back-button",children:e.jsx(se,{})}),e.jsxs("div",{className:"todo-items-heading",children:[e.jsx("h3",{children:G.title}),st&&e.jsx("span",{className:"todo-items-progress",children:o("todo.completedCount","{{completed}}/{{total}} complete",{completed:st.completed,total:st.total})})]}),e.jsxs("button",{type:"button",className:"btn btn-sm todo-hide-done-toggle","aria-pressed":P,onClick:()=>Et(t=>!t),"data-testid":"todo-hide-done-toggle",children:[P?e.jsx(oe,{"aria-hidden":"true"}):e.jsx(ne,{"aria-hidden":"true"}),P?o("todo.showDone","Show done"):o("todo.hideDone","Hide done")]})]}),e.jsxs("div",{className:"todo-add-item-row",children:[e.jsx("input",{className:"input",placeholder:o("todo.addItemPlaceholder","Add a todo item"),value:n,onChange:t=>i(t.target.value),onKeyDown:t=>{t.key==="Enter"&&xt(),t.key==="Escape"&&i("")},"data-testid":"new-item-input"}),e.jsxs("button",{type:"button",className:"btn btn-primary",onClick:()=>{xt()},children:[e.jsx(It,{size:14}),o("actions.add","Add")]})]}),U.length===0?e.jsx("div",{className:"todo-empty-state",children:e.jsx("p",{children:o("todo.noItemsEmpty","No items in this list. Add one above.")})}):Y.length===0?e.jsx("div",{className:"todo-empty-state","data-testid":"todo-all-done-hidden-empty",children:e.jsx("p",{children:o("todo.allDoneHidden","All items are complete. Choose Show done to view them.")})}):e.jsx("div",{className:"todo-items-list",children:Y.map((t,m)=>{const y=t.id===B;return e.jsxs("div",{className:"todo-item","data-testid":`todo-item-${t.id}`,children:[e.jsxs("div",{className:"todo-item-main-row",children:[e.jsx("input",{type:"checkbox",checked:t.completed,onChange:()=>{h(t.id)},className:"todo-item-checkbox","aria-label":`Toggle ${t.text}`,"data-testid":`toggle-item-${t.id}`}),y?e.jsx("input",{className:"input todo-inline-edit-input",value:z,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&pt(),g.key==="Escape"&&ft()},autoFocus:!0,"data-testid":`edit-item-input-${t.id}`}):e.jsx("button",{type:"button",className:`todo-item-text${t.completed?" todo-item-text--completed":""}`,onClick:()=>bt(t),children:t.text})]}),e.jsx("div",{className:"todo-item-actions","data-testid":`todo-item-actions-${t.id}`,children:y?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{pt()},"aria-label":o("todo.saveItemEdit","Save item edit"),children:e.jsx(at,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:ft,"aria-label":o("todo.cancelItemEdit","Cancel item edit"),children:e.jsx(it,{})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"todo-item-reorder-btns",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{gt(t.id,"up")},disabled:m===0,"aria-label":o("todo.moveItemUp","Move {{text}} up",{text:t.text}),"data-testid":`move-up-${t.id}`,children:e.jsx(ae,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{gt(t.id,"down")},disabled:m===Y.length-1,"aria-label":o("todo.moveItemDown","Move {{text}} down",{text:t.text}),"data-testid":`move-down-${t.id}`,children:e.jsx(ie,{})})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{f?.(t.text)},"aria-label":o("todo.startPlanning","Start planning from {{text}}",{text:t.text}),"data-testid":`planning-from-${t.id}`,children:e.jsx(de,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{Pt(t)},"aria-label":o("todo.createTaskFrom","Create task from {{text}}",{text:t.text}),"data-testid":`create-task-from-${t.id}`,children:e.jsx(me,{})}),e.jsxs("div",{className:"todo-agent-picker-trigger",ref:dt===t.id?et:void 0,children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{X(t.id),Mt()},"aria-label":o("todo.assignAgent","Assign {{text}} to agent",{text:t.text}),"data-testid":`assign-agent-for-${t.id}`,children:e.jsx(Nt,{})}),tt&&dt===t.id&&e.jsx("div",{className:"todo-agent-picker-dropdown",onMouseDown:g=>{g.preventDefault()},children:v?e.jsx("div",{className:"todo-agent-picker-loading",children:e.jsx(le,{label:o("todo.loadingAgents","Loading agents...")})}):d.length>0?d.map(g=>e.jsxs("button",{type:"button",className:"todo-agent-picker-item",onClick:()=>{Ut(t,g.id)},children:[e.jsx(Nt,{}),e.jsx("span",{children:g.name}),e.jsx("span",{className:"todo-agent-picker-role",children:g.role})]},g.id)):e.jsx("div",{className:"todo-agent-picker-empty",children:o("todo.noAgentsAvailable","No agents available")})})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>bt(t),"aria-label":o("todo.editItem","Edit {{text}}",{text:t.text}),"data-testid":`edit-item-${t.id}`,children:e.jsx(wt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{_t(t.id)},"aria-label":o("todo.deleteItem","Delete {{text}}",{text:t.text}),"data-testid":`delete-item-${t.id}`,children:e.jsx(Ct,{})})]})})]},t.id)})})]}):e.jsxs("div",{className:"todo-empty-state",children:[e.jsx(kt,{"aria-hidden":"true"}),e.jsx("p",{children:o("todo.selectListEmpty","Select a list from the sidebar")})]})]})]})]})}export{je as TodoView};
@@ -1,4 +1,4 @@
1
- import{r as a,j as e,b as Za}from"./vendor-react-SZ_qB27O.js";import{R as Bn,d as Gn,B as qn,e as ei,C as Vn,P as ti,g as oi,f as si,E as ni,H as nt,h as at,u as Hn,j as ai,k as ii,l as li,m as ri,M as di}from"./vendor-reactflow-9C3XTE7_.js";import{c as ci,eu as ui,ev as Jt,ew as qo,ex as we,ey as Un,ez as pi,eA as fi,eB as oo,eC as It,eD as At,eE as it,eF as Pt,eG as Ke,eH as Kn,eI as Yn,eJ as Xn,eK as Jn,eL as Qn,eM as mi,P as ye,eN as Zn,dm as Xo,eO as ea,eP as ta,bd as Jo,eQ as oa,eR as Qo,eS as Ft,eT as sa,eU as na,eV as aa,aP as ia,a7 as Zo,K as la,aQ as es,eW as wi,b$ as hi,aN as Le,eX as gi,eY as ra,X as ts,bL as ki,eZ as da,ba as le,b9 as Qt,bg as bi,ap as xi,C as Fe,s as Ce,e_ as vi,bs as Zt,e$ as qs,bm as ca,f0 as eo,a8 as Ni,e as $e,a9 as ji,bw as Vo,q as yi,f1 as Ci,f2 as Si,c4 as Vs,f3 as Ei,f4 as Ii,dy as Ai,Q as Hs,a1 as Pi,f5 as Ho,f6 as Fi,f7 as Mi,f8 as Ri,f9 as Oi,fa as Li,fb as Ti,a5 as Di,fc as zi,fd as $i,fe as Us,ff as Ks,fg as Ys,fh as Xs,fi as Js,fj as Wi,fk as _i,fl as Bi,fm as Gi,fn as Qs,fo as qi,fp as Zs,fq as en,fr as tn,fs as Vi,ft as Mo,fu as Hi,fv as on,ec as sn,fw as Ui,f as nn,aI as Ki,dd as an,fx as Ro,be as ln,L as Pe,fy as Ye,fz as Oo,fA as Lo,cQ as Xt,S as We,fB as Yi,de as rn,fC as dn,cR as Xi,fD as Ji,dg as Qi,fE as Zi,fF as el}from"./index-ClPjlOHJ.js";import{u as be}from"./vendor-i18n-GF3RlKbq.js";import{P as To}from"./puzzle-CE00Ce2g.js";import{S as tl,a as ol,b as sl,c as cn,d as nl,e as al}from"./SettingsTextareaRow-ByeSU4Pi.js";import{U as il}from"./upload-DbKZcYCW.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as a,j as e,b as Za}from"./vendor-react-SZ_qB27O.js";import{R as Bn,d as Gn,B as qn,e as ei,C as Vn,P as ti,g as oi,f as si,E as ni,H as nt,h as at,u as Hn,j as ai,k as ii,l as li,m as ri,M as di}from"./vendor-reactflow-9C3XTE7_.js";import{c as ci,ev as ui,ew as Jt,ex as qo,ey as we,ez as Un,eA as pi,eB as fi,eC as oo,eD as It,eE as At,eF as it,eG as Pt,eH as Ke,eI as Kn,eJ as Yn,eK as Xn,eL as Jn,eM as Qn,eN as mi,P as ye,eO as Zn,dn as Xo,eP as ea,eQ as ta,bf as Jo,eR as oa,eS as Qo,eT as Ft,eU as sa,eV as na,eW as aa,aR as ia,a7 as Zo,K as la,aS as es,eX as wi,c0 as hi,aP as Le,eY as gi,eZ as ra,X as ts,bM as ki,e_ as da,bc as le,bb as Qt,bi,ap as xi,C as Fe,s as Ce,e$ as vi,bu as Zt,f0 as qs,bo as ca,f1 as eo,a8 as Ni,e as $e,a9 as ji,by as Vo,q as yi,f2 as Ci,f3 as Si,c5 as Vs,f4 as Ei,f5 as Ii,dz as Ai,Q as Hs,a1 as Pi,f6 as Ho,f7 as Fi,f8 as Mi,f9 as Ri,fa as Oi,fb as Li,fc as Ti,a5 as Di,fd as zi,fe as $i,ff as Us,fg as Ks,fh as Ys,fi as Xs,fj as Js,fk as Wi,fl as _i,fm as Bi,fn as Gi,fo as Qs,fp as qi,fq as Zs,fr as en,fs as tn,ft as Vi,fu as Mo,fv as Hi,fw as on,ed as sn,fx as Ui,f as nn,aK as Ki,de as an,fy as Ro,bg as ln,L as Pe,fz as Ye,fA as Oo,fB as Lo,cR as Xt,S as We,fC as Yi,df as rn,fD as dn,cS as Xi,fE as Ji,dh as Qi,fF as Zi,fG as el}from"./index-D8sgsB8q.js";import{u as be}from"./vendor-i18n-GF3RlKbq.js";import{P as To}from"./puzzle-D7NHfczg.js";import{S as tl,a as ol,b as sl,c as cn,d as nl,e as al}from"./SettingsTextareaRow-DnsWtbkh.js";import{U as il}from"./upload-YGrA50-5.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.