@saluzi/saluzi-edu 0.5.21 → 0.5.22

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 (186) hide show
  1. package/dist/cli.js +67 -63
  2. package/dist/guide/guide-data.json +174 -174
  3. package/dist/rcs-web/assets/AdminPanel-w39uutIr.js +1 -0
  4. package/dist/rcs-web/assets/ArtifactView-wUyXqsCU.js +1 -0
  5. package/dist/rcs-web/assets/{ArtifactsGallery-B63LTThv.js → ArtifactsGallery-DxVwQ8Wh.js} +15 -15
  6. package/dist/rcs-web/assets/Claim-D7HLQsN_.js +1 -0
  7. package/dist/rcs-web/assets/Dashboard-Bz-0-u1i.js +31 -0
  8. package/dist/rcs-web/assets/{Join-zelwrNDz.js → Join-CIaF_Ohx.js} +1 -1
  9. package/dist/rcs-web/assets/{Login-BmYeCfbw.js → Login-DNiG6cNe.js} +1 -1
  10. package/dist/rcs-web/assets/{Register-Dfw4S_A0.js → Register-CZ5iK6MO.js} +1 -1
  11. package/dist/rcs-web/assets/SessionDetail-HEE0RVF6.js +73 -0
  12. package/dist/rcs-web/assets/SessionVisibilityBadge-BY5tHU7b.js +16 -0
  13. package/dist/rcs-web/assets/{Setup-BTTET7Rk.js → Setup-CJerwA76.js} +1 -1
  14. package/dist/rcs-web/assets/{ShareLanding-DaLDc5iV.js → ShareLanding-CgkypqyR.js} +1 -1
  15. package/dist/rcs-web/assets/TeamDetail-ChdJxhFx.js +6 -0
  16. package/dist/rcs-web/assets/TeamList-lVbIAJts.js +1 -0
  17. package/dist/rcs-web/assets/TeamSettings-Bk3T7qB1.js +1 -0
  18. package/dist/rcs-web/assets/UserSearchInput-nQ2jQJmj.js +6 -0
  19. package/dist/rcs-web/assets/UserSettings-BZP7lYFA.js +1 -0
  20. package/dist/rcs-web/assets/{arc-CPhgreP8.js → arc-BLA5f37u.js} +1 -1
  21. package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-CpAi-qzk.js → architectureDiagram-3BPJPVTR-GM4VEh2Q.js} +1 -1
  22. package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DcsxgO1K.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-C1u0Ojfk.js} +1 -1
  23. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-BQ5cjzbZ.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-1cul6feX.js} +1 -1
  24. package/dist/rcs-web/assets/channel-C0wRu8mS.js +1 -0
  25. package/dist/rcs-web/assets/{chunk-2J33WTMH-wa-oCiR6.js → chunk-2J33WTMH-CmySrkX6.js} +1 -1
  26. package/dist/rcs-web/assets/{chunk-4BX2VUAB-D2ybEyPG.js → chunk-4BX2VUAB-EzctfdX5.js} +1 -1
  27. package/dist/rcs-web/assets/{chunk-55IACEB6-CQGtwyGQ.js → chunk-55IACEB6-ClG1aobM.js} +1 -1
  28. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-D0ITaMeP.js → dist/rcs-web/assets/chunk-727SXJPM-D7CCqdxe.js} +1 -1
  29. package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-BWRrcP1d.js → dist/rcs-web/assets/chunk-AQP2D5EJ-C12KuaNz.js} +1 -1
  30. package/dist/rcs-web/assets/{chunk-FMBD7UC4-C-CaLwfI.js → chunk-FMBD7UC4-WFInUvtG.js} +1 -1
  31. package/dist/rcs-web/assets/{chunk-ND2GUHAM-OPpmIsi8.js → chunk-ND2GUHAM-79eEElwS.js} +1 -1
  32. package/dist/rcs-web/assets/{chunk-QZHKN3VN-Bq6R2yM7.js → chunk-QZHKN3VN-B2q3R-jr.js} +1 -1
  33. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DdKmm0r6.js +1 -0
  34. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DdKmm0r6.js +1 -0
  35. package/{packages/remote-control-server/web/dist/assets/code-block-IT6T5CEO-BQf-xjVa.js → dist/rcs-web/assets/code-block-IT6T5CEO-BxkGH7r3.js} +1 -1
  36. package/dist/rcs-web/assets/{copy-lzYYFmlH.js → copy-CJUB1OCZ.js} +1 -1
  37. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-CuUSRgoZ.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-D77W33NX.js} +1 -1
  38. package/{packages/remote-control-server/web/dist/assets/dagre-BM42HDAG-BP4ZP_3D.js → dist/rcs-web/assets/dagre-BM42HDAG-DWSpM1Pp.js} +1 -1
  39. package/dist/rcs-web/assets/{diagram-2AECGRRQ-XQnH0b9k.js → diagram-2AECGRRQ-BmjFx9zx.js} +1 -1
  40. package/dist/rcs-web/assets/{diagram-5GNKFQAL-BnuYmMPD.js → diagram-5GNKFQAL-XJL0kjUS.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-LymV4oAW.js → dist/rcs-web/assets/diagram-KO2AKTUF-BD-qltFe.js} +1 -1
  42. package/dist/rcs-web/assets/{diagram-LMA3HP47-NSg5NWFp.js → diagram-LMA3HP47-CC9yXUQZ.js} +1 -1
  43. package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-kVTMFgtZ.js → dist/rcs-web/assets/diagram-OG6HWLK6-CM4_62w2.js} +1 -1
  44. package/dist/rcs-web/assets/dialog-BnhKhSaK.js +1 -0
  45. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BJBTtX2s.js → erDiagram-TEJ5UH35-CLCbQ9SN.js} +1 -1
  46. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-CcQXZNID.js → flowDiagram-I6XJVG4X-BRJxpd6c.js} +1 -1
  47. package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-DW8iKyq_.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Q9D0n7zY.js} +1 -1
  48. package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-BTBYx3LF.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-DfDoy86d.js} +1 -1
  49. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-BRZAYc6t.js → infoDiagram-5YYISTIA-56dRcjZy.js} +1 -1
  50. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-BYMQtEeD.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-BHdffIkI.js} +1 -1
  51. package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-aqx7w1db.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-CsEp1AVc.js} +1 -1
  52. package/{packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-BxEHfP4O.js → dist/rcs-web/assets/kanban-definition-UN3LZRKU-_RE82LM5.js} +1 -1
  53. package/dist/rcs-web/assets/{linear-Chjw8hPE.js → linear-DDo4ZKYf.js} +1 -1
  54. package/dist/rcs-web/assets/main-BKohkTQG.css +1 -0
  55. package/dist/rcs-web/assets/{main-Dh-rPGBg.js → main-bwawHmb2.js} +15 -15
  56. package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-CrqI4db6.js → dist/rcs-web/assets/mermaid-VLURNSYL-BAWTa5p7.js} +4 -4
  57. package/dist/rcs-web/assets/{mermaid.core-EjsI3GC3.js → mermaid.core-Bk3OUzLn.js} +5 -5
  58. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-D2rO_fGA.js → mindmap-definition-RKZ34NQL-Dn3-IrmG.js} +1 -1
  59. package/dist/rcs-web/assets/{notifications-WMIbgYDP.js → notifications-BV1MotN8.js} +1 -1
  60. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DDwJZfoh.js → pieDiagram-4H26LBE5-BevMVM81.js} +1 -1
  61. package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-DDtqMwKx.js → quadrantDiagram-W4KKPZXB-ChsIQYAl.js} +1 -1
  62. package/dist/rcs-web/assets/{refresh-cw-l0u8pxJi.js → refresh-cw-CKRHMYj-.js} +1 -1
  63. package/{packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-BtSk2-5u.js → dist/rcs-web/assets/requirementDiagram-4Y6WPE33-dsySOh5e.js} +1 -1
  64. package/dist/rcs-web/assets/{sankeyDiagram-5OEKKPKP-SDLDMxUT.js → sankeyDiagram-5OEKKPKP-DNR-vE3O.js} +1 -1
  65. package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-D7iAclg1.js → sequenceDiagram-3UESZ5HK-D3qAxHng.js} +1 -1
  66. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-Bxx23fZH.js → stateDiagram-AJRCARHV-BWhyLeMU.js} +1 -1
  67. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-z1g82auz.js → stateDiagram-v2-BHNVJYJU-Cr7eEfN-.js} +1 -1
  68. package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-C8kBbm_V.js → timeline-definition-PNZ67QCA-iel9USPs.js} +1 -1
  69. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-CPldb1-R.js → vennDiagram-CIIHVFJN--VRUq03V.js} +1 -1
  70. package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-MCHB2fG7.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-Mbg_c9zq.js} +1 -1
  71. package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-CHj-KmL6.js → xychartDiagram-2RQKCTM6-475G72ds.js} +1 -1
  72. package/dist/rcs-web/index.html +2 -2
  73. package/package.json +1 -1
  74. package/packages/remote-control-server/src/__tests__/client-ip.test.ts +67 -0
  75. package/packages/remote-control-server/src/__tests__/teams.test.ts +44 -0
  76. package/packages/remote-control-server/src/client-ip.ts +57 -0
  77. package/packages/remote-control-server/src/db/sqlite.ts +22 -0
  78. package/packages/remote-control-server/src/routes/v1/environments.ts +4 -0
  79. package/packages/remote-control-server/src/routes/web/teams.ts +12 -1
  80. package/packages/remote-control-server/src/services/environment.ts +12 -0
  81. package/packages/remote-control-server/src/store.ts +37 -8
  82. package/packages/remote-control-server/src/types/api.ts +7 -0
  83. package/packages/remote-control-server/web/dist/assets/AdminPanel-w39uutIr.js +1 -0
  84. package/packages/remote-control-server/web/dist/assets/ArtifactView-wUyXqsCU.js +1 -0
  85. package/packages/remote-control-server/web/dist/assets/{ArtifactsGallery-B63LTThv.js → ArtifactsGallery-DxVwQ8Wh.js} +15 -15
  86. package/packages/remote-control-server/web/dist/assets/Claim-D7HLQsN_.js +1 -0
  87. package/packages/remote-control-server/web/dist/assets/Dashboard-Bz-0-u1i.js +31 -0
  88. package/packages/remote-control-server/web/dist/assets/{Join-zelwrNDz.js → Join-CIaF_Ohx.js} +1 -1
  89. package/packages/remote-control-server/web/dist/assets/{Login-BmYeCfbw.js → Login-DNiG6cNe.js} +1 -1
  90. package/packages/remote-control-server/web/dist/assets/{Register-Dfw4S_A0.js → Register-CZ5iK6MO.js} +1 -1
  91. package/packages/remote-control-server/web/dist/assets/SessionDetail-HEE0RVF6.js +73 -0
  92. package/packages/remote-control-server/web/dist/assets/SessionVisibilityBadge-BY5tHU7b.js +16 -0
  93. package/packages/remote-control-server/web/dist/assets/{Setup-BTTET7Rk.js → Setup-CJerwA76.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/{ShareLanding-DaLDc5iV.js → ShareLanding-CgkypqyR.js} +1 -1
  95. package/packages/remote-control-server/web/dist/assets/TeamDetail-ChdJxhFx.js +6 -0
  96. package/packages/remote-control-server/web/dist/assets/TeamList-lVbIAJts.js +1 -0
  97. package/packages/remote-control-server/web/dist/assets/TeamSettings-Bk3T7qB1.js +1 -0
  98. package/packages/remote-control-server/web/dist/assets/UserSearchInput-nQ2jQJmj.js +6 -0
  99. package/packages/remote-control-server/web/dist/assets/UserSettings-BZP7lYFA.js +1 -0
  100. package/packages/remote-control-server/web/dist/assets/{arc-CPhgreP8.js → arc-BLA5f37u.js} +1 -1
  101. package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-CpAi-qzk.js → architectureDiagram-3BPJPVTR-GM4VEh2Q.js} +1 -1
  102. package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DcsxgO1K.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-C1u0Ojfk.js} +1 -1
  103. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-BQ5cjzbZ.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-1cul6feX.js} +1 -1
  104. package/packages/remote-control-server/web/dist/assets/channel-C0wRu8mS.js +1 -0
  105. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-wa-oCiR6.js → chunk-2J33WTMH-CmySrkX6.js} +1 -1
  106. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-D2ybEyPG.js → chunk-4BX2VUAB-EzctfdX5.js} +1 -1
  107. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-CQGtwyGQ.js → chunk-55IACEB6-ClG1aobM.js} +1 -1
  108. package/{dist/rcs-web/assets/chunk-727SXJPM-D0ITaMeP.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-D7CCqdxe.js} +1 -1
  109. package/{dist/rcs-web/assets/chunk-AQP2D5EJ-BWRrcP1d.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-C12KuaNz.js} +1 -1
  110. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-C-CaLwfI.js → chunk-FMBD7UC4-WFInUvtG.js} +1 -1
  111. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-OPpmIsi8.js → chunk-ND2GUHAM-79eEElwS.js} +1 -1
  112. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-Bq6R2yM7.js → chunk-QZHKN3VN-B2q3R-jr.js} +1 -1
  113. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DdKmm0r6.js +1 -0
  114. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DdKmm0r6.js +1 -0
  115. package/{dist/rcs-web/assets/code-block-IT6T5CEO-BQf-xjVa.js → packages/remote-control-server/web/dist/assets/code-block-IT6T5CEO-BxkGH7r3.js} +1 -1
  116. package/packages/remote-control-server/web/dist/assets/{copy-lzYYFmlH.js → copy-CJUB1OCZ.js} +1 -1
  117. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-CuUSRgoZ.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-D77W33NX.js} +1 -1
  118. package/{dist/rcs-web/assets/dagre-BM42HDAG-BP4ZP_3D.js → packages/remote-control-server/web/dist/assets/dagre-BM42HDAG-DWSpM1Pp.js} +1 -1
  119. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-XQnH0b9k.js → diagram-2AECGRRQ-BmjFx9zx.js} +1 -1
  120. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-BnuYmMPD.js → diagram-5GNKFQAL-XJL0kjUS.js} +1 -1
  121. package/{dist/rcs-web/assets/diagram-KO2AKTUF-LymV4oAW.js → packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-BD-qltFe.js} +1 -1
  122. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-NSg5NWFp.js → diagram-LMA3HP47-CC9yXUQZ.js} +1 -1
  123. package/{dist/rcs-web/assets/diagram-OG6HWLK6-kVTMFgtZ.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-CM4_62w2.js} +1 -1
  124. package/packages/remote-control-server/web/dist/assets/dialog-BnhKhSaK.js +1 -0
  125. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BJBTtX2s.js → erDiagram-TEJ5UH35-CLCbQ9SN.js} +1 -1
  126. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-CcQXZNID.js → flowDiagram-I6XJVG4X-BRJxpd6c.js} +1 -1
  127. package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-DW8iKyq_.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Q9D0n7zY.js} +1 -1
  128. package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-BTBYx3LF.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-DfDoy86d.js} +1 -1
  129. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-BRZAYc6t.js → infoDiagram-5YYISTIA-56dRcjZy.js} +1 -1
  130. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-BYMQtEeD.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-BHdffIkI.js} +1 -1
  131. package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-aqx7w1db.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-CsEp1AVc.js} +1 -1
  132. package/{dist/rcs-web/assets/kanban-definition-UN3LZRKU-BxEHfP4O.js → packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-_RE82LM5.js} +1 -1
  133. package/packages/remote-control-server/web/dist/assets/{linear-Chjw8hPE.js → linear-DDo4ZKYf.js} +1 -1
  134. package/packages/remote-control-server/web/dist/assets/main-BKohkTQG.css +1 -0
  135. package/packages/remote-control-server/web/dist/assets/{main-Dh-rPGBg.js → main-bwawHmb2.js} +15 -15
  136. package/{dist/rcs-web/assets/mermaid-VLURNSYL-CrqI4db6.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-BAWTa5p7.js} +4 -4
  137. package/packages/remote-control-server/web/dist/assets/{mermaid.core-EjsI3GC3.js → mermaid.core-Bk3OUzLn.js} +5 -5
  138. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-D2rO_fGA.js → mindmap-definition-RKZ34NQL-Dn3-IrmG.js} +1 -1
  139. package/packages/remote-control-server/web/dist/assets/{notifications-WMIbgYDP.js → notifications-BV1MotN8.js} +1 -1
  140. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DDwJZfoh.js → pieDiagram-4H26LBE5-BevMVM81.js} +1 -1
  141. package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-DDtqMwKx.js → quadrantDiagram-W4KKPZXB-ChsIQYAl.js} +1 -1
  142. package/packages/remote-control-server/web/dist/assets/{refresh-cw-l0u8pxJi.js → refresh-cw-CKRHMYj-.js} +1 -1
  143. package/{dist/rcs-web/assets/requirementDiagram-4Y6WPE33-BtSk2-5u.js → packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-dsySOh5e.js} +1 -1
  144. package/packages/remote-control-server/web/dist/assets/{sankeyDiagram-5OEKKPKP-SDLDMxUT.js → sankeyDiagram-5OEKKPKP-DNR-vE3O.js} +1 -1
  145. package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-D7iAclg1.js → sequenceDiagram-3UESZ5HK-D3qAxHng.js} +1 -1
  146. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-Bxx23fZH.js → stateDiagram-AJRCARHV-BWhyLeMU.js} +1 -1
  147. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-z1g82auz.js → stateDiagram-v2-BHNVJYJU-Cr7eEfN-.js} +1 -1
  148. package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-C8kBbm_V.js → timeline-definition-PNZ67QCA-iel9USPs.js} +1 -1
  149. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-CPldb1-R.js → vennDiagram-CIIHVFJN--VRUq03V.js} +1 -1
  150. package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-MCHB2fG7.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-Mbg_c9zq.js} +1 -1
  151. package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-CHj-KmL6.js → xychartDiagram-2RQKCTM6-475G72ds.js} +1 -1
  152. package/packages/remote-control-server/web/dist/index.html +2 -2
  153. package/dist/rcs-web/assets/AdminPanel-fsacwgfK.js +0 -1
  154. package/dist/rcs-web/assets/ArtifactView-DmMwrTRk.js +0 -1
  155. package/dist/rcs-web/assets/Claim-hOGNTz-n.js +0 -1
  156. package/dist/rcs-web/assets/Dashboard-BBIlAMpr.js +0 -6
  157. package/dist/rcs-web/assets/SessionDetail-zXHv84SV.js +0 -83
  158. package/dist/rcs-web/assets/SessionVisibilityBadge-DA_Sg1dx.js +0 -11
  159. package/dist/rcs-web/assets/TeamCreate-BWtaB-_Z.js +0 -1
  160. package/dist/rcs-web/assets/TeamDetail-Crmn6PaC.js +0 -6
  161. package/dist/rcs-web/assets/TeamList-B8Rob6VK.js +0 -1
  162. package/dist/rcs-web/assets/TeamSettings-CfRHolhe.js +0 -1
  163. package/dist/rcs-web/assets/UserSearchInput-DkaGgR76.js +0 -1
  164. package/dist/rcs-web/assets/UserSettings-D1oW7oVv.js +0 -1
  165. package/dist/rcs-web/assets/channel-DHj-rIRW.js +0 -1
  166. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DsAw9J1B.js +0 -1
  167. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DsAw9J1B.js +0 -1
  168. package/dist/rcs-web/assets/dialog-DrDf89nL.js +0 -1
  169. package/dist/rcs-web/assets/main-CJvwpIVn.css +0 -1
  170. package/packages/remote-control-server/web/dist/assets/AdminPanel-fsacwgfK.js +0 -1
  171. package/packages/remote-control-server/web/dist/assets/ArtifactView-DmMwrTRk.js +0 -1
  172. package/packages/remote-control-server/web/dist/assets/Claim-hOGNTz-n.js +0 -1
  173. package/packages/remote-control-server/web/dist/assets/Dashboard-BBIlAMpr.js +0 -6
  174. package/packages/remote-control-server/web/dist/assets/SessionDetail-zXHv84SV.js +0 -83
  175. package/packages/remote-control-server/web/dist/assets/SessionVisibilityBadge-DA_Sg1dx.js +0 -11
  176. package/packages/remote-control-server/web/dist/assets/TeamCreate-BWtaB-_Z.js +0 -1
  177. package/packages/remote-control-server/web/dist/assets/TeamDetail-Crmn6PaC.js +0 -6
  178. package/packages/remote-control-server/web/dist/assets/TeamList-B8Rob6VK.js +0 -1
  179. package/packages/remote-control-server/web/dist/assets/TeamSettings-CfRHolhe.js +0 -1
  180. package/packages/remote-control-server/web/dist/assets/UserSearchInput-DkaGgR76.js +0 -1
  181. package/packages/remote-control-server/web/dist/assets/UserSettings-D1oW7oVv.js +0 -1
  182. package/packages/remote-control-server/web/dist/assets/channel-DHj-rIRW.js +0 -1
  183. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DsAw9J1B.js +0 -1
  184. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DsAw9J1B.js +0 -1
  185. package/packages/remote-control-server/web/dist/assets/dialog-DrDf89nL.js +0 -1
  186. package/packages/remote-control-server/web/dist/assets/main-CJvwpIVn.css +0 -1
