agent-tower 0.7.0-beta.1 → 0.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/web/assets/{AgentDemoPage-DVH2r8Bq.js → AgentDemoPage-DP9u0ylA.js} +1 -1
  2. package/dist/web/assets/{AgentEnvironmentSettingsPage-CgKLuSVi.js → AgentEnvironmentSettingsPage-B571SLF5.js} +1 -1
  3. package/dist/web/assets/{AgentLogo-BoU-DtS1.js → AgentLogo-VGcaaJum.js} +1 -1
  4. package/dist/web/assets/ConversationPage-CbMlQ5UC.js +3 -0
  5. package/dist/web/assets/CreateTaskInput-kkWy5nmc.js +1 -0
  6. package/dist/web/assets/{DemoPage-C_pqLAig.js → DemoPage-CpMV8Rv7.js} +1 -1
  7. package/dist/web/assets/{GeneralSettingsPage-DgGDkCei.js → GeneralSettingsPage-BvME4SJc.js} +1 -1
  8. package/dist/web/assets/{Icons-DxojzzgC.js → Icons-DXzgw2xT.js} +1 -1
  9. package/dist/web/assets/{LoadingPreviewPage-DB31Bua7.js → LoadingPreviewPage-D6OzaV9-.js} +1 -1
  10. package/dist/web/assets/{McpSettingsPage-CbD2WS6_.js → McpSettingsPage-CCWuZ-IU.js} +1 -1
  11. package/dist/web/assets/{MemberAvatar-C3SWnA21.js → MemberAvatar-DeKYSBH9.js} +1 -1
  12. package/dist/web/assets/{NotificationSettingsPage-B8phwndw.js → NotificationSettingsPage-BOhJqIXv.js} +1 -1
  13. package/dist/web/assets/{ProfileSettingsPage-DrGgBoYT.js → ProfileSettingsPage-BEMuDjhF.js} +1 -1
  14. package/dist/web/assets/{ProjectKanbanPage-Do_CnL-A.js → ProjectKanbanPage-Ka243_RU.js} +5 -5
  15. package/dist/web/assets/{ProjectSettingsPage-CWucCMvS.js → ProjectSettingsPage-sE0Thu7d.js} +1 -1
  16. package/dist/web/assets/{ProviderSettingsPage-Df0hDNzv.js → ProviderSettingsPage-BCXTXcbc.js} +1 -1
  17. package/dist/web/assets/{SettingsMasterDetail-BDYP0IlS.js → SettingsMasterDetail-DmqYixrL.js} +1 -1
  18. package/dist/web/assets/{TeamSettingsPage-DnUoFZy8.js → TeamSettingsPage-Dxk7-1fD.js} +1 -1
  19. package/dist/web/assets/{arc-OZ-vceMZ.js → arc-Bl7tPfS7.js} +1 -1
  20. package/dist/web/assets/{architectureDiagram-3BPJPVTR-BsdLkW1k.js → architectureDiagram-3BPJPVTR-CoP7qomY.js} +1 -1
  21. package/dist/web/assets/{arrow-left-DLv7xHB-.js → arrow-left-4_9exfZH.js} +1 -1
  22. package/dist/web/assets/{blockDiagram-GPEHLZMM-BkhEbwDp.js → blockDiagram-GPEHLZMM-Dyj3wCtX.js} +1 -1
  23. package/dist/web/assets/{c4Diagram-AAUBKEIU-COVRvZYn.js → c4Diagram-AAUBKEIU-BHpYwHH5.js} +1 -1
  24. package/dist/web/assets/channel-D6ei4By-.js +1 -0
  25. package/dist/web/assets/check-CIGH6GLr.js +1 -0
  26. package/dist/web/assets/{chevron-down-DO8ocuLa.js → chevron-down-B8PIP1yU.js} +1 -1
  27. package/dist/web/assets/{chevron-right-ffReG4fO.js → chevron-right-h-JkCAHM.js} +1 -1
  28. package/dist/web/assets/{chevron-up-1qS5XjTW.js → chevron-up-C5SQd6qy.js} +1 -1
  29. package/dist/web/assets/{chunk-2J33WTMH-Dtd7OE6g.js → chunk-2J33WTMH--mm3IA_q.js} +1 -1
  30. package/dist/web/assets/{chunk-4BX2VUAB-BYB7bgup.js → chunk-4BX2VUAB-DSTjg6vT.js} +1 -1
  31. package/dist/web/assets/{chunk-55IACEB6-D8eXYUvV.js → chunk-55IACEB6-BMI8DRl6.js} +1 -1
  32. package/dist/web/assets/{chunk-727SXJPM-CsspkJZ6.js → chunk-727SXJPM-DB6yt8nI.js} +1 -1
  33. package/dist/web/assets/{chunk-AQP2D5EJ-C4wKQyQJ.js → chunk-AQP2D5EJ-BMFO2BIQ.js} +1 -1
  34. package/dist/web/assets/{chunk-FMBD7UC4-BgPjdYy6.js → chunk-FMBD7UC4-BWW53Tgv.js} +1 -1
  35. package/dist/web/assets/{chunk-ND2GUHAM-DQZQZp-p.js → chunk-ND2GUHAM-3Q1rz4Rn.js} +1 -1
  36. package/dist/web/assets/{chunk-QZHKN3VN-CzuoyrRN.js → chunk-QZHKN3VN-DHZfBhTv.js} +1 -1
  37. package/dist/web/assets/{circle-alert-BhLONgEk.js → circle-alert-B2WJJFVc.js} +1 -1
  38. package/dist/web/assets/classDiagram-4FO5ZUOK-Dy0gEbpJ.js +1 -0
  39. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-Dy0gEbpJ.js +1 -0
  40. package/dist/web/assets/{code-block-OCS4YCEC-BuMUnxsm.js → code-block-OCS4YCEC-DAvNvPo_.js} +1 -1
  41. package/dist/web/assets/{confirm-dialog-CDinB23R.js → confirm-dialog-59aNupkb.js} +1 -1
  42. package/dist/web/assets/{cose-bilkent-S5V4N54A-BLfinhMU.js → cose-bilkent-S5V4N54A-BkBXPAOW.js} +1 -1
  43. package/dist/web/assets/{cssMode-CX7TV5AQ.js → cssMode-r4PsUEeI.js} +1 -1
  44. package/dist/web/assets/{dagre-BM42HDAG-Bu5izb1v.js → dagre-BM42HDAG-0o3tAN58.js} +1 -1
  45. package/dist/web/assets/{diagram-2AECGRRQ-CsRWxFV2.js → diagram-2AECGRRQ-BaozWVAC.js} +1 -1
  46. package/dist/web/assets/{diagram-5GNKFQAL-DrNRWf6l.js → diagram-5GNKFQAL-BQGxsEX-.js} +1 -1
  47. package/dist/web/assets/{diagram-KO2AKTUF-Dp7EY_gD.js → diagram-KO2AKTUF-BhOfCrvE.js} +1 -1
  48. package/dist/web/assets/{diagram-LMA3HP47-BDIdwePd.js → diagram-LMA3HP47-1C0Ajian.js} +1 -1
  49. package/dist/web/assets/{diagram-OG6HWLK6-CmfR47dA.js → diagram-OG6HWLK6-BZsvylQi.js} +1 -1
  50. package/dist/web/assets/{erDiagram-TEJ5UH35-Cy8PFuSb.js → erDiagram-TEJ5UH35-BODPoCQX.js} +1 -1
  51. package/dist/web/assets/{flowDiagram-I6XJVG4X-oE2ffGw2.js → flowDiagram-I6XJVG4X-B0BsMsro.js} +1 -1
  52. package/dist/web/assets/{folder-picker-0bwm5YE1.js → folder-picker-B5RdK3CX.js} +1 -1
  53. package/dist/web/assets/{freemarker2-B7H4PRb5.js → freemarker2-B62GnwxO.js} +1 -1
  54. package/dist/web/assets/{ganttDiagram-6RSMTGT7-CUBDtOgX.js → ganttDiagram-6RSMTGT7-BsXOoMru.js} +1 -1
  55. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CZe4VCfm.js → gitGraphDiagram-PVQCEYII-DVuq4oVA.js} +1 -1
  56. package/dist/web/assets/{handlebars-Cb8DyPaL.js → handlebars-BBm4KBDp.js} +1 -1
  57. package/dist/web/assets/{html-D542B6gH.js → html-BlMJourI.js} +1 -1
  58. package/dist/web/assets/{htmlMode-Ct2mDq0T.js → htmlMode-vGjPTlal.js} +1 -1
  59. package/dist/web/assets/{index-CUDYX2CO.js → index-BziFEuBL.js} +3 -3
  60. package/dist/web/assets/{index-BRYW86tJ.js → index-DfRNL5pP.js} +4 -4
  61. package/dist/web/assets/index-KjsBZlkg.css +1 -0
  62. package/dist/web/assets/{infoDiagram-5YYISTIA-DrabPhph.js → infoDiagram-5YYISTIA-CkI-s2fN.js} +1 -1
  63. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DIfxSpBY.js → ishikawaDiagram-YF4QCWOH-DExbu0jt.js} +1 -1
  64. package/dist/web/assets/javascript-CnnNs3bZ.js +1 -0
  65. package/dist/web/assets/{journeyDiagram-JHISSGLW-B7LiYPZk.js → journeyDiagram-JHISSGLW-C03_8hib.js} +1 -1
  66. package/dist/web/assets/{jsonMode-Cu2lWLKX.js → jsonMode-SxmrKu-q.js} +1 -1
  67. package/dist/web/assets/{kanban-definition-UN3LZRKU-DJ0tk4QS.js → kanban-definition-UN3LZRKU-CkQ5JqTm.js} +1 -1
  68. package/dist/web/assets/{layers-DRg_mgyk.js → layers-DVjF8vaY.js} +1 -1
  69. package/dist/web/assets/{linear-BHW5IboQ.js → linear-VXyesiU2.js} +1 -1
  70. package/dist/web/assets/{liquid-DTQCmN-t.js → liquid-B_CJMcDS.js} +1 -1
  71. package/dist/web/assets/{lspLanguageFeatures-DBps116H.js → lspLanguageFeatures-D46XQnYj.js} +1 -1
  72. package/dist/web/assets/{mdx-BguPTdam.js → mdx-B2i6poYS.js} +1 -1
  73. package/dist/web/assets/mermaid-NOHMQCX5-Cxj8y3xL.js +125 -0
  74. package/dist/web/assets/{message-square-CTVVQxz6.js → message-square-BleDaJqD.js} +1 -1
  75. package/dist/web/assets/{mindmap-definition-RKZ34NQL-BcqEpIG8.js → mindmap-definition-RKZ34NQL-OB13sryT.js} +1 -1
  76. package/dist/web/assets/{modal-D1r-F18d.js → modal-DCycqy3L.js} +1 -1
  77. package/dist/web/assets/{monaco-BDVujhQR.js → monaco-C5uCiSc1.js} +3 -3
  78. package/dist/web/assets/{pencil-CniYlzH3.js → pencil-7Lu7CiFO.js} +1 -1
  79. package/dist/web/assets/{pieDiagram-4H26LBE5-CI7jsHUn.js → pieDiagram-4H26LBE5-CU-pnTSj.js} +1 -1
  80. package/dist/web/assets/{python-B59lpYG0.js → python-CdqaVxbU.js} +1 -1
  81. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-lZRO7dcp.js → quadrantDiagram-W4KKPZXB-yZ7s-n8V.js} +1 -1
  82. package/dist/web/assets/{razor-Dp7HzFIW.js → razor-BZtfxDHk.js} +1 -1
  83. package/dist/web/assets/{requirementDiagram-4Y6WPE33-DkzFG3Tz.js → requirementDiagram-4Y6WPE33-B0anLb96.js} +1 -1
  84. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-D6DX95w9.js → sankeyDiagram-5OEKKPKP-DHcV9eve.js} +1 -1
  85. package/dist/web/assets/{select-npOSUcpP.js → select-EnAkHFwg.js} +1 -1
  86. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CqimAwem.js → sequenceDiagram-3UESZ5HK-DqgRRD9W.js} +1 -1
  87. package/dist/web/assets/{server-CP7SS59j.js → server-a_4ZRCwE.js} +1 -1
  88. package/dist/web/assets/{stateDiagram-AJRCARHV--zm2gvoI.js → stateDiagram-AJRCARHV-BM_vAe4X.js} +1 -1
  89. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DXSW0BBn.js +1 -0
  90. package/dist/web/assets/{switch-BYTZYAl5.js → switch-D_UoJD1K.js} +1 -1
  91. package/dist/web/assets/{textarea-C3iQ4ONP.js → textarea-Cmy7-X_E.js} +1 -1
  92. package/dist/web/assets/{timeline-definition-PNZ67QCA-DyTMvhUY.js → timeline-definition-PNZ67QCA-BRstBzgi.js} +1 -1
  93. package/dist/web/assets/{trash-2-0zy3IqlI.js → trash-2-0UA8zJ8I.js} +1 -1
  94. package/dist/web/assets/{tsMode-HgxC48Yq.js → tsMode-BASXySxT.js} +1 -1
  95. package/dist/web/assets/{typescript-CnJTMLZh.js → typescript-DbOfWuuq.js} +1 -1
  96. package/dist/web/assets/{upload-BLZ_nRBw.js → upload-CfzBeWxL.js} +1 -1
  97. package/dist/web/assets/{use-profiles-DFVi0aT0.js → use-profiles-MVQfFrhT.js} +1 -1
  98. package/dist/web/assets/{use-projects-CIn-ZTOZ.js → use-projects-CJ8Wn6Xl.js} +1 -1
  99. package/dist/web/assets/{use-providers-DQxnGN3a.js → use-providers-DvV0mdqo.js} +1 -1
  100. package/dist/web/assets/{useNormalizedLogs-Dc-ZYUbk.js → useNormalizedLogs-D8-yjxOI.js} +1 -1
  101. package/dist/web/assets/{vennDiagram-CIIHVFJN-C9ZqZYMv.js → vennDiagram-CIIHVFJN-DzhupKpF.js} +1 -1
  102. package/dist/web/assets/{wardley-L42UT6IY-DIkjJ-fY.js → wardley-L42UT6IY-BwWhS3dk.js} +1 -1
  103. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DRu59DgE.js → wardleyDiagram-YWT4CUSO-iG6xXnIJ.js} +1 -1
  104. package/dist/web/assets/{xml-8KGRJE7b.js → xml-Dn2Ep0JI.js} +1 -1
  105. package/dist/web/assets/{xychartDiagram-2RQKCTM6-obhyu3yJ.js → xychartDiagram-2RQKCTM6-hgKK9aU8.js} +1 -1
  106. package/dist/web/assets/{yaml-xUyCljQf.js → yaml-CA2Cgl3R.js} +1 -1
  107. package/dist/web/index.html +2 -2
  108. package/package.json +1 -1
  109. package/dist/web/assets/ConversationPage-BzxfS0Rj.js +0 -3
  110. package/dist/web/assets/CreateTaskInput-CbSZrOjZ.js +0 -1
  111. package/dist/web/assets/channel-Dnx8iy_z.js +0 -1
  112. package/dist/web/assets/check-06phvoBb.js +0 -1
  113. package/dist/web/assets/classDiagram-4FO5ZUOK-B4GBKzvA.js +0 -1
  114. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-B4GBKzvA.js +0 -1
  115. package/dist/web/assets/index-CVgeXPf_.css +0 -1
  116. package/dist/web/assets/javascript-CN2JLuRw.js +0 -1
  117. package/dist/web/assets/mermaid-NOHMQCX5-aLv2J0q_.js +0 -122
  118. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BgFhspSa.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-BDVujhQR.js","assets/index-CUDYX2CO.js","assets/index-CVgeXPf_.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{ah as od,ai as oo,aj as ad,ak as ld,al as cd,k as Ke,r as b,am as le,z as Ss,m as jt,an as Es,n as zt,p as Ee,o as bt,q as ce,u as ae,j as t,a9 as xt,Y as Ra,Z as dd,l as te,$ as Ws,B as Me,ao as Aa,ap as Ta,aq as Ma,af as Cs,X as qt,ar as gn,as as ud,O as br,at as hd,D as fd,au as md,av as pd,aw as gd,T as js,t as st,U as os,V as lt,W as Os,P as ze,ax as Ns,Q as lr,ay as vd,az as oi,ag as xd,ad as bd,ae as _d,aA as Da,aB as vn,aC as yd,aD as Pa,aE as La,aF as Ia,aG as Sd,aH as wd,a2 as Cd,aI as kd,aJ as Ed,aK as jd,_ as ao,a8 as lo}from"./index-CUDYX2CO.js";import{S as ct,u as xn,A as bn,l as Nd,F as Oa,p as Rd,m as Ad,o as Td,Q as _n,q as Md,r as Mt,W as _t,t as Ba,C as fr,v as Ir,w as Dd,x as Pd,y as Ld,T as Id,h as kt,b as qr,z as Fa,B as $t}from"./mermaid-NOHMQCX5-aLv2J0q_.js";import{C as yn}from"./confirm-dialog-CDinB23R.js";import{c as za,a as Wa,b as Ha,I as $a,d as Ua,A as co,G as qa}from"./Icons-DxojzzgC.js";import{C as wt}from"./chevron-down-DO8ocuLa.js";import{C as Pt}from"./chevron-right-ffReG4fO.js";import{d as Sn,S as Od,u as wn,A as mr,c as Cn,G as Ka,Z as Bd,e as kn,T as En,f as Fd,g as jn,h as uo,i as zd,b as Va,j as Xa,a as Ya,k as Ga,R as Qa,P as Za,l as Kr,m as Wd,C as ho,B as fo}from"./CreateTaskInput-CbSZrOjZ.js";import{a as Hd,F as $d,b as Ud}from"./folder-picker-0bwm5YE1.js";import{M as ai}from"./message-square-CTVVQxz6.js";import{L as Hs}from"./layers-DRg_mgyk.js";import{P as Nn,u as Ja,a as el,T as Vr}from"./useNormalizedLogs-Dc-ZYUbk.js";import{u as Ks}from"./use-providers-DQxnGN3a.js";import{A as li}from"./AgentLogo-BoU-DtS1.js";import{M as Ut}from"./MemberAvatar-C3SWnA21.js";import{C as tl}from"./chevron-up-1qS5XjTW.js";import{C as Kt}from"./check-06phvoBb.js";import{M as fs}from"./modal-D1r-F18d.js";import{S as as}from"./select-npOSUcpP.js";import{P as ls,T as Rn}from"./trash-2-0zy3IqlI.js";import{T as qd}from"./textarea-C3iQ4ONP.js";import{S as Zi,C as mo}from"./server-CP7SS59j.js";import{F as An,e as Kd,d as Vd,f as Xd,u as Yd}from"./use-projects-CIn-ZTOZ.js";import{U as Xr}from"./upload-BLZ_nRBw.js";import{A as $s}from"./arrow-left-DLv7xHB-.js";import{P as Gd}from"./pencil-CniYlzH3.js";var Qd=class extends od{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:oo()})}getOptimisticResult(e){return e.behavior=oo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",u=p&&i==="forward",c=v&&i==="backward",g=p&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ld(s,r.data),hasPreviousPage:ad(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:n&&!l&&!c,isRefetching:m&&!u&&!g}}};function Tn(e,s){return cd(e,Qd)}const Zd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],sl=Ke("arrow-right",Zd);const Jd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rl=Ke("ban",Jd);const eu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],tu=Ke("chevron-left",eu);const su=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],ru=Ke("clipboard-paste",su);const iu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=Ke("clock-3",iu);const nu=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ci=Ke("code-xml",nu);const ou=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],po=Ke("copy-plus",ou);const au=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],lu=Ke("earth",au);const cu=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],il=Ke("ellipsis-vertical",cu);const du=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],uu=Ke("file-braces-corner",du);const hu=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Yr=Ke("file-code-corner",hu);const fu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],mu=Ke("file-exclamation-point",fu);const pu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],di=Ke("folder-open",pu);const gu=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Vs=Ke("git-graph",gu);const vu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Us=Ke("history",vu);const xu=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],bu=Ke("maximize",xu);const _u=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],yu=Ke("panel-left-close",_u);const Su=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],wu=Ke("panel-left-open",Su);const Cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],ku=Ke("panel-right-close",Cu);const Eu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Ji=Ke("panel-right-open",Eu);const ju=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Nu=Ke("pen-line",ju);const Ru=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],es=Ke("play",Ru);const Au=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],nl=Ke("settings-2",Au);const Tu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],go=Ke("smartphone",Tu);const Mu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Or=Ke("user-plus",Mu);const Du=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Pu=Ke("zoom-in",Du);const Lu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Iu=Ke("zoom-out",Lu),ui=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Mn(e){return"nodeType"in e}function yt(e){var s,r;return e?Xs(e)?e:Mn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Dn(e){const{Document:s}=yt(e);return e instanceof s}function _r(e){return Xs(e)?!1:e instanceof yt(e).HTMLElement}function ol(e){return e instanceof yt(e).SVGElement}function Ys(e){return e?Xs(e)?e.document:Mn(e)?Dn(e)?e:_r(e)||ol(e)?e.ownerDocument:document:document:document}const ts=ui?b.useLayoutEffect:b.useEffect;function hi(e){const s=b.useRef(e);return ts(()=>{s.current=e}),b.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function Ou(){const e=b.useRef(null),s=b.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function pr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ts(()=>{r.current!==e&&(r.current=e)},s),r}function yr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Gr(e){const s=hi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Qr(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ri={};function fi(e,s){return b.useMemo(()=>{if(s)return s;const r=Ri[e]==null?0:Ri[e]+1;return Ri[e]=r,e+"-"+r},[e,s])}function al(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,v)=>{const n=Object.entries(v);for(const[i,l]of n){const u=m[i];u!=null&&(m[i]=u+e*l)}return m},{...s})}}const zs=al(1),Zr=al(-1);function Bu(e){return"clientX"in e&&"clientY"in e}function Pn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function Fu(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Jr(e){if(Fu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Bu(e)?{x:e.clientX,y:e.clientY}:null}const gr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[gr.Translate.toString(e),gr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),vo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function zu(e){return e.matches(vo)?e:e.querySelector(vo)}const Wu={display:"none"};function Hu(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:Wu},r)}function $u(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return le.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function Uu(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const ll=b.createContext(null);function qu(e){const s=b.useContext(ll);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Ku(){const[e]=b.useState(()=>new Set),s=b.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[b.useCallback(o=>{let{type:p,event:m}=o;e.forEach(v=>{var n;return(n=v[p])==null?void 0:n.call(v,m)})},[e]),s]}const Vu={draggable:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-C5uCiSc1.js","assets/index-BziFEuBL.js","assets/index-KjsBZlkg.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
+ import{ah as od,ai as oo,aj as ad,ak as ld,al as cd,k as Ke,r as b,am as le,z as Ss,m as jt,an as Es,n as zt,p as Ee,o as bt,q as ce,u as ae,j as t,a9 as xt,Y as Ra,Z as dd,l as te,$ as Ws,B as Me,ao as Aa,ap as Ta,aq as Ma,af as Cs,X as qt,ar as gn,as as ud,O as br,at as hd,D as fd,au as md,av as pd,aw as gd,T as js,t as st,U as os,V as lt,W as Os,P as ze,ax as Ns,Q as lr,ay as vd,az as oi,ag as xd,ad as bd,ae as _d,aA as Da,aB as vn,aC as yd,aD as Pa,aE as La,aF as Ia,aG as Sd,aH as wd,a2 as Cd,aI as kd,aJ as Ed,aK as jd,_ as ao,a8 as lo}from"./index-BziFEuBL.js";import{S as ct,u as xn,A as bn,l as Nd,F as Oa,p as Rd,m as Ad,o as Td,Q as _n,q as Md,r as Mt,W as _t,t as Ba,C as fr,v as Ir,w as Dd,x as Pd,y as Ld,T as Id,h as kt,b as qr,z as Fa,B as $t}from"./mermaid-NOHMQCX5-Cxj8y3xL.js";import{C as yn}from"./confirm-dialog-59aNupkb.js";import{c as za,a as Wa,b as Ha,I as $a,d as Ua,A as co,G as qa}from"./Icons-DXzgw2xT.js";import{C as wt}from"./chevron-down-B8PIP1yU.js";import{C as Pt}from"./chevron-right-h-JkCAHM.js";import{d as Sn,S as Od,u as wn,A as mr,c as Cn,G as Ka,Z as Bd,e as kn,T as En,f as Fd,g as jn,h as uo,i as zd,b as Va,j as Xa,a as Ya,k as Ga,R as Qa,P as Za,l as Kr,m as Wd,C as ho,B as fo}from"./CreateTaskInput-kkWy5nmc.js";import{a as Hd,F as $d,b as Ud}from"./folder-picker-B5RdK3CX.js";import{M as ai}from"./message-square-BleDaJqD.js";import{L as Hs}from"./layers-DVjF8vaY.js";import{P as Nn,u as Ja,a as el,T as Vr}from"./useNormalizedLogs-D8-yjxOI.js";import{u as Ks}from"./use-providers-DvV0mdqo.js";import{A as li}from"./AgentLogo-VGcaaJum.js";import{M as Ut}from"./MemberAvatar-DeKYSBH9.js";import{C as tl}from"./chevron-up-C5SQd6qy.js";import{C as Kt}from"./check-CIGH6GLr.js";import{M as fs}from"./modal-DCycqy3L.js";import{S as as}from"./select-EnAkHFwg.js";import{P as ls,T as Rn}from"./trash-2-0UA8zJ8I.js";import{T as qd}from"./textarea-Cmy7-X_E.js";import{S as Zi,C as mo}from"./server-a_4ZRCwE.js";import{F as An,e as Kd,d as Vd,f as Xd,u as Yd}from"./use-projects-CJ8Wn6Xl.js";import{U as Xr}from"./upload-CfzBeWxL.js";import{A as $s}from"./arrow-left-4_9exfZH.js";import{P as Gd}from"./pencil-7Lu7CiFO.js";var Qd=class extends od{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:oo()})}getOptimisticResult(e){return e.behavior=oo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",u=p&&i==="forward",c=v&&i==="backward",g=p&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ld(s,r.data),hasPreviousPage:ad(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:n&&!l&&!c,isRefetching:m&&!u&&!g}}};function Tn(e,s){return cd(e,Qd)}const Zd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],sl=Ke("arrow-right",Zd);const Jd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rl=Ke("ban",Jd);const eu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],tu=Ke("chevron-left",eu);const su=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],ru=Ke("clipboard-paste",su);const iu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=Ke("clock-3",iu);const nu=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ci=Ke("code-xml",nu);const ou=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],po=Ke("copy-plus",ou);const au=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],lu=Ke("earth",au);const cu=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],il=Ke("ellipsis-vertical",cu);const du=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],uu=Ke("file-braces-corner",du);const hu=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Yr=Ke("file-code-corner",hu);const fu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],mu=Ke("file-exclamation-point",fu);const pu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],di=Ke("folder-open",pu);const gu=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Vs=Ke("git-graph",gu);const vu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Us=Ke("history",vu);const xu=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],bu=Ke("maximize",xu);const _u=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],yu=Ke("panel-left-close",_u);const Su=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],wu=Ke("panel-left-open",Su);const Cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],ku=Ke("panel-right-close",Cu);const Eu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Ji=Ke("panel-right-open",Eu);const ju=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Nu=Ke("pen-line",ju);const Ru=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],es=Ke("play",Ru);const Au=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],nl=Ke("settings-2",Au);const Tu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],go=Ke("smartphone",Tu);const Mu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Or=Ke("user-plus",Mu);const Du=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Pu=Ke("zoom-in",Du);const Lu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Iu=Ke("zoom-out",Lu),ui=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Mn(e){return"nodeType"in e}function yt(e){var s,r;return e?Xs(e)?e:Mn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Dn(e){const{Document:s}=yt(e);return e instanceof s}function _r(e){return Xs(e)?!1:e instanceof yt(e).HTMLElement}function ol(e){return e instanceof yt(e).SVGElement}function Ys(e){return e?Xs(e)?e.document:Mn(e)?Dn(e)?e:_r(e)||ol(e)?e.ownerDocument:document:document:document}const ts=ui?b.useLayoutEffect:b.useEffect;function hi(e){const s=b.useRef(e);return ts(()=>{s.current=e}),b.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function Ou(){const e=b.useRef(null),s=b.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function pr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ts(()=>{r.current!==e&&(r.current=e)},s),r}function yr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Gr(e){const s=hi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Qr(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ri={};function fi(e,s){return b.useMemo(()=>{if(s)return s;const r=Ri[e]==null?0:Ri[e]+1;return Ri[e]=r,e+"-"+r},[e,s])}function al(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,v)=>{const n=Object.entries(v);for(const[i,l]of n){const u=m[i];u!=null&&(m[i]=u+e*l)}return m},{...s})}}const zs=al(1),Zr=al(-1);function Bu(e){return"clientX"in e&&"clientY"in e}function Pn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function Fu(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Jr(e){if(Fu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Bu(e)?{x:e.clientX,y:e.clientY}:null}const gr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[gr.Translate.toString(e),gr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),vo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function zu(e){return e.matches(vo)?e:e.querySelector(vo)}const Wu={display:"none"};function Hu(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:Wu},r)}function $u(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return le.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function Uu(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const ll=b.createContext(null);function qu(e){const s=b.useContext(ll);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Ku(){const[e]=b.useState(()=>new Set),s=b.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[b.useCallback(o=>{let{type:p,event:m}=o;e.forEach(v=>{var n;return(n=v[p])==null?void 0:n.call(v,m)})},[e]),s]}const Vu={draggable:`
3
3
  To pick up a draggable item, press the space bar.
4
4
  While dragging, use the arrow keys to move the item.
5
5
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -68,7 +68,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
68
68
  .transform-component-module_content__FBWxo img {
69
69
  pointer-events: none;
70
70
  }
71
- `,oa={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Mv(Dv);var Pv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,u=e.contentProps,c=u===void 0?{}:u,g=b.useContext(_i),x=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),a=b.useRef(null);return b.useEffect(function(){var h=w.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){_?.()}},[]),le.createElement("div",hs({},l,{ref:w,className:"".concat(dn.wrapperClass," ").concat(oa.wrapper," ").concat(o),style:v}),le.createElement("div",hs({},c,{ref:a,className:"".concat(dn.contentClass," ").concat(oa.content," ").concat(m),style:n}),s))},hc=function(){var e=b.useContext(_i);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Lv=function(){var e=hc();return ri(e)};function Iv(e){var s=hc(),r=b.useState(e(un(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,v=s.onChange(function(n){m&&p(e(un(n.instance)))});return function(){v(),m=!1}},[e,s]),o}function Ov(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Bv(e,s){return jt({queryKey:ce.files.tree(e||"",s),queryFn:()=>Ee.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Fv(e,s){return jt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>Ee.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function zv(e){const s=bt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Wv(){const e=bt();return zt({mutationFn:s=>Ee.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||Ov(r.path)})}})}function Hv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function $v(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const Uv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function qv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&Uv.has(s)?Ba:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Yr:s==="json"?uu:s==="md"||s==="mdx"||s==="txt"?Oa:$d}const aa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:te("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),fc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:n}=ae(),{data:i,isLoading:l,isError:u}=Bv(e,s),c=b.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=Hv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(aa,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Pt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(di,{size:14,className:"text-amber-500"}):t.jsx(An,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(fc,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const x=$v(s,g.name),_=qv(g),w=v===x,a=_===Ba;return t.jsx(aa,{depth:r,active:w,onClick:()=>m(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},Kv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ae(),[v,n]=b.useState(()=>new Set),i=zv(e),l=b.useCallback(u=>{n(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:te("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Ns,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(yu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(fc,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},Vv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Xv(e){const s=e.split(".").pop()?.toLowerCase();return s?Vv.has(s):!1}function Yv(e,s){const r=br(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Gv=({filePath:e})=>{const{t:s}=ae(),{zoomIn:r,zoomOut:o,centerView:p}=Lv(),m=Iv(n=>n.state.scale),v=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Iu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(Pu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(bu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Qv=({workingDir:e,filePath:s})=>{const{t:r}=ae(),[o,p]=b.useState(!1),m=Yv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Tv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Gv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Pv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function Zv(e){const s=e.split("/");return s[s.length-1]||e}function Jv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const e0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ae();return t.jsxs("button",{type:"button",onClick:o,className:te("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:te("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(qt,{size:12})})]})},t0=le.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ae(),[v,n]=b.useState([]),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),[_,w]=b.useState(0),[a,h]=b.useState(null),d=b.useRef(null),f=Wv();b.useEffect(()=>{let B=!1;return vd(async()=>{const{preloadMonaco:z}=await import("./monaco-BDVujhQR.js").then(U=>U.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{B||c(!0)}).catch(()=>{B||x(!0)}),()=>{B=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),L=b.useCallback(()=>{E(B=>(B?C(R.current):R.current=S,!B))},[S]),T=b.useCallback(B=>{B.preventDefault(),j(!0);const z=B.clientX,U=S,N=X=>{const V=X.clientX-z,ie=Math.min(480,Math.max(160,U+V));C(ie)},W=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",W)},[S]);b.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=b.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:H,error:q}=Fv(s,D?.isImage?null:i);b.useEffect(()=>{!i||!F||n(B=>B.map(z=>z.path!==i||z.isDirty||z.loaded?z:{...z,language:F.language||z.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[i,F]);const A=b.useCallback((B,z,U)=>{n(N=>{if(N.find(V=>V.path===B))return N;const X=Xv(B);return[...N,{path:B,name:Zv(B),language:Jv(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(B),h(z?{path:B,line:z,column:U}:null)},[]);le.useImperativeHandle(p,()=>({openFile:A}),[A]);const P=b.useCallback(B=>{n(z=>{const U=z.filter(N=>N.path!==B);return l(N=>N!==B?N:U.length?U[U.length-1].path:null),U})},[]),M=b.useCallback(B=>{n(z=>z.map(U=>{if(U.path!==i)return U;const N=B!==U.savedContent;return{...U,content:B,isDirty:N}}))},[i]),O=b.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(B=>B.map(z=>z.path===D.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[D,o,f,s]),$=b.useRef(()=>{});b.useEffect(()=>{$.current=()=>{O().catch(()=>{})}},[O]),b.useEffect(()=>{const B=z=>{o||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),$.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const K=b.useCallback((B,z)=>{d.current=B,w(U=>U+1),B.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{$.current()})},[]);return b.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const B=d.current,z=B?.getModel();if(!B||!z)return;const U=Math.min(a.line,z.getLineCount()),N=Math.min(a.column??1,z.getLineMaxColumn(U)),W={lineNumber:U,column:N};B.setPosition(W),B.revealPositionInCenter(W),B.focus(),h(null)},[i,D?.loaded,_,a]),t.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",r),style:y?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:S,transition:y?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:L,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(wu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Kv,{workingDir:s,onFileSelect:A,selectedFilePath:D?.path||null,onCollapse:L},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:te("w-1 shrink-0 cursor-col-resize transition-colors",y?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):v.map(B=>t.jsx(e0,{active:B.path===i,name:B.name,isDirty:B.isDirty,onClick:()=>l(B.path),onClose:z=>{z.stopPropagation(),P(B.path)}},B.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin"}),m("Saving")]}),D?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?D?D.isImage?t.jsx(Qv,{workingDir:s,filePath:D.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):u?t.jsxs(t.Fragment,{children:[t.jsx(Sg,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>M(B??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(ze,{size:14,className:"animate-spin"}),m("Loading file...")]})}),H&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),q instanceof Error?`: ${q.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function yi(e,s={}){const r=Es(p=>p.visibleContext),o=jl(e,r);return jt({queryKey:ce.git.changes(e||""),queryFn:()=>Ee.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function mc(e,s,r){const o=Es(m=>m.visibleContext),p=jl(e,o);return jt({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>Ee.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function Zn(e,s){return jt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>Ee.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Jn(e,s,r){return jt({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ee.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const s0=new Set(["STARTING","RUNNING","STOPPING"]);function pc(e){return s0.has(e.runtimeState)||e.runtimeInstanceId!==null}function gc(e){return e instanceof oi&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function r0({services:e,isLoading:s,isError:r}){const{t:o}=ae();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(ze,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(js,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}function vc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:v,isCheckingServices:n,serviceCheckFailed:i,error:l,onConfirm:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),x(p??""))},[e]),b.useEffect(()=>{_||!e||x(p??"")},[p,_,e]);const a=()=>{m||s()};return t.jsx(fs,{isOpen:e,onClose:a,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:a,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:c("取消")}),t.jsx("button",{onClick:()=>u(g.trim()||void 0,v.length>0),disabled:m||n,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m||n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"}),n?c("正在检查后台服务..."):v.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Xr,{size:14}),v.length>0?c("停止服务并提交"):c("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(sl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:h=>{w(!0),x(h.target.value)},placeholder:c("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(r0,{services:v,isLoading:n,isError:i}),l&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:l})]})})}function Ls(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function xc(e){if(!(e instanceof oi)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==fr.REBASE&&s.conflictOp!==fr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Ls(s,"sourceBranch"),targetBranch:Ls(s,"targetBranch"),sourceWorktreePath:Ls(s,"sourceWorktreePath"),targetWorktreePath:Ls(s,"targetWorktreePath"),sourceWorkspaceId:Ls(s,"sourceWorkspaceId"),targetWorkspaceId:Ls(s,"targetWorkspaceId")}}function la(e,s,r,o){const p=xc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function bc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:n}){const{t:i}=ae(),{data:l,isLoading:u}=Hn(e),c=Al(),g=Rl(),x=$n(),[_,w]=b.useState(!1),[a,h]=b.useState(null),d=Xn(e,_),f=(d.data??[]).filter(pc);if(b.useEffect(()=>{_&&m?.()},[_,m]),u||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const S=l.conflictedFiles.length>0,C=l.operation!=="idle",k=l.hasUncommittedChanges||l.untrackedCount>0,E=l.uncommittedCount+l.untrackedCount,y=!S&&!C&&!k,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!k&&!S,R=()=>{h(null),c.mutate(e,{onError:F=>{la(F,i("更新失败,请稍后重试"),I=>v(I),h)}})},L=()=>{h(null),w(!0)},T=(F,I)=>{h(null),g.mutate({id:e,commitMessage:F,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(gc(H)){h(i("后台服务仍在运行,请确认停止服务后再提交。"));return}la(H,i("提交失败,请稍后重试"),q=>{w(!1),v(q)},h)}})},D=()=>{g.isPending||(w(!1),h(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(xd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),k&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(mu,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(js,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),C&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(ze,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(bd,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!S&&!C&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:R,disabled:!y||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Ns,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!k?t.jsxs("button",{onClick:L,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Xr,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Xr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(vc,{isOpen:_,onClose:D,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:a,onConfirm:T})]})}const $i=50,Ui=400,ca={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},da={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function _c(e){const s=e.split("/");return s[s.length-1]||e}function i0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function n0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Ur(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const fn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:te("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),o0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:te("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},yc=({diff:e})=>{const{t:s}=ae(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
71
+ `,oa={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Mv(Dv);var Pv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,u=e.contentProps,c=u===void 0?{}:u,g=b.useContext(_i),x=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),a=b.useRef(null);return b.useEffect(function(){var h=w.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){_?.()}},[]),le.createElement("div",hs({},l,{ref:w,className:"".concat(dn.wrapperClass," ").concat(oa.wrapper," ").concat(o),style:v}),le.createElement("div",hs({},c,{ref:a,className:"".concat(dn.contentClass," ").concat(oa.content," ").concat(m),style:n}),s))},hc=function(){var e=b.useContext(_i);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Lv=function(){var e=hc();return ri(e)};function Iv(e){var s=hc(),r=b.useState(e(un(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,v=s.onChange(function(n){m&&p(e(un(n.instance)))});return function(){v(),m=!1}},[e,s]),o}function Ov(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Bv(e,s){return jt({queryKey:ce.files.tree(e||"",s),queryFn:()=>Ee.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Fv(e,s){return jt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>Ee.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function zv(e){const s=bt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Wv(){const e=bt();return zt({mutationFn:s=>Ee.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||Ov(r.path)})}})}function Hv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function $v(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const Uv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function qv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&Uv.has(s)?Ba:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Yr:s==="json"?uu:s==="md"||s==="mdx"||s==="txt"?Oa:$d}const aa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:te("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),fc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:n}=ae(),{data:i,isLoading:l,isError:u}=Bv(e,s),c=b.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=Hv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(aa,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Pt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(di,{size:14,className:"text-amber-500"}):t.jsx(An,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(fc,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const x=$v(s,g.name),_=qv(g),w=v===x,a=_===Ba;return t.jsx(aa,{depth:r,active:w,onClick:()=>m(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},Kv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ae(),[v,n]=b.useState(()=>new Set),i=zv(e),l=b.useCallback(u=>{n(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:te("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Ns,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(yu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(fc,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},Vv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Xv(e){const s=e.split(".").pop()?.toLowerCase();return s?Vv.has(s):!1}function Yv(e,s){const r=br(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Gv=({filePath:e})=>{const{t:s}=ae(),{zoomIn:r,zoomOut:o,centerView:p}=Lv(),m=Iv(n=>n.state.scale),v=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Iu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(Pu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(bu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Qv=({workingDir:e,filePath:s})=>{const{t:r}=ae(),[o,p]=b.useState(!1),m=Yv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Tv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Gv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Pv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function Zv(e){const s=e.split("/");return s[s.length-1]||e}function Jv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const e0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ae();return t.jsxs("button",{type:"button",onClick:o,className:te("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:te("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(qt,{size:12})})]})},t0=le.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ae(),[v,n]=b.useState([]),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),[_,w]=b.useState(0),[a,h]=b.useState(null),d=b.useRef(null),f=Wv();b.useEffect(()=>{let B=!1;return vd(async()=>{const{preloadMonaco:z}=await import("./monaco-C5uCiSc1.js").then(U=>U.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{B||c(!0)}).catch(()=>{B||x(!0)}),()=>{B=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),L=b.useCallback(()=>{E(B=>(B?C(R.current):R.current=S,!B))},[S]),T=b.useCallback(B=>{B.preventDefault(),j(!0);const z=B.clientX,U=S,N=X=>{const V=X.clientX-z,ie=Math.min(480,Math.max(160,U+V));C(ie)},W=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",W)},[S]);b.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=b.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:H,error:q}=Fv(s,D?.isImage?null:i);b.useEffect(()=>{!i||!F||n(B=>B.map(z=>z.path!==i||z.isDirty||z.loaded?z:{...z,language:F.language||z.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[i,F]);const A=b.useCallback((B,z,U)=>{n(N=>{if(N.find(V=>V.path===B))return N;const X=Xv(B);return[...N,{path:B,name:Zv(B),language:Jv(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(B),h(z?{path:B,line:z,column:U}:null)},[]);le.useImperativeHandle(p,()=>({openFile:A}),[A]);const P=b.useCallback(B=>{n(z=>{const U=z.filter(N=>N.path!==B);return l(N=>N!==B?N:U.length?U[U.length-1].path:null),U})},[]),M=b.useCallback(B=>{n(z=>z.map(U=>{if(U.path!==i)return U;const N=B!==U.savedContent;return{...U,content:B,isDirty:N}}))},[i]),O=b.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(B=>B.map(z=>z.path===D.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[D,o,f,s]),$=b.useRef(()=>{});b.useEffect(()=>{$.current=()=>{O().catch(()=>{})}},[O]),b.useEffect(()=>{const B=z=>{o||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),$.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const K=b.useCallback((B,z)=>{d.current=B,w(U=>U+1),B.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{$.current()})},[]);return b.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const B=d.current,z=B?.getModel();if(!B||!z)return;const U=Math.min(a.line,z.getLineCount()),N=Math.min(a.column??1,z.getLineMaxColumn(U)),W={lineNumber:U,column:N};B.setPosition(W),B.revealPositionInCenter(W),B.focus(),h(null)},[i,D?.loaded,_,a]),t.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",r),style:y?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:S,transition:y?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:L,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(wu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Kv,{workingDir:s,onFileSelect:A,selectedFilePath:D?.path||null,onCollapse:L},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:te("w-1 shrink-0 cursor-col-resize transition-colors",y?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):v.map(B=>t.jsx(e0,{active:B.path===i,name:B.name,isDirty:B.isDirty,onClick:()=>l(B.path),onClose:z=>{z.stopPropagation(),P(B.path)}},B.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(ze,{size:14,className:"animate-spin"}),m("Saving")]}),D?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?D?D.isImage?t.jsx(Qv,{workingDir:s,filePath:D.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):u?t.jsxs(t.Fragment,{children:[t.jsx(Sg,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>M(B??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(ze,{size:14,className:"animate-spin"}),m("Loading file...")]})}),H&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),q instanceof Error?`: ${q.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function yi(e,s={}){const r=Es(p=>p.visibleContext),o=jl(e,r);return jt({queryKey:ce.git.changes(e||""),queryFn:()=>Ee.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function mc(e,s,r){const o=Es(m=>m.visibleContext),p=jl(e,o);return jt({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>Ee.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function Zn(e,s){return jt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>Ee.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Jn(e,s,r){return jt({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ee.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const s0=new Set(["STARTING","RUNNING","STOPPING"]);function pc(e){return s0.has(e.runtimeState)||e.runtimeInstanceId!==null}function gc(e){return e instanceof oi&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function r0({services:e,isLoading:s,isError:r}){const{t:o}=ae();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(ze,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(js,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}function vc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:v,isCheckingServices:n,serviceCheckFailed:i,error:l,onConfirm:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),x(p??""))},[e]),b.useEffect(()=>{_||!e||x(p??"")},[p,_,e]);const a=()=>{m||s()};return t.jsx(fs,{isOpen:e,onClose:a,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:a,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:c("取消")}),t.jsx("button",{onClick:()=>u(g.trim()||void 0,v.length>0),disabled:m||n,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m||n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"}),n?c("正在检查后台服务..."):v.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Xr,{size:14}),v.length>0?c("停止服务并提交"):c("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(sl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:h=>{w(!0),x(h.target.value)},placeholder:c("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(r0,{services:v,isLoading:n,isError:i}),l&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:l})]})})}function Ls(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function xc(e){if(!(e instanceof oi)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==fr.REBASE&&s.conflictOp!==fr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Ls(s,"sourceBranch"),targetBranch:Ls(s,"targetBranch"),sourceWorktreePath:Ls(s,"sourceWorktreePath"),targetWorktreePath:Ls(s,"targetWorktreePath"),sourceWorkspaceId:Ls(s,"sourceWorkspaceId"),targetWorkspaceId:Ls(s,"targetWorkspaceId")}}function la(e,s,r,o){const p=xc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function bc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:n}){const{t:i}=ae(),{data:l,isLoading:u}=Hn(e),c=Al(),g=Rl(),x=$n(),[_,w]=b.useState(!1),[a,h]=b.useState(null),d=Xn(e,_),f=(d.data??[]).filter(pc);if(b.useEffect(()=>{_&&m?.()},[_,m]),u||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const S=l.conflictedFiles.length>0,C=l.operation!=="idle",k=l.hasUncommittedChanges||l.untrackedCount>0,E=l.uncommittedCount+l.untrackedCount,y=!S&&!C&&!k,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!k&&!S,R=()=>{h(null),c.mutate(e,{onError:F=>{la(F,i("更新失败,请稍后重试"),I=>v(I),h)}})},L=()=>{h(null),w(!0)},T=(F,I)=>{h(null),g.mutate({id:e,commitMessage:F,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(gc(H)){h(i("后台服务仍在运行,请确认停止服务后再提交。"));return}la(H,i("提交失败,请稍后重试"),q=>{w(!1),v(q)},h)}})},D=()=>{g.isPending||(w(!1),h(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(xd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),k&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(mu,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(js,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),C&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(ze,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(bd,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!S&&!C&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:R,disabled:!y||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Ns,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!k?t.jsxs("button",{onClick:L,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Xr,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Xr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(vc,{isOpen:_,onClose:D,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:a,onConfirm:T})]})}const $i=50,Ui=400,ca={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},da={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function _c(e){const s=e.split("/");return s[s.length-1]||e}function i0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function n0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Ur(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const fn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:te("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),o0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:te("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},yc=({diff:e})=>{const{t:s}=ae(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
72
72
  `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>Ui,v=m?p.slice(0,Ui):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(o0,{line:n,lineNum:i+1},i)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Ui})})]})},a0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=mc(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(yc,{diff:m?.diff||""})},l0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ae(),{data:m,isLoading:v,isError:n}=Jn(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(ze,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(yc,{diff:m?.diff||""})},qi=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,v]=b.useState(!1),[n,i]=b.useState(!1),l=b.useRef(null),u=Ur(s,e.path);b.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),b.useEffect(()=>{const x=l.current;if(!x||n)return;const _=new IntersectionObserver(w=>{w.some(a=>a.isIntersecting)&&(i(!0),_.disconnect())},{rootMargin:"300px 0px"});return _.observe(x),()=>_.disconnect()},[n]);const c=ca[e.status]||ca.M,g=i0(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:te("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Pt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:_c(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(fn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(a0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(l0,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function c0(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const v=o[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return Sc(s)}function Sc(e){const s=new Map;for(const r of e.dirs.values()){let o=Sc(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const d0=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=b.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(di,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(An,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(wc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},wc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(d0,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:te("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:te("w-1.5 h-1.5 rounded-full shrink-0",da[p.status]||da.M)}),t.jsx("span",{className:te("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:_c(p.path)})]},p.cardKey)})]}),u0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ae(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=Tn({queryKey:ce.git.log(e),queryFn:({pageParam:u=0})=>Ee.get("/git/log",{params:{workingDir:e,limit:String($i),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<$i?void 0:c.length*$i}),l=p?.pages.flatMap(u=>u.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(ze,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:te("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:u.message,children:[t.jsx("span",{className:te("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:te("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",n0(u.timestamp)]})]})]},u.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},h0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=ae(),[u,c]=b.useState({kind:"overview"}),[g,x]=b.useState(""),[_,w]=b.useState(null),[a,h]=b.useState(null),{data:d,isLoading:f,isError:S}=yi(e),C=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:E}=Zn(e,C),y=b.useRef(new Map),j=b.useRef(null),R=b.useRef(null),L=b.useCallback((B,z)=>{z?y.current.set(B,z):y.current.delete(B)},[]),{uncommitted:T,committed:D,commitFiles:F}=b.useMemo(()=>{const B=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},W=(k?.files||[]).filter(B).map(X=>({...X,cardKey:Ur(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const z=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:Ur({kind:"working",diffType:"uncommitted"},N.path)})),U=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:Ur({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:z,committed:U,commitFiles:[]}},[u,d,k,g]),I=u.kind==="commit"?F:[...T,...D],H=b.useMemo(()=>c0(I),[I]),q=b.useMemo(()=>{let B=0,z=0;for(const U of I)B+=U.additions??0,z+=U.deletions??0;return{additions:B,deletions:z,files:I.length}},[I]),A=b.useCallback(()=>{const B=j.current;if(!B)return;const z=B.getBoundingClientRect().top;let U=null,N=Number.NEGATIVE_INFINITY;for(const[W,X]of y.current){const V=X.getBoundingClientRect().top-z;V<=48&&V>N&&(N=V,U=W)}if(!U){let W=null,X=Number.POSITIVE_INFINITY;for(const[V,ie]of y.current){const ee=ie.getBoundingClientRect().top-z;ee<X&&(X=ee,W=V)}U=W}w(U)},[]);b.useEffect(()=>{const B=j.current;if(!B)return;let z=0;const U=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(A)};return B.addEventListener("scroll",U,{passive:!0}),()=>{B.removeEventListener("scroll",U),cancelAnimationFrame(z)}},[A]);const P=b.useCallback(B=>{const z=y.current.get(B.cardKey);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),h(B.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),M=b.useCallback(B=>{c(z=>z.kind==="commit"&&z.commit.hash===B.hash?{kind:"overview"}:{kind:"commit",commit:B}),x(""),w(null),j.current?.scrollTo({top:0})},[]),O=b.useCallback(()=>{c({kind:"overview"}),x(""),w(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const $=m&&s&&r&&o,K=u.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&n&&i&&t.jsx(bc,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Vs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:q.files})}),t.jsx(fn,{additions:q.additions,deletions:q.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx($s,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx($s,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(fn,{className:"ml-auto",additions:q.additions,deletions:q.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:K?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(B=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},B))}):S&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Yr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:F.map(B=>t.jsx(qi,{entry:B,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(B=>t.jsx(qi,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))})]}),D.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map(B=>t.jsx(qi,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===B.cardKey,registerNode:L},B.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(Sn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:B=>x(B.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(wc,{node:H,depth:0,activeKey:_,onSelect:P})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Us,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(u0,{workingDir:e,selectedHash:C,onSelectCommit:M})})]})]})]})]})},Ki=50,ua={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function f0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function m0(e){const s=e.split("/");return s[s.length-1]||e}function p0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const g0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:te("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},v0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ae(),{data:p,isLoading:m,isError:v}=Jn(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const i=n.split(`
73
73
  `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,u)=>t.jsx(g0,{line:l,lineNum:u+1},u))})},x0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ae(),{data:m,isLoading:v}=Zn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(ze,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const n=m?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const l=ua[i.status]||ua.M,u=p0(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:te("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:m0(i.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},i.path)})})},b0=({workingDir:e})=>{const{t:s}=ae(),r=Es(E=>E.visibleContext),o=wf(e,r),{data:p,isLoading:m,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=Tn({queryKey:ce.git.log(e||""),queryFn:({pageParam:E=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Ki),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,y)=>E.commits.length<Ki?void 0:y.length*Ki,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),u=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[x,_]=b.useState(null),[w,a]=b.useState(280),[h,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const y=E.clientX,j=w,R=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-y)));a(D)},L=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",L)},[w]),S=E=>{c===E?(g(null),_(null)):(g(E),_(null))},C=b.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(u.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Us,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=u.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:w},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Us,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:u.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[u.map(E=>{const y=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>S(E.hash),className:te("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",y?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:te("w-2 h-2 rounded-full shrink-0 transition-colors",y?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Pt,{size:12,className:te("shrink-0 text-muted-foreground/70 transition-transform",y&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:f0(E.timestamp)})]})]})]}),y&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(x0,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:_})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:l,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:l?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:te("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Yr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(v0,{workingDir:e,hash:c,filePath:x})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Yr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},ha=br();function _0(e){if(!ha)return e;try{const s=new URL(ha);return new URL(e,s.origin).toString()}catch{return e}}function Cc(e){return{...e,viewUrl:e.viewUrl?_0(e.viewUrl):null}}function y0(e,s=!0){return jt({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await Ee.get(`/previews/${e}/status`);return Cc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function S0(e){const s=bt();return zt({mutationFn:async r=>{const o=await Ee.put(`/previews/${e}/config`,{target:r});return Cc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function w0(){return window.location.protocol==="https:"?"remote":"local"}function C0(e,s,r=!0){const[o,p]=b.useState(null),[m,v]=b.useState(!1),[n,i]=b.useState(null),[l,u]=b.useState(0);return b.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),v(!1),i(null);return}let c=!1,g=null,x=null;p(null);const _=a=>{Ee.delete(`/previews/${e}/sessions/${a}`).catch(()=>{})};return(async()=>{v(!0),i(null);try{const a={mode:w0(),localHostname:window.location.hostname},h=await Ee.post(`/previews/${e}/sessions`,a);if(c){_(h.id);return}g=h.id,p(h),x=window.setInterval(async()=>{if(g)try{const d=await Ee.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),i(null))}catch(d){!c&&d instanceof oi&&d.status===404?u(f=>f+1):c||i(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(a){c||(p(null),i(a instanceof Error?a:new Error("Failed to open preview session")))}finally{c||v(!1)}})(),()=>{c=!0,x!==null&&window.clearInterval(x),g&&_(g)}},[r,l,s?.ready,s?.target,e]),{session:o,isOpening:m,error:n,retry:()=>u(c=>c+1)}}const k0="agent-tower-preview",E0="agent-tower-preview-host";function j0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function N0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function R0(e){return t.jsx(A0,{...e},e.workspaceId??"no-workspace")}function A0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=ae(),[m,v]=b.useState(null),i=!(r?.source.kind==="visualization")&&!m,{data:l,isLoading:u,refetch:c,isFetching:g}=y0(e,i),x=S0(e),{session:_,isOpening:w,error:a,retry:h}=C0(e,l,i),d=b.useRef(null),f=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(null),E=b.useRef(null),[y,j]=b.useState(0),[R,L]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),T=N0(_?.viewUrl),D=l&&R.target!==l.target?{target:l.target,address:l.target??"",iframeSrc:null,isFrameLoading:!1}:l&&!l.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,F=b.useCallback(K=>{L(B=>({...l&&B.target!==l.target?{target:l.target,address:l.target??"",iframeSrc:null,isFrameLoading:!1}:B,...K}))},[l]);b.useEffect(()=>{if(!_||_.target!==l?.target)return;const K=k.current!==T;k.current=T,L(B=>{const z=r?.source.kind==="web"&&E.current!==r.id?Ir(r.source.url,_.target,_.viewUrl):null;if(!K&&B.iframeSrc&&B.target===_.target&&z?.kind!=="proxy")return B;let U=B.iframeSrc;if(z?.kind==="proxy")U=z.url;else if(!U||B.target!==_.target||K){const W=S.current;if(W)U=Dd(_.viewUrl,W);else{const X=Ir(B.address||_.target,_.target,_.viewUrl);U=X?.kind==="proxy"?X.url:_.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&U&&N.location.replace(U),C.current=null,{target:_.target,address:z?.kind==="proxy"?r?.source.kind==="web"?r.source.url:B.address:B.address||_.target,iframeSrc:U,isFrameLoading:!!U}})},[r,_,T,l?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(K,B=!1)=>{const z=Ir(K,l?.target??null,_?.viewUrl??null);if(!z||!e)return;if(v(null),z.kind==="proxy"){if(B){window.open(z.url,"_blank","noopener,noreferrer");return}L({target:l?.target??null,address:K,iframeSrc:z.url,isFrameLoading:!0});return}if(s)return;const U=B?window.open("about:blank","_blank"):null;U&&(U.opener=null);try{S.current=z.path,C.current=U;const N=await x.mutateAsync(z.target);L({target:N.target,address:K.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(W=>W+1),st.success(p("Preview target saved")),N.ready||(C.current?.close(),C.current=null)}catch(N){C.current?.close(),C.current=null,S.current=null;const W=N instanceof Error?N.message:p("Failed to save preview target");st.error(W)}},[_?.viewUrl,s,l?.target,p,x,e]);b.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&u)return;const K=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(v({source:r.source,iframeSrc:Pd(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(B=>B+1)):(v(null),I(r.source.url))},0);return()=>window.clearTimeout(K)},[u,I,r,o]),b.useEffect(()=>{if(m)return;const K=B=>{if(B.source!==d.current?.contentWindow)return;const z=B.data;if(!(!z||z.source!==k0)){if(z.type==="location"&&typeof z.href=="string"){const U=Ld(l?.target??null,_?.viewUrl??null,z.href,window.location.href);U&&document.activeElement!==f.current&&F({target:l?.target??D.target,address:U,isFrameLoading:!1});return}z.type==="navigate-loopback"&&typeof z.href=="string"&&I(z.href,z.newTab===!0)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[D.target,I,F,_?.viewUrl,l?.target,m]);const H=K=>{d.current?.contentWindow?.postMessage({source:E0,action:K},"*")},q=K=>{K.preventDefault(),I(D.address)},A=async()=>{if(m){v(B=>B&&{...B,isFrameLoading:!0}),j(B=>B+1);return}const K=await c();if(!K.data?.ready){F({target:K.data?.target??D.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!D.iframeSrc){h();return}F({isFrameLoading:!0}),H("reload")},P=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const K=Ir(D.address||_.target,_.target,_.viewUrl),B=K?.kind==="proxy"?K.url:_.viewUrl;window.open(B,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:p("No active workspace.")});const M=m?.iframeSrc??D.iframeSrc,O=!!m,$=!O&&(u||g||x.isPending||w);return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{O?v(null):H("back")},disabled:!O&&!D.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx($s,{})}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:O||!D.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(sl,{})}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&D.isFrameLoading?()=>{H("stop"),F({isFrameLoading:!1})}:A,disabled:!O&&!D.isFrameLoading&&g,title:!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&D.isFrameLoading?t.jsx(qt,{}):g?t.jsx(ze,{className:"animate-spin"}):t.jsx(Ns,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:q,children:[t.jsx(lu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:f,value:m?.source.file??D.address,onChange:K=>F({address:K.target.value}),onKeyDown:K=>{K.key==="Enter"&&K.nativeEvent.isComposing&&K.preventDefault()},disabled:O||s||x.isPending,placeholder:j0(),"aria-label":p("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"ghost",onClick:P,disabled:!M,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(gn,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:O?p("Viewing agent visualization"):$?p("Checking preview target..."):a?a.message:l?.ready?`${p("Proxying")} ${l.target}`:l?.configured?`${p("Preview target is not reachable")}${l.error?`: ${l.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(O?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:M?t.jsx("iframe",{ref:d,src:M,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:O?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{O?v(K=>K&&{...K,isFrameLoading:!1}):F({isFrameLoading:!1})}},y):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:l?.configured?l.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function T0(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function fa(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function M0(e){return e.length<=34?e:`...${e.slice(-31)}`}function kc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:n}=ae(),[i,l]=b.useState(!1),u=b.useRef(null),c=b.useMemo(()=>Kn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return b.useEffect(()=>{if(!i)return;const x=_=>{u.current&&!u.current.contains(_.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:u,className:te("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),disabled:p,className:te("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:n("Workspace"),children:[t.jsx(Hs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",fa(g.roleLabel)),children:n(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:M0(qs(g.workspace))}),t.jsx(wt,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(x=>{const _=x.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!1)},className:te("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",_&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:_?t.jsx(Kt,{size:13}):t.jsx(Ka,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:n(x.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",fa(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",T0(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:qs(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const D0=[{key:"review",label:"Changes",icon:t.jsx(Vs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ci,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(lr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(qa,{size:14})}],P0=[{key:"history",label:"History",icon:t.jsx(Us,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ci,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(lr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(qa,{size:14})}],L0=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:te("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),I0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:te("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),Ec=le.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:u,teamStatus:c,gitProps:g,workspaces:x,selectedWorkspaceId:_,onSelectWorkspace:w,variant:a="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ae(),y=Es(G=>G.setVisibleContext),j=a==="rail",[R,L]=b.useState(!1),T=j?h??R:!0,D=b.useCallback(G=>{h===void 0&&L(G),d?.(G)},[h,d]),F=b.useMemo(()=>{const G=v?P0:D0,pe=n?G:G.filter(We=>We.key!=="review"&&We.key!=="history"),oe=i?pe.filter(We=>We.key!=="terminal"):pe;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(Cs,{size:14})},...oe]:oe},[n,v,i,u]),[I,H]=b.useState(()=>C?"preview":n?v?"history":"review":"editor"),q=b.useRef(null),A=b.useRef(0),[P,M]=b.useState(),O=b.useCallback(G=>{H(G),j&&D(!0)},[j,D]);b.useImperativeHandle(S,()=>({setTab:G=>O(G),openFile:(G,pe,oe)=>{O("editor"),requestAnimationFrame(()=>q.current?.openFile(G,pe,oe))},openPreview:(G,pe)=>{A.current+=1,M({id:A.current,source:G,workspaceId:pe}),O("preview")}}),[O]);const $=C??P,K=$?.workspaceId&&$.workspaceId!==o?void 0:$,B=b.useCallback(G=>{M(pe=>pe?.id===G?void 0:pe),k?.(G)},[k]),{data:z}=Kd(m??""),U=b.useMemo(()=>{if(!z?.quickCommands)return[];try{return JSON.parse(z.quickCommands)}catch{return[]}},[z?.quickCommands]),[N,W]=b.useState([]),X=b.useRef(void 0);b.useEffect(()=>{p&&p!==X.current&&(X.current=p,W(G=>G.includes(p)?G:[...G,p]))},[p]),b.useEffect(()=>{F.some(G=>G.key===I)||H(F[0]?.key??"editor")},[I,F]),b.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!G){y(null);return}return y({workspaceId:o,workingDir:p,tab:G}),()=>{y(null)}},[I,T,j,y,p,o]);const V=!!w&&Kn(x,u).length>1,ie=F.find(G=>G.key===I)??F[0],ee=ie?E(ie.label):"",me=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[V&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(kc,{workspaces:x,teamRun:u,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&u&&c,I==="editor"&&t.jsx(t0,{ref:q,workingDir:p,readOnly:i}),N.map(G=>{const pe=I==="terminal"&&p===G;return t.jsx("div",{"aria-hidden":!pe,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:pe?"block":"none"},children:t.jsx(fp,{cwd:G,workspaceId:pe?o:void 0,isVisible:pe,quickCommands:U})},G)}),I==="preview"&&t.jsx(R0,{workspaceId:o,readOnly:i,navigationRequest:K,onNavigationRequestHandled:B}),I==="review"&&t.jsx(h0,{workingDir:p,workspaceId:o,branchName:g?.branchName,targetBranch:g?.targetBranch,commitMessage:g?.commitMessage,canRunGitOperations:g?.canRunGitOperations,onRefreshCommitMessage:g?.onRefreshCommitMessage,onConflict:g?.onConflict,onResolveConflicts:g?.onResolveConflicts}),I==="history"&&t.jsx(b0,{workingDir:p})]})]});return j?t.jsxs("div",{className:te("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:F.map(G=>t.jsx(I0,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[me,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:ie?.icon}),t.jsx("span",{className:"truncate",children:ee})]}),t.jsx("button",{type:"button",onClick:()=>D(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(ku,{size:15})})]}),he]})]}):t.jsxs("div",{className:te("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&me,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:F.map(G=>t.jsx(L0,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),he]})}),ma=1500,O0=3e3;function B0(e){const[s,r]=b.useState(null),o=b.useRef(0),p=b.useRef(null),m=b.useRef(null);return b.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},n=os.connect(),i=u=>{r(u),m.current=setTimeout(()=>r(null),O0)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const g=o.current>0?Date.now()-o.current:0,x=ma-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>i(c),ma)):x>0?(p.current=c,v(),m.current=setTimeout(()=>i(c),x)):i(c)};return n.on(lt.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(lt.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function jc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:u}){const{t:c}=ae(),[g,x]=b.useState(""),[_,w]=b.useState(""),[a,h]=b.useState(_t.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),y=bt(),j=Nl(o),R=kn(),L=Vd(),{data:T,isLoading:D}=Ks(),F=d?.isGitRepo??i,I=d?.worktreeReady??l,H=d?.reason??u,q=F!==!1&&I!==!1;b.useEffect(()=>{if(!e||!T)return;const N=T.find(W=>W.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),b.useEffect(()=>{if(e){const N=[m];v&&N.push(v),w(n?.trim()||N.join(`
74
74
 
@@ -78,11 +78,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
78
78
  `)}function q0(e){const s=e.conflictOp===fr.REBASE?"Rebase":"Merge",r=Ac(e.conflictedFiles),o=[...Tc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===fr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":$0(e)].join(`
79
79
  `)}function K0(e){if(e.teamRunId)return{type:"team_room",message:q0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:U0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Mc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:_,sessions:w,currentSessionId:a,teamRunId:h}){const{t:d}=ae(),[f,S]=b.useState(""),C=jn(),k=vn(h??""),E=Wn(),y=!!h,j=a||f,R=y?k.isPending:C.isPending,L=()=>{const H=K0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:_,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(H.type==="team_room"){k.mutate({content:H.message,kind:"chat"},{onSuccess:()=>{st.success(d("已发送到 Team Room")),s(!1)}});return}H.type==="session"&&C.mutate({id:H.sessionId,message:H.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",F=!y&&!a&&w.length>0,I=y||!!j;return t.jsx(fs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Me,{onClick:L,disabled:!I||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(H=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:H},H))})]}),y&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),F&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:H=>S(H.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),w.map(H=>t.jsxs("option",{value:H.id,children:[H.agentType," — ",H.status]},H.id))]})]}),!y&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function V0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function pa(e,s,r,o){const p=xc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Dc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ae(),x=Al(),_=Rl(),w=$n(),[a,h]=b.useState(!1),[d,f]=b.useState(null),S=Xn(e,a),C=(S.data??[]).filter(pc),k=b.useMemo(()=>V0(p),[p]),E=k.additions+k.deletions,y=k.files>0&&E>0,j=(m?.conflictedFiles.length??0)>0,R=!!(m&&m.operation!=="idle"),L=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),T=(m?.uncommittedCount??0)+(m?.untrackedCount??0),D=(m?.behind??0)>0,F=(m?.ahead??0)>0,I=v||!m&&n,H=!!(n&&e&&m&&D&&!j&&!R&&!L),q=!!(n&&e&&m&&F&&!D&&!j&&!R&&!L);if(b.useEffect(()=>{a&&l?.()},[a,l]),!y)return null;const A=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):T>0?g("{count} 未提交",{count:T}):D?g("落后 {count}",{count:m?.behind??0}):g(F?"可合并":"已是最新"),P=g("{files} 个文件 · {lines} 行",{files:k.files,lines:E}),M=()=>{H&&(f(null),x.mutate(e,{onError:B=>{pa(B,g("更新失败,请稍后重试"),z=>u(z),f)}}))},O=()=>{q&&(f(null),h(!0))},$=(B,z)=>{f(null),_.mutate({id:e,commitMessage:B,stopActiveServices:z},{onSuccess:()=>h(!1),onError:U=>{if(gc(U)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}pa(U,g("提交失败,请稍后重试"),N=>{h(!1),u(N)},f)}})},K=()=>{_.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:te("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Vs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:P}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[k.additions>0&&t.jsxs("span",{className:"text-success",children:["+",k.additions]}),k.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",k.deletions]})]}),j&&t.jsx(js,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:A})]}),t.jsx(Pt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[R&&t.jsx("button",{type:"button",onClick:()=>w.mutate(e),disabled:w.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:w.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:M,disabled:!H||x.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(D?"同步更新":"已是最新"),children:[x.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Ns,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!q||_.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:q?g("合并到 {target}",{target:r}):g("提交变更"),children:[_.isPending?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(Xr,{size:12}),t.jsx("span",{children:_.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(vc,{isOpen:a,onClose:K,branchName:s,targetBranch:r,commitMessage:o,isPending:_.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:$})]})}function X0({agentType:e,workingDir:s}){return jt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await Ee.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===kt.CODEX,staleTime:3e4})}function Y0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Pc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[n,i]=b.useState(0),{data:l=[]}=X0({agentType:e,workingDir:s}),c=b.useMemo(()=>e===kt.CODEX?uo(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:zd(l,c),[c,l]),x=b.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);b.useEffect(()=>{i(0)},[e,c]),b.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const _=b.useCallback(a=>{const h=uo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),w=b.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+g.length)%g.length),!0):Y0(a)?(a.preventDefault(),_(g[n]??g[0]),!0):!1,[_,g,c,n]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:_,handleKeyDown:w}}const Vi=200,G0=180;function Lc({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:v=!1}){const{t:n}=ae(),[i,l]=b.useState(!1),[u,c]=b.useState(s),[g,x]=b.useState(!1),_=b.useRef(null),w=b.useRef(null),a=yd();b.useEffect(()=>{i||c(s)},[s,i]),b.useEffect(()=>{i&&_.current&&(_.current.focus(),_.current.select())},[i]),b.useEffect(()=>{if(!i)return;const j=R=>{w.current&&!w.current.contains(R.target)&&f()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[i,u]);const h=b.useCallback(()=>{r||(l(!0),c(s))},[r,s]),d=b.useCallback(()=>{l(!1),c(s)},[s]),f=b.useCallback(async()=>{const j=u.trim();if(!j){c(s),l(!1);return}if(j===s){l(!1);return}try{await a.mutateAsync({id:e,title:j}),o?.(j),l(!1)}catch(R){console.error("Failed to update task title:",R),c(s)}},[u,s,e,a,o]),S=b.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),f()):j.key==="Escape"&&(j.preventDefault(),d())},[f,d]),C=b.useCallback(j=>{const R=j.target.value;R.length<=Vi&&c(R)},[]),k=u.length,E=k>=G0,y=k>=Vi;return i?t.jsxs("div",{ref:w,className:te("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:_,type:"text",value:u,onChange:C,onKeyDown:S,disabled:a.isPending,className:te("flex-1 min-w-0 px-2 py-1 text-lg font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",v&&"text-base py-0.5",m),placeholder:n("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Me,{size:v?"sm":"default",variant:"ghost",onClick:f,disabled:a.isPending||!u.trim(),className:"h-8 w-8 p-0",children:a.isPending?t.jsx(ze,{size:16,className:"animate-spin"}):t.jsx(Kt,{size:16})}),t.jsx(Me,{size:v?"sm":"default",variant:"ghost",onClick:d,disabled:a.isPending,className:"h-8 w-8 p-0",children:t.jsx(qt,{size:16})})]})]}),E&&t.jsxs("div",{className:te("text-xs",y?"text-destructive":"text-muted-foreground"),children:[k," / ",Vi," ",n("字符")]})]}):t.jsxs("div",{ref:w,className:te("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[t.jsx("h2",{onClick:h,className:te("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!r&&"cursor-text hover:text-foreground/80 transition-colors",v&&"text-base",m),children:s}),!r&&g&&t.jsx(Me,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:n("编辑标题"),children:t.jsx(Gd,{size:14})})]})}const Q0=br(),Z0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Q0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Is=520,Xi=48,J0=4,ex=420;function tx(){const{t:e}=ae();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ga=[{status:we.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ua,{className:"w-3 h-3"})},{status:we.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx($a,{className:"w-3 h-3"})},{status:we.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Ha,{className:"w-3 h-3"})},{status:we.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Wa,{className:"w-3 h-3"})},{status:we.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(za,{className:"w-3 h-3"})}];function sx({status:e,onChangeStatus:s}){const{t:r}=ae(),[o,p]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{if(!o)return;const n=i=>{m.current&&!m.current.contains(i.target)&&p(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=ga.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ga.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function va({state:e,onRetry:s}){const{t:r}=ae(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(es,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function rx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),[n,i]=b.useState(""),[l,u]=b.useState(!1),[c,g]=b.useState(!1),[x,_]=b.useState(!1),[w,a]=b.useState(!1),[h,d]=b.useState(!1),[f,S]=b.useState(!1),[C,k]=b.useState(null),E=b.useRef(null),[y,j]=b.useState(!1),[R,L]=b.useState(null),[T,D]=b.useState(void 0),[F,I]=b.useState(!1),H=b.useRef(null),q=b.useRef(null),A=b.useRef(null),P=b.useRef(null),{scrollRef:M,contentRef:O,isAtBottom:$,scrollToBottom:K,stopScroll:B}=wn({resize:"smooth",initial:"instant"}),[z,U]=b.useState(!1),[N,W]=b.useState(Is),[X,V]=b.useState(!1),ie=b.useRef(0),ee=b.useRef(Is),me=b.useRef(null),he=b.useCallback((Q,re,Ie)=>{E.current?.openFile(Q,re,Ie)},[]),{data:G,isLoading:pe}=zn(e?.id??""),oe=B0(e?.id),{data:We}=Pa(e?.id??""),{data:ut}=La(We?.id??""),Oe=vn(We?.id??""),be=We??null,Ue=!!be,Be=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,tt=We===null&&Be,Ye=!!(e?.id&&We===null),{data:Ze,isLoading:Xe}=Ia(e?.id??"",Ye);b.useEffect(()=>{I(!1),L(null),D(void 0)},[e?.id]);const Ne=b.useMemo(()=>Il(G,be,T),[T,be,G]);b.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const Ae=b.useMemo(()=>G?.find(Q=>Q.id===Ne),[Ne,G]),ve=Ae?.status===Mt.ACTIVE?Ae.id:void 0,He=Be&&Ol(Ae,be);b.useEffect(()=>{if(!F||!G)return;G.some(re=>re.status==="ACTIVE"&&re.sessions&&re.sessions.length>0)&&I(!1)},[G,F]);const _e=b.useMemo(()=>{if(F||!G)return null;const Q=mt=>{const Ni=mt.createdAt,rr=mt.endedAt??mt.startedAt??Ni;if(!rr)return 0;const Ds=Date.parse(rr);return Number.isNaN(Ds)?0:Ds},re=(mt,Ni)=>{const rr=mt.filter(Ds=>Ni.includes(Ds.status));return rr.length===0?null:rr.sort((Ds,nd)=>Q(nd)-Q(Ds))[0]??null},Ie=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=re(Ie,[ct.RUNNING])??re(Ie,[ct.PENDING])??re(Ie,[ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(ht)return ht;const ft=G.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return re(ft,[ct.COMPLETED,ct.FAILED,ct.CANCELLED])},[G,F]),pt=_e?.id??"",Je=Ue?R??"":pt,Lt=b.useMemo(()=>{if(!R||!G)return null;for(const Q of G){const re=Q.sessions?.find(Ie=>Ie.id===R);if(re)return re}return null},[R,G]),J=b.useMemo(()=>{if(!R||!be?.invocations)return null;const Q=be.invocations.filter(re=>re.sessionId===R);return Q.length===0?null:Q.sort((re,Ie)=>{const ht=Date.parse(re.updatedAt??re.createdAt??""),ft=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(ft)?0:ft)-(Number.isNaN(ht)?0:ht)})[0]??null},[R,be?.invocations]),fe=b.useMemo(()=>!J?.memberId||!be?.members?null:be.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,be?.members]),ue=R?Lt:_e??null,ge=ue?.id,Ce=b.useMemo(()=>{if(ue?.workspaceId)return ue.workspaceId;if(!(!ue||!G))return G.find(Q=>Q.sessions?.some(re=>re.id===ue.id))?.id},[ue,G]),Y=b.useCallback((Q,re)=>{const ht=(re&&G?.some(ft=>ft.id===re)?re:void 0)??Ce??Ne??void 0;ht&&D(ht),E.current?.openPreview(Q,ht)},[Ce,Ne,G]),se=b.useCallback((Q,re)=>{Y({kind:"web",url:Q},re)},[Y]),ne=b.useCallback((Q,re,Ie)=>{Y({kind:"visualization",sessionId:Q,file:re},Ie)},[Y]),ke=b.useCallback(Q=>{se(Q,Ce)},[Ce,se]),xe=b.useCallback(Q=>{ge&&ne(ge,Q,Ce)},[ge,Ce,ne]),{isActive:je,isCancelling:Te}=Va(ge??"",ue?.status),ye=!!e?.projectArchivedAt,Le=!!e?.projectRepoDeletedAt,Se=v(Le?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:De}=Ks(),[Qe,rt]=b.useState(null);b.useEffect(()=>{rt(_e?.providerId??null)},[_e?.providerId]);const Ct=b.useMemo(()=>!_e||!G?!1:!G.some(re=>re.status==="ACTIVE"&&re.sessions?.some(Ie=>Ie.id===_e.id)),[_e,G]),it=b.useMemo(()=>{if(!(!G||F)){if(Ae)return ds(Ae);for(const Q of G)if(Q.status==="ACTIVE"&&ds(Q))return ds(Q);return ds(G[0])}},[F,Ae,G]),nt=Xa({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),gt=Pc({agentType:_e?.agentType,workingDir:it,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),Vt=Es(Q=>Q.setVisibleContext),Xt=!!(He&&ve&&it&&!ye),{data:Nt,isLoading:Yt}=Hn(ve??"",{enabled:Xt}),{data:Gt}=yi(it,{enabled:Xt});b.useEffect(()=>{if(!(z||!Xt||!ve||!it))return Vt({workspaceId:ve,workingDir:it,tab:"changes"}),()=>{Vt(null)}},[z,ve,Vt,Xt,it]);const Rs=Ae?.sessions??[],ss=qs(Ae),Gs=Ae?.commitMessage,Rt=b.useMemo(()=>Bl(Ae,G,e?.mainBranch??""),[Ae,e?.mainBranch,G]),vt=b.useMemo(()=>Nt?.conflictOp&&Nt.conflictedFiles.length>0?{conflictOp:Nt.conflictOp,conflictedFiles:Nt.conflictedFiles}:C,[Nt?.conflictOp,Nt?.conflictedFiles,C]),Qs=vt?.targetWorkspaceId??ve,jr=vt?.targetWorktreePath??Ae?.worktreePath,Nr=vt?.sourceBranch??ss,gs=vt?.targetBranch??Rt,at=bt(),Qt=b.useCallback(async()=>e?.id?at.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}):null,[at,e?.id]),vs=b.useCallback(()=>e?.id?at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,at]);b.useEffect(()=>{if(!y)return;const Q=re=>{q.current&&!q.current.contains(re.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[y]);const As=jn(),xs=Wn(),Rr=Sd(),Zs=Nl(e?.id??""),Js=kn(),Zt=Cf(),Wt=b.useMemo(()=>!G||G.some(re=>re.status==="ACTIVE")?null:G.find(re=>re.status==="HIBERNATED")??null,[G]),er=b.useRef(null);b.useEffect(()=>{Wt&&er.current!==Wt.id&&(Zt.isPending||(er.current=Wt.id,Zt.mutate(Wt.id,{onSettled:()=>{er.current=null}})))},[Wt,Zt]);const Ar=b.useCallback(async()=>{if(!e?.id)return;const Q=_e?.providerId??De?.find(re=>re.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Ie=(await Qt())?.prompt??e.title;await Rr.mutateAsync(e.id),I(!0);const ht=await Zs.mutateAsync({workspaceKind:Be?void 0:_t.MAIN_DIRECTORY}),ft=await Ee.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Ie});await Js.mutateAsync(ft.id),await at.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(re){console.error("[retry] failed:",re),I(!1)}finally{d(!1)}}},[e?.id,e?.title,Be,_e?.providerId,De,Qt,Rr,Zs,Js,at]),Ts=b.useCallback(async()=>{e?.id&&(await Qt(),u(!0))},[Qt,e?.id]),tr=b.useCallback(()=>{Ae?.id&&xs.mutate({workspaceId:Ae.id})},[xs,Ae?.id]),Tr=b.useCallback(()=>{!e?.id||!s||(s(e.id),_(!1))},[e?.id,s]),Mr=b.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{K()})},[K]),Si=b.useCallback(()=>{L(null)},[]),bs=b.useCallback(Q=>{k(Q??null),S(!0)},[]),wi=b.useCallback(Q=>Oe.mutateAsync(Q),[Oe]),rs=b.useCallback(()=>{at.invalidateQueries({queryKey:wd.all})},[at]),{isConnected:sr,isLoadingSnapshot:Dr,isOutputActive:Pr,lastExitAt:Lr,logs:_s,entries:ys,attach:Z}=Ja({sessionId:Je,sessionStatus:ue?.status,sessionStartedAt:ue?.startedAt??ue?.createdAt,sessionEndedAt:ue?.endedAt??(je?null:ue?.updatedAt),onExit:b.useCallback(()=>{at.invalidateQueries({queryKey:["workspaces"]})},[at])});b.useEffect(()=>{if(!e?.id)return;const Q=os.connect();Q.emit(Os.SUBSCRIBE,{topic:"task",id:e.id});const re=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:["tasks"]}),rs())},Ie=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),rs())},ht=ft=>{ft.taskId===e.id&&(at.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),rs())};return Q.on(lt.TASK_UPDATED,re),Q.on(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.on(lt.WORKSPACE_HIBERNATED,ht),()=>{Q.off(lt.TASK_UPDATED,re),Q.off(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.off(lt.WORKSPACE_HIBERNATED,ht),Q.emit(Os.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,at,rs]),b.useEffect(()=>{if(!Je)return;const Q=os.connect(),re=Ie=>{Ie.sessionId===Je&&(at.invalidateQueries({queryKey:["workspaces"]}),rs())};return Q.on(lt.SESSION_COMPLETED,re),()=>{Q.off(lt.SESSION_COMPLETED,re)}},[Je,at,rs]);const{todos:de}=el(ys),{files:Fe,addFiles:Pe,removeFile:St,clear:It,buildMarkdownLinks:$e,hasFiles:At,isUploading:Ot}=xn(),Ms=b.useMemo(()=>Nc(ue),[ue?.tokenUsage]),to=Ya(_s,Ms);b.useEffect(()=>{Je&&sr&&Z()},[Je,sr,Z]);const so=b.useRef(e?.id);b.useEffect(()=>{if(so.current!==e?.id&&M.current){const Q=M.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}so.current=e?.id},[e?.id,M]);const is=Ga(),Ci=b.useRef(!1),ro=b.useCallback(async()=>{if(!n.trim()&&!At||!Je||Ci.current||is.isPending||Te||Ot)return;Ci.current=!0;const Q=$e(),re=[n.trim(),Q].filter(Boolean).join(`
80
80
 
81
- `);i(""),It(),A.current&&(A.current.style.height="60px"),As.mutate({id:Je,message:re,providerId:Qe??void 0},{onSuccess:()=>{Z()},onError:()=>{i(Ie=>Ie||re)},onSettled:()=>{Ci.current=!1}})},[n,Je,As,Z,At,Ot,$e,It,Qe,is.isPending,Te]),Gc=b.useCallback(()=>{!Je||is.isPending||is.mutate(Je)},[Je,is]),Qc=b.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&Pe(Array.from(re)),Q.target.value=""},[Pe]),Zc=b.useCallback(Q=>{const re=Q.clipboardData.items,Ie=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Ie.push(ft)}Ie.length>0&&(Q.preventDefault(),Pe(Ie))},[Pe]),[io,ki]=b.useState(!1),Jc=b.useCallback(Q=>{Q.preventDefault(),ki(!0)},[]),ed=b.useCallback(Q=>{Q.preventDefault(),ki(!1)},[]),td=b.useCallback(Q=>{Q.preventDefault(),ki(!1);const re=Q.dataTransfer.files;re.length>0&&Pe(Array.from(re))},[Pe]),Jt=b.useCallback(Q=>{const re=me.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=re?Math.max(Is,re-Xi-J0-ex):Is;return Math.max(Is,Math.min(Math.round(Q),Ie))},[]),Ei=b.useCallback(Q=>{const re=Q.clientX-ie.current;W(Jt(ee.current-re))},[Jt]),ji=b.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(X)return document.addEventListener("mousemove",Ei),document.addEventListener("mouseup",ji),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Ei),document.removeEventListener("mouseup",ji),document.body.style.cursor="",document.body.style.userSelect=""}},[ji,Ei,X]);const sd=b.useCallback(Q=>{Q.preventDefault(),ie.current=Q.clientX,ee.current=N,V(!0)},[N]);b.useEffect(()=>{!z||X||W(Q=>Jt(Q))},[Jt,z,X]),b.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Jt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Jt,z]);const rd=b.useCallback(()=>{W(Q=>Jt(Q)),U(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Jt]),id=b.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Ie=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),no=Xt&&ve?t.jsx(Dc,{workspaceId:ve,branchName:ss,targetBranch:Rt,commitMessage:Gs,changes:Gt,gitStatus:Nt,isGitStatusLoading:Yt,canRunGitOperations:He,onOpenChanges:rd,onRefreshCommitMessage:vs,onConflict:bs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(Lc,{taskId:e.id,title:e.title,readOnly:ye})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(sx,{status:e.status,onChangeStatus:!ye&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:tr,disabled:!it||ye,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(ci,{size:16})}),(s||tt)&&!ye&&t.jsxs("div",{className:"relative",ref:q,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(il,{size:16})}),y&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[tt&&t.jsxs("button",{onClick:()=>{g(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ls,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Cd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{_(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Rn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),He&&ve&&Nt&&t.jsx(W0,{workspaceId:ve,gitStatus:Nt,onResolve:()=>bs()}),t.jsxs("div",{ref:me,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ue&&be?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Rc,{session:ue,providers:De,usage:to,providerIdFallback:fe?.providerId,agentTypeFallback:ue?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:Si,children:[t.jsx($s,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe})})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Vr,{todos:de})})})]}):t.jsx(Ll,{teamRun:be,messages:ut??be.messages??[],readOnly:ye,readOnlyMessage:Se,onSendMessage:wi,onViewInvocationSession:Mr,changeSummaryBar:no,centered:!0,workingDir:it,onOpenWorkspaceFile:he,onOpenPreviewUrl:se,onOpenVisualization:ne}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Xe||Ze?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Xe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ze?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(_n,{urlTransform:Z0,components:Fa,children:Ze.body})}):null}),oe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[oe.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:oe.currentIndex,total:oe.totalCommands,command:oe.currentCommand})})]}),oe.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),oe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:oe.error})})]}),!ye&&p&&(pe||pt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(va,{state:p,onRetry:p.status==="failed"?Ts:void 0})}):null,pe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):pt?Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(es,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(ye?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:ye?Se:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ye&&p?t.jsx(va,{state:p}):null,!ye&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:Ts,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(Me,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ls,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Vr,{todos:de})})}),ye?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:Se})})}):Ct?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:Ts,children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Jc,onDragLeave:ed,onDrop:td,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[no,Je?t.jsx(Qa,{sessionId:Je}):null,t.jsxs("div",{ref:H,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${io?"border-info bg-info/5":"border-border"}`,children:[t.jsx(bn,{files:Fe,onRemove:St}),t.jsx("textarea",{ref:A,value:n,onChange:id,onPaste:Zc,onKeyDown:Q=>{gt.handleKeyDown(Q)||nt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),ro())},rows:1,placeholder:v(io?"Drop files here...":pt&&!je?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Qc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>P.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(Nn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[_e&&De&&t.jsx(Za,{providers:De,currentProviderId:Qe,agentType:_e.agentType,runtimeType:_e.runtimeType,onSelect:rt}),t.jsx(En,{usage:to}),je&&!n.trim()&&!At?t.jsx("button",{onClick:Gc,disabled:is.isPending||Te,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ws,{size:14})}):t.jsx("button",{onClick:ro,disabled:!n.trim()&&!At||Ot||As.isPending||is.isPending||Te,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||At)&&!Ot&&!As.isPending&&!is.isPending&&!Te?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Cn,{size:18})})]})]})]})]}),t.jsx(Kr,{open:nt.query!==null,anchorRef:H,commands:nt.filteredCommands,selectedIndex:nt.selectedIndex,query:nt.query??"",hasCatalog:nt.allCommands.length>0,onSelect:nt.applyCommand}),t.jsx(Kr,{open:gt.query!==null,anchorRef:H,commands:gt.filteredSkills,selectedIndex:gt.selectedIndex,query:gt.query??"",hasCatalog:gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:gt.applySkill})]})]})}),z&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:sd,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:z?Xi+N:Xi},children:t.jsx(Ec,{sessionId:pt||void 0,workspaceId:Ne,workingDir:it,projectId:e.projectId,readOnly:ye,repoDeleted:Le,teamRun:be,teamStatus:be?t.jsx(Wl,{teamRun:be,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,onViewInvocationSession:Mr}):void 0,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Jt(re)),U(Q)},minContentWidth:Is,tabRef:E,gitAvailable:Be,gitProps:He&&ve?{branchName:ss,targetBranch:Rt,commitMessage:Gs,canRunGitOperations:!0,onRefreshCommitMessage:vs,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!ye&&t.jsx(jc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ze?.title??e.title,taskDescription:Ze?.body??"",taskPrompt:Ze?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),tt&&!ye&&t.jsx(z0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),He&&Qs&&vt&&t.jsx(Mc,{open:f,onOpenChange:Q=>{S(Q),Q||k(null)},workspaceId:Qs,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Nr,targetBranch:gs,operation:Nt?.operation,worktreePath:jr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:Rs,currentSessionId:Ue?void 0:pt,teamRunId:be?.id}),t.jsx(yn,{isOpen:w,onClose:()=>a(!1),onConfirm:Ar,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Un,{isOpen:x,onClose:()=>_(!1),onConfirm:Tr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(tx,{})}function eo(e){switch(e){case $t.TODO:return we.Pending;case $t.IN_PROGRESS:return we.Running;case $t.IN_REVIEW:return we.Review;case $t.DONE:return we.Done;case $t.CANCELLED:return we.Cancelled}}function ix(e){switch(e){case we.Pending:return $t.TODO;case we.Running:return $t.IN_PROGRESS;case we.Review:return $t.IN_REVIEW;case we.Done:return $t.DONE;case we.Cancelled:return $t.CANCELLED}}function nx(e){switch(e){case kt.CLAUDE_CODE:return"Claude Code";case kt.GEMINI_CLI:return"Gemini CLI";case kt.CURSOR_AGENT:return"Cursor Agent";case kt.CODEX:return"Codex";case kt.QWEN_CODE:return"Qwen Code";case kt.KIRO_CLI:return"Kiro CLI";case kt.OPENCODE:return"OpenCode";case kt.PI_CODING_AGENT:return"Pi Coding Agent";case kt.GROK_BUILD:return"Grok Build";case kt.MINION_CODE:return"Minion Code";case kt.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const ii=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Ic(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function ox(e){return{id:e.id,name:e.name,color:e.color||ii[Ic(e.name,ii.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function ax(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:eo(e.status),agent:e.latestAgentType?nx(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function lx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||ii[Ic(s.name,ii.length)],title:e.title,status:eo(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const xa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function cx(e){const s=e.split("/");return s[s.length-1]||e}function dx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function ux({workingDir:e,filePath:s,type:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=mc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
81
+ `);i(""),It(),A.current&&(A.current.style.height="60px"),As.mutate({id:Je,message:re,providerId:Qe??void 0},{onSuccess:()=>{Z()},onError:()=>{i(Ie=>Ie||re)},onSettled:()=>{Ci.current=!1}})},[n,Je,As,Z,At,Ot,$e,It,Qe,is.isPending,Te]),Gc=b.useCallback(()=>{!Je||is.isPending||is.mutate(Je)},[Je,is]),Qc=b.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&Pe(Array.from(re)),Q.target.value=""},[Pe]),Zc=b.useCallback(Q=>{const re=Q.clipboardData.items,Ie=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Ie.push(ft)}Ie.length>0&&(Q.preventDefault(),Pe(Ie))},[Pe]),[io,ki]=b.useState(!1),Jc=b.useCallback(Q=>{Q.preventDefault(),ki(!0)},[]),ed=b.useCallback(Q=>{Q.preventDefault(),ki(!1)},[]),td=b.useCallback(Q=>{Q.preventDefault(),ki(!1);const re=Q.dataTransfer.files;re.length>0&&Pe(Array.from(re))},[Pe]),Jt=b.useCallback(Q=>{const re=me.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=re?Math.max(Is,re-Xi-J0-ex):Is;return Math.max(Is,Math.min(Math.round(Q),Ie))},[]),Ei=b.useCallback(Q=>{const re=Q.clientX-ie.current;W(Jt(ee.current-re))},[Jt]),ji=b.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(X)return document.addEventListener("mousemove",Ei),document.addEventListener("mouseup",ji),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Ei),document.removeEventListener("mouseup",ji),document.body.style.cursor="",document.body.style.userSelect=""}},[ji,Ei,X]);const sd=b.useCallback(Q=>{Q.preventDefault(),ie.current=Q.clientX,ee.current=N,V(!0)},[N]);b.useEffect(()=>{!z||X||W(Q=>Jt(Q))},[Jt,z,X]),b.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Jt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Jt,z]);const rd=b.useCallback(()=>{W(Q=>Jt(Q)),U(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Jt]),id=b.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Ie=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),no=Xt&&ve?t.jsx(Dc,{workspaceId:ve,branchName:ss,targetBranch:Rt,commitMessage:Gs,changes:Gt,gitStatus:Nt,isGitStatusLoading:Yt,canRunGitOperations:He,onOpenChanges:rd,onRefreshCommitMessage:vs,onConflict:bs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(Lc,{taskId:e.id,title:e.title,readOnly:ye})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(sx,{status:e.status,onChangeStatus:!ye&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:tr,disabled:!it||ye,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(ci,{size:16})}),(s||tt)&&!ye&&t.jsxs("div",{className:"relative",ref:q,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(il,{size:16})}),y&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[tt&&t.jsxs("button",{onClick:()=>{g(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ls,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Cd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{_(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Rn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),He&&ve&&Nt&&t.jsx(W0,{workspaceId:ve,gitStatus:Nt,onResolve:()=>bs()}),t.jsxs("div",{ref:me,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ue&&be?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Rc,{session:ue,providers:De,usage:to,providerIdFallback:fe?.providerId,agentTypeFallback:ue?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:Si,children:[t.jsx($s,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,scrollElementRef:M,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe})})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Vr,{todos:de})})})]}):t.jsx(Ll,{teamRun:be,messages:ut??be.messages??[],readOnly:ye,readOnlyMessage:Se,onSendMessage:wi,onViewInvocationSession:Mr,changeSummaryBar:no,centered:!0,workingDir:it,onOpenWorkspaceFile:he,onOpenPreviewUrl:se,onOpenVisualization:ne}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Xe||Ze?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Xe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ze?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(_n,{urlTransform:Z0,components:Fa,children:Ze.body})}):null}),oe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[oe.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:oe.currentIndex,total:oe.totalCommands,command:oe.currentCommand})})]}),oe.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),oe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:oe.error})})]}),!ye&&p&&(pe||pt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(va,{state:p,onRetry:p.status==="failed"?Ts:void 0})}):null,pe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):pt?Dr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):_s.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(je?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:_s,downloadSessionId:ge,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:B,workingDir:it,scrollElementRef:M,onOpenWorkspaceFile:he,onOpenPreviewUrl:ke,onOpenVisualization:xe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(es,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(ye?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:ye?Se:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!ye&&p?t.jsx(va,{state:p}):null,!ye&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:Ts,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(Me,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ls,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>K(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),de.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Vr,{todos:de})})}),ye?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:Se})})}):Ct?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:Ts,children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Jc,onDragLeave:ed,onDrop:td,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[no,Je?t.jsx(Qa,{sessionId:Je}):null,t.jsxs("div",{ref:H,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${io?"border-info bg-info/5":"border-border"}`,children:[t.jsx(bn,{files:Fe,onRemove:St}),t.jsx("textarea",{ref:A,value:n,onChange:id,onPaste:Zc,onKeyDown:Q=>{gt.handleKeyDown(Q)||nt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),ro())},rows:1,placeholder:v(io?"Drop files here...":pt&&!je?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Qc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>P.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(Nn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[_e&&De&&t.jsx(Za,{providers:De,currentProviderId:Qe,agentType:_e.agentType,runtimeType:_e.runtimeType,onSelect:rt}),t.jsx(En,{usage:to}),je&&!n.trim()&&!At?t.jsx("button",{onClick:Gc,disabled:is.isPending||Te,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ws,{size:14})}):t.jsx("button",{onClick:ro,disabled:!n.trim()&&!At||Ot||As.isPending||is.isPending||Te,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||At)&&!Ot&&!As.isPending&&!is.isPending&&!Te?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Cn,{size:18})})]})]})]})]}),t.jsx(Kr,{open:nt.query!==null,anchorRef:H,commands:nt.filteredCommands,selectedIndex:nt.selectedIndex,query:nt.query??"",hasCatalog:nt.allCommands.length>0,onSelect:nt.applyCommand}),t.jsx(Kr,{open:gt.query!==null,anchorRef:H,commands:gt.filteredSkills,selectedIndex:gt.selectedIndex,query:gt.query??"",hasCatalog:gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:gt.applySkill})]})]})}),z&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:sd,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:z?Xi+N:Xi},children:t.jsx(Ec,{sessionId:pt||void 0,workspaceId:Ne,workingDir:it,projectId:e.projectId,readOnly:ye,repoDeleted:Le,teamRun:be,teamStatus:be?t.jsx(Wl,{teamRun:be,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,onViewInvocationSession:Mr}):void 0,workspaces:G,selectedWorkspaceId:Ne,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Jt(re)),U(Q)},minContentWidth:Is,tabRef:E,gitAvailable:Be,gitProps:He&&ve?{branchName:ss,targetBranch:Rt,commitMessage:Gs,canRunGitOperations:!0,onRefreshCommitMessage:vs,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!ye&&t.jsx(jc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ze?.title??e.title,taskDescription:Ze?.body??"",taskPrompt:Ze?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),tt&&!ye&&t.jsx(z0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),He&&Qs&&vt&&t.jsx(Mc,{open:f,onOpenChange:Q=>{S(Q),Q||k(null)},workspaceId:Qs,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Nr,targetBranch:gs,operation:Nt?.operation,worktreePath:jr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:Rs,currentSessionId:Ue?void 0:pt,teamRunId:be?.id}),t.jsx(yn,{isOpen:w,onClose:()=>a(!1),onConfirm:Ar,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Un,{isOpen:x,onClose:()=>_(!1),onConfirm:Tr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(tx,{})}function eo(e){switch(e){case $t.TODO:return we.Pending;case $t.IN_PROGRESS:return we.Running;case $t.IN_REVIEW:return we.Review;case $t.DONE:return we.Done;case $t.CANCELLED:return we.Cancelled}}function ix(e){switch(e){case we.Pending:return $t.TODO;case we.Running:return $t.IN_PROGRESS;case we.Review:return $t.IN_REVIEW;case we.Done:return $t.DONE;case we.Cancelled:return $t.CANCELLED}}function nx(e){switch(e){case kt.CLAUDE_CODE:return"Claude Code";case kt.GEMINI_CLI:return"Gemini CLI";case kt.CURSOR_AGENT:return"Cursor Agent";case kt.CODEX:return"Codex";case kt.QWEN_CODE:return"Qwen Code";case kt.KIRO_CLI:return"Kiro CLI";case kt.OPENCODE:return"OpenCode";case kt.PI_CODING_AGENT:return"Pi Coding Agent";case kt.GROK_BUILD:return"Grok Build";case kt.MINION_CODE:return"Minion Code";case kt.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const ii=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Ic(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function ox(e){return{id:e.id,name:e.name,color:e.color||ii[Ic(e.name,ii.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function ax(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:eo(e.status),agent:e.latestAgentType?nx(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function lx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||ii[Ic(s.name,ii.length)],title:e.title,status:eo(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const xa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function cx(e){const s=e.split("/");return s[s.length-1]||e}function dx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function ux({workingDir:e,filePath:s,type:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=mc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
82
82
  `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function hx({entry:e,type:s,workingDir:r}){const[o,p]=b.useState(!1),m=xa[e.status]||xa.M,v=dx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:cx(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsx(ux,{workingDir:r,filePath:e.path,type:s})]})}function ba({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ae(),[v,n]=b.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(hx,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function fx({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p}=yi(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Vs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(ba,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(ba,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Yi=50,_a={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function mx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function px(e){const s=e.split("/");return s[s.length-1]||e}function gx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function vx({workingDir:e,hash:s,filePath:r}){const{t:o}=ae(),{data:p,isLoading:m,isError:v}=Jn(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
83
83
  `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function xx({entry:e,workingDir:s,hash:r}){const[o,p]=b.useState(!1),m=_a[e.status]||_a.M,v=gx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:px(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsx(vx,{workingDir:s,hash:r,filePath:e.path})]})}function bx({commit:e,workingDir:s}){const{t:r}=ae(),[o,p]=b.useState(!1),{data:m,isLoading:v}=Zn(s,o?e.hash:null),n=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:te("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:te("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:mx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Pt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(ze,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(xx,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function _x({workingDir:e}){const{t:s}=ae(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:n}=Tn({queryKey:ce.git.log(e||""),queryFn:({pageParam:l=0})=>Ee.get("/git/log",{params:{workingDir:e||"",limit:String(Yi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Yi?void 0:u.length*Yi,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(ze,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Us,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(l=>t.jsx(bx,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(ze,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const yx=br(),Sx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${yx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function wx({status:e}){const s={[we.Running]:"bg-blue-500",[we.Review]:"bg-amber-500",[we.Pending]:"bg-neutral-400",[we.Done]:"bg-emerald-500",[we.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const Cx=[{key:"chat",label:"Chat",icon:ai},{key:"changes",label:"Changes",icon:Vs},{key:"history",label:"History",icon:Us},{key:"workspace",label:"Workspace",icon:di}],kx=[{key:"chat",label:"Team room",icon:ai},{key:"team-status",label:"Team Status",icon:Cs},{key:"changes",label:"Changes",icon:Vs},{key:"workspace",label:"Workspace",icon:di}];function ya({state:e,onRetry:s}){const{t:r}=ae(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(es,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function Ex({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ae(),n=Es(Z=>Z.setVisibleContext),[i,l]=b.useState("chat"),[u,c]=b.useState(""),[g,x]=b.useState(!1),[_,w]=b.useState(!1),[a,h]=b.useState(!1),[d,f]=b.useState(null),[S,C]=b.useState(void 0),k=b.useRef(0),[E,y]=b.useState(),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),T=b.useRef(null),{scrollRef:D,contentRef:F,isAtBottom:I,scrollToBottom:H,stopScroll:q}=wn({resize:"smooth",initial:"instant"}),A=bt();b.useEffect(()=>{if(!a)return;const Z=de=>{R.current&&!R.current.contains(de.target)&&h(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[a]);const{data:P,isLoading:M}=zn(e.id),{data:O}=Pa(e.id),{data:$}=La(O?.id??""),K=vn(O?.id??""),B=O??null,z=e.isGitRepo!==!1&&e.worktreeReady!==!1,U=b.useMemo(()=>(B?kx:Cx).filter(Z=>z||Z.key!=="changes"&&Z.key!=="history"),[z,B]),N=O===null,{data:W,isLoading:X}=Ia(e.id,N),V=!!e.projectArchivedAt,ie=!!e.projectRepoDeletedAt,ee=v(ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{C(void 0),f(null),y(void 0)},[e.id]),b.useEffect(()=>{B&&i==="history"&&l("chat"),!B&&i==="team-status"&&l("chat"),U.some(Z=>Z.key===i)||l("chat")},[i,U,B]);const me=b.useMemo(()=>Il(P,B,S),[S,B,P]);b.useEffect(()=>{S&&!P?.some(Z=>Z.id===S)&&C(void 0)},[S,P]);const he=b.useMemo(()=>P?.find(Z=>Z.id===me),[me,P]),G=b.useMemo(()=>{if(P){if(he)return ds(he);for(const Z of P)if(Z.status==="ACTIVE"&&ds(Z))return ds(Z);return ds(P[0])}},[he,P]),pe=he?.status===Mt.ACTIVE?he.id:void 0,oe=z&&Ol(he,B),We=he?.branchName??"",ut=he?.commitMessage,Oe=b.useMemo(()=>Bl(he,P,e?.mainBranch??""),[he,e?.mainBranch,P]),be=!!(oe&&pe&&G&&!V),{data:Ue,isLoading:Be}=Hn(pe??"",{enabled:be}),{data:tt}=yi(G,{enabled:be}),Ye=tt?.committed?.length,[Ze,Xe]=b.useState(!1),[Ne,Ae]=b.useState(null);b.useEffect(()=>{const Z=z&&(i==="changes"||i==="chat"&&be)?"changes":z&&i==="history"?"history":null;if(!pe||!G||!Z){n(null);return}return n({workspaceId:pe,workingDir:G,tab:Z}),()=>{n(null)}},[i,z,pe,n,be,G]);const ve=b.useMemo(()=>Ue?.conflictOp&&Ue.conflictedFiles.length>0?{conflictOp:Ue.conflictOp,conflictedFiles:Ue.conflictedFiles}:Ne,[Ue?.conflictOp,Ue?.conflictedFiles,Ne]),He=ve?.targetWorkspaceId??pe,_e=ve?.targetWorktreePath??he?.worktreePath,pt=ve?.sourceBranch??We,Je=ve?.targetBranch??Oe,Lt=he?.sessions??[],J=b.useCallback(Z=>{Ae(Z??null),Xe(!0)},[]),fe=b.useCallback(()=>e?.id?A.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,A]),ue=b.useCallback(async()=>A.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>Ee.get(`/tasks/${e.id}/body`)}),[A,e.id]),ge=b.useMemo(()=>{if(!P)return null;const Z=P.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),de=$e=>{const At=$e.createdAt,Ot=$e.endedAt??$e.startedAt??At;if(!Ot)return 0;const Ms=Date.parse(Ot);return Number.isNaN(Ms)?0:Ms},Fe=$e=>{const At=Z.filter(Ot=>$e.includes(Ot.status));return At.length===0?null:At.sort((Ot,Ms)=>de(Ms)-de(Ot))[0]??null},Pe=Fe([ct.RUNNING])??Fe([ct.PENDING])??Fe([ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(Pe)return Pe;const It=P.filter($e=>($e.status==="ABANDONED"||$e.status==="MERGED"||$e.status==="HIBERNATED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]).filter($e=>[ct.COMPLETED,ct.FAILED,ct.CANCELLED].includes($e.status));return It.length===0?null:It.sort(($e,At)=>de(At)-de($e))[0]??null},[P]),Ce=ge?.id??"",Y=B?d??"":Ce,se=b.useMemo(()=>{if(!d||!P)return null;for(const Z of P){const de=Z.sessions?.find(Fe=>Fe.id===d);if(de)return de}return null},[d,P]),ne=b.useMemo(()=>{if(!d||!B?.invocations)return null;const Z=B.invocations.filter(de=>de.sessionId===d);return Z.length===0?null:Z.sort((de,Fe)=>{const Pe=Date.parse(de.updatedAt??de.createdAt??""),St=Date.parse(Fe.updatedAt??Fe.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Pe)?0:Pe)})[0]??null},[d,B?.invocations]),ke=b.useMemo(()=>!ne?.memberId||!B?.members?null:B.members.find(Z=>Z.id===ne.memberId)??null,[ne?.memberId,B?.members]),xe=d?se:ge??null,je=xe?.id,Te=b.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!P))return P.find(Z=>Z.sessions?.some(de=>de.id===xe.id))?.id},[xe,P]),ye=b.useCallback((Z,de)=>{const Pe=(de&&P?.some(St=>St.id===de)?de:void 0)??Te??me??void 0;Pe&&C(Pe),k.current+=1,y({id:k.current,source:Z,workspaceId:Pe}),l("workspace")},[Te,me,P]),Le=b.useCallback((Z,de)=>{ye({kind:"web",url:Z},de)},[ye]),Se=b.useCallback((Z,de,Fe)=>{ye({kind:"visualization",sessionId:Z,file:de},Fe)},[ye]),De=b.useCallback(Z=>{Le(Z,Te)},[Te,Le]),Qe=b.useCallback(Z=>{je&&Se(je,Z,Te)},[je,Te,Se]),{isActive:rt,isCancelling:Ct}=Va(je??"",xe?.status),it=b.useMemo(()=>!ge||!P?!1:!P.some(de=>de.status==="ACTIVE"&&de.sessions?.some(Fe=>Fe.id===ge.id)),[ge,P]),{data:nt}=Ks(),[gt,Vt]=b.useState(null),Xt=gt?.sessionId===Ce?gt.providerId:ge?.providerId??null,Nt=b.useCallback(Z=>{Vt({sessionId:Ce,providerId:Z})},[Ce]),Yt=Xa({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Gt=Pc({agentType:ge?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Rs=G&&he?he.id:void 0,ss=jn(),Gs=Wn(),Rt=Ga(),{isConnected:vt,isLoadingSnapshot:Qs,isOutputActive:jr,lastExitAt:Nr,logs:gs,entries:at,attach:Qt}=Ja({sessionId:Y,sessionStatus:xe?.status,sessionStartedAt:xe?.startedAt??xe?.createdAt,sessionEndedAt:xe?.endedAt??(rt?null:xe?.updatedAt),onExit:b.useCallback(()=>{A.invalidateQueries({queryKey:["workspaces"]})},[A])}),{todos:vs}=el(at),{files:As,addFiles:xs,removeFile:Rr,clear:Zs,buildMarkdownLinks:Js,hasFiles:Zt,isUploading:Wt}=xn(),er=b.useMemo(()=>Nc(xe),[xe?.tokenUsage]),Ar=Ya(gs,er);b.useEffect(()=>{Y&&vt&&Qt()},[Y,vt,Qt]);const Ts=b.useRef(null);b.useEffect(()=>{if(Ts.current!==e.id&&D.current){const Z=D.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Ts.current=e.id},[e.id,D]);const tr=b.useRef(!1),Tr=b.useCallback(async()=>{if(!u.trim()&&!Zt||!Ce||tr.current||Rt.isPending||Ct||Wt)return;tr.current=!0;const Z=Js(),de=[u.trim(),Z].filter(Boolean).join(`
84
84
 
85
- `);c(""),Zs(),L.current&&(L.current.style.height="40px"),ss.mutate({id:Ce,message:de,providerId:Xt??void 0},{onSuccess:()=>Qt(),onError:()=>c(Fe=>Fe||de),onSettled:()=>{tr.current=!1}})},[u,Ce,ss,Qt,Zt,Wt,Js,Zs,Xt,Rt.isPending,Ct]),Mr=b.useCallback(()=>{!Ce||Rt.isPending||Rt.mutate(Ce)},[Ce,Rt]),Si=b.useCallback(Z=>K.mutateAsync(Z),[K]),bs=b.useCallback(Z=>{f(Z),l("chat"),requestAnimationFrame(()=>{H()})},[H]),wi=b.useCallback(()=>{f(null)},[]),rs=b.useCallback(()=>{l("changes")},[]),sr=be&&pe?t.jsx(Dc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,changes:tt,gitStatus:Ue,isGitStatusLoading:Be,canRunGitOperations:oe,onOpenChanges:rs,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Dr=b.useCallback(Z=>{const de=Z.target.files;de&&de.length>0&&xs(Array.from(de)),Z.target.value=""},[xs]),Pr=b.useCallback(Z=>{const de=Z.clipboardData.items,Fe=[];for(const Pe of de)if(Pe.kind==="file"){const St=Pe.getAsFile();St&&Fe.push(St)}Fe.length>0&&(Z.preventDefault(),xs(Fe))},[xs]),Lr=b.useCallback(Z=>{c(Z.target.value);const de=Z.target;de.style.height="auto",de.style.height=`${Math.max(40,Math.min(de.scrollHeight,140))}px`},[]),_s=b.useCallback(()=>{Rs&&Gs.mutate({workspaceId:Rs})},[Gs,Rs]),ys=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let de=!1;const Fe=()=>{ys.current&&(ys.current.style.height=`${Z.height}px`,ys.current.style.top=`${Z.offsetTop}px`)},Pe=()=>Fe(),St=()=>{de||Fe()},It=()=>{de=!0},$e=()=>{de=!1,requestAnimationFrame(Fe)};return Z.addEventListener("resize",Pe),Z.addEventListener("scroll",St),document.addEventListener("touchstart",It,{passive:!0}),document.addEventListener("touchend",$e,{passive:!0}),document.addEventListener("touchcancel",$e,{passive:!0}),()=>{Z.removeEventListener("resize",Pe),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",It),document.removeEventListener("touchend",$e),document.removeEventListener("touchcancel",$e)}},[]),b.useEffect(()=>{const Z=ys.current;if(!Z)return;const de=Fe=>{let Pe=Fe.target;for(;Pe&&Pe!==Z;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const It=window.getComputedStyle(Pe).overflowY;if((It==="auto"||It==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Fe.preventDefault()};return Z.addEventListener("touchmove",de,{passive:!1}),()=>Z.removeEventListener("touchmove",de)},[]),t.jsxs("div",{ref:ys,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx($s,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Lc,{taskId:e.id,title:e.title,readOnly:V,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(wx,{status:e.status}),t.jsx("button",{onClick:_s,disabled:!Rs||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(ci,{size:16})}),r&&!V&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>h(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(il,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{w(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(Rn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:U.map(({key:Z,label:de,icon:Fe})=>t.jsxs("button",{onClick:()=>l(Z),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===Z?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Fe,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(de)})]},Z))})]}),i==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Rc,{session:xe,providers:nt,usage:Ar,compact:!0,providerIdFallback:ke?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:wi,children:[t.jsx($s,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:F,children:Qs?t.jsx(Gi,{label:v("Loading logs...")}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(rt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,onOpenPreviewUrl:De,onOpenVisualization:Qe})})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Vr,{todos:vs,compact:!0})})]}):t.jsx(Ll,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:Si,onViewInvocationSession:bs,changeSummaryBar:sr,compactComposer:!0,workingDir:G,onOpenPreviewUrl:Le,onOpenVisualization:Se})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:F,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):W?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(_n,{urlTransform:Sx,components:Fa,children:W.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!V&&p&&(M||Ce)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(ya,{state:p,onRetry:p.status==="failed"?async()=>{await ue(),x(!0)}:void 0})}):null,M?t.jsx(Gi,{label:"Loading..."}):Ce?Qs?t.jsx(Gi,{label:"Loading logs..."}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:rt?"Waiting for agent output...":"No logs recorded."}):t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,onOpenPreviewUrl:De,onOpenVisualization:Qe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(es,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:V?ee:v("选择一个 Agent 来执行此任务")}),!V&&p?t.jsx(ya,{state:p}):null,!V&&t.jsxs(Me,{onClick:async()=>{await ue(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Vr,{todos:vs,compact:!0})}),V?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ee})}):it?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:async()=>{await ue(),x(!0)},children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):Ce&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[sr,t.jsx(Qa,{sessionId:Y||Ce,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(bn,{files:As,onRemove:Rr}),t.jsx("textarea",{ref:L,value:u,onChange:Lr,onPaste:Pr,onKeyDown:Z=>{Gt.handleKeyDown(Z)||Yt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Tr())},rows:1,placeholder:rt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Dr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Nn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ge&&nt&&t.jsx(Za,{providers:nt,currentProviderId:Xt,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Nt}),t.jsx(En,{usage:Ar}),rt&&!u.trim()&&!Zt?t.jsx("button",{onClick:Mr,disabled:Rt.isPending||Ct,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ws,{size:12})}):t.jsx("button",{onClick:Tr,disabled:!u.trim()&&!Zt||Wt||ss.isPending||Rt.isPending||Ct,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Zt)&&!Wt&&!ss.isPending&&!Rt.isPending&&!Ct?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Cn,{size:15})})]})]})]}),t.jsx(Kr,{open:Yt.query!==null,anchorRef:j,commands:Yt.filteredCommands,selectedIndex:Yt.selectedIndex,query:Yt.query??"",hasCatalog:Yt.allCommands.length>0,compact:!0,onSelect:Yt.applyCommand}),t.jsx(Kr,{open:Gt.query!==null,anchorRef:j,commands:Gt.filteredSkills,selectedIndex:Gt.selectedIndex,query:Gt.query??"",hasCatalog:Gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Gt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Wl,{teamRun:B,workspaces:P,selectedWorkspaceId:me,onSelectWorkspace:C,onViewInvocationSession:bs})}),i==="changes"&&z&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[P&&P.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(kc,{workspaces:P,teamRun:B,selectedWorkspaceId:me,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),oe&&pe&&t.jsx("div",{className:"shrink-0",children:t.jsx(bc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,committedFileCount:Ye,onRefreshCommitMessage:fe,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(fx,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(_x,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Ec,{sessionId:Ce||void 0,workspaceId:me,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:z,readOnly:V,repoDeleted:ie,previewRequest:E,onPreviewRequestHandled:Z=>{y(de=>de?.id===Z?void 0:de)}})}),!V&&t.jsx(jc,{isOpen:g,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:W?.title??e.title,taskDescription:W?.body??"",taskPrompt:W?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),t.jsx(Un,{isOpen:_,onClose:()=>w(!1),onConfirm:()=>{r?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title,workspaces:P,isLoading:o}),Ze&&ve&&He&&t.jsx(Mc,{open:Ze,onOpenChange:Z=>{Xe(Z),Z||Ae(null)},workspaceId:He,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:pt,targetBranch:Je,operation:Ue?.operation,worktreePath:_e,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Lt,currentSessionId:B?void 0:Ce,teamRunId:B?.id})]})}function Gi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var jx=Object.defineProperty,ni=Object.getOwnPropertySymbols,Oc=Object.prototype.hasOwnProperty,Bc=Object.prototype.propertyIsEnumerable,Sa=(e,s,r)=>s in e?jx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,mn=(e,s)=>{for(var r in s||(s={}))Oc.call(s,r)&&Sa(e,r,s[r]);if(ni)for(var r of ni(s))Bc.call(s,r)&&Sa(e,r,s[r]);return e},pn=(e,s)=>{var r={};for(var o in e)Oc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ni)for(var o of ni(e))s.indexOf(o)<0&&Bc.call(e,o)&&(r[o]=e[o]);return r};var ks;(e=>{const s=class Re{constructor(i,l,u,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let _=0;_<this.size;_++)g.push(!1);for(let _=0;_<this.size;_++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let _=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const a=this.getPenaltyScore();a<_&&(c=w,_=a),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const u=e.QrSegment.makeSegments(i);return Re.encodeSegments(u,l)}static encodeBinary(i,l){const u=e.QrSegment.makeBytes(i);return Re.encodeSegments([u],l)}static encodeSegments(i,l,u=1,c=40,g=-1,x=!0){if(!(Re.MIN_VERSION<=u&&u<=c&&c<=Re.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=u;;_++){const f=Re.getNumDataCodewords(_,l)*8,S=v.getTotalBits(i,_);if(S<=f){w=S;break}if(_>=c)throw new RangeError("Data too long")}for(const f of[Re.Ecc.MEDIUM,Re.Ecc.QUARTILE,Re.Ecc.HIGH])x&&w<=Re.getNumDataCodewords(_,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(_),a);for(const S of f.getData())a.push(S)}p(a.length==w);const h=Re.getNumDataCodewords(_,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,S)=>d[S>>>3]|=f<<7-(S&7)),new Re(_,l,d,g)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(i[u],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;p(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),g=this.size-11+u%3,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,g,c)}}drawFinderPattern(i,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),x=i+c,_=l+u;0<=x&&x<this.size&&0<=_&&_<this.size&&this.setFunctionModule(x,_,g!=2&&g!=4)}}drawAlignmentPattern(i,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(i,l,u){this.modules[l][i]=u,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,u=this.errorCorrectionLevel;if(i.length!=Re.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Re.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=Re.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],x=Math.floor(Re.getNumRawDataModules(l)/8),_=c-x%c,w=Math.floor(x/c);let a=[];const h=Re.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=i.slice(S,S+w-g+(f<_?0:1));S+=C.length;const k=Re.reedSolomonComputeRemainder(C,h);f<_&&C.push(0),a.push(C.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((S,C)=>{(f!=w-g||C>=_)&&d.push(S[f])});return p(d.length==x),d}drawCodewords(i){if(i.length!=Math.floor(Re.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const x=u-g,w=(u+1&2)==0?this.size-1-c:c;!this.isFunction[w][x]&&l<i.length*8&&(this.modules[w][x]=o(i[l>>>3],7-(l&7)),l++)}}p(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(i){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[g][a],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[a][g],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const _=this.modules[g][x];_==this.modules[g][x+1]&&_==this.modules[g+1][x]&&_==this.modules[g+1][x+1]&&(i+=Re.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,_)=>x+(_?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),i+=c*Re.PENALTY_N4,p(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let u=[6];for(let c=this.size-7;u.length<i;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(i){if(i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;l-=(25*u-10)*u-55,i>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(Re.getNumRawDataModules(i)/8)-Re.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*Re.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<i;c++){for(let g=0;g<l.length;g++)l[g]=Re.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=Re.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(i,l){let u=l.map(c=>0);for(const c of i){const g=c^u.shift();u.push(0),l.forEach((x,_)=>u[_]^=Re.reedSolomonMultiply(x,g))}return u}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*i;return p(u>>>8==0),u}finderPenaltyCountPatterns(i){const l=i[1];p(l<=this.size*3);const u=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(u&&i[0]>=l*4&&i[6]>=l?1:0)+(u&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,u){return i&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)l.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function p(n){if(!n)throw new Error("Assertion error")}const m=class et{constructor(i,l,u){if(this.mode=i,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let l=[];for(const u of i)r(u,8,l);return new et(et.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!et.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<i.length;){const c=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+c),10),c*3+1,l),u+=c}return new et(et.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!et.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=i.length;u+=2){let c=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;c+=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(c,11,l)}return u<i.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,l),new et(et.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:et.isNumeric(i)?[et.makeNumeric(i)]:et.isAlphanumeric(i)?[et.makeAlphanumeric(i)]:[et.makeBytes(et.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,l)}static isNumeric(i){return et.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return et.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let u=0;for(const c of i){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?l.push(i.charCodeAt(u)):(l.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(ks||(ks={}));var Fs=ks;var Nx={L:Fs.QrCode.Ecc.LOW,M:Fs.QrCode.Ecc.MEDIUM,Q:Fs.QrCode.Ecc.QUARTILE,H:Fs.QrCode.Ecc.HIGH},Fc=128,zc="L",Wc="#FFFFFF",Hc="#000000",$c=!1,Uc=1,Rx=4,Ax=0,Tx=.1;function qc(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,n){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${n-m}v1H${m+s}z`),m=null;return}if(n===o.length-1){if(!v)return;m===null?r.push(`M${n+s},${p+s} h1v1H${n+s}z`):r.push(`M${m+s},${p+s} h${n+1-m}v1H${m+s}z`);return}v&&m===null&&(m=n)})}),r.join("")}function Kc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Mx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Tx),v=p/s,n=(o.width||m)*v,i=(o.height||m)*v,l=o.x==null?e.length/2-n/2:o.x*v,u=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let _=Math.floor(l),w=Math.floor(u),a=Math.ceil(n+l-_),h=Math.ceil(i+u-w);g={x:_,y:w,w:a,h}}const x=o.crossOrigin;return{x:l,y:u,h:i,w:n,excavation:g,opacity:c,crossOrigin:x}}function Dx(e,s){return s!=null?Math.max(Math.floor(s),0):e?Rx:Ax}function Vc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:n}){let i=le.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,a)=>(w.push(...Fs.QrSegment.makeSegments(a)),w),[]);return Fs.QrCode.encodeSegments(_,Nx[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=le.useMemo(()=>{let x=i.getModules();const _=Dx(o,p),w=x.length+_*2,a=Mx(x,v,_,m);return{cells:x,margin:_,numCells:w,calculatedImageSettings:a}},[i,v,m,o,p]);return{qrcode:i,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var Px=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Lx=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Fc,level:v=zc,bgColor:n=Wc,fgColor:i=Hc,includeMargin:l=$c,minVersion:u=Uc,boostLevel:c,marginSize:g,imageSettings:x}=o,w=pn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=w,h=pn(w,["style"]),d=x?.src,f=le.useRef(null),S=le.useRef(null),C=le.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=le.useState(!1),{margin:y,cells:j,numCells:R,calculatedImageSettings:L}=Vc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:x,size:m});le.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let H=j;const q=S.current,A=L!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;A&&L.excavation!=null&&(H=Kc(j,L.excavation));const P=window.devicePixelRatio||1;F.height=F.width=m*P;const M=m/R*P;I.scale(M,M),I.fillStyle=n,I.fillRect(0,0,R,R),I.fillStyle=i,Px?I.fill(new Path2D(qc(H,y))):j.forEach(function(O,$){O.forEach(function(K,B){K&&I.fillRect(B+y,$+y,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(q,L.x+y,L.y+y,L.w,L.h)}}),le.useEffect(()=>{E(!1)},[d]);const T=mn({height:m,width:m},a);let D=null;return d!=null&&(D=le.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:L?.crossOrigin})),le.createElement(le.Fragment,null,le.createElement("canvas",mn({style:T,height:m,width:m,ref:C,role:"img"},h)),D)});Lx.displayName="QRCodeCanvas";var Xc=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Fc,level:v=zc,bgColor:n=Wc,fgColor:i=Hc,includeMargin:l=$c,minVersion:u=Uc,boostLevel:c,title:g,marginSize:x,imageSettings:_}=o,w=pn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Vc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:_,size:m});let S=h,C=null;_!=null&&f!=null&&(f.excavation!=null&&(S=Kc(h,f.excavation)),C=le.createElement("image",{href:_.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=qc(S,a);return le.createElement("svg",mn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&le.createElement("title",null,g),le.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),le.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Xc.displayName="QRCodeSVG";function Yc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Ix(){return jt({queryKey:ce.tunnel.status,queryFn:()=>Ee.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Ox(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/start",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Bx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/regenerate",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Fx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function zx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function Wx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function Hx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function wa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function or(e){const s=e?.trim();return s||null}function $x(e){if(!e)return"";const s=[or(e.lastLocalError),or(e.lastRemoteError),or(e.lastError)].filter(p=>p!==null),r=or(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!or(e.lastError));return r&&o&&s.push(r),s.join(`
85
+ `);c(""),Zs(),L.current&&(L.current.style.height="40px"),ss.mutate({id:Ce,message:de,providerId:Xt??void 0},{onSuccess:()=>Qt(),onError:()=>c(Fe=>Fe||de),onSettled:()=>{tr.current=!1}})},[u,Ce,ss,Qt,Zt,Wt,Js,Zs,Xt,Rt.isPending,Ct]),Mr=b.useCallback(()=>{!Ce||Rt.isPending||Rt.mutate(Ce)},[Ce,Rt]),Si=b.useCallback(Z=>K.mutateAsync(Z),[K]),bs=b.useCallback(Z=>{f(Z),l("chat"),requestAnimationFrame(()=>{H()})},[H]),wi=b.useCallback(()=>{f(null)},[]),rs=b.useCallback(()=>{l("changes")},[]),sr=be&&pe?t.jsx(Dc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,changes:tt,gitStatus:Ue,isGitStatusLoading:Be,canRunGitOperations:oe,onOpenChanges:rs,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Dr=b.useCallback(Z=>{const de=Z.target.files;de&&de.length>0&&xs(Array.from(de)),Z.target.value=""},[xs]),Pr=b.useCallback(Z=>{const de=Z.clipboardData.items,Fe=[];for(const Pe of de)if(Pe.kind==="file"){const St=Pe.getAsFile();St&&Fe.push(St)}Fe.length>0&&(Z.preventDefault(),xs(Fe))},[xs]),Lr=b.useCallback(Z=>{c(Z.target.value);const de=Z.target;de.style.height="auto",de.style.height=`${Math.max(40,Math.min(de.scrollHeight,140))}px`},[]),_s=b.useCallback(()=>{Rs&&Gs.mutate({workspaceId:Rs})},[Gs,Rs]),ys=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let de=!1;const Fe=()=>{ys.current&&(ys.current.style.height=`${Z.height}px`,ys.current.style.top=`${Z.offsetTop}px`)},Pe=()=>Fe(),St=()=>{de||Fe()},It=()=>{de=!0},$e=()=>{de=!1,requestAnimationFrame(Fe)};return Z.addEventListener("resize",Pe),Z.addEventListener("scroll",St),document.addEventListener("touchstart",It,{passive:!0}),document.addEventListener("touchend",$e,{passive:!0}),document.addEventListener("touchcancel",$e,{passive:!0}),()=>{Z.removeEventListener("resize",Pe),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",It),document.removeEventListener("touchend",$e),document.removeEventListener("touchcancel",$e)}},[]),b.useEffect(()=>{const Z=ys.current;if(!Z)return;const de=Fe=>{let Pe=Fe.target;for(;Pe&&Pe!==Z;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const It=window.getComputedStyle(Pe).overflowY;if((It==="auto"||It==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Fe.preventDefault()};return Z.addEventListener("touchmove",de,{passive:!1}),()=>Z.removeEventListener("touchmove",de)},[]),t.jsxs("div",{ref:ys,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx($s,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Lc,{taskId:e.id,title:e.title,readOnly:V,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(wx,{status:e.status}),t.jsx("button",{onClick:_s,disabled:!Rs||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(ci,{size:16})}),r&&!V&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>h(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(il,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{w(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(Rn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:U.map(({key:Z,label:de,icon:Fe})=>t.jsxs("button",{onClick:()=>l(Z),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===Z?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Fe,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(de)})]},Z))})]}),i==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Rc,{session:xe,providers:nt,usage:Ar,compact:!0,providerIdFallback:ke?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:wi,children:[t.jsx($s,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:F,children:Qs?t.jsx(Gi,{label:v("Loading logs...")}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(rt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,scrollElementRef:D,onOpenPreviewUrl:De,onOpenVisualization:Qe})})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Vr,{todos:vs,compact:!0})})]}):t.jsx(Ll,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:Si,onViewInvocationSession:bs,changeSummaryBar:sr,compactComposer:!0,workingDir:G,onOpenPreviewUrl:Le,onOpenVisualization:Se})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:F,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):W?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(_n,{urlTransform:Sx,components:Fa,children:W.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!V&&p&&(M||Ce)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(ya,{state:p,onRetry:p.status==="failed"?async()=>{await ue(),x(!0)}:void 0})}):null,M?t.jsx(Gi,{label:"Loading..."}):Ce?Qs?t.jsx(Gi,{label:"Loading logs..."}):gs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:rt?"Waiting for agent output...":"No logs recorded."}):t.jsx(qr,{logs:gs,downloadSessionId:je,isOutputActive:jr,lastExitAt:Nr,onUserToggleDetails:q,scrollElementRef:D,onOpenPreviewUrl:De,onOpenVisualization:Qe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(es,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:V?ee:v("选择一个 Agent 来执行此任务")}),!V&&p?t.jsx(ya,{state:p}):null,!V&&t.jsxs(Me,{onClick:async()=>{await ue(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(es,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(mr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),vs.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Vr,{todos:vs,compact:!0})}),V?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ee})}):it?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Me,{size:"sm",onClick:async()=>{await ue(),x(!0)},children:[t.jsx(es,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):Ce&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[sr,t.jsx(Qa,{sessionId:Y||Ce,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(bn,{files:As,onRemove:Rr}),t.jsx("textarea",{ref:L,value:u,onChange:Lr,onPaste:Pr,onKeyDown:Z=>{Gt.handleKeyDown(Z)||Yt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Tr())},rows:1,placeholder:rt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Dr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Nn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ge&&nt&&t.jsx(Za,{providers:nt,currentProviderId:Xt,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Nt}),t.jsx(En,{usage:Ar}),rt&&!u.trim()&&!Zt?t.jsx("button",{onClick:Mr,disabled:Rt.isPending||Ct,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ws,{size:12})}):t.jsx("button",{onClick:Tr,disabled:!u.trim()&&!Zt||Wt||ss.isPending||Rt.isPending||Ct,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Zt)&&!Wt&&!ss.isPending&&!Rt.isPending&&!Ct?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Cn,{size:15})})]})]})]}),t.jsx(Kr,{open:Yt.query!==null,anchorRef:j,commands:Yt.filteredCommands,selectedIndex:Yt.selectedIndex,query:Yt.query??"",hasCatalog:Yt.allCommands.length>0,compact:!0,onSelect:Yt.applyCommand}),t.jsx(Kr,{open:Gt.query!==null,anchorRef:j,commands:Gt.filteredSkills,selectedIndex:Gt.selectedIndex,query:Gt.query??"",hasCatalog:Gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Gt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Wl,{teamRun:B,workspaces:P,selectedWorkspaceId:me,onSelectWorkspace:C,onViewInvocationSession:bs})}),i==="changes"&&z&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[P&&P.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(kc,{workspaces:P,teamRun:B,selectedWorkspaceId:me,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),oe&&pe&&t.jsx("div",{className:"shrink-0",children:t.jsx(bc,{workspaceId:pe,branchName:We,targetBranch:Oe,commitMessage:ut,committedFileCount:Ye,onRefreshCommitMessage:fe,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(fx,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(_x,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Ec,{sessionId:Ce||void 0,workspaceId:me,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:z,readOnly:V,repoDeleted:ie,previewRequest:E,onPreviewRequestHandled:Z=>{y(de=>de?.id===Z?void 0:de)}})}),!V&&t.jsx(jc,{isOpen:g,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:W?.title??e.title,taskDescription:W?.body??"",taskPrompt:W?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),t.jsx(Un,{isOpen:_,onClose:()=>w(!1),onConfirm:()=>{r?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title,workspaces:P,isLoading:o}),Ze&&ve&&He&&t.jsx(Mc,{open:Ze,onOpenChange:Z=>{Xe(Z),Z||Ae(null)},workspaceId:He,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:pt,targetBranch:Je,operation:Ue?.operation,worktreePath:_e,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Lt,currentSessionId:B?void 0:Ce,teamRunId:B?.id})]})}function Gi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var jx=Object.defineProperty,ni=Object.getOwnPropertySymbols,Oc=Object.prototype.hasOwnProperty,Bc=Object.prototype.propertyIsEnumerable,Sa=(e,s,r)=>s in e?jx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,mn=(e,s)=>{for(var r in s||(s={}))Oc.call(s,r)&&Sa(e,r,s[r]);if(ni)for(var r of ni(s))Bc.call(s,r)&&Sa(e,r,s[r]);return e},pn=(e,s)=>{var r={};for(var o in e)Oc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ni)for(var o of ni(e))s.indexOf(o)<0&&Bc.call(e,o)&&(r[o]=e[o]);return r};var ks;(e=>{const s=class Re{constructor(i,l,u,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let _=0;_<this.size;_++)g.push(!1);for(let _=0;_<this.size;_++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let _=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const a=this.getPenaltyScore();a<_&&(c=w,_=a),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const u=e.QrSegment.makeSegments(i);return Re.encodeSegments(u,l)}static encodeBinary(i,l){const u=e.QrSegment.makeBytes(i);return Re.encodeSegments([u],l)}static encodeSegments(i,l,u=1,c=40,g=-1,x=!0){if(!(Re.MIN_VERSION<=u&&u<=c&&c<=Re.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=u;;_++){const f=Re.getNumDataCodewords(_,l)*8,S=v.getTotalBits(i,_);if(S<=f){w=S;break}if(_>=c)throw new RangeError("Data too long")}for(const f of[Re.Ecc.MEDIUM,Re.Ecc.QUARTILE,Re.Ecc.HIGH])x&&w<=Re.getNumDataCodewords(_,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(_),a);for(const S of f.getData())a.push(S)}p(a.length==w);const h=Re.getNumDataCodewords(_,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,S)=>d[S>>>3]|=f<<7-(S&7)),new Re(_,l,d,g)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(i[u],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;p(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),g=this.size-11+u%3,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,g,c)}}drawFinderPattern(i,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),x=i+c,_=l+u;0<=x&&x<this.size&&0<=_&&_<this.size&&this.setFunctionModule(x,_,g!=2&&g!=4)}}drawAlignmentPattern(i,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(i,l,u){this.modules[l][i]=u,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,u=this.errorCorrectionLevel;if(i.length!=Re.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Re.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=Re.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],x=Math.floor(Re.getNumRawDataModules(l)/8),_=c-x%c,w=Math.floor(x/c);let a=[];const h=Re.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=i.slice(S,S+w-g+(f<_?0:1));S+=C.length;const k=Re.reedSolomonComputeRemainder(C,h);f<_&&C.push(0),a.push(C.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((S,C)=>{(f!=w-g||C>=_)&&d.push(S[f])});return p(d.length==x),d}drawCodewords(i){if(i.length!=Math.floor(Re.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const x=u-g,w=(u+1&2)==0?this.size-1-c:c;!this.isFunction[w][x]&&l<i.length*8&&(this.modules[w][x]=o(i[l>>>3],7-(l&7)),l++)}}p(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(i){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[g][a],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,_=0,w=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(_++,_==5?i+=Re.PENALTY_N1:_>5&&i++):(this.finderPenaltyAddHistory(_,w),x||(i+=this.finderPenaltyCountPatterns(w)*Re.PENALTY_N3),x=this.modules[a][g],_=1);i+=this.finderPenaltyTerminateAndCount(x,_,w)*Re.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const _=this.modules[g][x];_==this.modules[g][x+1]&&_==this.modules[g+1][x]&&_==this.modules[g+1][x+1]&&(i+=Re.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,_)=>x+(_?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),i+=c*Re.PENALTY_N4,p(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let u=[6];for(let c=this.size-7;u.length<i;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(i){if(i<Re.MIN_VERSION||i>Re.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;l-=(25*u-10)*u-55,i>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(Re.getNumRawDataModules(i)/8)-Re.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*Re.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<i;c++){for(let g=0;g<l.length;g++)l[g]=Re.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=Re.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(i,l){let u=l.map(c=>0);for(const c of i){const g=c^u.shift();u.push(0),l.forEach((x,_)=>u[_]^=Re.reedSolomonMultiply(x,g))}return u}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*i;return p(u>>>8==0),u}finderPenaltyCountPatterns(i){const l=i[1];p(l<=this.size*3);const u=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(u&&i[0]>=l*4&&i[6]>=l?1:0)+(u&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,u){return i&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)l.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function p(n){if(!n)throw new Error("Assertion error")}const m=class et{constructor(i,l,u){if(this.mode=i,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let l=[];for(const u of i)r(u,8,l);return new et(et.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!et.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<i.length;){const c=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+c),10),c*3+1,l),u+=c}return new et(et.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!et.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=i.length;u+=2){let c=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;c+=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(c,11,l)}return u<i.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,l),new et(et.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:et.isNumeric(i)?[et.makeNumeric(i)]:et.isAlphanumeric(i)?[et.makeAlphanumeric(i)]:[et.makeBytes(et.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,l)}static isNumeric(i){return et.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return et.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let u=0;for(const c of i){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?l.push(i.charCodeAt(u)):(l.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(ks||(ks={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(ks||(ks={}));var Fs=ks;var Nx={L:Fs.QrCode.Ecc.LOW,M:Fs.QrCode.Ecc.MEDIUM,Q:Fs.QrCode.Ecc.QUARTILE,H:Fs.QrCode.Ecc.HIGH},Fc=128,zc="L",Wc="#FFFFFF",Hc="#000000",$c=!1,Uc=1,Rx=4,Ax=0,Tx=.1;function qc(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,n){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${n-m}v1H${m+s}z`),m=null;return}if(n===o.length-1){if(!v)return;m===null?r.push(`M${n+s},${p+s} h1v1H${n+s}z`):r.push(`M${m+s},${p+s} h${n+1-m}v1H${m+s}z`);return}v&&m===null&&(m=n)})}),r.join("")}function Kc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Mx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Tx),v=p/s,n=(o.width||m)*v,i=(o.height||m)*v,l=o.x==null?e.length/2-n/2:o.x*v,u=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let _=Math.floor(l),w=Math.floor(u),a=Math.ceil(n+l-_),h=Math.ceil(i+u-w);g={x:_,y:w,w:a,h}}const x=o.crossOrigin;return{x:l,y:u,h:i,w:n,excavation:g,opacity:c,crossOrigin:x}}function Dx(e,s){return s!=null?Math.max(Math.floor(s),0):e?Rx:Ax}function Vc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:n}){let i=le.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,a)=>(w.push(...Fs.QrSegment.makeSegments(a)),w),[]);return Fs.QrCode.encodeSegments(_,Nx[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=le.useMemo(()=>{let x=i.getModules();const _=Dx(o,p),w=x.length+_*2,a=Mx(x,v,_,m);return{cells:x,margin:_,numCells:w,calculatedImageSettings:a}},[i,v,m,o,p]);return{qrcode:i,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var Px=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Lx=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Fc,level:v=zc,bgColor:n=Wc,fgColor:i=Hc,includeMargin:l=$c,minVersion:u=Uc,boostLevel:c,marginSize:g,imageSettings:x}=o,w=pn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=w,h=pn(w,["style"]),d=x?.src,f=le.useRef(null),S=le.useRef(null),C=le.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=le.useState(!1),{margin:y,cells:j,numCells:R,calculatedImageSettings:L}=Vc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:x,size:m});le.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let H=j;const q=S.current,A=L!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;A&&L.excavation!=null&&(H=Kc(j,L.excavation));const P=window.devicePixelRatio||1;F.height=F.width=m*P;const M=m/R*P;I.scale(M,M),I.fillStyle=n,I.fillRect(0,0,R,R),I.fillStyle=i,Px?I.fill(new Path2D(qc(H,y))):j.forEach(function(O,$){O.forEach(function(K,B){K&&I.fillRect(B+y,$+y,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(q,L.x+y,L.y+y,L.w,L.h)}}),le.useEffect(()=>{E(!1)},[d]);const T=mn({height:m,width:m},a);let D=null;return d!=null&&(D=le.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:L?.crossOrigin})),le.createElement(le.Fragment,null,le.createElement("canvas",mn({style:T,height:m,width:m,ref:C,role:"img"},h)),D)});Lx.displayName="QRCodeCanvas";var Xc=le.forwardRef(function(s,r){const o=s,{value:p,size:m=Fc,level:v=zc,bgColor:n=Wc,fgColor:i=Hc,includeMargin:l=$c,minVersion:u=Uc,boostLevel:c,title:g,marginSize:x,imageSettings:_}=o,w=pn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Vc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:_,size:m});let S=h,C=null;_!=null&&f!=null&&(f.excavation!=null&&(S=Kc(h,f.excavation)),C=le.createElement("image",{href:_.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=qc(S,a);return le.createElement("svg",mn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&le.createElement("title",null,g),le.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),le.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Xc.displayName="QRCodeSVG";function Yc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Ix(){return jt({queryKey:ce.tunnel.status,queryFn:()=>Ee.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Ox(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/start",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Bx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/regenerate",{port:Yc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Fx(){const e=bt();return zt({mutationFn:()=>Ee.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function zx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function Wx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function Hx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function wa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function or(e){const s=e?.trim();return s||null}function $x(e){if(!e)return"";const s=[or(e.lastLocalError),or(e.lastRemoteError),or(e.lastError)].filter(p=>p!==null),r=or(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!or(e.lastError));return r&&o&&s.push(r),s.join(`
86
86
  `)}function Ca(){const{t:e}=ae(),{data:s}=Ix(),r=Ox(),o=Fx(),p=Bx(),[m,v]=b.useState(!1),[n,i]=b.useState(null),l=b.useRef(null),[u,c]=b.useState({top:0,right:0}),[g,x]=b.useState(!1),[_,w]=b.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,S=s?.token,C=zx(s),k=Wx(s),E=$x(s);b.useEffect(()=>{if(m&&l.current){const F=l.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[m]);const y=b.useCallback(()=>{v(!0)},[a]),j=b.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=b.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),L=b.useCallback(()=>{S&&(navigator.clipboard.writeText(S),i("token"),setTimeout(()=>i(null),2e3))},[S]),T=b.useCallback(()=>{o.mutate(),v(!1),x(!1),w(!1)},[o]),D=b.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{w(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:y,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(ze,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(js,{size:16}):t.jsx(go,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!a&&Ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(go,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(qt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(ze,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&Ss.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(Hx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(qt,{size:14})})]}),S&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Wd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Xc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:F=>F.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Kt,{size:14,className:"text-emerald-500"}):t.jsx(mo,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:wa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:wa(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),S&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:S}),t.jsx("button",{onClick:L,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Kt,{size:14,className:"text-emerald-500"}):t.jsx(mo,{size:14})})]})]}),_&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!_&&t.jsxs("button",{onClick:()=>w(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Ns,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Qi({isOpen:e,onClose:s}){const{t:r}=ae(),o=Xd(),[p,m]=b.useState(""),[v,n]=b.useState(""),[i,l]=b.useState(null),[u,c]=b.useState(!1),[g,x]=b.useState(!1),_=p.trim(),w=v.trim(),a=u||o.isPending,h=b.useMemo(()=>!!(_&&w&&!a),[_,w,a]),d=b.useCallback(()=>{m(""),n(""),l(null),x(!1)},[]),f=b.useCallback(()=>{a||(d(),s())},[a,s,d]);b.useEffect(()=>{e||d()},[e,d]);const S=b.useCallback(async y=>{try{await o.mutateAsync({name:_,repoPath:w,initEmptyRepo:y}),d(),s()}catch(j){const R=j instanceof Error?j.message:r("Failed to create project");l(R),st.error(R)}},[o,s,d,r,_,w]),C=b.useCallback(async()=>{if(!(!_||!w||a)){l(null),c(!0);try{const y=await Ee.get("/filesystem/validate",{params:{path:w}});if(!y.valid){l(y.error??r("Selected path is not a valid directory"));return}if(y.isGitRepo){await S(!1);return}if(y.reason==="no_git"&&y.isEmpty){x(!0);return}if(y.reason==="no_git"){await S(!1);return}await S(!1)}catch(y){l(y instanceof Error?y.message:r("Could not check project path"))}finally{c(!1)}}},[S,a,r,_,w]),k=b.useCallback(()=>{x(!1),S(!1)},[S]),E=b.useCallback(()=>{x(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(fs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:y=>m(y.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(Ud,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(fs,{isOpen:g,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function ka(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Ux(e){return e.map((s,r)=>({project:s,index:r,activityTime:ka(s.lastActivityAt??s.createdAt),createdTime:ka(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function Ea({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ae(),[v,n]=b.useState(!1),i=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:te("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Hs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Hs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Kt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(Kt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(ls,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function ja(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const qx=260,Kx=600,Na=400,Vx=100,Xx=1e3;function Yx(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===_t.MAIN_DIRECTORY?{workspaceKind:_t.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function Gx(){const{t:e,locale:s}=ae(),[r,o]=b.useState(null),[p,m]=b.useState(null),[v,n]=b.useState(Na),[i,l]=b.useState(!1),[u,c]=b.useState("idle"),[g,x]=b.useState({}),_=b.useRef(!1),w=b.useRef(0),a=b.useRef(Na),h=b.useRef(null),d=bt(),{data:f,isLoading:S}=Ks(),{data:C,isLoading:k}=Yd({limit:Vx}),E=b.useMemo(()=>C?.data??[],[C?.data]),y=p&&E.some(J=>J.id===p)?p:null,{data:j,isLoading:R}=kd({...y?{projectId:y}:{},limit:Xx}),L=b.useMemo(()=>j?.data??[],[j?.data]),[T,D]=b.useState([]),F=b.useMemo(()=>{if(T.length===0)return L;const J=new Set(L.map(fe=>fe.id));return[...T.filter(fe=>!J.has(fe.id)),...L]},[L,T]),[I,H]=b.useState(null),q=b.useMemo(()=>r&&F.some(J=>J.id===r)?r:I&&r===I?I:null,[r,F,I]);b.useEffect(()=>{I&&F.some(J=>J.id===I)&&H(null)},[I,F]),b.useEffect(()=>{if(T.length===0)return;const J=new Set(L.map(fe=>fe.id));T.some(fe=>J.has(fe.id))&&D(fe=>fe.filter(ue=>!J.has(ue.id)))},[L,T]);const A=b.useMemo(()=>Ux(E),[E]),P=b.useMemo(()=>A.map(ox),[A]),M=b.useMemo(()=>A.filter(J=>!J.archivedAt),[A]),O=b.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),fe=J?JSON.parse(J):{};return[...f].sort((ue,ge)=>{const Ce=ue.availability.type!=="NOT_FOUND",Y=ge.availability.type!=="NOT_FOUND";if(Ce!==Y)return Ce?-1:1;const se=fe[ue.provider.id]??0;return(fe[ge.provider.id]??0)-se})},[f]),$=b.useMemo(()=>F.map(J=>ax(J,E.find(fe=>fe.id===J.projectId))),[E,F]),K=b.useMemo(()=>{if(!q)return null;const J=F.find(ue=>ue.id===q);if(!J)return null;const fe=E.find(ue=>ue.id===J.projectId);if(!fe){const ue=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:eo(J.status),branch:ue,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return lx(J,fe)},[q,F,E]),B=Da(),z=Ed(),U=jd(),N=kn(),W=b.useCallback(J=>{const fe=Yx(J);D(ue=>ue.some(ge=>ge.id===J.id)?ue.map(ge=>ge.id===J.id?fe:ge):[fe,...ue]),d.setQueryData(ce.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=b.useCallback((J,fe,ue)=>{const ge=J.id,Ce=[J.title,J.description].filter(Boolean).join(`
87
87
 
88
88
  `);x(Y=>({...Y,[ge]:{status:"creating-workspace"}})),(async()=>{try{const Y=await Ee.post(`/tasks/${ge}/workspaces`,{workspaceKind:ue});x(ne=>({...ne,[ge]:{status:"creating-session"}}));const se=await Ee.post(`/workspaces/${Y.id}/sessions`,{providerId:fe,prompt:Ce});x(ne=>({...ne,[ge]:{status:"starting-session"}})),await N.mutateAsync(se.id),await d.invalidateQueries({queryKey:ce.workspaces.list(ge)}),await d.invalidateQueries({queryKey:ce.tasks.all}),x(ne=>{const{[ge]:ke,...xe}=ne;return xe})}catch(Y){const se=Y instanceof Error?Y.message:e("启动 Agent 失败");x(ne=>({...ne,[ge]:{status:"failed",error:se}})),st.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ce.workspaces.list(ge)}),d.invalidateQueries({queryKey:ce.tasks.all})}})()},[d,N,e]),V=b.useCallback(J=>{x(fe=>{const{[J]:ue,...ge}=fe;return ge}),d.invalidateQueries({queryKey:ce.workspaces.list(J)}),d.invalidateQueries({queryKey:ce.tasks.all})},[d]),ie=b.useCallback(J=>{z.mutate(J,{onSuccess:()=>{q===J&&o(null),x(fe=>{const{[J]:ue,...ge}=fe;return ge}),D(fe=>fe.filter(ue=>ue.id!==J)),d.invalidateQueries({queryKey:ce.tasks.all})},onError:()=>{st.error(e("删除任务失败"))}})},[z,q,d,e]),ee=b.useCallback((J,fe)=>{U.mutate({id:J,status:ix(fe)},{onError:()=>{st.error(e("状态变更失败,该操作不被允许"))}})},[U,e]),me=b.useCallback(J=>{J.preventDefault(),_.current=!0,w.current=J.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);b.useEffect(()=>{const J=ue=>{if(!_.current)return;const ge=ue.clientX-w.current,Ce=Math.max(qx,Math.min(Kx,a.current+ge));n(Ce)},fe=()=>{_.current&&(_.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",fe)}},[]);const he=b.useCallback(()=>{l(!0)},[]),G=b.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[M,e]),pe=b.useCallback(()=>{l(!1)},[]),oe=b.useCallback(async J=>{const{title:fe,description:ue,projectId:ge,providerId:Ce,mode:Y,workspaceMode:se,teamRunMode:ne,teamTemplateId:ke,memberPresetIds:xe,attachmentLinks:je}=J,Te=[ue,je].filter(Boolean).join(`