@@ -1,83 +0,0 @@
1
- var Us=Object.defineProperty;var Fs=(s,t,n)=>t in s?Us(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var M=(s,t,n)=>Fs(s,typeof t!="symbol"?t+"":t,n);import{e as l,j as e}from"./vendor-DE_-CLIE.js";import{al as L,a4 as Ks,au as Tt,at as Mt,aA as d,aw as Ls,av as Oe,aB as O,aq as oe,af as Bs,ae as z,a7 as Hs,ac as Ws,aF as Qs,H as es,g as Rt,ap as ts,L as _e,J as Vs,aI as J,am as Ue,d as Se,S as it,M as zs,w as Gs,X as Ys,G as Js,an as Q,aj as ee,ao as Xs,aC as Zs,z as en,D as tn,aD as At,a8 as sn,Y as nn,ab as rn,A as an,ar as on,ax as ln,ay as cn,Q as $t,W as dn,aE as un,b as mn,_ as It,a9 as xn,I as ss,P as fn,F as pn,c as hn,C as yn,a3 as Dt,j as gn,a as bn,s as Fe,u as Ke,y as wn,f as Le,e as Be,t as He,q as jn,B as vn}from"./main-Dh-rPGBg.js";import{g as kn}from"./workerType-BOi1t0TG.js";import{D as de,a as ue,c as me,d as xe,b as Nn}from"./dialog-DrDf89nL.js";import{R as _n}from"./refresh-cw-l0u8pxJi.js";import{C as Sn}from"./copy-lzYYFmlH.js";import{E as Cn,A as En}from"./ArtifactsGallery-B63LTThv.js";import{S as Tn}from"./SessionVisibilityBadge-DA_Sg1dx.js";import{U as Mn}from"./UserSearchInput-DkaGgR76.js";import{S as Rn,b as An}from"./notifications-WMIbgYDP.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";/**
2
- * @license lucide-react v0.555.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const $n=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],In=L("activity",$n);/**
7
- * @license lucide-react v0.555.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Dn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],qn=L("arrow-left",Dn);/**
12
- * @license lucide-react v0.555.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Pn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ns=L("chevron-right",Pn);/**
17
- * @license lucide-react v0.555.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const On=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],rs=L("cpu",On);/**
22
- * @license lucide-react v0.555.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Un=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Fn=L("gauge",Un);/**
27
- * @license lucide-react v0.555.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Kn=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ln=L("hash",Kn);/**
32
- * @license lucide-react v0.555.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Bn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Hn=L("info",Bn);/**
37
- * @license lucide-react v0.555.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Wn=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],as=L("message-circle-question-mark",Wn);/**
42
- * @license lucide-react v0.555.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Qn=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],Vn=L("message-square-text",Qn);/**
47
- * @license lucide-react v0.555.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const zn=[["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"}]],Gn=L("play",zn);/**
52
- * @license lucide-react v0.555.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const Yn=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],os=L("plug",Yn);/**
57
- * @license lucide-react v0.555.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const Jn=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Xn=L("server-cog",Jn);/**
62
- * @license lucide-react v0.555.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const Zn=[["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"}]],is=L("settings-2",Zn);/**
67
- * @license lucide-react v0.555.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const er=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],tr=L("share-2",er);/**
72
- * @license lucide-react v0.555.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const sr=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],nr=L("shield-check",sr);function ls(){return{tasks:{}}}const qt=3e4;function Pe(s){const t=s.trim();if(!t)return"agent";const n=t.split(/\s+/).slice(0,2).join(" ");return n.length>40?n.slice(0,40)+"…":n}function rr(s,t){var i,u,g,p,y,v,N,S,x,c,w,h;const n=t.subtype;if(n!=="task_started"&&n!=="task_progress"&&n!=="task_notification")return s;const r=t.task_id;if(!r)return s;const a=Date.now(),m=s.tasks[r];if(n==="task_started"){if(m)return{tasks:{...s.tasks,[r]:{...m,description:t.description??m.description,name:Pe(t.description??m.description),taskType:t.task_type??m.taskType,workflowName:t.workflow_name??m.workflowName,prompt:t.prompt??m.prompt,toolUseId:t.tool_use_id??m.toolUseId,status:"running",startTime:a,evictAfter:void 0}}};const b=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:Pe(b),description:b,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:a}}}}if(n==="task_progress"){if(!m){const b=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:Pe(b),description:b,toolUseId:t.tool_use_id,status:"running",startTime:a,tokenCount:(i=t.usage)==null?void 0:i.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(g=t.usage)==null?void 0:g.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...m,description:t.description??m.description,tokenCount:((p=t.usage)==null?void 0:p.total_tokens)??m.tokenCount,toolUseCount:((y=t.usage)==null?void 0:y.tool_uses)??m.toolUseCount,durationMs:((v=t.usage)==null?void 0:v.duration_ms)??m.durationMs,lastToolName:t.last_tool_name??m.lastToolName,summary:t.summary??m.summary}}}}return m?{tasks:{...s.tasks,[r]:{...m,status:t.status??"completed",endTime:a,finalSummary:t.summary??m.finalSummary,outputFile:t.output_file??m.outputFile,tokenCount:((c=t.usage)==null?void 0:c.total_tokens)??m.tokenCount,toolUseCount:((w=t.usage)==null?void 0:w.tool_uses)??m.toolUseCount,durationMs:((h=t.usage)==null?void 0:h.duration_ms)??m.durationMs,evictAfter:a+qt}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:Pe(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:a,endTime:a,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(S=t.usage)==null?void 0:S.tool_uses,durationMs:(x=t.usage)==null?void 0:x.duration_ms,evictAfter:a+qt}}}}function ar(s,t=Date.now()){return Object.values(s.tasks).filter(n=>n.evictAfter===void 0||n.evictAfter>t).sort((n,r)=>n.startTime-r.startTime)}function or(s){if(!s||typeof s!="object"||Array.isArray(s))return null;const t=s,n={file_search:t.file_search===!0,clear:t.clear===!0,set_max_thinking_tokens:t.set_max_thinking_tokens===!0,get_context_usage:t.get_context_usage===!0,stop_task:t.stop_task===!0,set_model:t.set_model===!0,set_permission_mode:t.set_permission_mode===!0,interrupt:t.interrupt===!0,end_session:t.end_session===!0,mcp_management:t.mcp_management===!0,remote_settings:t.remote_settings===!0,rewind:t.rewind===!0,resume:t.resume===!0,set_effort:t.set_effort===!0,side_question:t.side_question===!0};return Object.values(n).some(Boolean)?n:null}function Pt(s,t){const n=[];if(Array.isArray(s)){for(const r of s){if(!r||typeof r!="object")continue;const a=r;if(typeof a.name!="string"||!a.name)continue;const m=a.type==="prompt"||a.type==="local"||a.type==="local-jsx"?a.type:void 0;n.push({name:a.name,...typeof a.description=="string"&&a.description?{description:a.description}:{},...typeof a.argumentHint=="string"&&a.argumentHint?{argumentHint:a.argumentHint}:{},...m?{type:m}:{}})}if(n.length>0)return n}if(Array.isArray(t))for(const r of t)typeof r=="string"&&r&&n.push({name:r});return n}function Ot(s){const t=s.raw&&typeof s.raw=="object"&&!Array.isArray(s.raw)?s.raw:s,n=Pt(t.slash_command_details??s.slash_command_details,t.slash_commands??s.slash_commands),r=Pt(t.skill_details??s.skill_details,t.skills??s.skills),a=or(t.remote_capabilities??s.remote_capabilities);return n.length===0&&r.length===0&&!a?null:{commands:n,skills:r,capabilities:a}}class ir{constructor(t){M(this,"listeners",new Set);M(this,"stateListeners",new Set);M(this,"eventSource",null);M(this,"sessionId",null);M(this,"_lastSeqNum",0);M(this,"lastFrameAt",0);M(this,"firstEventAfterOpen",!1);M(this,"watchdogTimer",null);M(this,"visibilityHandler",null);M(this,"reconnectTimer",null);M(this,"reconnectAttempts",0);M(this,"_state","idle");M(this,"opts");this.opts={stallThresholdMs:45e3,watchdogTickMs:5e3,reconnectBaseDelayMs:1e3,reconnectMaxDelayMs:15e3,maxReconnectAttempts:6,...t}}get state(){return this._state}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onStateChange(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}connect(t){this.stopReconnectTimer(),this.reconnectAttempts=0,this.sessionId=t,this.openStream()}openStream(){if(this.closeStream(),!this.sessionId)return;this.setState("connecting");const t=this._lastSeqNum>0?`/web/sessions/${this.sessionId}/events?fromSeqNum=${this._lastSeqNum}`:`/web/sessions/${this.sessionId}/events`,n=new EventSource(t,{withCredentials:!0});this.eventSource=n,this.lastFrameAt=Date.now(),this.firstEventAfterOpen=!0,n.addEventListener("open",()=>{this.lastFrameAt=Date.now(),this.reconnectAttempts=0,this.firstEventAfterOpen=!0,this.setState("open")}),n.addEventListener("ping",()=>{this.lastFrameAt=Date.now()}),n.addEventListener("message",r=>{this.lastFrameAt=Date.now();try{const a=JSON.parse(r.data);if(this.firstEventAfterOpen&&(this.firstEventAfterOpen=!1,typeof a.seqNum=="number"&&a.seqNum<this._lastSeqNum&&(this._lastSeqNum=a.seqNum-1,this.notifyResync())),a.seqNum!==void 0&&a.seqNum<=this._lastSeqNum)return;a.seqNum!==void 0&&(this._lastSeqNum=a.seqNum);for(const m of this.listeners)m(a)}catch{}}),n.addEventListener("error",()=>{n.readyState===EventSource.CLOSED&&this.scheduleReconnect()}),this.startWatchdog()}disconnect(){this.sessionId=null,this.stopReconnectTimer(),this.closeStream(),this._lastSeqNum=0,this.reconnectAttempts=0,this.setState("idle")}closeStream(){this.stopWatchdog(),this.eventSource&&(this.eventSource.close(),this.eventSource=null)}startWatchdog(){this.stopWatchdog(),this.watchdogTimer=setInterval(()=>{this.probeStall()},this.opts.watchdogTickMs),typeof document<"u"&&(this.visibilityHandler=()=>{document.visibilityState==="visible"&&this.probeStall()},document.addEventListener("visibilitychange",this.visibilityHandler))}probeStall(){const t=this.eventSource;!t||t.readyState!==EventSource.OPEN||Date.now()-this.lastFrameAt<=this.opts.stallThresholdMs||this.scheduleReconnect()}stopWatchdog(){this.watchdogTimer&&(clearInterval(this.watchdogTimer),this.watchdogTimer=null),this.visibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}stopReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}scheduleReconnect(){if(this.reconnectTimer||!this.sessionId)return;if(this.closeStream(),this.reconnectAttempts++,this.reconnectAttempts>this.opts.maxReconnectAttempts){this.setState("failed");return}this.setState("reconnecting");const t=Math.min(this.opts.reconnectBaseDelayMs*2**(this.reconnectAttempts-1),this.opts.reconnectMaxDelayMs),n=Math.max(0,t+t*.25*(2*Math.random()-1));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnect()},n)}async reconnect(){this.sessionId&&(await Qs(),this.sessionId&&this.openStream())}setState(t){if(this._state!==t){this._state=t;for(const n of this.stateListeners)n(t,{})}}notifyResync(){for(const t of this.stateListeners)t(this._state,{resync:!0})}}const ie=new ir;function nt(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("")}return""}function Ut(s,t){for(let n=s.length-1;n>=0;n--){const r=s[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}const rt="streaming-";function lr(s){const t=s.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const n=[];for(const r of t.content)if((r==null?void 0:r.type)==="thinking"){const a=typeof r.thinking=="string"&&r.thinking||typeof r.text=="string"&&r.text||"";a&&n.push(a)}return n.join("")}function Ft(s){return s.filter(t=>typeof t.subject=="string"&&t.subject).map(t=>({content:t.subject,priority:"medium",status:t.status==="completed"?"completed":t.status==="in_progress"?"in_progress":"pending"}))}function Kt(s){if(!s||typeof s!="object")return"";const t=s;if(typeof t.target_event_id=="string"&&t.target_event_id)return t.target_event_id;const n=t.raw;if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.target_event_id;if(typeof r=="string"&&r)return r}return""}class cr{constructor(t,n,r){M(this,"sessionId");M(this,"setEntries");M(this,"unsub",null);M(this,"unsubState",null);M(this,"onStatusChange");M(this,"onError");M(this,"onPermissionRequest");M(this,"onModelsStateChange");M(this,"onSubagentUpdate");M(this,"onControlResponse");M(this,"onPermissionModeChange");M(this,"onUsageChange");M(this,"onElicitationRequest");M(this,"onWorkerInfoChange");M(this,"subagentState",ls());M(this,"seenUuids",new Set);M(this,"seenToolCallIds",new Set);M(this,"postedUserUuids",new Set);M(this,"pendingControlRequests",new Map);M(this,"turnEnded",!1);M(this,"userSinceTurnEnd",!1);M(this,"closed",!1);this.sessionId=t,this.setEntries=n,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate,this.onControlResponse=r==null?void 0:r.onControlResponse,this.onPermissionModeChange=r==null?void 0:r.onPermissionModeChange,this.onUsageChange=r==null?void 0:r.onUsageChange,this.onElicitationRequest=r==null?void 0:r.onElicitationRequest,this.onWorkerInfoChange=r==null?void 0:r.onWorkerInfoChange}markClosed(){this.closed=!0}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var v,N,S,x,c,w;const{events:t}=await Ks(this.sessionId);if(!t||t.length===0)return;const n=new Set;for(const h of t){if(h.type!=="user"||h.direction==="inbound")continue;const b=(v=h.payload)==null?void 0:v.uuid;typeof b=="string"&&b&&n.add(b)}const r=[];let a=null;const m=()=>{a&&(r.push(a),a=null)};for(const h of t){const b=h.payload||{},k=b.uuid;if(typeof k=="string"&&k&&this.seenUuids.add(k),h.type==="tool_use"){const j=b.tool_call_id;typeof j=="string"&&j&&this.seenToolCallIds.add(j)}if(h.type==="user"){if(h.direction==="inbound"){const T=b.uuid;if(typeof T!="string"||!T||n.has(T))continue}m();const j=nt(b);j&&r.push({type:"user_message",id:h.id||`hist-user-${r.length}`,content:j})}else if(h.type==="assistant"){m();const j=nt(b);if(Tt(j))continue;const T=[],I=b.message;if(I&&typeof I=="object"&&Array.isArray(I.content)){for(const D of I.content)if(D.type==="tool_use"){const B=D.id;B&&this.seenToolCallIds.add(B),T.push({type:"tool_call",toolCall:{id:B||`hist-tool-${r.length}`,title:D.name||"tool",status:"complete",rawInput:D.input||{}}})}}if(j||T.length>0){a={type:"assistant_message",id:h.id||`hist-asst-${r.length}`,chunks:j?[{type:"message",text:j}]:[]},r.push(a);for(const D of T)r.push(D);a=null}}else if(h.type==="conversation_rewound"){const j=Kt(b);if(j){const T=r.findIndex(I=>Mt(I)===j);T>=0&&(r.length=T)}}else if(h.type==="tool_use"){const j=b,T={type:"tool_call",toolCall:{id:j.tool_call_id||`hist-tool-${r.length}`,title:j.tool_name||"tool",status:"complete",rawInput:j.tool_input||{}}};r.push(T)}else if(h.type==="tool_result"){const j=b,T=Ut(r,j.tool_call_id||"");if(T>=0){const I=r[T];r[T]={type:"tool_call",toolCall:{...I.toolCall,rawOutput:{output:j.content||j.output||""}}}}}}m();let i=null;for(const h of t){if(h.type!=="task_state")continue;const b=h.payload||{};Array.isArray(b.tasks)&&(i=b.tasks)}if(i&&i.length>0){const h=Ft(i);h.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:h})}this.setEntries(r);let u=null,g=null,p=null,y=null;for(const h of t){const b=h.payload||{};if(h.type==="user"?y="user":(h.type==="result"||h.type==="result_success"||h.type==="interrupt")&&(y="turn_end"),h.type==="system"&&(b.subtype==="init"||((N=b.raw)==null?void 0:N.subtype)==="init")&&(g=Ot(b)),h.type==="models_state"){const k=b.raw,j=k&&typeof k=="object"?k.models_state:b.models_state;j&&Array.isArray(j.availableModels)&&typeof j.currentModelId=="string"&&(u=j)}else if(h.type==="result"||h.type==="result_success"){const k=b.usage,j=typeof b.total_cost_usd=="number"?b.total_cost_usd:null;(k||j!==null)&&(p={inputTokens:((k==null?void 0:k.input_tokens)??0)+((k==null?void 0:k.cache_read_input_tokens)??0)+((k==null?void 0:k.cache_creation_input_tokens)??0),outputTokens:(k==null?void 0:k.output_tokens)??0,totalCostUsd:j})}}u&&((S=this.onModelsStateChange)==null||S.call(this,u)),g&&((x=this.onWorkerInfoChange)==null||x.call(this,g)),p&&((c=this.onUsageChange)==null||c.call(this,p)),this.turnEnded=y==="turn_end",this.userSinceTurnEnd=y==="user",this.turnEnded&&!this.closed&&((w=this.onStatusChange)==null||w.call(this,"idle"))}connectSSE(){ie.connect(this.sessionId),this.unsub=ie.onEvent(t=>this.handleEvent(t)),this.unsubState=ie.onStateChange((t,n)=>{n.resync&&!this.closed&&this.loadHistory().catch(()=>{})})}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),this.unsubState&&(this.unsubState(),this.unsubState=null),ie.disconnect()}handleEvent(t){var a,m,i,u,g,p,y,v,N,S;const n=t.type,r=t.payload||{};switch(n){case"user":{if(this.userSinceTurnEnd=!0,t.direction==="inbound"){const x=r.uuid;if(typeof x!="string"||!x||this.postedUserUuids.has(x)||this.seenUuids.has(x))break;this.seenUuids.add(x);const c=nt(r);c&&this.setEntries(w=>[...w,{type:"user_message",id:t.id||`user-${Date.now()}`,content:c}])}break}case"assistant":{const x=r.uuid;if(typeof x=="string"&&x){if(this.seenUuids.has(x))break;this.seenUuids.add(x)}const c=typeof r.content=="string"?r.content:"";if(Tt(c))break;const w=lr(r);this.setEntries(b=>{const k=b[b.length-1];if((k==null?void 0:k.type)==="assistant_message"&&k.id.startsWith(rt))return[...b.slice(0,-1),{...k,id:`assistant-${Date.now()}`,chunks:[...w?[{type:"thought",text:w}]:[],{type:"message",text:c}]}];if((k==null?void 0:k.type)==="assistant_message"){const j=k.chunks[k.chunks.length-1];return(j==null?void 0:j.type)==="message"?[...b.slice(0,-1),{...k,chunks:[...k.chunks.slice(0,-1),{type:"message",text:j.text+c}]}]:[...b.slice(0,-1),{...k,chunks:[...k.chunks,{type:"message",text:c}]}]}if(c&&c.trim()||w){const j={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...w?[{type:"thought",text:w}]:[],...c?[{type:"message",text:c}]:[]]};return[...b,j]}return b});const h=r.message;if(h&&typeof h=="object"&&Array.isArray(h.content)){const b=h.content.filter(k=>k.type==="tool_use");for(const k of b){const j=k.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(j))continue;this.seenToolCallIds.add(j);const T={id:j,title:k.name||"tool",status:"running",rawInput:k.input||{}};this.setEntries(I=>[...I,{type:"tool_call",toolCall:T}])}}break}case"tool_use":{const x=r,c=x.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(c))break;this.seenToolCallIds.add(c);const w={id:c,title:x.tool_name||"tool",status:"running",rawInput:x.tool_input||{}};this.setEntries(h=>[...h,{type:"tool_call",toolCall:w}]);break}case"tool_result":{const x=r,c=x.tool_call_id||"";this.setEntries(w=>{const h=Ut(w,c);if(h<0)return w;const b=w[h];return w.map((k,j)=>j===h?{type:"tool_call",toolCall:{...b.toolCall,status:"complete",rawOutput:{output:x.content||x.output||""}}}:k)});break}case"control_request":case"permission_request":{const x=r.request;if(x&&x.subtype==="can_use_tool"){const c=r.request_id||"",w=x.tool_name||"unknown",h=x.input||x.tool_input||{},b=x.description||"",k=Array.isArray(x.permission_suggestions)?x.permission_suggestions:[];this.setEntries(j=>{const T=[...j].reverse().findIndex(I=>I.type==="tool_call");if(T>=0){const I=j.length-1-T,D=j[I];if(D.toolCall.status==="running")return j.map((B,te)=>te===I?{type:"tool_call",toolCall:{...D.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:c,options:[]}}}:B)}return j}),(a=this.onPermissionRequest)==null||a.call(this,{requestId:c,toolName:w,toolInput:h,description:b,suggestions:k})}else x&&x.subtype==="elicitation"&&((m=this.onElicitationRequest)==null||m.call(this,{requestId:r.request_id||"",serverName:x.mcp_server_name||"",message:x.message||"",mode:x.mode==="url"?"url":"form",url:typeof x.url=="string"?x.url:void 0,requestedSchema:x.requested_schema||void 0}));break}case"conversation_rewound":{const x=Kt(r);x&&this.setEntries(c=>{const w=c.findIndex(h=>Mt(h)===x);return w===-1?c:c.slice(0,w)});break}case"session_status":{if(Ls(r)){this.setEntries([]);break}if(typeof r.status=="string"){if(Oe(r.status))this.closed=!0;else if(this.closed)break;if(r.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(i=this.onStatusChange)==null||i.call(this,r.status)}break}case"error":{const x=String(r.message||r.content||"Unknown error");(u=this.onError)==null||u.call(this,x);break}case"models_state":{const x=r.raw,c=typeof x=="object"&&x!==null?x.models_state:r.models_state;c&&Array.isArray(c.availableModels)&&typeof c.currentModelId=="string"&&((g=this.onModelsStateChange)==null||g.call(this,c));break}case"system":{const x=r.raw,c=x&&typeof x=="object"?x:r,w=typeof c.subtype=="string"?c.subtype:void 0;if(w==="task_started"||w==="task_progress"||w==="task_notification"){const b={subtype:w,task_id:typeof c.task_id=="string"?c.task_id:void 0,tool_use_id:typeof c.tool_use_id=="string"?c.tool_use_id:void 0,description:typeof c.description=="string"?c.description:void 0,task_type:typeof c.task_type=="string"?c.task_type:void 0,workflow_name:typeof c.workflow_name=="string"?c.workflow_name:void 0,prompt:typeof c.prompt=="string"?c.prompt:void 0,usage:c.usage&&typeof c.usage=="object"?c.usage:void 0,last_tool_name:typeof c.last_tool_name=="string"?c.last_tool_name:void 0,summary:typeof c.summary=="string"?c.summary:void 0,status:c.status==="completed"||c.status==="failed"||c.status==="stopped"?c.status:void 0,output_file:typeof c.output_file=="string"?c.output_file:void 0};this.subagentState=rr(this.subagentState,b)}const h=typeof c.permissionMode=="string"?c.permissionMode:typeof r.permissionMode=="string"?r.permissionMode:null;if(h&&((p=this.onPermissionModeChange)==null||p.call(this,h)),w==="init"){const b=Ot(r);b&&((y=this.onWorkerInfoChange)==null||y.call(this,b))}break}case"control_response":{const x=r.response;if(x&&typeof x=="object"){const c=typeof x.request_id=="string"?x.request_id:"",w=typeof x.subtype=="string"?x.subtype:"";if(c){(v=this.onControlResponse)==null||v.call(this,{subtype:w,requestId:c,error:typeof x.error=="string"?x.error:void 0});const h=this.pendingControlRequests.get(c);h&&(this.pendingControlRequests.delete(c),h({data:w==="success"&&x.response&&typeof x.response=="object"?x.response:null,...w==="error"&&typeof x.error=="string"?{error:x.error}:{}}))}}break}case"stream_event":{const x=r.event;if(!x||typeof x.type!="string")break;if(x.type==="content_block_delta"){const c=x.delta;if(!c||typeof c.type!="string")break;const w=c.type==="text_delta"?"message":c.type==="thinking_delta"?"thought":null;if(!w)break;const h=c.text??c.thinking;if(typeof h!="string"||!h)break;this.appendStreamingDelta(w,h)}break}case"partial_assistant":{const x=typeof r.content=="string"?r.content:"";x&&this.appendStreamingDelta("message",x);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.closed||(N=this.onStatusChange)==null||N.call(this,"idle");const x=r.usage,c=typeof r.total_cost_usd=="number"?r.total_cost_usd:null;if(x||c!==null){const j=((x==null?void 0:x.input_tokens)??0)+((x==null?void 0:x.cache_read_input_tokens)??0)+((x==null?void 0:x.cache_creation_input_tokens)??0);(S=this.onUsageChange)==null||S.call(this,{inputTokens:j,outputTokens:(x==null?void 0:x.output_tokens)??0,totalCostUsd:c})}const w=typeof r.subtype=="string"?r.subtype:"",h=r.raw&&typeof r.raw=="object"?r.raw:void 0,k=(typeof r.result=="string"?r.result:typeof(h==null?void 0:h.result)=="string"?h.result:"").trim();w.startsWith("error_")&&k&&this.setEntries(j=>[...j,{type:"command_output",id:`exit-error-${typeof r.uuid=="string"?r.uuid:Date.now()}`,commandName:"worker",inputText:"",title:d("adapter.workerCrashed"),outputText:k,variant:"error"}]);break}case"task_state":{const x=Array.isArray(r.tasks)?r.tasks:[];if(x.length===0)break;const c=Ft(x);if(c.length===0)break;this.setEntries(w=>[...w.filter(b=>b.type!=="plan"),{type:"plan",id:`plan-${r.task_list_id||Date.now()}`,entries:c}]);break}}}appendStreamingDelta(t,n){this.setEntries(r=>{const a=r[r.length-1];if((a==null?void 0:a.type)==="assistant_message"&&a.id.startsWith(rt)){const i=a.chunks[a.chunks.length-1];return(i==null?void 0:i.type)===t?[...r.slice(0,-1),{...a,chunks:[...a.chunks.slice(0,-1),{type:t,text:i.text+n}]}]:[...r.slice(0,-1),{...a,chunks:[...a.chunks,{type:t,text:n}]}]}const m={type:"assistant_message",id:`${rt}${Date.now()}`,chunks:[{type:t,text:n}]};return[...r,m]})}async sendMessage(t,n,r){var p;const a=n&&n.length>0,m=r&&r.length>0;if(!t.trim()&&!a&&!m)return;const i={type:"user_message",id:`user-${Date.now()}`,content:t,images:a?n:void 0,attachments:m?r:void 0};this.setEntries(y=>[...y,i]);const u=[];if(t&&u.push({type:"text",text:t}),a)for(const y of n)u.push({type:"image",source:{type:"base64",media_type:y.mimeType,data:y.data}});if(m){for(const y of r)if(y.kind==="text"||y.kind==="table"){const v=`📎 ${y.name}${y.size!=null?` (${dr(y.size)})`:""}`,N=y.textContent||d("attach.emptyFile");u.push({type:"text",text:`${v}
77
- \`\`\`
78
- ${N}
79
- \`\`\``})}else if(y.kind==="directory"){const v=y.files!=null?`${O("attach.directoryHeader",{name:y.name})} ${O("attach.fileCount",{n:y.files.length})}`:O("attach.directoryHeader",{name:y.name}),N=y.textContent||d("attach.emptyDirectory");u.push({type:"text",text:`${v}
80
- ${N}`})}}const g=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;try{const y=oe();this.postedUserUuids.add(y);const v=await Bs(this.sessionId,{type:"user",uuid:y,content:t,message:{content:g}}),N=(p=v==null?void 0:v.event)==null?void 0:p.id;N&&this.setEntries(S=>S.map(x=>x.type==="user_message"&&x.id===i.id?{...x,id:N}:x))}catch(y){throw this.setEntries(v=>v.filter(N=>!(N.type==="user_message"&&N.id===i.id))),y}}async respondPermission(t,n,r){await z(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(a=>a.map(m=>{var i;return m.type!=="tool_call"||((i=m.toolCall.permissionRequest)==null?void 0:i.requestId)!==t?m:{type:"tool_call",toolCall:{...m.toolCall,status:n?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(n=>n.type!=="tool_call"||n.toolCall.status!=="running"&&n.toolCall.status!=="waiting_for_confirmation"?n:{type:"tool_call",toolCall:{...n.toolCall,status:"canceled",permissionRequest:void 0}})),await Hs(this.sessionId)}async setPermissionMode(t){const n=oe();return await z(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"set_permission_mode",mode:t}}),n}async controlRoundTrip(t,n=8e3){const r=oe(),a=new Promise(i=>{this.pendingControlRequests.set(r,i)}),m=setTimeout(()=>{const i=this.pendingControlRequests.get(r);i&&(this.pendingControlRequests.delete(r),i({data:null,error:"timeout"}))},n);try{return await z(this.sessionId,{type:"control_request",request_id:r,request:t}),await a}catch(i){throw this.pendingControlRequests.delete(r),i}finally{clearTimeout(m)}}async searchFiles(t,n=20){const r=await this.controlRoundTrip({subtype:"file_search",query:t,limit:n});try{if(!r.data||!Array.isArray(r.data.suggestions))return[];const a=[];for(const m of r.data.suggestions)m&&typeof m=="object"&&typeof m.path=="string"&&a.push(m.path);return a}catch{return[]}}async respondElicitation(t,n,r){await z(this.sessionId,{type:"permission_response",approved:n==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:n,...r?{content:r}:{}}}})}async askSideQuestion(t){const n=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(n.error||!n.data)return null;const r=n.data.response;return typeof r=="string"?r:null}async listResumableSessions(){const t=await this.controlRoundTrip({subtype:"list_sessions"});if(!t.data||!Array.isArray(t.data.sessions))throw new Error(t.error??"list_sessions failed");const n=[];for(const r of t.data.sessions){if(!r||typeof r!="object")continue;const a=r;typeof a.session_id!="string"||!a.session_id||n.push({sessionId:a.session_id,title:typeof a.title=="string"&&a.title?a.title:a.session_id.slice(0,8),modified:typeof a.modified=="number"?a.modified:0,...typeof a.created_at=="number"?{createdAt:a.created_at}:{},...typeof a.git_branch=="string"&&a.git_branch?{gitBranch:a.git_branch}:{}})}return n}async resumeSession(t){const n=await this.controlRoundTrip({subtype:"resume_session",session_id:t},3e4);if(!n.data)throw new Error(n.error??"resume_session failed");return{title:typeof n.data.title=="string"?n.data.title:null,messageCount:typeof n.data.message_count=="number"?n.data.message_count:0}}async setEffort(t){const n=oe();return await z(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),n}async setThinkingBudget(t){const n=oe();return await z(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:t}}),n}async getContextUsage(){const t=await this.controlRoundTrip({subtype:"get_context_usage"});try{if(!t.data)return null;const n=t.data.totalTokens,r=t.data.rawMaxTokens,a=t.data.percentage;if(typeof n!="number"||typeof r!="number")return null;const m=t.data.categories,i=Array.isArray(m)?m.filter(u=>!!u&&typeof u=="object"&&typeof u.name=="string").map(u=>({name:u.name,tokens:typeof u.tokens=="number"?u.tokens:0,...u.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:n,rawMaxTokens:r,percentage:typeof a=="number"?a:0,...typeof t.data.model=="string"&&t.data.model?{model:t.data.model}:{},...i&&i.length>0?{categories:i}:{}}}catch{return null}}async stopSubagent(t){const n=await this.controlRoundTrip({subtype:"stop_task",task_id:t});try{return n.error?{ok:!1,error:n.error==="timeout"?d("adapter.stopTimeout"):n.error}:{ok:!0}}catch{return{ok:!1,error:d("adapter.stopFailed")}}}async getMcpServers(){var a;const n=(a=(await this.controlRoundTrip({subtype:"mcp_status"})).data)==null?void 0:a.mcpServers;if(!Array.isArray(n))return[];const r=[];for(const m of n){if(!m||typeof m!="object")continue;const i=m;if(typeof i.name!="string"||!i.name)continue;const u=i.status;if(u!=="connected"&&u!=="failed"&&u!=="needs-auth"&&u!=="pending"&&u!=="disabled")continue;const g=i.serverInfo,p=i.config;r.push({name:i.name,status:u,...g&&typeof g.name=="string"&&typeof g.version=="string"?{serverInfo:{name:g.name,version:g.version}}:{},...typeof i.error=="string"&&i.error?{error:i.error}:{},...typeof(p==null?void 0:p.url)=="string"&&p.url?{url:p.url}:{},...Array.isArray(i.tools)?{toolCount:i.tools.length}:{}})}return r}async toggleMcpServer(t,n){const r=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:n},15e3);return r.error?{ok:!1,error:r.error==="timeout"?d("adapter.requestTimeout"):r.error}:{ok:!0}}async reconnectMcpServer(t){const n=await this.controlRoundTrip({subtype:"mcp_reconnect",serverName:t},2e4);return n.error?{ok:!1,error:n.error==="timeout"?d("adapter.requestTimeout"):n.error}:{ok:!0}}async getRemoteSettings(){const n=(await this.controlRoundTrip({subtype:"get_settings"})).data;if(!n)return null;const r=n.applied,a=n.effective&&typeof n.effective=="object"&&!Array.isArray(n.effective)?n.effective:{},m=n.sources,i=[];if(Array.isArray(m))for(const u of m){if(!u||typeof u!="object")continue;const g=u;typeof g.source=="string"&&i.push({source:g.source,settings:g.settings&&typeof g.settings=="object"&&!Array.isArray(g.settings)?g.settings:{}})}return{applied:{model:typeof(r==null?void 0:r.model)=="string"?r.model:null,effort:typeof(r==null?void 0:r.effort)=="string"?r.effort:null},effective:a,sources:i}}async applyFlagSettings(t){const n=await this.controlRoundTrip({subtype:"apply_flag_settings",settings:t},15e3);return n.error?{ok:!1,error:n.error==="timeout"?d("adapter.requestTimeout"):n.error}:{ok:!0}}async rewindToMessage(t){await Ws(this.sessionId,t)}async endSession(t){await z(this.sessionId,{type:"control_request",request_id:oe(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function dr(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ur(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function mr(s){return s?Date.now()-s<6e4:!1}function xr({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:a,onDelete:m,onEndSession:i}){const[u,g]=l.useState(!1),p=async()=>{await navigator.clipboard.writeText(t.id),g(!0),setTimeout(()=>g(!1),1500)},[y,v]=l.useState(!1),N=async()=>{if(!(!i||y)&&window.confirm(d("task.endConfirm"))){v(!0);try{await i(),s()}catch{v(!1)}}},S=r.length,x=t.worker,c=t.work_item,w=t.environment;return e.jsx(de,{open:!0,onOpenChange:h=>{h||s()},children:e.jsxs(ue,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(me,{children:e.jsx(xe,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(In,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:x&&(mr(x.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Rt,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ur(x.last_heartbeat_at)})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(rs,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:w.machine_name||w.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Rt,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ts(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),S>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[S," permission request",S>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Xn,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:a,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),i&&e.jsx("button",{onClick:N,disabled:y,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:d("task.endHint"),children:y?"Ending…":"End session"}),e.jsxs("button",{onClick:m,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(Vs,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Ln,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:p,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:u?"✓":"⧉"})]})]}),c&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:c.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:c.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:w.worker_type})]})]})]})]})]})})}const fr={connected:"bg-status-success/15 text-status-success",failed:"bg-status-error/15 text-status-error","needs-auth":"bg-status-warning/15 text-status-warning",pending:"bg-status-active/15 text-status-active",disabled:"bg-surface-3 text-text-muted"},pr={connected:"mcp.status.connected",failed:"mcp.status.failed","needs-auth":"mcp.status.needsAuth",pending:"mcp.status.pending",disabled:"mcp.status.disabled"};function hr({onClose:s,fetchServers:t,onToggle:n,onReconnect:r}){J();const[a,m]=l.useState(null),[i,u]=l.useState(null),[g,p]=l.useState(null),[y,v]=l.useState(null),N=l.useCallback(async()=>{p(null),v(null);try{const c=await t();m(c),u(null)}catch(c){Ue("[McpPanel] fetch failed",c),u(d("mcp.loadFailed"))}},[t]);l.useEffect(()=>{N()},[N]);const S=async c=>{const w=c.status==="disabled";p(`toggle:${c.name}`),v(null);try{const h=await n(c.name,w);h.ok||v(h.error||d("mcp.toggleFailed"))}finally{await N()}},x=async c=>{p(`reconnect:${c.name}`),v(null);try{const w=await r(c.name);w.ok||v(w.error||d("mcp.reconnectFailed"))}finally{await N()}};return e.jsx(de,{open:!0,onOpenChange:c=>{c||s()},children:e.jsxs(ue,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(os,{className:"h-4 w-4"}),d("session.mcp.title")]})}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[y&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:y}),a===null&&!i&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),d("mcp.loading")]}),i&&e.jsx("p",{className:"text-xs text-status-error",children:i}),a!==null&&a.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:d("mcp.empty")}),a==null?void 0:a.map(c=>{const w=g===`toggle:${c.name}`,h=g===`reconnect:${c.name}`,b=c.status==="disabled";return e.jsx("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:c.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${fr[c.status]}`,children:d(pr[c.status])})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[c.serverInfo?`${c.serverInfo.name} v${c.serverInfo.version}`:c.url||"stdio",c.toolCount!==void 0&&` · ${O("mcp.toolCount",{n:c.toolCount})}`]}),c.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:c.error,children:c.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void x(c),disabled:h||b,className:"rounded-md p-1.5 text-text-muted hover:bg-surface-3 hover:text-text-primary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:d("mcp.reconnect"),children:e.jsx(_n,{className:`h-3.5 w-3.5 ${h?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!b,onClick:()=>void S(c),disabled:w,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${b?"bg-surface-3":"bg-brand"}`,title:b?d("mcp.enable"):d("mcp.disable"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${b?"left-0.5":"left-4.5"}`})})]})]})},c.name)})]})]})})}function yr(s){if(s==null)return d("settings.unset");if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}function Lt(s){if(s==null)return d("settings.unset");if(typeof s=="object")try{return JSON.stringify(s,null,2)}catch{return String(s)}return String(s)}function gr({onClose:s,fetchSettings:t,onApply:n}){J();const[r,a]=l.useState(null),[m,i]=l.useState(null),[u,g]=l.useState(""),[p,y]=l.useState(null),[v,N]=l.useState(null),[S,x]=l.useState(null),[c,w]=l.useState(!1),h=l.useCallback(async()=>{y(null),N(null),x(null),w(!1);try{const E=await t();a(E),i(E?null:d("settings.loadFailed"))}catch(E){Ue("[SettingsDrawer] fetch failed",E),i(d("settings.loadFailed"))}},[t]);l.useEffect(()=>{h()},[h]);const b=l.useMemo(()=>r?Object.entries(r.effective).filter(([,E])=>E!==void 0).sort(([E],[U])=>E.localeCompare(U)):[],[r]),k=l.useMemo(()=>{const E=u.trim().toLowerCase();return E?b.filter(([U,V])=>`${U} ${yr(V)}`.toLowerCase().includes(E)):b},[b,u]),j=E=>typeof E[1]=="boolean",T=l.useMemo(()=>k.filter(j),[k]),I=l.useMemo(()=>k.filter(E=>!j(E)),[k]),D=l.useMemo(()=>S===null?null:b.find(([E])=>E===S)??null,[b,S]),B=async()=>{if(D)try{await navigator.clipboard.writeText(Lt(D[1])),w(!0),window.setTimeout(()=>w(!1),1500)}catch(E){Ue("[SettingsDrawer] copy failed",E)}},te=async(E,U)=>{y(E),N(null);try{const V=await n({[E]:!U});V.ok||N(V.error||d("settings.writeFailed"))}finally{await h()}};return e.jsx(de,{open:!0,onOpenChange:E=>{E||s()},children:e.jsxs(ue,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(is,{className:"h-4 w-4"}),d("session.settings.title")]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[v&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:v}),r===null&&!m&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),d("settings.loading")]}),m&&e.jsx("p",{className:"text-xs text-status-error",children:m}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:d("settings.model")}),e.jsx("code",{className:"font-mono text-text-secondary",children:r.applied.model||d("settings.defaultModel")})]}),r.applied.effort&&e.jsxs("div",{className:"mt-1 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"Effort"}),e.jsx("code",{className:"font-mono text-text-secondary",children:r.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-text-muted",children:d("settings.hint")})]}),D?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>{x(null),w(!1)},className:"flex items-center gap-1.5 text-xs text-text-muted transition-colors hover:text-text-primary",children:[e.jsx(qn,{className:"h-3.5 w-3.5"}),d("settings.back")]}),e.jsx("div",{className:"break-all font-mono text-xs font-medium text-text-primary",children:D[0]}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 p-3 font-mono text-[11px] leading-relaxed text-text-secondary",children:Lt(D[1])}),e.jsxs("button",{type:"button",onClick:()=>void B(),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:[c?e.jsx(Se,{className:"h-3.5 w-3.5 text-status-success"}):e.jsx(Sn,{className:"h-3.5 w-3.5"}),c?d("settings.copied"):d("settings.copyValue")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2.5 py-1.5",children:[e.jsx(it,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:u,onChange:E=>g(E.target.value),placeholder:d("settings.searchPlaceholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),k.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:d("settings.noMatch")}),T.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted",children:O("settings.togglable",{n:T.length})}),T.map(([E,U])=>{const V=p===E;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2",children:[e.jsx("div",{className:"truncate font-mono text-xs text-text-primary",children:E}),e.jsx("button",{type:"button",role:"switch","aria-checked":U,disabled:V,onClick:()=>void te(E,U),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${U?"bg-brand":"bg-surface-3"}`,title:U?d("settings.turnOff"):d("settings.turnOn"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${U?"left-4.5":"left-0.5"}`})})]},E)})]}),I.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted",children:O("settings.readOnly",{n:I.length})}),I.map(([E])=>e.jsxs("button",{type:"button",onClick:()=>x(E),className:"flex w-full items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2 text-left transition-colors hover:bg-surface-3",title:d("settings.viewDetail"),children:[e.jsx("span",{className:"truncate font-mono text-xs text-text-primary",children:E}),e.jsx(ns,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},E))]})]})]})]})]})})}function br({onClose:s,onAsk:t}){J();const[n,r]=l.useState([]),[a,m]=l.useState(""),[i,u]=l.useState(!1),g=async()=>{const p=a.trim();if(!p||i)return;const y=Date.now();r(v=>[...v,{id:y,question:p,answer:null}]),m(""),u(!0);try{const v=await t(p);r(N=>N.map(S=>S.id===y?{...S,answer:v??d("sideQuestion.noAnswer"),error:v===null}:S))}finally{u(!1)}};return e.jsx(de,{open:!0,onOpenChange:p=>{p||s()},children:e.jsxs(ue,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-[26rem] h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md flex flex-col",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(as,{className:"h-4 w-4"}),d("sideQuestion.title")]})}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-text-muted",children:d("sideQuestion.desc")}),e.jsxs("div",{className:"mt-3 flex-1 space-y-4 overflow-y-auto",children:[n.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:d("sideQuestion.empty")}),n.map(p=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md border border-user-bubble-border bg-user-bubble px-4 py-2 text-sm text-text-primary",children:p.question})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:24,height:24,className:"object-contain",draggable:!1})}),e.jsx("div",{className:"min-w-0 flex-1 pt-1 text-sm text-text-primary",children:p.answer===null?e.jsxs("span",{className:"chat-typing-indicator inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):e.jsx("div",{className:p.error?"text-status-error":"",children:e.jsx(zs,{children:p.answer})})})]})]},p.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:a,onChange:p=>m(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&!p.nativeEvent.isComposing&&(p.preventDefault(),g())},rows:Math.min(4,Math.max(1,a.split(`
81
- `).length)),placeholder:d("sideQuestion.placeholder"),disabled:i,className:"flex-1 resize-none rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"button",onClick:()=>void g(),disabled:i||!a.trim(),className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-brand text-white transition-colors hover:bg-brand-light disabled:opacity-40 disabled:cursor-not-allowed",title:d("sideQuestion.send"),children:i?e.jsx(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(Gs,{className:"h-4 w-4"})})]})]})})}const Bt="rcs:subagent-panel:collapsed";function wr(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;const a=Math.floor(n/60),m=n%60;return m?`${a}h${m}m`:`${a}h`}function jr(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function vr({status:s}){return s==="running"?e.jsx(_e,{className:"h-3 w-3 animate-spin text-brand-text"}):s==="completed"?e.jsx(Gn,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(Js,{className:"h-3 w-3 text-status-error"}):null}function kr({task:s,onStopTask:t}){const n=s.status==="running",r=n?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,a=jr(s.tokenCount),m=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",i=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"group/task flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(vr,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:wr(r)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:i}),(a||m||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[a&&e.jsxs("span",{children:["↕ ",a," tok"]}),m&&e.jsxs("span",{children:["· ",m]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!n&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]}),n&&t&&e.jsx("button",{type:"button",onClick:()=>t(s.taskId),title:d("subagent.stop"),className:"mt-0.5 flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:bg-status-error/10 hover:text-status-error focus:opacity-100 group-hover/task:opacity-100",children:e.jsx(Ys,{className:"h-3.5 w-3.5"})})]})}function Nr({state:s,onStopTask:t}){const[n,r]=l.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Bt)==="1"}catch{return!1}}),a=()=>{r(p=>{const y=!p;try{window.localStorage.setItem(Bt,y?"1":"0")}catch{}return y})},[,m]=l.useState(0);l.useEffect(()=>{const p=Object.values(s.tasks).some(N=>N.status==="running"),y=Object.values(s.tasks).some(N=>N.status!=="running"&&N.evictAfter!==void 0);if(!p&&!y)return;const v=setInterval(()=>{m(N=>N+1)},1e3);return()=>clearInterval(v)},[s]);const i=ar(s);if(i.length===0)return null;const u=i.filter(p=>p.status==="running").length,g=u>0?`${u} running`:`${i.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:a,"aria-expanded":!n,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ns,{className:`h-3 w-3 transition-transform ${n?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:g})]}),!n&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:i.map(p=>e.jsx(kr,{task:p,onStopTask:t},p.taskId))})]})})}const at="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-1";function Ht(s,t){var a;const n=(a=t==null?void 0:t.find(m=>m.type==="addRules"||m.type==="replaceRules"))==null?void 0:a.rules,r=n==null?void 0:n[0];return r!=null&&r.ruleContent?`${r.toolName}(${r.ruleContent})`:r!=null&&r.toolName?r.toolName:s}function _r({requestId:s,toolName:t,toolInput:n,description:r,suggestions:a,onApprove:m,onApproveAlways:i,onReject:u}){J();const g=n&&typeof n=="object"&&!Array.isArray(n)?n:{},p=Xs(Zs(t),g,{writeUnknownLabel:d("permission.writeUnknown")}),y=typeof n=="string"?n:JSON.stringify(n,null,2),v=Array.isArray(a)&&a.length>0;return e.jsxs("div",{role:"group","aria-label":O("permission.requestAria",{tool:t}),className:"rounded-xl border border-approve/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-approve/15 text-approve-text",children:e.jsx(en,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold font-display text-approve-text",children:d("permission.title")})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:Q(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:Q(t)}),t!=="AskUserQuestion"&&(p?e.jsx("div",{className:"mb-3 space-y-2",children:p.map((N,S)=>e.jsx(tn,{filePath:N.filePath,oldString:N.oldString,newString:N.newString,label:N.label},S))}):e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:At(y,500)})),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:m,className:ee("rounded-lg bg-approve px-4 py-2 text-sm font-medium font-display text-white hover:bg-approve-hover transition-colors",at),children:d("permission.approve")}),v&&i&&e.jsxs("button",{onClick:i,className:ee("flex items-center gap-1.5 rounded-lg border border-approve/40 bg-approve/10 px-4 py-2 text-sm font-medium font-display text-approve-text hover:bg-approve/20 transition-colors",at),title:d("permission.alwaysAllowHint").replace("{rule}",Ht(t,a)),children:[e.jsx(nr,{className:"h-3.5 w-3.5"}),d("permission.alwaysAllow")," ",At(Ht(t,a),40)]}),e.jsx("button",{onClick:u,className:ee("rounded-lg border border-status-error/40 px-4 py-2 text-sm font-medium font-display text-status-error hover:bg-status-error/10 transition-colors",at),children:d("permission.reject")})]})]})}function Sr({questions:s,description:t,onSubmit:n,onSkip:r}){const[a,m]=l.useState({}),[i,u]=l.useState({}),[g,p]=l.useState(0),y=(x,c,w)=>{if(w){const h=a[x]||[],b=h.includes(c)?h.filter(k=>k!==c):[...h,c];m({...a,[x]:b})}else m({...a,[x]:c})},v=x=>{var w;const c=(w=i[x])==null?void 0:w.trim();c&&(m({...a,[x]:c}),u({...i,[x]:""}))},N=()=>{var c,w;const x={};for(const[h,b]of Object.entries(a)){const k=s[parseInt(h,10)];k&&(typeof b=="number"?x[h]=((w=(c=k.options)==null?void 0:c[b])==null?void 0:w.label)||String(b):Array.isArray(b)?x[h]=b.map(j=>{var T,I;return((I=(T=k.options)==null?void 0:T[j])==null?void 0:I.label)||String(j)}):x[h]=b)}n(x)};if(s.length<=1){const x=s[0]||{question:t,options:[],multiSelect:!1},c=x.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold font-display text-text-primary",children:Q(t||x.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(x.options||[]).map((w,h)=>{const b=c?(a[0]||[]).includes(h):a[0]===h;return e.jsxs("button",{onClick:()=>y(0,h,c),className:ee("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",b?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium font-display",children:Q(w.label)}),w.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:Q(w.description)})]},h)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i[0]||"",onChange:w=>u({...i,0:w.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:w=>w.key==="Enter"&&v(0)}),e.jsx("button",{onClick:()=>v(0),className:"rounded-lg border border-border px-3 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const S=s[g];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold font-display text-text-primary",children:Q(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((x,c)=>e.jsx("button",{onClick:()=>p(c),className:ee("rounded-md px-3 py-1.5 text-xs font-display whitespace-nowrap transition-colors",g===c?"bg-brand/20 text-brand-text":"text-text-muted hover:bg-surface-2"),children:x.header||`Q${c+1}`},c))}),S&&e.jsx(Cr,{question:S,qIdx:g,answers:a,otherTexts:i,onSelect:y,onOtherTextChange:(x,c)=>u({...i,[x]:c}),onOtherSubmit:v}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-display text-text-muted",children:[g+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function Cr({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:a,onOtherTextChange:m,onOtherSubmit:i}){const u=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:Q(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((g,p)=>{const y=u?(n[t]||[]).includes(p):n[t]===p;return e.jsxs("button",{onClick:()=>a(t,p,u),className:ee("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",y?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium font-display",children:Q(g.label)}),g.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:Q(g.description)})]},p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:g=>m(t,g.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:g=>g.key==="Enter"&&i(t)}),e.jsx("button",{onClick:()=>i(t),className:"rounded-lg border border-border px-3 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function Er({planContent:s,description:t,onSubmit:n}){const[r,a]=l.useState(null),[m,i]=l.useState(""),u=!s||!s.trim(),g=()=>{r&&n(r,r==="no"?m:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand-text",children:e.jsx(Se,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold font-display text-text-primary",children:u?"Exit plan mode?":"Ready to code?"})]}),!u&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:Tr(s)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{selected:r==="yes-default",onClick:()=>a("yes-default"),label:"Yes"}),e.jsx(Ne,{selected:r==="no",onClick:()=>a("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{selected:r==="yes-accept-edits",onClick:()=>a("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(Ne,{selected:r==="yes-default",onClick:()=>a("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Ne,{selected:r==="no",onClick:()=>a("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:m,onChange:p=>i(p.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:g,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function Ne({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:ee("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:ee("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium font-display",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs font-sans text-text-muted",children:r})]})}function Tr(s){let t=Q(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,a)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${a.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function Mr({request:s,onSubmit:t}){J();const n=Rr(s.requestedSchema),r=Ar(s.requestedSchema),[a,m]=l.useState({}),i=n.length===0||r.every(u=>(a[u]??"").trim()!=="");return s.mode==="url"&&s.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Wt,{serverName:s.serverName,message:s.message}),e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-4 py-2.5 text-sm text-brand-text hover:bg-brand/10 transition-colors",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s.url}),e.jsx(Cn,{className:"ml-2 h-4 w-4 flex-shrink-0"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>t("accept"),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:d("elicitation.done")}),e.jsx("button",{onClick:()=>t("cancel"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:d("common.cancel")})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Wt,{serverName:s.serverName,message:s.message}),n.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:n.map(({name:u,prop:g})=>e.jsxs("label",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium text-text-primary",children:u}),r.includes(u)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:d("elicitation.required")})]}),g.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:Q(g.description)}),e.jsx("input",{type:g.type==="number"?"number":"text",value:a[u]??"",onChange:p=>m(y=>({...y,[u]:p.target.value})),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const u={};for(const{name:g,prop:p}of n){const y=(a[g]??"").trim();y&&(u[g]=p.type==="number"?Number(y):y)}t("accept",u)},disabled:!i,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:d("elicitation.submit")}),e.jsx("button",{onClick:()=>t("decline"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:d("elicitation.decline")})]})]})}function Wt({serverName:s,message:t}){return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand-text",children:e.jsx(Vn,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:[d("elicitation.title")," ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:Q(s)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:Q(t)})]})}function Rr(s){const t=s==null?void 0:s.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,n])=>n&&typeof n=="object").map(([n,r])=>({name:n,prop:r}))}function Ar(s){const t=s==null?void 0:s.required;return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function $r(s){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[m,i]=l.useState(null),u=l.useCallback(async()=>{a(!0),i(null);try{const y=await sn(s);n(y)}catch(y){i(y instanceof Error?y.message:"Failed to load shares")}finally{a(!1)}},[s]);l.useEffect(()=>{u()},[u]);const g=l.useCallback(async y=>{i(null);try{const v=await nn(s,y);return await u(),v}catch(v){throw i(v instanceof Error?v.message:"Failed to create share"),v}},[s,u]),p=l.useCallback(async y=>{i(null);try{await rn(s,y),await u()}catch(v){throw i(v instanceof Error?v.message:"Failed to revoke share"),v}},[s,u]);return{shares:t,isLoading:r,error:m,createShare:g,revokeShare:p,refresh:u}}function Ir({open:s,onClose:t,sessionId:n,sessionTitle:r}){J();const{shares:a,isLoading:m,error:i,createShare:u,revokeShare:g}=$r(n),[p,y]=l.useState("user"),[v,N]=l.useState(""),[S,x]=l.useState(""),[c,w]=l.useState("read"),[h,b]=l.useState(""),[k,j]=l.useState(!1),[T,I]=l.useState(null),[D,B]=l.useState(""),[te,E]=l.useState(!1),[U,V]=l.useState(!1);l.useEffect(()=>{s&&(y("user"),N(""),x(""),w("read"),b(""),j(!1),I(null),B(""),E(!1),V(!1))},[s]);const Ce=async()=>{j(!0),B(""),I(null);try{const A={grantedTo:p==="user"?{userId:v.trim()}:{teamId:S.trim()},permission:c};h.trim()&&(A.expiresAt=h.trim());const fe=await u(A);I(`${window.location.origin}/code/s/${fe.shareToken}`)}catch(A){B(A instanceof Error?A.message:"Failed to create share")}finally{j(!1)}},Ee=async A=>{try{await g(A)}catch{}},Y=async()=>{if(!T)return;V(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),E(!0),setTimeout(()=>E(!1),2e3);return}}catch{}const A=document.createElement("textarea");A.value=T,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy"),E(!0),setTimeout(()=>E(!1),2e3)}catch{V(!0)}document.body.removeChild(A)};return e.jsx(de,{open:s,onOpenChange:A=>{A||t()},children:e.jsxs(ue,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(me,{children:e.jsxs(xe,{className:"font-display text-lg font-semibold text-text-primary",children:[d("share.title"),r?`: ${r}`:""]})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:d("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>y("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${p==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:d("share.user")}),e.jsx("button",{onClick:()=>y("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${p==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:d("share.team")})]}),p==="user"?e.jsx(Mn,{onSelect:N,placeholder:d("share.userIdPlaceholder"),actionLabel:d("share.selectUser")}):e.jsx("input",{type:"text",value:S,onChange:A=>x(A.target.value),placeholder:d("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),p==="user"&&v&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[d("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:v})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:d("share.permission")}),e.jsxs("select",{value:c,onChange:A=>w(A.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"read",children:d("share.permissionRead")}),e.jsx("option",{value:"write",children:d("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:d("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:h,onChange:A=>b(A.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none"})]}),(D||i)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:D||i}),T&&e.jsxs("div",{className:"rounded-md bg-surface-2 px-3 py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-1",children:d("share.linkCreated")}),e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs text-text-primary",children:T}),e.jsx("button",{onClick:Y,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:te?d("share.copied"):d("share.copy")})]}),U&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:d("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:d("share.existingShares")}),m?e.jsx("p",{className:"text-sm text-text-muted",children:d("share.loading")}):a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:d("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:a.map(A=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:A.granted_to_user||A.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[A.permission==="write"?d("share.permissionWrite"):d("share.permissionRead"),A.expires_at?` · expires ${A.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>Ee(A.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:d("share.revoke")})]},A.id))})]})]}),e.jsxs(Nn,{children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:d("common.close")}),e.jsx("button",{onClick:Ce,disabled:k||(p==="user"?!v.trim():!S.trim()),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:k?d("common.creating"):d("share.createShare")})]})]})})}function Dr(s){const t=new Date,n=new Date(t.getTime()-1440*60*1e3),r=(i,u)=>i.getFullYear()===u.getFullYear()&&i.getMonth()===u.getMonth()&&i.getDate()===u.getDate(),a={today:[],yesterday:[],earlier:[]};for(const i of s){const u=new Date(i.modified||0);r(u,t)?a.today.push(i):r(u,n)?a.yesterday.push(i):a.earlier.push(i)}return[["today",d("resume.today")],["yesterday",d("resume.yesterday")],["earlier",d("resume.earlier")]].map(([i,u])=>({label:u,items:a[i]})).filter(i=>i.items.length>0)}function qr(s){return s?new Date(s).toLocaleString():""}function Pr({open:s,onClose:t,adapter:n,onResume:r}){const a=J(),[m,i]=l.useState([]),[u,g]=l.useState(!1),[p,y]=l.useState("");l.useEffect(()=>{if(!s)return;let N=!1;return g(!0),y(""),i([]),n.listResumableSessions().then(S=>{N||i(S)}).catch(S=>{N||y(S instanceof Error?S.message:String(S))}).finally(()=>{N||g(!1)}),()=>{N=!0}},[s,n]);const v=l.useMemo(()=>Dr(m),[m,a]);return e.jsx(de,{open:s,onOpenChange:N=>{N||t()},children:e.jsxs(ue,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(me,{children:e.jsx(xe,{className:"font-display text-lg font-semibold text-text-primary",children:d("session.resume.title")})}),e.jsxs("div",{className:"max-h-96 min-w-0 space-y-4 overflow-y-auto",children:[u&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:d("resume.loading")}),!u&&p&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:p}),!u&&!p&&m.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:d("resume.empty")}),!u&&!p&&v.map(N=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-text-muted",children:N.label}),e.jsx("div",{className:"space-y-1",children:N.items.map(S=>e.jsxs("button",{type:"button",onClick:()=>r(S),className:"w-full rounded-md px-3 py-2 text-left transition-colors hover:bg-surface-3",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:S.title}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[qr(S.modified),S.gitBranch?` · ${S.gitBranch}`:""]})]},S.sessionId))})]},N.label))]}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx("button",{type:"button",onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-2",children:d("common.cancel")})})]})})}class Or{constructor(t,n,r,a){M(this,"pending",null);this.current=t,this.apply=n,this.send=r,this.onError=a}set(t){if(t===this.current)return;const n=this.current;this.current=t,this.pending={requestId:null,previous:n},this.apply(t);try{Promise.resolve(this.send(t)).then(r=>{this.pending&&(this.pending.requestId=r)}).catch(r=>{this.rollback(n,Qt(r),"send")})}catch(r){this.rollback(n,Qt(r),"send")}}handleControlResponse(t){const n=this.pending;if(!n||n.requestId!==t.requestId)return!1;const{previous:r}=n;return this.pending=null,t.subtype==="error"&&this.rollback(r,t.error??"","response"),!0}sync(t){t!==this.current&&(this.current=t,this.apply(t),this.pending=null)}adoptExternal(t){this.pending||t!==this.current&&(this.current=t)}getCurrent(){return this.current}rollback(t,n,r){var a;this.pending=null,this.current=t,this.apply(t),n&&((a=this.onError)==null||a.call(this,n,r))}}function Qt(s){return s instanceof Error?s.message:String(s)}function ot(s){const t=l.useRef(s);t.current=s;const n=l.useRef(null);n.current||(n.current=new Or(s.value,a=>t.current.apply(a),a=>t.current.send(a),(a,m)=>{var i,u;return(u=(i=t.current).onError)==null?void 0:u.call(i,a,m)}));const r=n.current;return l.useEffect(()=>{r.adoptExternal(s.value)}),l.useMemo(()=>({set:a=>r.set(a),handleControlResponse:a=>r.handleControlResponse(a),sync:a=>r.sync(a)}),[r])}const cs="rcs_context_usage_";function ds(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function Vt(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function Ur(s){if(!s||typeof s!="object"||Array.isArray(s))return null;const t=s,{totalTokens:n,rawMaxTokens:r,percentage:a}=t;if(typeof n!="number"||typeof r!="number"||typeof a!="number")return null;const m=t.categories,i=Array.isArray(m)?m.filter(u=>!!u&&typeof u=="object"&&typeof u.name=="string").map(u=>({name:u.name,tokens:typeof u.tokens=="number"?u.tokens:0,...u.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:n,rawMaxTokens:r,percentage:a,...typeof t.model=="string"&&t.model?{model:t.model}:{},...i&&i.length>0?{categories:i}:{}}}function Fr(s,t=ds()){if(!t||!s)return null;try{const n=t.getItem(cs+s);return n?Ur(JSON.parse(n)):null}catch{return null}}function Kr(s,t,n=ds()){if(!(!n||!s))try{n.setItem(cs+s,JSON.stringify(t))}catch{}}function Lr(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Br(s){const t=Lr(s),n=on(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new an(r)}const le=[{value:"default",labelKey:"session.mode.default",descKey:"session.mode.defaultDesc"},{value:"acceptEdits",labelKey:"session.mode.acceptEdits",descKey:"session.mode.acceptEditsDesc"},{value:"plan",labelKey:"session.mode.plan",descKey:"session.mode.planDesc"},{value:"bypassPermissions",labelKey:"session.mode.bypass",descKey:"session.mode.bypassDesc"}],zt="rcs_permission_mode";function ce(s){return s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}k`:`${(s/1e6).toFixed(1)}M`}function Hr(s){const t=le.findIndex(n=>n.value===s);return le[(t+1+le.length)%le.length].value}const lt=[{value:"off",labelKey:"session.thinking.off",descKey:"session.thinking.offDesc",label:void 0,description:void 0,tokens:null},{value:"on",labelKey:"session.thinking.on",descKey:"session.thinking.onDesc",label:void 0,description:void 0,tokens:0},{value:"8192",labelKey:void 0,descKey:void 0,label:"8k",description:"8192 tokens",tokens:8192},{value:"16384",labelKey:void 0,descKey:void 0,label:"16k",description:"16384 tokens",tokens:16384},{value:"32768",labelKey:void 0,descKey:void 0,label:"32k",description:"32768 tokens",tokens:32768}],Gt="rcs_thinking_budget",ct=[{value:"auto",effort:void 0,labelKey:"session.effort.auto",descKey:"session.effort.autoDesc",label:void 0},{value:"low",effort:"low",labelKey:void 0,descKey:"session.effort.lowDesc",label:"low"},{value:"medium",effort:"medium",labelKey:void 0,descKey:"session.effort.mediumDesc",label:"medium"},{value:"high",effort:"high",labelKey:void 0,descKey:"session.effort.highDesc",label:"high"},{value:"xhigh",effort:"xhigh",labelKey:void 0,descKey:"session.effort.xhighDesc",label:"xhigh"},{value:"max",effort:"max",labelKey:void 0,descKey:"session.effort.maxDesc",label:"max"}],Yt=s=>s.labelKey?d(s.labelKey):s.label,Jt=s=>s.labelKey?d(s.labelKey):s.label,Xt="rcs_effort";function Wr(s){return s!=null&&s.capabilities?s.capabilities:s?{file_search:!0,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!0,stop_task:!0,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!0,mcp_management:!0,remote_settings:!0,rewind:!0,resume:!0,set_effort:!0,side_question:!0}:{file_search:!1,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!1,stop_task:!1,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!1,mcp_management:!1,remote_settings:!1,rewind:!1,resume:!1,set_effort:!1,side_question:!1}}function Qr({budget:s,onBudgetChange:t,disabled:n}){const[r,a]=l.useState(!1),m=lt.find(i=>i.value===s);return e.jsxs(Fe,{open:r,onOpenChange:a,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:d("session.thinking.title"),children:[e.jsx(vn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:m?Jt(m):d("session.thinking.fallback")}),r?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:lt.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value,i.tokens),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:s===i.value&&e.jsx(Se,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:Jt(i)}),e.jsx("div",{className:"text-xs text-text-muted",children:i.descKey?d(i.descKey):i.description})]})]},i.value))})]})}function Vr({effort:s,onEffortChange:t,disabled:n}){const[r,a]=l.useState(!1),m=ct.find(i=>i.value===s);return e.jsxs(Fe,{open:r,onOpenChange:a,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:d("session.effort.title"),children:[e.jsx(Fn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:m?Yt(m):d("session.effort.fallback")}),r?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:ct.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:s===i.value&&e.jsx(Se,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:Yt(i)}),e.jsx("div",{className:"text-xs text-text-muted",children:d(i.descKey)})]})]},i.value))})]})}const zr=new Set(["Free space","Autocompact buffer","Compact buffer"]),Zt=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function Gr({usage:s}){const t=Math.min(100,Math.max(0,s.percentage)),n=t>=80,r=(s.categories??[]).filter(u=>!u.isDeferred&&!zr.has(u.name)),a=(s.categories??[]).filter(u=>u.isDeferred),m=r.reduce((u,g)=>u+g.tokens,0),i=[`${O("session.context.tooltip",{used:ce(s.totalTokens),max:ce(s.rawMaxTokens)})}${s.model?` · ${s.model}`:""}`,...r.slice(0,8).map(u=>`${u.name}: ${ce(u.tokens)}`),...a.slice(0,3).map(u=>`${u.name}${d("session.context.deferredSuffix")}: ${ce(u.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",title:i.join(`
82
- `),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:r.length>0?r.map((u,g)=>e.jsx("span",{className:n&&g===0?"bg-status-warning":Zt[g%Zt.length],style:{width:`${Math.min(100,Math.max(0,m>0?u.tokens/m*t:0))}%`}},u.name)):e.jsx("span",{className:`absolute inset-y-0 left-0 rounded-full transition-all ${n?"bg-status-warning":"bg-brand/70"}`,style:{width:`${t}%`}})}),e.jsxs("span",{children:[t,"%"]})]})}function Yr({models:s,currentModelId:t,onSelect:n,disabled:r}){const[a,m]=l.useState(!1),i=s.find(p=>p.modelId===t)??null,u=s.length>0,g=async p=>{n(p.modelId),m(!1)};return e.jsxs(Fe,{open:a,onOpenChange:u?m:void 0,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r||!u,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:d("session.model.title"),children:[e.jsx(rs,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(i==null?void 0:i.name)??t??d("session.model.title")}),a?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-72 p-0",align:"start",children:e.jsx(jn,{models:s,currentModelId:t,onSelect:g,showSearch:s.length>5})})]})}function Jr({mode:s,onModeChange:t,disabled:n}){const[r,a]=l.useState(!1),m=le.find(i=>i.value===s);return e.jsxs(Fe,{open:r,onOpenChange:a,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:d("session.mode.title"),children:[e.jsx(wn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:m?d(m.labelKey):s}),r?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:le.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:s===i.value&&e.jsx(Se,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:d(i.labelKey)}),e.jsx("div",{className:"text-xs text-text-muted",children:d(i.descKey)})]})]},i.value))})]})}function xa({sessionId:s,onSessionLoaded:t}){J();const[n,r]=l.useState(null),[a,m]=l.useState(null),[i,u]=l.useState(""),[g,p]=l.useState(!1),[y,v]=l.useState(!1),[N,S]=l.useState(!1),[x,c]=l.useState(!1),[w,h]=l.useState(!1),[b,k]=l.useState(!1),[j,T]=l.useState(""),[I,D]=l.useState(0),B=l.useRef(null),[te,E]=l.useState({text:"",nonce:0}),[U,V]=l.useState(!1),[Ce,Ee]=l.useState(!1),[Y,A]=l.useState(!1),[fe,dt]=l.useState(0),[us,ms]=l.useState(0),[pe,X]=l.useState([]),[G,he]=l.useState(!1),[ye,re]=l.useState([]),[H,We]=l.useState(null),[xs,fs]=l.useState(()=>ls()),[W,ps]=l.useState(null),[ut,hs]=l.useState(()=>localStorage.getItem(Gt)||"off"),[ys,mt]=l.useState(()=>Fr(s)),[Qe,Ve]=l.useState(!0),[ge,gs]=l.useState(null),[Te,xt]=l.useState(null),[Me,Re]=l.useState([]),[ft,ze]=l.useState(!1),[Ge,pt]=l.useState(""),Ye=l.useRef(null),[Ae,bs]=l.useState(()=>localStorage.getItem(zt)||"default"),[ht,yt]=l.useState(null),be=l.useRef(null),[gt,bt]=l.useState(null),we=l.useRef(null),ae=l.useRef(null),wt=l.useRef(pe);wt.current=pe;const $e=l.useRef(t);$e.current=t;const Ie=l.useRef(null);Ie.current||(Ie.current=new Rn(An()));const jt=l.useRef(s);jt.current=(n==null?void 0:n.title)||s,l.useEffect(()=>{var o;(o=Ie.current)==null||o.reset()},[s]);const se=l.useCallback(o=>{yt(o),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>yt(null),5e3)},[]),Z=l.useCallback(o=>{bt(o),we.current&&clearTimeout(we.current),we.current=setTimeout(()=>bt(null),5e3)},[]),De=ot({value:Ae,apply:o=>{bs(o);try{localStorage.setItem(zt,o)}catch{}},send:o=>{const f=ae.current;return f?f.setPermissionMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,f)=>{console.error("[SessionDetail] set permission mode failed:",o),se(f==="send"?O("session.mode.switchFailedRequest",{message:o}):o||d("session.mode.switchFailed"))}}),Je=l.useCallback(o=>De.set(o),[De]),Xe=ot({value:ut,apply:o=>{hs(o);try{localStorage.setItem(Gt,o)}catch{}},send:o=>{var _;const f=ae.current;if(!f)return Promise.reject(new Error("adapter not ready"));const C=((_=lt.find(R=>R.value===o))==null?void 0:_.tokens)??null;return f.setThinkingBudget(C)},onError:(o,f)=>{console.error("[SessionDetail] set thinking budget failed:",o),se(f==="send"?O("session.thinking.failedRequest",{message:o}):o||d("session.thinking.failed"))}}),$=l.useMemo(()=>new cr(s,X,{onStatusChange:o=>{var f;m(o),he(o==="running"||o==="requires_action"),(f=Ie.current)==null||f.onStatus(o,jt.current)},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{re(f=>f.some(C=>C.requestId===o.requestId)?f:[...f,o])},onModelsStateChange:o=>{We(o)},onSubagentUpdate:o=>{fs(o)},onControlResponse:o=>{Xe.handleControlResponse(o)||De.handleControlResponse(o)},onPermissionModeChange:o=>{De.sync(o)},onUsageChange:o=>{gs(f=>({inputTokens:Math.max((f==null?void 0:f.inputTokens)??0,o.inputTokens),outputTokens:Math.max((f==null?void 0:f.outputTokens)??0,o.outputTokens),totalCostUsd:o.totalCostUsd??(f==null?void 0:f.totalCostUsd)??null}))},onWorkerInfoChange:o=>{ps(f=>JSON.stringify(f)===JSON.stringify(o)?f:o)},onElicitationRequest:o=>{xt(o)}}),[s,se]);l.useEffect(()=>(ae.current=$,()=>{$.disconnect()}),[$]);const P=l.useMemo(()=>Wr(W),[W]),ws=J(),Ze=l.useMemo(()=>ln((W==null?void 0:W.commands)??[],(W==null?void 0:W.skills)??[]),[W,ws]),je=l.useMemo(()=>cn(pe,j),[pe,j]),js=l.useCallback(o=>Xe.set(o),[Xe]),[vt,vs]=l.useState(()=>localStorage.getItem(Xt)||"auto"),ks=ot({value:vt,apply:o=>{vs(o);try{localStorage.setItem(Xt,o)}catch{}},send:o=>{var _;const f=ae.current;if(!f)return Promise.reject(new Error("adapter not ready"));const C=(_=ct.find(R=>R.value===o))==null?void 0:_.effort;return f.setEffort(C)},onError:(o,f)=>{console.error("[SessionDetail] set effort failed:",o),se(f==="send"?O("session.effort.failedRequest",{message:o}):o||d("session.effort.failed"))}}),et=l.useCallback(()=>{var o;P.get_context_usage&&((o=ae.current)==null||o.getContextUsage().then(f=>{f&&(mt(f),Kr(s,f))}).catch(()=>{}).finally(()=>Ve(!1)))},[P,s]);l.useEffect(()=>{if(!P.get_context_usage)return;G||et();const o=setInterval(et,6e4);return()=>clearInterval(o)},[P,G,et]),l.useEffect(()=>{W&&!P.get_context_usage&&Ve(!1)},[W,P]),l.useEffect(()=>{if(!Qe)return;const o=setTimeout(()=>Ve(!1),1e4);return()=>clearTimeout(o)},[Qe]);const kt=l.useRef(Y);kt.current=Y,l.useEffect(()=>ie.onEvent(f=>{f.type!=="artifact_created"&&f.type!=="artifact_updated"||(kt.current&&ms(C=>C+1),dt(C=>C+1))}),[]);const[ve,Ns]=l.useState("idle");l.useEffect(()=>ie.onStateChange(f=>Ns(f)),[]),l.useEffect(()=>{Y&&dt(0)},[Y]),l.useEffect(()=>{let o=!1;async function f(){var C;u("");try{const _=await Dt(s);if(o)return;r(_),m(_.status),Oe(_.status)&&$.markClosed(),he(_.status==="running"||_.status==="requires_action"),(C=$e.current)==null||C.call($e,_)}catch(_){if(o)return;u(_ instanceof Error?_.message:d("session.loadFailed"));return}try{await $.init()}catch(_){console.warn("Failed to init adapter:",_)}}return f(),()=>{o=!0}},[s,$]);const q=Oe(a),Nt=l.useRef(a);Nt.current=a,l.useEffect(()=>{if(q)return;let o=!1;const C=setInterval(async()=>{try{const _=await Dt(s);if(o||_.status===Nt.current)return;Oe(_.status)&&$.markClosed(),m(_.status),he(_.status==="running"||_.status==="requires_action")}catch{}},6e4);return()=>{o=!0,clearInterval(C)}},[s,q,$]);const F=(n==null?void 0:n.access_level)==="read",_t=ys??(Qe&&!q&&!F?Vt():null),tt=l.useCallback(()=>{X([]),mt(Vt()),$t(s).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[s]),ke=l.useCallback(async(o,f)=>{const C=ae.current;if(!C||q)return;if(o.sessionId===s){X(R=>[...R,{type:"command_output",id:`cmd-resume-${Date.now()}`,commandName:"resume",inputText:f??"/resume",title:"Resume",subtitle:d("session.resume.title"),outputText:d("session.resume.currentBlocked"),variant:"error"}]);return}const _=(R,K="default")=>X(ne=>[...ne,{type:"command_output",id:`cmd-resume-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,commandName:"resume",inputText:f??`/resume ${o.sessionId.slice(0,8)}`,title:"Resume",subtitle:d("session.resume.title"),outputText:R,variant:K}]);_(O("session.resume.restoring",{title:o.title??""}));try{await $t(s),X([]);const R=await C.resumeSession(o.sessionId);_(R.title?O("session.resume.restoredWithTitle",{count:R.messageCount,title:R.title}):O("session.resume.restored",{count:R.messageCount}))}catch(R){_(O("session.resume.failed",{message:R instanceof Error?R.message:String(R)}),"error")}},[q,s]),_s=l.useCallback(async()=>{if(n!=null&&n.environment_id)try{const o=await dn({environment_id:n.environment_id});window.location.href=`/code/${o.id}?resumeFrom=${s}`}catch(o){Z(O("session.createFailedWithReason",{message:o instanceof Error?o.message:String(o)}))}},[n,s,Z]),Ss=l.useRef(new URLSearchParams(window.location.search).get("resumeFrom")),St=l.useRef(!1);l.useEffect(()=>{const o=Ss.current;!o||St.current||!W||!P.resume||(St.current=!0,window.history.replaceState({},"",window.location.pathname),ke({sessionId:o,title:o.slice(0,8),modified:0},null))},[W,P.resume,ke]);const qe=l.useCallback(async o=>{const f=o.text.trim(),C=o.images&&o.images.length>0||o.attachments&&o.attachments.length>0;if(!f&&!C||q)return;const _=/^\/resume(?:\s+(.*))?$/.exec(f);if(_){const K=(_[1]??"").trim();if(!P.resume){X(ne=>[...ne,{type:"user_message",id:`user-${Date.now()}`,content:f},{type:"command_output",id:`cmd-${Date.now()}`,commandName:"resume",inputText:f,title:"Resume",subtitle:d("session.resume.title"),outputText:d("session.resume.unsupported"),variant:"error"}]);return}K?await ke({sessionId:K,title:K,modified:0},f):h(!0);return}const R=await un(f,{sessionId:s,availableCommands:Ze,availableModels:(H==null?void 0:H.availableModels)??[],currentModel:H?{modelId:H.currentModelId,name:H.currentModelId}:null,supportsImages:!0,entries:wt.current,setModel:async K=>{await z(s,{type:"control_request",request:{subtype:"set_model",model:K}}),We(ne=>ne&&{...ne,currentModelId:K})},onNewSession:()=>{X([])}}).catch(()=>null);if(R){if(Ue("[SessionDetail] local command result",R),"clearEntries"in R&&R.clearEntries){tt();return}if("newSession"in R&&R.newSession){tt();return}if("userEntry"in R){X(K=>[...K,R.userEntry,R.cmdEntry]);return}}he(!0);try{await $.sendMessage(f,o.images,o.attachments)}catch(K){if(console.error("Send failed:",K),K instanceof mn&&K.type==="session_closed"){m("archived"),$.markClosed(),Z(d("session.closedSendBlocked"));return}Z(`${d("session.sendFailed")}${K instanceof Error?`: ${K.message}`:""}`)}},[$,q,s,H,Ze,tt,Z,ke,P]),Cs=l.useCallback(o=>{if(G){Re(f=>[...f,o]);return}qe(o)},[G,qe]),st=l.useRef(!1);l.useEffect(()=>{if(q){Re(f=>f.length>0?[]:f);return}if(G||Me.length===0||st.current)return;const o=Me[0];o&&(st.current=!0,Re(f=>f.slice(1)),qe(o).finally(()=>{st.current=!1}))},[G,Me,qe,q]);const Es=l.useCallback((o,f)=>{if(G)return;const C=f==="edit"?d("session.rewind.confirmEdit"):d("session.rewind.confirm");window.confirm(`${C}
83
- ${d("session.rewind.confirmBody")}`)&&$.rewindToMessage(o.id).then(()=>{f==="edit"&&o.content&&E(_=>({text:o.content,nonce:_.nonce+1}))}).catch(_=>{console.error("[SessionDetail] rewind failed:",_),Z(O("session.rewind.failed",{message:_ instanceof Error?_.message:String(_)}))})},[G,Z]),Ts=l.useCallback(o=>{const f=je.orderedMatchIds;if(f.length===0)return;const C=(o%f.length+f.length)%f.length;D(C);const _=f[C],R=document.querySelector(`[data-entry-id="${CSS.escape(_)}"]`);R==null||R.scrollIntoView({block:"center",behavior:"smooth"})},[je]),Ct=l.useCallback(async()=>{try{await $.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{he(!1)}},[$]),Ms=l.useCallback(()=>{Je(Hr(Ae))},[Je,Ae]);l.useEffect(()=>()=>{be.current&&clearTimeout(be.current),we.current&&clearTimeout(we.current)},[]);const Rs=l.useCallback(async()=>{if(n&&window.confirm(d("dashboard.confirmDelete").replace("{id}",n.title||n.id)))try{await It(n.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:d("dashboard.deleteFailed"))}},[n]),As=l.useCallback(async o=>{try{await $.respondPermission(o,!0)}catch(f){console.error("Failed to approve:",f)}re(f=>f.filter(C=>C.requestId!==o))},[$]),$s=l.useCallback(async(o,f)=>{try{await $.respondPermission(o,!0,{updated_permissions:f})}catch(C){console.error("Failed to approve with rules:",C)}re(C=>C.filter(_=>_.requestId!==o))},[$]),Is=l.useCallback(async(o,f)=>{const C=Te;if(xt(null),!!C)try{await $.respondElicitation(C.requestId,o,f)}catch(_){console.error("Failed to submit elicitation:",_)}},[Te,$]),Ds=l.useCallback(()=>{!n||F||(pt(n.title||""),ze(!0),setTimeout(()=>{var o,f;(o=Ye.current)==null||o.focus(),(f=Ye.current)==null||f.select()},0))},[n,F]),Et=l.useCallback(async()=>{const o=Ge.trim();if(ze(!1),!(!n||!o||o===n.title))try{const f=await xn(n.id,o);r(C=>C&&{...C,title:f.title??o})}catch(f){console.error("Rename failed:",f),alert(f instanceof Error?f.message:d("session.rename.failed"))}},[n,Ge]),qs=l.useCallback(async o=>{try{await $.respondPermission(o,!1)}catch(f){console.error("Failed to reject:",f)}re(f=>f.filter(C=>C.requestId!==o))},[$]),Ps=l.useCallback(async(o,f,C)=>{try{await z(s,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:C,answers:f}})}catch(_){console.error("Failed to submit answers:",_)}re(_=>_.filter(R=>R.requestId!==o))},[s]),Os=l.useCallback(async(o,f,C)=>{try{f==="no"?await z(s,{type:"permission_response",approved:!1,request_id:o,...C?{message:C}:{}}):await z(s,{type:"permission_response",approved:!0,request_id:o,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[f]||"default",destination:"session"}]})}catch(_){console.error("Failed to submit plan response:",_)}re(_=>_.filter(R=>R.requestId!==o))},[s]);return i?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-status-error",children:i}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand-text hover:underline",children:d("session.backToDashboard")})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(Zr,{sessionId:s,agentId:n.environment_id}):e.jsx(ss,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:n.title||n.id}),e.jsx("div",{className:"border-b bg-surface-1 py-3",children:e.jsxs("div",{className:"mx-auto page-measure px-4 sm:px-8",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ft?e.jsx("input",{ref:Ye,value:Ge,onChange:o=>pt(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Et()):o.key==="Escape"&&(o.preventDefault(),ze(!1))},onBlur:()=>void Et(),maxLength:200,className:"w-full max-w-md rounded-lg border border-brand/50 bg-surface-2 px-2.5 py-1 font-display text-lg font-semibold text-text-primary focus:outline-none focus:ring-2 focus:ring-brand/30"}):e.jsxs("h2",{className:"group/title flex min-w-0 items-center gap-1.5 font-display text-lg font-semibold text-text-primary",children:[e.jsx("span",{className:"truncate",children:n.title||n.id}),!F&&!q&&e.jsx("button",{type:"button",onClick:Ds,className:"flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:text-text-primary group-hover/title:opacity-100",title:d("session.rename.title"),children:e.jsx(fn,{className:"h-3.5 w-3.5"})})]}),n.visibility&&!ft&&e.jsx(Tn,{visibility:n.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var C;const o=n.source==="acp"?"acp":(C=n.environment)==null?void 0:C.worker_type,f=kn(o);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${f.colorClass}`,children:f.fullLabel})})(),a&&e.jsx(es,{status:a}),e.jsx("span",{className:"text-xs text-text-muted",children:ts(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>A(!Y),className:`relative flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${Y?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:d("artifacts.title"),children:[e.jsx(pn,{className:"h-3.5 w-3.5"}),fe>0&&!Y&&e.jsx("span",{className:"absolute -right-1.5 -top-1.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand px-1 text-[10px] font-bold text-white",children:fe>9?"9+":fe})]}),P.side_question&&!q&&!F&&e.jsx("button",{onClick:()=>c(!x),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${x?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:d("session.sideQuestion.title"),children:e.jsx(as,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const o=!b;k(o),o?setTimeout(()=>{var f;return(f=B.current)==null?void 0:f.focus()},0):(T(""),D(0))},className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${b?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:d("session.search.title"),children:e.jsx(it,{className:"h-3.5 w-3.5"})}),P.mcp_management&&!q&&!F&&e.jsx("button",{onClick:()=>v(!y),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${y?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:d("session.mcp.title"),children:e.jsx(os,{className:"h-3.5 w-3.5"})}),P.remote_settings&&!q&&!F&&e.jsx("button",{onClick:()=>S(!N),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${N?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:d("session.settings.title"),children:e.jsx(is,{className:"h-3.5 w-3.5"})}),!F&&(n==null?void 0:n.access_level)!=="write"&&e.jsx("button",{onClick:()=>Ee(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:d("session.share"),children:e.jsx(tr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>V(!U),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:d("session.info"),children:e.jsx(Hn,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>p(!g),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:[d("session.tasks"),ye.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning/15 px-1.5 py-0.5 text-[10px] font-medium text-status-warning",children:ye.length})]})]})]}),U&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:d("session.metaSession")})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:d("session.metaEnvironment")})," ",n.environment_id]})]})]})}),(ve==="reconnecting"||ve==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${ve==="failed"?"bg-status-error/10 text-status-error":"bg-status-warning/10 text-status-warning"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${ve==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),ve==="failed"?d("session.sseFailed"):d("session.sseReconnecting")]}),Y&&e.jsx("div",{className:"border-b bg-surface-1 py-4",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(En,{sessionId:s,embedded:!0,refreshTick:us})})}),b&&e.jsx("div",{className:"border-b bg-surface-1 py-2",children:e.jsxs("div",{className:"mx-auto flex page-measure px-4 sm:px-8 items-center gap-2",children:[e.jsx(it,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:B,value:j,onChange:o=>{T(o.target.value),D(0)},onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Ts(j&&o.shiftKey?I-1:I+1)):o.key==="Escape"&&(o.preventDefault(),k(!1),T(""))},placeholder:d("session.search.placeholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),j.trim()&&e.jsx("span",{className:"flex-shrink-0 font-mono text-[11px] text-text-muted",children:je.orderedMatchIds.length===0?d("session.search.noResults"):`${I+1}/${je.orderedMatchIds.length}`})]})}),e.jsx(hn,{entries:pe,isLoading:G,emptyTitle:d("session.emptyTitle"),emptyDescription:d("session.emptyDescription"),searchMatchIds:j.trim()?je.matchIds:void 0,onRewindEntry:P.rewind&&!q&&!F&&!G?(o,f)=>Es(o,f):void 0}),e.jsx(Nr,{state:xs,onStopTask:P.stop_task?o=>{$.stopSubagent(o).then(f=>{f.ok||Z(f.error||d("session.stopTask.failed"))})}:void 0}),ye.length>0&&e.jsx("div",{className:"border-t bg-surface-1 py-3",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8 space-y-3",children:ye.map(o=>e.jsx(Xr,{request:o,onApprove:()=>As(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>$s(o.requestId,o.suggestions??[]):void 0,onReject:()=>qs(o.requestId),onSubmitAnswers:Ps,onSubmitPlan:Os},o.requestId))})}),Te&&e.jsx("div",{className:"border-t bg-surface-1 py-3",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(Mr,{request:Te,onSubmit:Is})})}),gt&&e.jsx("div",{className:"mx-auto page-measure w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:gt})}),ht&&e.jsx("div",{className:"mx-auto page-measure w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:ht})}),e.jsxs("div",{className:"page-measure mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Jr,{mode:Ae,onModeChange:Je,disabled:q||F}),e.jsx(Yr,{models:(H==null?void 0:H.availableModels)??[],currentModelId:(H==null?void 0:H.currentModelId)??null,onSelect:o=>{z(s,{type:"control_request",request:{subtype:"set_model",model:o}}),We(f=>f&&{...f,currentModelId:o})},disabled:q||F}),P.set_max_thinking_tokens&&e.jsx(Qr,{budget:ut,onBudgetChange:js,disabled:q||F}),P.set_effort&&e.jsx(Vr,{effort:vt,onEffortChange:o=>ks.set(o),disabled:q||F})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[_t&&e.jsx(Gr,{usage:_t}),ge&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:d("session.usage.total"),children:[ce(ge.inputTokens)," in / ",ce(ge.outputTokens)," out",ge.totalCostUsd!=null&&` · $${ge.totalCostUsd.toFixed(2)}`]})]})]}),q&&(n==null?void 0:n.environment_id)&&e.jsx("div",{className:"mx-auto w-full page-measure px-4 pb-2 sm:px-8",children:e.jsx("button",{type:"button",onClick:()=>void _s(),className:"w-full rounded-lg border border-border bg-surface-1 px-4 py-2.5 text-sm text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:d("session.resumeInNew")})}),e.jsx(yn,{onSubmit:Cs,isLoading:G,onInterrupt:Ct,onCycleMode:Ms,disabled:q||F,placeholder:q?d("session.closed"):F?d("session.readOnly"):d("session.inputPlaceholder"),supportsAttachments:!0,commands:Ze,queueWhileLoading:!0,queuedCount:Me.length,onDequeue:o=>Re(f=>f.filter((C,_)=>_!==o)),onSearchFiles:P.file_search?o=>$.searchFiles(o):void 0,historyKey:s,draftOverride:te}),y&&e.jsx(hr,{onClose:()=>v(!1),fetchServers:()=>$.getMcpServers(),onToggle:(o,f)=>$.toggleMcpServer(o,f),onReconnect:o=>$.reconnectMcpServer(o)}),N&&e.jsx(gr,{onClose:()=>S(!1),fetchSettings:()=>$.getRemoteSettings(),onApply:o=>$.applyFlagSettings(o)}),x&&e.jsx(br,{onClose:()=>c(!1),onAsk:o=>$.askSideQuestion(o)}),g&&n&&e.jsx(xr,{onClose:()=>p(!1),session:n,liveStatus:a,pendingPermissions:ye,onInterrupt:Ct,onDelete:Rs,onEndSession:P.end_session&&!q&&!F?async()=>{await $.endSession("ended from web"),await It(n.id),window.location.href="/code/"}:void 0}),e.jsx(Ir,{open:Ce,onClose:()=>Ee(!1),sessionId:n.id,sessionTitle:n.title||void 0}),e.jsx(Pr,{open:w,onClose:()=>h(!1),adapter:$,onResume:o=>{h(!1),ke(o,null)}})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:d("session.loading")})})}function Xr({request:s,onApprove:t,onApproveAlways:n,onReject:r,onSubmitAnswers:a,onSubmitPlan:m}){const i=s.toolName,u=s.toolInput,g=s.description||"";if(i==="AskUserQuestion"){const p=u.questions||[];return e.jsx(Sr,{requestId:s.requestId,questions:p,description:g,onSubmit:y=>a(s.requestId,y,p),onSkip:r})}if(i==="ExitPlanMode"){const p=u.plan||"";return e.jsx(Er,{requestId:s.requestId,planContent:p,description:g,onSubmit:(y,v)=>m(s.requestId,y,v)})}return e.jsx(_r,{requestId:s.requestId,toolName:i,toolInput:u,description:g,suggestions:s.suggestions,onApprove:t,onApproveAlways:n,onReject:r})}function Zr({sessionId:s,agentId:t}){const[n,r]=l.useState(null),[a,m]=l.useState("disconnected"),[i,u]=l.useState(null),g=l.useRef(null);return l.useEffect(()=>{const p=Br(t);return p.setConnectionStateHandler((y,v)=>{m(y),u(v||null)}),g.current=p,r(p),p.connect().catch(y=>{y instanceof gn||(u(y.message),m("error"))}),()=>{p.disconnect(),g.current=null,r(null),m("disconnected")}},[t]),e.jsx(ss,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i&&a==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:i}),a==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:d("session.connectingAgent")})]})}),a==="error"&&!n&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:d("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:i})]})}),n&&a==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(bn,{client:n,agentId:t})})]})})}export{xa as SessionDetail};
@@ -1,11 +0,0 @@
1
- import{j as e}from"./vendor-DE_-CLIE.js";import{al as c,U as n,aj as i}from"./main-Dh-rPGBg.js";/**
2
- * @license lucide-react v0.555.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const d=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],x=c("globe",d);/**
7
- * @license lucide-react v0.555.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const b=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],m=c("lock",b);function u({visibility:o,className:t}){const a={private:{label:"Private",Icon:m,colorClass:"text-text-muted border-border/60"},team:{label:"Team",Icon:n,colorClass:"text-accent border-accent/40"},public:{label:"Public",Icon:x,colorClass:"text-accent border-accent/40"}},{label:s,Icon:r,colorClass:l}=a[o];return e.jsxs("span",{className:i("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",l,t),children:[e.jsx(r,{className:"h-3 w-3"}),s]})}export{u as S};
@@ -1 +0,0 @@
1
- import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{aI as f,aJ as y,aA as r}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function S(){f();const{createTeam:u}=y(),[o,p]=a.useState(""),[s,c]=a.useState(""),[i,b]=a.useState(""),[m,l]=a.useState(null),[d,x]=a.useState(!1),h=t=>{p(t),s||c(t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"))},g=async t=>{t.preventDefault(),l(null),x(!0);try{const n=await u({name:o,slug:s,description:i||void 0});window.location.href=`/teams/${n.slug}`}catch(n){l(n instanceof Error?n.message:"Failed to create team")}finally{x(!1)}};return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"mb-10 font-display text-2xl font-semibold tracking-tight text-text-primary",children:r("team.create.title")}),e.jsxs("form",{onSubmit:g,className:"max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.name")}),e.jsx("input",{id:"name",type:"text",required:!0,value:o,onChange:t=>h(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"Engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.nameHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"slug",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.slug")}),e.jsx("input",{id:"slug",type:"text",required:!0,value:s,onChange:t=>c(t.target.value),pattern:"^[a-z0-9-]{3,32}$",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.slugHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.description")}),e.jsx("textarea",{id:"description",value:i,onChange:t=>b(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:d||!o||!s,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:d?r("common.creating"):r("team.create.submit")})]})]})]})})}export{S as TeamCreate};
@@ -1,6 +0,0 @@
1
- import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{al as B,K as T,aI as P,aA as i,d as H,X as I,H as G,a2 as z,ah as W,ag as q,aH as J,x as K,aj as X,k as Y,p as Q,P as V,l as Z,n as ee,m as M,o as te,J as se}from"./main-Dh-rPGBg.js";import{U as ae}from"./UserSearchInput-DkaGgR76.js";import{C as D}from"./copy-lzYYFmlH.js";import{g as ne}from"./workerType-BOi1t0TG.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";/**
2
- * @license lucide-react v0.555.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const re=[["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"}]],ie=B("user-plus",re);function O(a){const[m,r]=n.useState([]),[N,j]=n.useState(!1),c=n.useCallback(async()=>{if(a){j(!0);try{const u=await T("GET",`/web/teams/${a}/members`);r(u)}catch{r([])}finally{j(!1)}}},[a]);n.useEffect(()=>{c()},[c]);const h=n.useCallback(async(u,f)=>{await T("POST",`/web/teams/${a}/members`,{userId:u,role:f}),await c()},[a,c]),x=n.useCallback(async u=>{await T("DELETE",`/web/teams/${a}/members/${u}`),await c()},[a,c]),l=n.useCallback(async(u,f)=>{await T("PATCH",`/web/teams/${a}/members/${u}`,{role:f}),await c()},[a,c]);return{members:m,isLoading:N,addMember:h,removeMember:x,updateRole:l,refetch:c}}function oe(a){const[m,r]=n.useState([]),N=n.useCallback(async c=>{if(!a)return null;const h=await T("POST",`/web/teams/${a}/invitations`,c);return r(x=>[...x,h]),h},[a]),j=n.useCallback(async c=>{a&&(await T("DELETE",`/web/teams/${a}/invitations/${c}`),r(h=>h.filter(x=>x.token!==c)))},[a]);return{invitations:m,createInvitation:N,revokeInvitation:j}}function ce({teamId:a,canManage:m}){P();const{invitations:r,createInvitation:N,revokeInvitation:j}=oe(a),{addMember:c}=O(a),[h,x]=n.useState(!1),[l,u]=n.useState(null),[f,E]=n.useState("member"),[d,g]=n.useState(!1),[y,b]=n.useState("member"),[v,L]=n.useState(null),[$,_]=n.useState(!1),[s,t]=n.useState(!1),[p,w]=n.useState(!1),S=async()=>{x(!0);try{const o=await N({role:f,expiresIn:86400,maxUses:5});o&&u(o.token||o.inviteToken||null)}catch{}finally{x(!1)}},A=async()=>{if(!l)return;const o=`${window.location.origin}/join?invite=${l}`;let k=!1;try{navigator.clipboard&&window.isSecureContext&&(await navigator.clipboard.writeText(o),k=!0)}catch{}if(!k){const C=document.createElement("textarea");C.value=o,C.style.position="fixed",C.style.top="0",C.style.opacity="0",document.body.appendChild(C),C.focus(),C.select(),C.setSelectionRange(0,o.length);try{k=document.execCommand("copy")}catch{k=!1}document.body.removeChild(C)}k?(w(!1),t(!0),setTimeout(()=>t(!1),2e3)):(t(!1),w(!0),setTimeout(()=>w(!1),4e3))},R=async o=>{_(!0),L(null);try{await c(o,y),g(!1)}catch(k){L(k instanceof Error?k.message:"Failed to add user")}finally{_(!1)}};return e.jsxs("div",{className:"space-y-5",children:[m&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",value:f,onChange:o=>E(o.target.value),children:[e.jsx("option",{value:"member",children:i("invitation.member")}),e.jsx("option",{value:"admin",children:i("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:S,disabled:h,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:opacity-50",children:h?i("invitation.creating"):i("invitation.create")}),e.jsxs("button",{type:"button",onClick:()=>g(!d),className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2",title:i("invitation.addExistingHint"),children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),i("invitation.addExisting")]})]}),d&&m&&e.jsxs("div",{className:"space-y-3 rounded border border-border bg-surface-2 p-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:i("invitation.addExistingHint")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{className:"rounded border border-border bg-surface-1 px-2 py-1.5 text-sm",value:y,onChange:o=>b(o.target.value),children:[e.jsx("option",{value:"member",children:i("invitation.member")}),e.jsx("option",{value:"admin",children:i("invitation.admin")})]})}),v&&e.jsx("p",{className:"text-xs text-destructive",children:v}),e.jsx(ae,{onSelect:R,actionDisabled:$,placeholder:i("invitation.searchUser")})]}),l&&e.jsxs("div",{className:"space-y-1.5 rounded border border-accent/40 bg-accent/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-xs text-text-primary break-all",children:`${window.location.origin}/join?invite=${l}`}),e.jsx("button",{type:"button",onClick:A,className:s?"text-status-active":"text-text-muted hover:text-text-primary",title:s?i("share.copied"):i("share.copy"),children:s?e.jsx(H,{className:"h-4 w-4"}):e.jsx(D,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>u(null),className:"text-text-muted hover:text-text-primary",children:e.jsx(I,{className:"h-4 w-4"})})]}),s&&e.jsx("p",{className:"text-xs text-status-active",children:i("share.copied")}),p&&e.jsx("p",{className:"text-xs text-status-error",children:i("share.copyFailed")})]}),r.length>0&&e.jsx("ul",{className:"space-y-2",children:r.map(o=>e.jsxs("li",{className:"flex items-center justify-between rounded border border-border/60 bg-surface-2 p-2 text-sm",children:[e.jsxs("span",{className:"text-text-muted",children:[o.role," — expires ",new Date(o.expiresAt).toLocaleDateString()]}),m&&e.jsx("button",{type:"button",onClick:()=>j(o.token),className:"text-sm text-destructive hover:underline",children:i("invitation.revoke")})]},o.token))})]})}function le({teamId:a,canManage:m}){const[r,N]=n.useState([]),[j,c]=n.useState(!0),[h,x]=n.useState(null),[l,u]=n.useState(""),[f,E]=n.useState(null),[d,g]=n.useState(!1),y=async()=>{try{const s=await z();N(s||[])}catch(s){x(s instanceof Error?s.message:"Failed to load environments")}finally{c(!1)}};n.useEffect(()=>{y()},[]);const b=n.useMemo(()=>r.filter(s=>s.team_id===a),[r,a]),v=n.useMemo(()=>r.filter(s=>!s.team_id),[r]),L=async()=>{if(l){E(null);try{await q(l,a),u(""),await y()}catch(s){E(s instanceof Error?s.message:"Failed to link environment")}}},$=async s=>{if(window.confirm("Unlink this environment from the team? It will revert to personal scope.")){E(null);try{await W(a,s),await y()}catch(t){E(t instanceof Error?t.message:"Failed to unlink environment")}}},_=async()=>{const s=`slz rc --team-id ${a}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),g(!0),setTimeout(()=>g(!1),2e3);return}}catch{}const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),g(!0),setTimeout(()=>g(!1),2e3)}catch{}document.body.removeChild(t)};return j?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading environments..."}):h?e.jsx("p",{className:"text-sm text-destructive",children:h}):e.jsxs("div",{className:"space-y-8",children:[e.jsx("ul",{className:"space-y-3",children:b.length===0?e.jsx("li",{className:"text-sm text-text-muted",children:"No environments linked to this team yet."}):b.map(s=>{const t=ne(s.worker_type);return e.jsxs("li",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t.colorClass}`,children:t.shortLabel}),e.jsx(G,{status:s.status}),m&&e.jsx("button",{type:"button",onClick:()=>$(s.id),className:"ml-2 text-xs text-text-muted underline-offset-2 transition-colors hover:text-destructive hover:underline",children:"Unlink"})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-text-muted",children:[s.directory||""," ",s.branch?`· ${s.branch}`:""]})]},s.id)})}),m&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Register a new worker to this team:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"rounded-md border border-border bg-surface-2 px-3 py-1.5 font-mono text-xs text-text-primary",children:["slz rc --team-id ",a]}),e.jsx("button",{type:"button",onClick:_,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy command",children:e.jsx(D,{className:"h-3.5 w-3.5"})}),d&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"})]})]}),v.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Link an existing personal environment:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:l,onChange:s=>u(s.target.value),className:"max-w-md rounded-md border border-border bg-surface-2 px-3 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"",children:"Select environment..."}),v.map(s=>e.jsxs("option",{value:s.id,children:[s.machine_name||s.id," ",s.branch?`· ${s.branch}`:""]},s.id))]}),e.jsx("button",{type:"button",onClick:L,disabled:!l,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:"Link"})]})]}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})]})}async function de(a){try{const m=a.startsWith("team_")?`/web/teams/${a}`:`/web/teams/by-slug/${a}`;return await T("GET",m)}catch{return null}}const me={owner:"team.member.roleOwner",admin:"team.member.roleAdmin",member:"team.member.roleMember"},U={owner:"border-brand/30 bg-brand/10 text-brand-text",admin:"border-accent/30 bg-accent/10 text-accent",member:"border-border/60 bg-surface-2 text-text-muted"};function F(a){return i(me[a]||"team.member.roleMember")}function ve(){P();const a=window.location.pathname.split("/"),m=a[a.length-1]||"",[r,N]=n.useState(null),[j,c]=n.useState(!0),[h,x]=n.useState(!1),{members:l,isLoading:u,updateRole:f,removeMember:E}=O((r==null?void 0:r.id)||null),{user:d}=J(),[g,y]=n.useState("");if(n.useEffect(()=>{m&&(c(!0),de(m).then(t=>{N(t),c(!1)}))},[m]),j)return e.jsx("div",{className:"px-6 py-16 text-sm text-text-muted",children:"Loading..."});if(!r)return e.jsx("div",{className:"px-6 py-16 sm:px-10",children:e.jsxs("div",{className:"max-w-3xl",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})});const b=l.find(t=>t.user_id===(d==null?void 0:d.userId)),v=(d==null?void 0:d.role)==="admin"||(b==null?void 0:b.role)==="owner"||(b==null?void 0:b.role)==="admin",L=(d==null?void 0:d.role)==="admin"||(b==null?void 0:b.role)==="owner",$=async()=>{const t=r.id;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(t),x(!0),setTimeout(()=>x(!1),2e3);return}}catch{}const p=document.createElement("textarea");p.value=t,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select();try{document.execCommand("copy"),x(!0),setTimeout(()=>x(!1),2e3)}catch{}document.body.removeChild(p)},_=async(t,p)=>{if(t.role!==p){y("");try{await f(t.user_id,p)}catch(w){y(w instanceof Error?w.message:i("team.member.updateFailed"))}}},s=async t=>{const p=t.username||t.user_id;if(window.confirm(i("team.member.removeConfirm").replace("{name}",p))){y("");try{await E(t.user_id)}catch(S){y(S instanceof Error?S.message:i("team.member.updateFailed"))}}};return e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:r.name}),e.jsxs("p",{className:"mt-2 font-mono text-xs text-text-muted",children:["/",r.slug]}),r.description&&e.jsx("p",{className:"mt-5 max-w-2xl text-sm leading-relaxed text-text-muted",children:r.description}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("code",{className:"font-mono text-xs text-text-muted",children:r.id}),e.jsx("button",{type:"button",onClick:$,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy team ID",children:e.jsx(D,{className:"h-3.5 w-3.5"})}),h&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"}),v&&e.jsx("a",{href:`/teams/${r.slug}/settings`,className:"ml-1 text-text-muted transition-colors hover:text-text-primary","aria-label":"Team settings",title:"Team settings",children:e.jsx(K,{className:"h-4 w-4"})})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("div",{className:"mb-6 flex items-baseline justify-between",children:e.jsxs("h2",{className:"text-sm font-medium text-text-primary",children:[i("team.detail.members")," (",l.length,")"]})}),g&&e.jsx("div",{className:"mb-4 rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:g}),u?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading members..."}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No members."}):e.jsx("ul",{className:"space-y-2",children:l.map(t=>{const p=t.user_id===(d==null?void 0:d.userId),w=t.role==="owner"||t.role==="admin",S=v&&(!w||L),A=S&&!(t.role==="owner"&&l.filter(o=>o.role==="owner").length<=1),R=["owner","admin","member"];return e.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-xl border border-border bg-surface-1 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.username||t.user_id}),p&&e.jsx("span",{className:"text-xs text-text-muted",children:i("team.member.you")}),e.jsx("span",{className:X("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium",U[t.role]||U.member),children:F(t.role)})]}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-text-muted",children:t.user_id})]}),v&&e.jsxs(Y,{children:[e.jsx(Q,{asChild:!0,children:e.jsx("button",{type:"button",disabled:!S,className:"shrink-0 rounded-md p-1.5 text-text-muted transition-colors hover:bg-surface-2 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent","aria-label":i("team.member.changeRole"),title:i("team.member.changeRole"),children:e.jsx(V,{className:"h-4 w-4"})})}),e.jsxs(Z,{align:"end",className:"w-48",children:[e.jsx(ee,{className:"text-xs text-text-muted",children:i("team.member.changeRole")}),R.map(o=>e.jsxs(M,{onSelect:()=>_(t,o),className:"flex items-center justify-between",children:[e.jsx("span",{children:F(o)}),t.role===o&&e.jsx(H,{className:"h-3.5 w-3.5 text-brand-text"})]},o)),e.jsx(te,{}),e.jsxs(M,{variant:"destructive",disabled:!A,onSelect:()=>s(t),className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i("team.member.remove")})]})]})]})]},t.user_id)})})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:i("team.detail.environments")}),e.jsx(le,{teamId:r.id,canManage:v})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:i("team.detail.invitations")}),e.jsx(ce,{teamId:r.id,canManage:v})]})]})}export{ve as TeamDetail};
@@ -1 +0,0 @@
1
- import{j as e}from"./vendor-DE_-CLIE.js";import{aJ as l,r as a}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function c(){const{myTeams:t,isLoading:i}=l();return i?e.jsx("div",{className:"px-6 py-20 sm:px-10",children:e.jsxs("div",{className:"max-w-4xl",children:[e.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"mt-12 space-y-10",children:[0,1,2].map(s=>e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-surface-2"})]},s))})]})}):e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary sm:text-4xl",children:"Teams"}),e.jsx("p",{className:"mt-3 text-sm text-text-muted",children:t.length===0?"Create your first team to start collaborating.":`${t.length} ${t.length===1?"team":"teams"}`})]}),t.length===0?e.jsx("div",{className:"py-8",children:e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-2 rounded-md bg-accent px-5 py-2.5 text-sm font-medium text-white transition-all hover:bg-accent/90 active:translate-y-px",children:[e.jsx(a,{className:"h-4 w-4"}),"Create team"]})}):e.jsx("ul",{className:"space-y-10",children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:`/teams/${s.slug}`,className:"group block",children:[e.jsxs("div",{className:"flex items-baseline gap-4",children:[e.jsx("h2",{className:"font-display text-xl font-medium tracking-tight text-text-primary transition-colors group-hover:text-accent",children:s.name}),e.jsxs("span",{className:"font-mono text-xs text-text-muted",children:["/",s.slug]})]}),s.description?e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-text-muted",children:s.description}):e.jsx("p",{className:"mt-2 text-sm italic text-text-muted/60",children:"No description"})]})},s.id))}),t.length>0&&e.jsx("div",{className:"mt-16",children:e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-2 rounded-md border border-border px-4 py-2 text-sm font-medium text-text-primary transition-all hover:bg-surface-2 active:translate-y-px",children:[e.jsx(a,{className:"h-4 w-4"}),"New team"]})})]})}export{c as TeamList};
@@ -1 +0,0 @@
1
- import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{K as c}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";async function j(s){try{const r=s.startsWith("team_")?`/web/teams/${s}`:`/web/teams/by-slug/${s}`;return await c("GET",r)}catch{return null}}async function w(s,r){await c("PATCH",`/web/teams/${s}`,r)}async function N(s){await c("DELETE",`/web/teams/${s}`)}function k(){const s=window.location.pathname.split("/"),r=s[s.length-2]||"",[a,h]=n.useState(null),[b,y]=n.useState(!0),[i,m]=n.useState(""),[l,d]=n.useState(""),[u,o]=n.useState(null),[x,p]=n.useState(!1);n.useEffect(()=>{r&&j(r).then(t=>{t&&(h(t),m(t.name),d(t.description||"")),y(!1)})},[r]);const g=async t=>{if(t.preventDefault(),!!a){o(null),p(!0);try{await w(a.id,{name:i,description:l}),window.location.href=`/teams/${a.slug}`}catch(f){o(f instanceof Error?f.message:"Failed to update")}finally{p(!1)}}},v=async()=>{if(a&&window.confirm("Delete this team? Environments must be transferred first."))try{await N(a.id),window.location.href="/teams"}catch(t){o(t instanceof Error?t.message:"Failed to delete")}};return b?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."}):a?e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsxs("header",{className:"mb-12",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:a.name}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-text-muted",children:["/",a.slug]})]}),e.jsxs("form",{onSubmit:g,className:"mb-16 max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:"Team Name"}),e.jsx("input",{id:"name",type:"text",required:!0,value:i,onChange:t=>m(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:"Description"}),e.jsx("textarea",{id:"description",value:l,onChange:t=>d(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),u&&e.jsx("p",{className:"text-sm text-destructive",children:u}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:x||!i,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:x?"Saving...":"Save Changes"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-sm font-medium text-destructive",children:"Delete team"}),e.jsx("p",{className:"mb-4 text-sm text-text-muted",children:"Deleting a team requires all environments to be transferred first."}),e.jsx("button",{type:"button",onClick:v,className:"rounded-md border border-destructive/60 px-4 py-2 text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors",children:"Delete Team"})]})]})}):e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})}export{k as TeamSettings};
@@ -1 +0,0 @@
1
- import{e as a,j as t}from"./vendor-DE_-CLIE.js";import{aI as v,aA as l,K as S}from"./main-Dh-rPGBg.js";function C({onSelect:o,excludeUserIds:x=[],placeholder:u,actionLabel:m,actionDisabled:h=!1,className:p}){v();const[n,c]=a.useState(""),[b,s]=a.useState([]),[i,d]=a.useState(!1),f=async e=>{if(c(e),e.trim().length<2){s([]);return}d(!0);try{const N=await S("GET",`/web/users/search?q=${encodeURIComponent(e.trim())}`);s(N)}catch{s([])}finally{d(!1)}},y=e=>{o(e),c(""),s([])},r=b.filter(e=>!x.includes(e.id)),g=m??l("invitation.add"),j=u??l("invitation.searchUser");return t.jsxs("div",{className:p,children:[t.jsx("input",{type:"text",value:n,onChange:e=>f(e.target.value),placeholder:j,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),i&&t.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Searching..."}),r.length>0&&t.jsx("ul",{className:"mt-2 divide-y divide-border rounded border border-border bg-surface-1",children:r.map(e=>t.jsxs("li",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-text-primary",children:e.username}),t.jsx("div",{className:"truncate font-mono text-xs text-text-muted",children:e.id})]}),t.jsx("button",{type:"button",onClick:()=>y(e.id),disabled:h,className:"rounded bg-accent px-2 py-1 text-xs text-white hover:bg-accent/90 disabled:opacity-50",children:g})]},e.id))}),n.trim().length>=2&&r.length===0&&!i&&t.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"No users found."})]})}export{C as U};
@@ -1 +0,0 @@
1
- import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{aH as D,aI as I,aA as t,az as R}from"./main-Dh-rPGBg.js";import{a as A,i as L,s as N}from"./notifications-WMIbgYDP.js";import{C as O}from"./copy-lzYYFmlH.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function W(){const{user:n,logout:j}=D(),v=I(),[m,u]=a.useState(""),[i,x]=a.useState(""),[p,h]=a.useState(""),[f,b]=a.useState(""),[g,o]=a.useState(""),[C,c]=a.useState(!1),w=A(),[d,y]=a.useState(()=>L()),[S,P]=a.useState(()=>w&&Notification.permission==="denied"),E=async()=>{if(d){N(!1),y(!1);return}let s=!0;try{Notification.permission==="default"?s=await Notification.requestPermission()==="granted":s=Notification.permission==="granted"}catch{s=!1}P(!s),s&&(N(!0),y(!0))};if(!n)return null;const k=async()=>{const s=n.userId;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),c(!0),setTimeout(()=>c(!1),2e3);return}}catch{}const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();try{document.execCommand("copy"),c(!0),setTimeout(()=>c(!1),2e3)}catch{}document.body.removeChild(r)},q=async s=>{if(s.preventDefault(),o(""),b(""),i.length<8){o(t("auth.setup.passwordTooShort"));return}if(i!==p){o(t("auth.setup.passwordMismatch"));return}try{const r=await fetch("/web/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({currentPassword:m,newPassword:i})});if(!r.ok){const l=await r.json();throw new Error(l.error||t("user.settings.changeFailed"))}b(t("user.settings.passwordChanged")),u(""),x(""),h("")}catch(r){const l=r instanceof Error?r.message:t("user.settings.changeFailed");o(l)}},T=async()=>{try{if(!(await fetch("/web/auth/logout-all",{method:"POST",credentials:"include",headers:{"X-Requested-With":"XMLHttpRequest"}})).ok){o(t("common.error"));return}await j()}catch{o(t("common.error"))}};return e.jsx("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:e.jsxs("div",{children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:n.username}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("code",{className:"font-mono text-xs text-text-muted",children:n.userId}),e.jsx("button",{type:"button",onClick:k,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy user ID",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),C&&e.jsx("span",{className:"text-xs text-status-active",children:t("share.copied")}),e.jsx("span",{className:"text-text-muted/40",children:"·"}),e.jsx("span",{className:"text-xs text-text-muted",children:n.role})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-text-primary",children:t("user.settings.notifications")}),w?e.jsxs("div",{className:"max-w-md",children:[e.jsx("button",{type:"button",onClick:E,className:`rounded-md px-4 py-2 text-sm font-medium transition-colors ${d?"bg-brand text-white hover:bg-brand-light":"bg-surface-2 text-text-primary hover:bg-surface-3"}`,children:d?t("user.settings.notificationsOn"):t("user.settings.notificationsOff")}),e.jsx("p",{className:"mt-3 text-xs text-text-muted",children:t("user.settings.notificationsDesc")}),S&&e.jsx("p",{className:"mt-2 text-xs text-status-warning",children:t("user.settings.notificationsDenied")})]}):e.jsx("p",{className:"text-xs text-text-muted",children:t("user.settings.notificationsUnsupported")})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-text-primary",children:t("user.settings.language")}),e.jsxs("select",{value:v,onChange:s=>R(s.target.value),className:"rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"zh",children:"中文"}),e.jsx("option",{value:"en",children:"English"})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-text-primary",children:t("user.settings.changePassword")}),e.jsxs("form",{onSubmit:q,className:"max-w-md space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-text-primary",children:t("user.settings.currentPassword")}),e.jsx("input",{type:"password",value:m,onChange:s=>u(s.target.value),required:!0,autoComplete:"current-password",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-text-primary",children:t("user.settings.newPassword")}),e.jsx("input",{type:"password",value:i,onChange:s=>x(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-text-primary",children:t("user.settings.confirmNewPassword")}),e.jsx("input",{type:"password",value:p,onChange:s=>h(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"})]}),g&&e.jsx("p",{className:"text-sm text-status-error",children:g}),f&&e.jsx("p",{className:"text-sm text-status-active",children:f}),e.jsx("div",{className:"pt-2",children:e.jsx("button",{type:"submit",className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-accent/90",children:t("user.settings.submit")})})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-destructive",children:t("user.settings.logoutAll")}),e.jsx("p",{className:"mb-4 text-sm text-text-muted",children:"Revoke sessions on all devices."}),e.jsx("button",{onClick:T,className:"rounded-md border border-status-error/30 px-4 py-2 text-sm font-medium text-status-error transition-colors hover:bg-status-error/10",children:t("user.settings.logoutAll")})]})]})})}export{W as UserSettings};
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-EjsI3GC3.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,a as s,c as t,C as e}from"./chunk-727SXJPM-D0ITaMeP.js";import{b as i}from"./mermaid.core-EjsI3GC3.js";import"./chunk-FMBD7UC4-C-CaLwfI.js";import"./chunk-ND2GUHAM-OPpmIsi8.js";import"./chunk-55IACEB6-CQGtwyGQ.js";import"./chunk-2J33WTMH-wa-oCiR6.js";import"./preload-helper-BiaRt2Oj.js";import"./vendor-DE_-CLIE.js";import"./mermaid-VLURNSYL-CrqI4db6.js";import"./main-Dh-rPGBg.js";import"./motion-BILbV7YQ.js";import"./shiki-ChKhlm5h.js";var w={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{w as diagram};
@@ -1 +0,0 @@
1
- import{s as a,a as s,c as t,C as e}from"./chunk-727SXJPM-D0ITaMeP.js";import{b as i}from"./mermaid.core-EjsI3GC3.js";import"./chunk-FMBD7UC4-C-CaLwfI.js";import"./chunk-ND2GUHAM-OPpmIsi8.js";import"./chunk-55IACEB6-CQGtwyGQ.js";import"./chunk-2J33WTMH-wa-oCiR6.js";import"./preload-helper-BiaRt2Oj.js";import"./vendor-DE_-CLIE.js";import"./mermaid-VLURNSYL-CrqI4db6.js";import"./main-Dh-rPGBg.js";import"./motion-BILbV7YQ.js";import"./shiki-ChKhlm5h.js";var w={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{w as diagram};
@@ -1 +0,0 @@
1
- import{j as t}from"./vendor-DE_-CLIE.js";import{R as l,i,h as d,X as r,aj as o,T as c,v as g,O as u}from"./main-Dh-rPGBg.js";function j({...a}){return t.jsx(l,{"data-slot":"dialog",...a})}function f({...a}){return t.jsx(g,{"data-slot":"dialog-portal",...a})}function x({className:a,...e}){return t.jsx(u,{"data-slot":"dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e})}function v({className:a,children:e,showCloseButton:s=!0,...n}){return t.jsxs(f,{"data-slot":"dialog-portal",children:[t.jsx(x,{}),t.jsxs(i,{"data-slot":"dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...n,children:[e,s&&t.jsxs(d,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(r,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...e})}function h({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}function y({className:a,...e}){return t.jsx(c,{"data-slot":"dialog-title",className:o("text-lg leading-none font-semibold",a),...e})}export{j as D,v as a,h as b,b as c,y as d};