@saluzi/saluzi-edu 0.7.24 → 0.7.26
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.
- package/dist/cli.js +47 -47
- package/dist/rcs-web/assets/{AdminPanel-kHOmCjvI.js → AdminPanel-B5r-j_pk.js} +1 -1
- package/dist/rcs-web/assets/{ArtifactView-DSEwTsDl.js → ArtifactView-D7UBrBa9.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactsGallery-BBnDfj2k.js → dist/rcs-web/assets/ArtifactsGallery-C_xQd43k.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Claim-B2Xu_cvl.js → dist/rcs-web/assets/Claim-BGzDL0Qw.js} +1 -1
- package/dist/rcs-web/assets/{Dashboard-BJqvH4Wh.js → Dashboard-BtnSabxQ.js} +1 -1
- package/dist/rcs-web/assets/{Join-C3FQBiYX.js → Join-DJ_IXKdV.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Login-DMdqmsTJ.js → dist/rcs-web/assets/Login-CN3qVWJv.js} +1 -1
- package/dist/rcs-web/assets/{MemoriesPage-CjRfwKDG.js → MemoriesPage-DOvZ8ChD.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/MemoryTypeChips-DmuM1mnc.js → dist/rcs-web/assets/MemoryTypeChips-VJ7BJmCi.js} +1 -1
- package/dist/rcs-web/assets/{Register-n4PilsVQ.js → Register-HLpHgUEs.js} +1 -1
- package/dist/rcs-web/assets/{RegisterEmpty-X-9vRPKk.js → RegisterEmpty-CRUB4yEZ.js} +1 -1
- package/dist/rcs-web/assets/SessionDetail-BjVcvCfd.js +83 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-DuPAMDm1.js → SessionVisibilityBadge-CLREwggU.js} +1 -1
- package/dist/rcs-web/assets/{Setup-DfGuh7jn.js → Setup-DujdwzXx.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-CkVddcMe.js → ShareLanding-BOSIpzJj.js} +1 -1
- package/dist/rcs-web/assets/{TeamDetail-DuizvSbi.js → TeamDetail-DDNxumxT.js} +1 -1
- package/dist/rcs-web/assets/{TeamList-BdVZ9Tjt.js → TeamList-XBGstrgY.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-B8P4jDlV.js → TeamSettings-CqXRgHg4.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-eNdovFoR.js → UserSearchInput-BC4G8fqt.js} +1 -1
- package/dist/rcs-web/assets/{UserSettings-Bif5fxbq.js → UserSettings-C4ksj9xI.js} +1 -1
- package/dist/rcs-web/assets/{arc-ApDTthsU.js → arc-BXaQDpdZ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-bsc4_GGC.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-BJUcTTFb.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-fIfab7zF.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM--sHW0x9o.js} +1 -1
- package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-CZfXwXa1.js → c4Diagram-AAUBKEIU-CtPJk05b.js} +1 -1
- package/dist/rcs-web/assets/channel-B-rv6G5F.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-b8OaiWft.js → chunk-2J33WTMH-CiN5Q9dh.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-D3B2lnxT.js → chunk-4BX2VUAB-CwzhiSd4.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-Cpmx_iFV.js → chunk-55IACEB6-BH39Wjkd.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-M4sLpc_k.js → dist/rcs-web/assets/chunk-727SXJPM-rHT8TI2l.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-CIA-MGb9.js → dist/rcs-web/assets/chunk-AQP2D5EJ-KHoGyBPu.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-CKNzLHmp.js → chunk-FMBD7UC4-BLgKKRIv.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-DN0Pnvc3.js → chunk-ND2GUHAM-9ec1s_Ys.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-BLV90OZ4.js → chunk-QZHKN3VN-D0paPXdO.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-CQyFrlew.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-CQyFrlew.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-YmW1Op0G.js → code-block-IT6T5CEO-DzLv4X6n.js} +1 -1
- package/dist/rcs-web/assets/{copy-B9nUKyEJ.js → copy-DC3pycaX.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-CcOR8zyS.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-Dd9_tuah.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-L7HbuqzP.js → dagre-BM42HDAG-DS65SVsM.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-l1-ofpMb.js → diagram-2AECGRRQ-CS9MObfx.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-D2K3iWps.js → diagram-5GNKFQAL-DsH3D3KX.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-CQixgeJD.js → diagram-KO2AKTUF-D0QcWqIW.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-Dn_sZo_M.js → diagram-LMA3HP47-WADSAiXy.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-1pw2POh5.js → dist/rcs-web/assets/diagram-OG6HWLK6-BSXMTT8s.js} +1 -1
- package/dist/rcs-web/assets/{dialog-BrV9mMDa.js → dialog-FXbBrT_y.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-BQQDCBvA.js → dist/rcs-web/assets/erDiagram-TEJ5UH35-BHEn0Frq.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-B2kdDyaf.js → dist/rcs-web/assets/flowDiagram-I6XJVG4X-K5QplS6B.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Bpl3yw8I.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-B_8nUWHj.js} +1 -1
- package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-D-G0DXPv.js → gitGraphDiagram-PVQCEYII-BLYJxkdm.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-BZeanrdj.js → infoDiagram-5YYISTIA-B2JPe8rO.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DnY_nCN3.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-7M78jaW5.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-CrEsg35t.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-BKIialt4.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-C13u_rgt.js → dist/rcs-web/assets/kanban-definition-UN3LZRKU-CbKINHZI.js} +1 -1
- package/dist/rcs-web/assets/{linear-CvzpbjB-.js → linear-CuEoGOaD.js} +1 -1
- package/dist/rcs-web/assets/{main-B2Nonos_.js → main-AdFlZL5H.js} +5 -5
- package/dist/rcs-web/assets/main-CIqv5Bfq.css +1 -0
- package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-CTnstEJM.js → dist/rcs-web/assets/mermaid-VLURNSYL-BnTvPMFR.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-B3yjGcGs.js → mermaid.core-CEncWaEl.js} +5 -5
- package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-DAntFhWL.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-BV6sPWLy.js} +1 -1
- package/dist/rcs-web/assets/{notifications-ohY2H57s.js → notifications-CiqeO7fT.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/pieDiagram-4H26LBE5-zxkZXG3z.js → dist/rcs-web/assets/pieDiagram-4H26LBE5-Dqgtf0mo.js} +1 -1
- package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-CcUtZsbh.js → quadrantDiagram-W4KKPZXB-hYslH32p.js} +1 -1
- package/dist/rcs-web/assets/{refresh-cw-Cgx8H9zR.js → refresh-cw-DVG2vRaP.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-CY2QH1gL.js → dist/rcs-web/assets/requirementDiagram-4Y6WPE33-D78rEROd.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-DbcEA3qL.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-CrgaaL4B.js} +1 -1
- package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-Dqd1vAf1.js → sequenceDiagram-3UESZ5HK-BQnDBzEC.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-B-atzG-h.js → dist/rcs-web/assets/stateDiagram-AJRCARHV-C7rbWnJ3.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BNE2glm0.js → stateDiagram-v2-BHNVJYJU-3jT2MQkA.js} +1 -1
- package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-C4O4XjXc.js → timeline-definition-PNZ67QCA-CSTITeHu.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-C60HcUPn.js → vennDiagram-CIIHVFJN-tfP_OcYV.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-DwrjdIQB.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-BSooVt7M.js} +1 -1
- package/dist/rcs-web/assets/{workerType-DA-wSQX5.js → workerType-CGf9PPvL.js} +1 -1
- package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-B-C8mDsp.js → xychartDiagram-2RQKCTM6-DCymrjwM.js} +1 -1
- package/dist/rcs-web/index.html +2 -2
- package/package.json +1 -1
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-kHOmCjvI.js → AdminPanel-B5r-j_pk.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ArtifactView-DSEwTsDl.js → ArtifactView-D7UBrBa9.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactsGallery-BBnDfj2k.js → packages/remote-control-server/web/dist/assets/ArtifactsGallery-C_xQd43k.js} +1 -1
- package/{dist/rcs-web/assets/Claim-B2Xu_cvl.js → packages/remote-control-server/web/dist/assets/Claim-BGzDL0Qw.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Dashboard-BJqvH4Wh.js → Dashboard-BtnSabxQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Join-C3FQBiYX.js → Join-DJ_IXKdV.js} +1 -1
- package/{dist/rcs-web/assets/Login-DMdqmsTJ.js → packages/remote-control-server/web/dist/assets/Login-CN3qVWJv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{MemoriesPage-CjRfwKDG.js → MemoriesPage-DOvZ8ChD.js} +1 -1
- package/{dist/rcs-web/assets/MemoryTypeChips-DmuM1mnc.js → packages/remote-control-server/web/dist/assets/MemoryTypeChips-VJ7BJmCi.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-n4PilsVQ.js → Register-HLpHgUEs.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{RegisterEmpty-X-9vRPKk.js → RegisterEmpty-CRUB4yEZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-BjVcvCfd.js +83 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-DuPAMDm1.js → SessionVisibilityBadge-CLREwggU.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Setup-DfGuh7jn.js → Setup-DujdwzXx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-CkVddcMe.js → ShareLanding-BOSIpzJj.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamDetail-DuizvSbi.js → TeamDetail-DDNxumxT.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamList-BdVZ9Tjt.js → TeamList-XBGstrgY.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-B8P4jDlV.js → TeamSettings-CqXRgHg4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-eNdovFoR.js → UserSearchInput-BC4G8fqt.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSettings-Bif5fxbq.js → UserSettings-C4ksj9xI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-ApDTthsU.js → arc-BXaQDpdZ.js} +1 -1
- package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-bsc4_GGC.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-BJUcTTFb.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-fIfab7zF.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM--sHW0x9o.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-CZfXwXa1.js → c4Diagram-AAUBKEIU-CtPJk05b.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-B-rv6G5F.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-b8OaiWft.js → chunk-2J33WTMH-CiN5Q9dh.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-D3B2lnxT.js → chunk-4BX2VUAB-CwzhiSd4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-Cpmx_iFV.js → chunk-55IACEB6-BH39Wjkd.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-M4sLpc_k.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-rHT8TI2l.js} +1 -1
- package/{dist/rcs-web/assets/chunk-AQP2D5EJ-CIA-MGb9.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-KHoGyBPu.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-CKNzLHmp.js → chunk-FMBD7UC4-BLgKKRIv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-DN0Pnvc3.js → chunk-ND2GUHAM-9ec1s_Ys.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-BLV90OZ4.js → chunk-QZHKN3VN-D0paPXdO.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-CQyFrlew.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-CQyFrlew.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-YmW1Op0G.js → code-block-IT6T5CEO-DzLv4X6n.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-B9nUKyEJ.js → copy-DC3pycaX.js} +1 -1
- package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-CcOR8zyS.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-Dd9_tuah.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-L7HbuqzP.js → dagre-BM42HDAG-DS65SVsM.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-l1-ofpMb.js → diagram-2AECGRRQ-CS9MObfx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-D2K3iWps.js → diagram-5GNKFQAL-DsH3D3KX.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-CQixgeJD.js → diagram-KO2AKTUF-D0QcWqIW.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-Dn_sZo_M.js → diagram-LMA3HP47-WADSAiXy.js} +1 -1
- package/{dist/rcs-web/assets/diagram-OG6HWLK6-1pw2POh5.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-BSXMTT8s.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dialog-BrV9mMDa.js → dialog-FXbBrT_y.js} +1 -1
- package/{dist/rcs-web/assets/erDiagram-TEJ5UH35-BQQDCBvA.js → packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-BHEn0Frq.js} +1 -1
- package/{dist/rcs-web/assets/flowDiagram-I6XJVG4X-B2kdDyaf.js → packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-K5QplS6B.js} +1 -1
- package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Bpl3yw8I.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-B_8nUWHj.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-D-G0DXPv.js → gitGraphDiagram-PVQCEYII-BLYJxkdm.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-BZeanrdj.js → infoDiagram-5YYISTIA-B2JPe8rO.js} +1 -1
- package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DnY_nCN3.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-7M78jaW5.js} +1 -1
- package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-CrEsg35t.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-BKIialt4.js} +1 -1
- package/{dist/rcs-web/assets/kanban-definition-UN3LZRKU-C13u_rgt.js → packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-CbKINHZI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-CvzpbjB-.js → linear-CuEoGOaD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-B2Nonos_.js → main-AdFlZL5H.js} +5 -5
- package/packages/remote-control-server/web/dist/assets/main-CIqv5Bfq.css +1 -0
- package/{dist/rcs-web/assets/mermaid-VLURNSYL-CTnstEJM.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-BnTvPMFR.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-B3yjGcGs.js → mermaid.core-CEncWaEl.js} +5 -5
- package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-DAntFhWL.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-BV6sPWLy.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{notifications-ohY2H57s.js → notifications-CiqeO7fT.js} +1 -1
- package/{dist/rcs-web/assets/pieDiagram-4H26LBE5-zxkZXG3z.js → packages/remote-control-server/web/dist/assets/pieDiagram-4H26LBE5-Dqgtf0mo.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-CcUtZsbh.js → quadrantDiagram-W4KKPZXB-hYslH32p.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{refresh-cw-Cgx8H9zR.js → refresh-cw-DVG2vRaP.js} +1 -1
- package/{dist/rcs-web/assets/requirementDiagram-4Y6WPE33-CY2QH1gL.js → packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-D78rEROd.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-DbcEA3qL.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-CrgaaL4B.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-Dqd1vAf1.js → sequenceDiagram-3UESZ5HK-BQnDBzEC.js} +1 -1
- package/{dist/rcs-web/assets/stateDiagram-AJRCARHV-B-atzG-h.js → packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-C7rbWnJ3.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BNE2glm0.js → stateDiagram-v2-BHNVJYJU-3jT2MQkA.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-C4O4XjXc.js → timeline-definition-PNZ67QCA-CSTITeHu.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-C60HcUPn.js → vennDiagram-CIIHVFJN-tfP_OcYV.js} +1 -1
- package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-DwrjdIQB.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-BSooVt7M.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{workerType-DA-wSQX5.js → workerType-CGf9PPvL.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-B-C8mDsp.js → xychartDiagram-2RQKCTM6-DCymrjwM.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +2 -2
- package/dist/rcs-web/assets/SessionDetail-CM8lZ9rp.js +0 -78
- package/dist/rcs-web/assets/channel-BGtRlTca.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-BgkYB8h2.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-BgkYB8h2.js +0 -1
- package/dist/rcs-web/assets/main-CsENcSJO.css +0 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-CM8lZ9rp.js +0 -78
- package/packages/remote-control-server/web/dist/assets/channel-BGtRlTca.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-BgkYB8h2.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-BgkYB8h2.js +0 -1
- package/packages/remote-control-server/web/dist/assets/main-CsENcSJO.css +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var jn=Object.defineProperty;var vn=(r,t,s)=>t in r?jn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var I=(r,t,s)=>vn(r,typeof t!="symbol"?t+"":t,s);import{j as e,e as l}from"./vendor-DE_-CLIE.js";import{aA as J,af as wn,aI as es,aH as ts,aO as i,aK as Nn,aJ as ut,aP as U,aF as je,at as kn,as as X,ai as Sn,ap as _n,aT as Cn,aW as se,T as Tn,Q as En,X as Ds,L as Ye,H as Mn,I as Rn,i as ss,aE as An,N as In,aB as xt,e as ft,S as pt,M as $n,y as Dn,aC as Z,ay as xe,aD as qn,aQ as Pn,G as On,D as Fn,aR as ns,aj as Kn,a1 as Ln,ao as Un,aX as Bn,ad as qs,ab as Hn,a9 as Qn,aq as Wn,al as zn,P as Yn,t as Vn,B as Ps,$ as Gn,A as Jn,aG as Xn,aL as Zn,aM as er,Z as rs,a0 as tr,aS as sr,b as nr,a4 as as,am as rr,K as Os,F as ar,d as or,C as ir,ae as os,l as lr,a as cr,u as Mt,w as Rt,E as dr,g as At,f as It,v as $t,s as ur}from"./main-AdFlZL5H.js";import{A as mr,g as Fs}from"./workerType-CGf9PPvL.js";import{D as ve,a as we,c as Ae,d as Ne,b as xr}from"./dialog-FXbBrT_y.js";import{R as pr}from"./refresh-cw-DVG2vRaP.js";import{A as fr,U as hr}from"./UserSearchInput-BC4G8fqt.js";import{C as yr}from"./copy-DC3pycaX.js";import{E as gr,S as br,A as jr}from"./ArtifactsGallery-C_xQd43k.js";import{S as vr}from"./SessionVisibilityBadge-CLREwggU.js";import{D as St,u as wr,d as Nr,e as kr,F as is,c as Sr,b as _r,T as Cr,h as Tr,a as Er,M as Mr}from"./MemoryTypeChips-VJ7BJmCi.js";import{S as Rr,b as Ar}from"./notifications-CiqeO7fT.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 Ir=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ks=J("chevron-right",Ir);/**
|
|
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 $r=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],Dr=J("coins",$r);/**
|
|
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 qr=[["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"}]],Ls=J("cpu",qr);/**
|
|
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 Pr=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ls=J("gauge",Pr);/**
|
|
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 Or=[["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"}]],Fr=J("hash",Or);/**
|
|
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 Kr=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Lr=J("layers",Kr);/**
|
|
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 Ur=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],cs=J("lightbulb",Ur);/**
|
|
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 Br=[["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"}]],Us=J("message-circle-question-mark",Br);/**
|
|
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 Hr=[["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"}]],Qr=J("message-square-text",Hr);/**
|
|
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 Wr=[["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"}]],zr=J("play",Wr);/**
|
|
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 Yr=[["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"}]],Bs=J("plug",Yr);/**
|
|
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 Vr=[["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"}]],Gr=J("server-cog",Vr);/**
|
|
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 Jr=[["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"}]],Hs=J("settings-2",Jr);/**
|
|
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 Xr=[["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"}]],Zr=J("share-2",Xr);/**
|
|
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 ea=[["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"}]],ta=J("shield-check",ea);function Et(){return{tasks:{}}}const ds=3e4;function it(r){const t=r.trim();if(!t)return"agent";const s=t.split(/\s+/).slice(0,2).join(" ");return s.length>40?s.slice(0,40)+"…":s}function us(r,t){var c,d,f,p,y,g,S,E,T,m,h,w;const s=t.subtype;if(s!=="task_started"&&s!=="task_progress"&&s!=="task_notification")return r;const n=t.task_id;if(!n)return r;const a=Date.now(),u=r.tasks[n];if(s==="task_started"){if(u)return{tasks:{...r.tasks,[n]:{...u,description:t.description??u.description,name:it(t.description??u.description),taskType:t.task_type??u.taskType,workflowName:t.workflow_name??u.workflowName,prompt:t.prompt??u.prompt,toolUseId:t.tool_use_id??u.toolUseId,status:"running",startTime:a,evictAfter:void 0}}};const N=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:it(N),description:N,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:a}}}}if(s==="task_progress"){if(!u){const N=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:it(N),description:N,toolUseId:t.tool_use_id,status:"running",startTime:a,tokenCount:(c=t.usage)==null?void 0:c.total_tokens,toolUseCount:(d=t.usage)==null?void 0:d.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...r.tasks,[n]:{...u,description:t.description??u.description,tokenCount:((p=t.usage)==null?void 0:p.total_tokens)??u.tokenCount,toolUseCount:((y=t.usage)==null?void 0:y.tool_uses)??u.toolUseCount,durationMs:((g=t.usage)==null?void 0:g.duration_ms)??u.durationMs,lastToolName:t.last_tool_name??u.lastToolName,summary:t.summary??u.summary}}}}return u?{tasks:{...r.tasks,[n]:{...u,status:t.status??"completed",endTime:a,finalSummary:t.summary??u.finalSummary,outputFile:t.output_file??u.outputFile,tokenCount:((m=t.usage)==null?void 0:m.total_tokens)??u.tokenCount,toolUseCount:((h=t.usage)==null?void 0:h.tool_uses)??u.toolUseCount,durationMs:((w=t.usage)==null?void 0:w.duration_ms)??u.durationMs,evictAfter:a+ds}}}:{tasks:{...r.tasks,[n]:{taskId:n,name:it(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:a,endTime:a,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(S=t.usage)==null?void 0:S.total_tokens,toolUseCount:(E=t.usage)==null?void 0:E.tool_uses,durationMs:(T=t.usage)==null?void 0:T.duration_ms,evictAfter:a+ds}}}}function Qs(r,t=Date.now()){return Object.values(r.tasks).filter(s=>s.evictAfter===void 0||s.evictAfter>t).sort((s,n)=>s.startTime-n.startTime)}const ms={in_process_teammate:0,local_bash:1,monitor_mcp:2,remote_agent:3,local_agent:4,dream:5},xs=100;function sa(r){const t=new Map;for(const s of r){const n=s.taskType??"",a=t.get(n);a?a.push(s):t.set(n,[s])}return[...t.entries()].sort(([s],[n])=>{const a=ms[s]??xs,u=ms[n]??xs;return a===u?s.localeCompare(n):a-u}).map(([s,n])=>({taskType:s,tasks:[...n].sort((a,u)=>a.startTime-u.startTime)}))}function ps(r){const t=r.raw,s=t&&typeof t=="object"?t:r,n=typeof s.subtype=="string"?s.subtype:void 0;return n!=="task_started"&&n!=="task_progress"&&n!=="task_notification"?null:{subtype:n,task_id:typeof s.task_id=="string"?s.task_id:void 0,tool_use_id:typeof s.tool_use_id=="string"?s.tool_use_id:void 0,description:typeof s.description=="string"?s.description:void 0,task_type:typeof s.task_type=="string"?s.task_type:void 0,workflow_name:typeof s.workflow_name=="string"?s.workflow_name:void 0,prompt:typeof s.prompt=="string"?s.prompt:void 0,usage:s.usage&&typeof s.usage=="object"?s.usage:void 0,last_tool_name:typeof s.last_tool_name=="string"?s.last_tool_name:void 0,summary:typeof s.summary=="string"?s.summary:void 0,status:s.status==="completed"||s.status==="failed"||s.status==="stopped"?s.status:void 0,output_file:typeof s.output_file=="string"?s.output_file:void 0}}function na(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,s={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,set_token_mode:t.set_token_mode===!0,side_question:t.side_question===!0};return Object.values(s).some(Boolean)?s:null}function fs(r,t){const s=[];if(Array.isArray(r)){for(const n of r){if(!n||typeof n!="object")continue;const a=n;if(typeof a.name!="string"||!a.name)continue;const u=a.type==="prompt"||a.type==="local"||a.type==="local-jsx"?a.type:void 0;s.push({name:a.name,...typeof a.description=="string"&&a.description?{description:a.description}:{},...typeof a.argumentHint=="string"&&a.argumentHint?{argumentHint:a.argumentHint}:{},...u?{type:u}:{}})}if(s.length>0)return s}if(Array.isArray(t))for(const n of t)typeof n=="string"&&n&&s.push({name:n});return s}function hs(r){const t=r.raw&&typeof r.raw=="object"&&!Array.isArray(r.raw)?r.raw:r,s=fs(t.slash_command_details??r.slash_command_details,t.slash_commands??r.slash_commands),n=fs(t.skill_details??r.skill_details,t.skills??r.skills),a=na(t.remote_capabilities??r.remote_capabilities);return s.length===0&&n.length===0&&!a?null:{commands:s,skills:n,capabilities:a}}class ra{constructor(t){I(this,"listeners",new Set);I(this,"stateListeners",new Set);I(this,"eventSource",null);I(this,"sessionId",null);I(this,"_lastSeqNum",0);I(this,"lastFrameAt",0);I(this,"firstEventAfterOpen",!1);I(this,"watchdogTimer",null);I(this,"visibilityHandler",null);I(this,"reconnectTimer",null);I(this,"reconnectAttempts",0);I(this,"_state","idle");I(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`,s=new EventSource(t,{withCredentials:!0});this.eventSource=s,this.lastFrameAt=Date.now(),this.firstEventAfterOpen=!0,s.addEventListener("open",()=>{this.lastFrameAt=Date.now(),this.reconnectAttempts=0,this.firstEventAfterOpen=!0,this.setState("open")}),s.addEventListener("ping",()=>{this.lastFrameAt=Date.now()}),s.addEventListener("message",n=>{this.lastFrameAt=Date.now();try{const a=JSON.parse(n.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 u of this.listeners)u(a)}catch{}}),s.addEventListener("error",()=>{s.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),s=Math.max(0,t+t*.25*(2*Math.random()-1));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnect()},s)}async reconnect(){this.sessionId&&(await Cn(),this.sessionId&&this.openStream())}setState(t){if(this._state!==t){this._state=t;for(const s of this.stateListeners)s(t,{})}}notifyResync(){for(const t of this.stateListeners)t(this._state,{resync:!0})}}const me=new ra;function _t(r){if(typeof r.content=="string")return r.content;if(r.message&&typeof r.message=="object"){const t=r.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(s=>s.type==="text"&&typeof s.text=="string").map(s=>s.text).join("")}return""}function ys(r,t){for(let s=r.length-1;s>=0;s--){const n=r[s];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return s}return-1}const Ct="streaming-";function gs(r){const t=r.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const s=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const a=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";a&&s.push(a)}return s.join("")}function bs(r){return r.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 js(r){if(!r||typeof r!="object")return"";const t=r;if(typeof t.target_event_id=="string"&&t.target_event_id)return t.target_event_id;const s=t.raw;if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s.target_event_id;if(typeof n=="string"&&n)return n}return""}class aa{constructor(t,s,n){I(this,"sessionId");I(this,"setEntries");I(this,"unsub",null);I(this,"unsubState",null);I(this,"onStatusChange");I(this,"onError");I(this,"onPermissionRequest");I(this,"onModelsStateChange");I(this,"onSubagentUpdate");I(this,"onControlResponse");I(this,"onPermissionModeChange");I(this,"onElicitationRequest");I(this,"onWorkerInfoChange");I(this,"onTurnStart");I(this,"subagentState",Et());I(this,"seenUuids",new Set);I(this,"seenToolCallIds",new Set);I(this,"pendingToolCallIds",new Set);I(this,"pendingPermissionToolIds",new Map);I(this,"postedUserUuids",new Set);I(this,"pendingControlRequests",new Map);I(this,"turnEnded",!1);I(this,"userSinceTurnEnd",!1);I(this,"turnStartedAt",null);I(this,"closed",!1);this.sessionId=t,this.setEntries=s,this.onStatusChange=n==null?void 0:n.onStatusChange,this.onError=n==null?void 0:n.onError,this.onPermissionRequest=n==null?void 0:n.onPermissionRequest,this.onModelsStateChange=n==null?void 0:n.onModelsStateChange,this.onSubagentUpdate=n==null?void 0:n.onSubagentUpdate,this.onControlResponse=n==null?void 0:n.onControlResponse,this.onPermissionModeChange=n==null?void 0:n.onPermissionModeChange,this.onElicitationRequest=n==null?void 0:n.onElicitationRequest,this.onWorkerInfoChange=n==null?void 0:n.onWorkerInfoChange,this.onTurnStart=n==null?void 0:n.onTurnStart}markClosed(){this.closed=!0}setTurnStartedAt(t){var s;this.turnStartedAt!==t&&(this.turnStartedAt=t,(s=this.onTurnStart)==null||s.call(this,t))}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var T,m,h,w,N,M;const{events:t}=await wn(this.sessionId);if(!t||t.length===0)return;const s=new Set;for(const j of t){if(j.type!=="user"||j.direction==="inbound")continue;const v=(T=j.payload)==null?void 0:T.uuid;typeof v=="string"&&v&&s.add(v)}const n=[];let a=null;const u=()=>{a&&(n.push(a),a=null)};for(const j of t){const v=j.payload||{},P=v.uuid;if(typeof P=="string"&&P&&this.seenUuids.add(P),j.type==="tool_use"){const k=v.tool_call_id;typeof k=="string"&&k&&this.seenToolCallIds.add(k)}if(j.type==="user"){if(j.direction==="inbound"){const F=v.uuid;if(typeof F!="string"||!F||s.has(F))continue}u();const k=_t(v);k&&n.push({type:"user_message",id:j.id||`hist-user-${n.length}`,content:k})}else if(j.type==="assistant"){u();const k=_t(v);if(es(k))continue;const F=gs(v),D=[],_=v.message;if(_&&typeof _=="object"&&Array.isArray(_.content)){for(const q of _.content)if(q.type==="tool_use"){const K=q.id;K&&this.seenToolCallIds.add(K),D.push({type:"tool_call",toolCall:{id:K||`hist-tool-${n.length}`,title:q.name||"tool",status:"complete",rawInput:q.input||{}}})}}if(k||F||D.length>0){a={type:"assistant_message",id:j.id||`hist-asst-${n.length}`,chunks:[...F?[{type:"thought",text:F}]:[],...k?[{type:"message",text:k}]:[]]},n.push(a);for(const q of D)n.push(q);a=null}}else if(j.type==="conversation_rewound"){const k=js(v);if(k){const F=n.findIndex(D=>ts(D)===k);F>=0&&(n.length=F)}}else if(j.type==="tool_use"){const k=v,F={type:"tool_call",toolCall:{id:k.tool_call_id||`hist-tool-${n.length}`,title:k.tool_name||"tool",status:"complete",rawInput:k.tool_input||{}}};n.push(F)}else if(j.type==="tool_result"){const k=v,F=ys(n,k.tool_call_id||"");if(F>=0){const D=n[F];n[F]={type:"tool_call",toolCall:{...D.toolCall,rawOutput:{output:k.content||k.output||""}}}}}}u();let c=null;for(const j of t){if(j.type!=="task_state")continue;const v=j.payload||{};Array.isArray(v.tasks)&&(c=v.tasks)}if(c&&c.length>0){const j=bs(c);j.length>0&&n.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:j})}this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(n);let d=null,f=null,p=null,y=0,g=0;for(const j of t){const v=j.payload||{};if(typeof j.createdAt=="number"&&(j.createdAt>g&&(g=j.createdAt),j.type==="user"&&p!=="user"&&j.createdAt>0&&(y=j.createdAt)),j.type==="user"?p="user":(j.type==="result"||j.type==="result_success"||j.type==="interrupt")&&(p="turn_end"),j.type==="system"&&(v.subtype==="init"||((m=v.raw)==null?void 0:m.subtype)==="init")&&(f=hs(v)),j.type==="models_state"){const P=v.raw,k=P&&typeof P=="object"?P.models_state:v.models_state;k&&Array.isArray(k.availableModels)&&typeof k.currentModelId=="string"&&(d=k)}}let S=!1,E=Et();for(const j of t){if(j.type!=="system")continue;const v=ps(j.payload||{});v&&(E=us(E,v),S=!0)}S&&(this.subagentState=E,(h=this.onSubagentUpdate)==null||h.call(this,this.subagentState)),d&&((w=this.onModelsStateChange)==null||w.call(this,d)),f&&((N=this.onWorkerInfoChange)==null||N.call(this,f)),this.turnEnded=p==="turn_end",this.userSinceTurnEnd=p==="user",this.setTurnStartedAt(!this.closed&&p==="user"&&y>0&&g>=y?Date.now()-(g-y):null),this.turnEnded&&!this.closed&&((M=this.onStatusChange)==null||M.call(this,"idle"))}connectSSE(){me.connect(this.sessionId),this.unsub=me.onEvent(t=>this.handleEvent(t)),this.unsubState=me.onStateChange((t,s)=>{s.resync&&!this.closed&&this.loadHistory().catch(()=>{})})}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),this.unsubState&&(this.unsubState(),this.unsubState=null),me.disconnect()}handleEvent(t){var a,u,c,d,f,p,y,g,S,E,T;const s=t.type,n=t.payload||{};switch(s){case"user":{if(this.applyEmbeddedToolResults(n),this.userSinceTurnEnd=!0,!this.closed&&this.turnStartedAt===null&&this.setTurnStartedAt(Date.now()),t.direction==="inbound"){const m=n.uuid;if(typeof m!="string"||!m||this.postedUserUuids.has(m)||this.seenUuids.has(m))break;this.seenUuids.add(m);const h=_t(n);h&&this.setEntries(w=>[...w,{type:"user_message",id:t.id||`user-${Date.now()}`,content:h}])}break}case"assistant":{const m=n.uuid;if(typeof m=="string"&&m){if(this.seenUuids.has(m))break;this.seenUuids.add(m)}const h=typeof n.content=="string"?n.content:"";if(es(h))break;const w=gs(n);this.setEntries(M=>{const j=M[M.length-1];if((j==null?void 0:j.type)==="assistant_message"&&j.id.startsWith(Ct))return[...M.slice(0,-1),{...j,id:`assistant-${Date.now()}`,chunks:[...w?[{type:"thought",text:w}]:[],{type:"message",text:h}]}];if((j==null?void 0:j.type)==="assistant_message"){const v=j.chunks[j.chunks.length-1];return(v==null?void 0:v.type)==="message"?[...M.slice(0,-1),{...j,chunks:[...j.chunks.slice(0,-1),{type:"message",text:v.text+h}]}]:[...M.slice(0,-1),{...j,chunks:[...j.chunks,{type:"message",text:h}]}]}if(h&&h.trim()||w){const v={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...w?[{type:"thought",text:w}]:[],...h?[{type:"message",text:h}]:[]]};return[...M,v]}return M});const N=n.message;if(N&&typeof N=="object"&&Array.isArray(N.content)){const M=N.content.filter(j=>j.type==="tool_use");for(const j of M){const v=j.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(v))continue;this.seenToolCallIds.add(v),this.pendingToolCallIds.add(v);const P={id:v,title:j.name||"tool",status:"running",rawInput:j.input||{}};this.setEntries(k=>[...k,{type:"tool_call",toolCall:P}])}}break}case"tool_use":{const m=n,h=m.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(h))break;this.seenToolCallIds.add(h),this.pendingToolCallIds.add(h);const w={id:h,title:m.tool_name||"tool",status:"running",rawInput:m.tool_input||{}};this.setEntries(N=>[...N,{type:"tool_call",toolCall:w}]);break}case"tool_result":{const m=n;this.applyToolResult(m.tool_call_id||"",m.content??m.output);break}case"interrupt":{this.finalizePendingToolCalls("canceled"),this.turnEnded=!0,this.userSinceTurnEnd=!1,this.setTurnStartedAt(null),this.closed||(a=this.onStatusChange)==null||a.call(this,"idle");break}case"control_request":case"permission_request":{const m=n.request;if(m&&m.subtype==="can_use_tool"){const h=n.request_id||"",w=m.tool_name||"unknown",N=m.input||m.tool_input||{},M=m.description||"",j=Array.isArray(m.permission_suggestions)?m.permission_suggestions:[];this.setEntries(v=>{const P=[...v].reverse().findIndex(k=>k.type==="tool_call");if(P>=0){const k=v.length-1-P,F=v[k];if(F.toolCall.status==="running")return this.pendingPermissionToolIds.set(h,F.toolCall.id),v.map((D,_)=>_===k?{type:"tool_call",toolCall:{...F.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:h,options:[]}}}:D)}return v}),(u=this.onPermissionRequest)==null||u.call(this,{requestId:h,toolName:w,toolInput:N,description:M,suggestions:j})}else m&&m.subtype==="elicitation"&&((c=this.onElicitationRequest)==null||c.call(this,{requestId:n.request_id||"",serverName:m.mcp_server_name||"",message:m.message||"",mode:m.mode==="url"?"url":"form",url:typeof m.url=="string"?m.url:void 0,requestedSchema:m.requested_schema||void 0}));break}case"conversation_rewound":{const m=js(n);m&&(this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(h=>{const w=h.findIndex(N=>ts(N)===m);return w===-1?h:h.slice(0,w)}));break}case"session_status":{if(Nn(n)){this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries([]);break}if(typeof n.status=="string"){if(ut(n.status))this.closed=!0,this.finalizePendingToolCalls("canceled");else if(this.closed)break;if(n.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(d=this.onStatusChange)==null||d.call(this,n.status)}break}case"error":{const m=String(n.message||n.content||"Unknown error");(f=this.onError)==null||f.call(this,m);break}case"models_state":{const m=n.raw,h=typeof m=="object"&&m!==null?m.models_state:n.models_state;h&&Array.isArray(h.availableModels)&&typeof h.currentModelId=="string"&&((p=this.onModelsStateChange)==null||p.call(this,h));break}case"system":{const m=n.raw,h=m&&typeof m=="object"?m:n,w=typeof h.subtype=="string"?h.subtype:void 0,N=ps(n);N&&(this.subagentState=us(this.subagentState,N),(y=this.onSubagentUpdate)==null||y.call(this,this.subagentState));const M=typeof h.permissionMode=="string"?h.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;if(M&&((g=this.onPermissionModeChange)==null||g.call(this,M)),w==="init"){const j=hs(n);j&&((S=this.onWorkerInfoChange)==null||S.call(this,j))}break}case"control_response":{const m=n.response;if(m&&typeof m=="object"){const h=typeof m.request_id=="string"?m.request_id:"",w=typeof m.subtype=="string"?m.subtype:"";if(h){(E=this.onControlResponse)==null||E.call(this,{subtype:w,requestId:h,error:typeof m.error=="string"?m.error:void 0});const N=this.pendingControlRequests.get(h);N&&(this.pendingControlRequests.delete(h),N({data:w==="success"&&m.response&&typeof m.response=="object"?m.response:null,...w==="error"&&typeof m.error=="string"?{error:m.error}:{}}))}}break}case"stream_event":{const m=n.event;if(!m||typeof m.type!="string")break;if(m.type==="content_block_delta"){const h=m.delta;if(!h||typeof h.type!="string")break;const w=h.type==="text_delta"?"message":h.type==="thinking_delta"?"thought":null;if(!w)break;const N=h.text??h.thinking;if(typeof N!="string"||!N)break;this.appendStreamingDelta(w,N)}break}case"partial_assistant":{const m=typeof n.content=="string"?n.content:"";m&&this.appendStreamingDelta("message",m);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.setTurnStartedAt(null),this.finalizePendingToolCalls(n.is_error?"canceled":"complete"),this.closed||(T=this.onStatusChange)==null||T.call(this,"idle");const m=typeof n.subtype=="string"?n.subtype:"",h=n.raw&&typeof n.raw=="object"?n.raw:void 0,N=(typeof n.result=="string"?n.result:typeof(h==null?void 0:h.result)=="string"?h.result:"").trim();m.startsWith("error_")&&N&&this.setEntries(M=>[...M,{type:"command_output",id:`exit-error-${typeof n.uuid=="string"?n.uuid:Date.now()}`,commandName:"worker",inputText:"",title:i("adapter.workerCrashed"),outputText:N,variant:"error"}]);break}case"task_state":{const m=Array.isArray(n.tasks)?n.tasks:[];if(m.length===0)break;const h=bs(m);if(h.length===0)break;this.setEntries(w=>[...w.filter(M=>M.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:h}]);break}}}applyEmbeddedToolResults(t){const s=t.message;if(!(!s||typeof s!="object"||!Array.isArray(s.content)))for(const n of s.content)!n||n.type!=="tool_result"||this.applyToolResult(n.tool_use_id||"",n.content??n.output)}applyToolResult(t,s){t&&(this.pendingToolCallIds.delete(t),this.setEntries(n=>{const a=ys(n,t);if(a<0)return n;const u=n[a];return u.toolCall.status!=="running"&&u.toolCall.status!=="waiting_for_confirmation"?n:n.map((c,d)=>d===a?{type:"tool_call",toolCall:{...u.toolCall,status:"complete",permissionRequest:void 0,rawOutput:{output:s||""}}}:c)}))}finalizePendingToolCalls(t){if(this.pendingToolCallIds.size===0)return;const s=this.pendingToolCallIds;this.pendingToolCallIds=new Set,this.setEntries(n=>n.map(a=>a.type!=="tool_call"||!s.has(a.toolCall.id)?a:{type:"tool_call",toolCall:{...a.toolCall,status:t,permissionRequest:void 0}}))}appendStreamingDelta(t,s){this.setEntries(n=>{const a=n[n.length-1];if((a==null?void 0:a.type)==="assistant_message"&&a.id.startsWith(Ct)){const c=a.chunks[a.chunks.length-1];return(c==null?void 0:c.type)===t?[...n.slice(0,-1),{...a,chunks:[...a.chunks.slice(0,-1),{type:t,text:c.text+s}]}]:[...n.slice(0,-1),{...a,chunks:[...a.chunks,{type:t,text:s}]}]}const u={type:"assistant_message",id:`${Ct}${Date.now()}`,chunks:[{type:t,text:s}]};return[...n,u]})}async sendMessage(t,s,n){var p;const a=s&&s.length>0,u=n&&n.length>0;if(!t.trim()&&!a&&!u)return;const c={type:"user_message",id:`user-${Date.now()}`,content:t,images:a?s:void 0,attachments:u?n:void 0};this.setEntries(y=>[...y,c]);const d=[];if(t&&d.push({type:"text",text:t}),a)for(const y of s)d.push({type:"image",source:{type:"base64",media_type:y.mimeType,data:y.data}});if(u){for(const y of n)if(y.kind==="text"||y.kind==="table"){const g=`📎 ${y.name}${y.size!=null?` (${oa(y.size)})`:""}`,S=y.textContent||i("attach.emptyFile");d.push({type:"text",text:`${g}
|
|
77
|
+
\`\`\`
|
|
78
|
+
${S}
|
|
79
|
+
\`\`\``})}else if(y.kind==="directory"){const g=y.files!=null?`${U("attach.directoryHeader",{name:y.name})} ${U("attach.fileCount",{n:y.files.length})}`:U("attach.directoryHeader",{name:y.name}),S=y.textContent||i("attach.emptyDirectory");d.push({type:"text",text:`${g}
|
|
80
|
+
${S}`})}}const f=d.length===1&&d[0].type==="text"?d[0].text||t:d.length>0?d:t;try{const y=je();this.postedUserUuids.add(y);const g=await kn(this.sessionId,{type:"user",uuid:y,content:t,message:{content:f}}),S=(p=g==null?void 0:g.event)==null?void 0:p.id;S&&this.setEntries(E=>E.map(T=>T.type==="user_message"&&T.id===c.id?{...T,id:S}:T))}catch(y){throw this.setEntries(g=>g.filter(S=>!(S.type==="user_message"&&S.id===c.id))),y}}async respondPermission(t,s,n){await X(this.sessionId,{type:"permission_response",approved:s,request_id:t,...n});const a=this.pendingPermissionToolIds.get(t);this.pendingPermissionToolIds.delete(t),a&&!s&&this.pendingToolCallIds.delete(a),this.setEntries(u=>u.map(c=>{var d;return c.type!=="tool_call"||((d=c.toolCall.permissionRequest)==null?void 0:d.requestId)!==t?c:{type:"tool_call",toolCall:{...c.toolCall,status:s?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.finalizePendingToolCalls("canceled"),await Sn(this.sessionId)}async setPermissionMode(t){const s=je();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const n=je(),a=new Promise(c=>{this.pendingControlRequests.set(n,c)}),u=setTimeout(()=>{const c=this.pendingControlRequests.get(n);c&&(this.pendingControlRequests.delete(n),c({data:null,error:"timeout"}))},s);try{return await X(this.sessionId,{type:"control_request",request_id:n,request:t}),await a}catch(c){throw this.pendingControlRequests.delete(n),c}finally{clearTimeout(u)}}async searchFiles(t,s=20){const n=await this.controlRoundTrip({subtype:"file_search",query:t,limit:s});try{if(!n.data||!Array.isArray(n.data.suggestions))return[];const a=[];for(const u of n.data.suggestions)u&&typeof u=="object"&&typeof u.path=="string"&&a.push(u.path);return a}catch{return[]}}async respondElicitation(t,s,n){await X(this.sessionId,{type:"permission_response",approved:s==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:s,...n?{content:n}:{}}}})}async askSideQuestion(t){const s=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(s.error||!s.data)return null;const n=s.data.response;return typeof n=="string"?n: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 s=[];for(const n of t.data.sessions){if(!n||typeof n!="object")continue;const a=n;typeof a.session_id!="string"||!a.session_id||s.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 s}async resumeSession(t){const s=await this.controlRoundTrip({subtype:"resume_session",session_id:t},3e4);if(!s.data)throw new Error(s.error??"resume_session failed");return{title:typeof s.data.title=="string"?s.data.title:null,messageCount:typeof s.data.message_count=="number"?s.data.message_count:0}}async setEffort(t){const s=je();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setTokenMode(t){const s=je();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_token_mode",mode:t}}),s}async setThinkingBudget(t){const s=je();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:t}}),s}async getContextUsage(){const t=await this.controlRoundTrip({subtype:"get_context_usage"});try{if(!t.data)return null;const s=t.data.totalTokens,n=t.data.rawMaxTokens,a=t.data.percentage;if(typeof s!="number"||typeof n!="number")return null;const u=t.data.categories,c=Array.isArray(u)?u.filter(d=>!!d&&typeof d=="object"&&typeof d.name=="string").map(d=>({name:d.name,tokens:typeof d.tokens=="number"?d.tokens:0,...d.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:typeof a=="number"?a:0,...typeof t.data.model=="string"&&t.data.model?{model:t.data.model}:{},...c&&c.length>0?{categories:c}:{}}}catch{return null}}async stopSubagent(t){const s=await this.controlRoundTrip({subtype:"stop_task",task_id:t});try{return s.error?{ok:!1,error:s.error==="timeout"?i("adapter.stopTimeout"):s.error}:{ok:!0}}catch{return{ok:!1,error:i("adapter.stopFailed")}}}async getMcpServers(){var a;const s=(a=(await this.controlRoundTrip({subtype:"mcp_status"})).data)==null?void 0:a.mcpServers;if(!Array.isArray(s))return[];const n=[];for(const u of s){if(!u||typeof u!="object")continue;const c=u;if(typeof c.name!="string"||!c.name)continue;const d=c.status;if(d!=="connected"&&d!=="failed"&&d!=="needs-auth"&&d!=="pending"&&d!=="disabled")continue;const f=c.serverInfo,p=c.config;n.push({name:c.name,status:d,...f&&typeof f.name=="string"&&typeof f.version=="string"?{serverInfo:{name:f.name,version:f.version}}:{},...typeof c.error=="string"&&c.error?{error:c.error}:{},...typeof(p==null?void 0:p.url)=="string"&&p.url?{url:p.url}:{},...Array.isArray(c.tools)?{toolCount:c.tools.length}:{}})}return n}async toggleMcpServer(t,s){const n=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:s},15e3);return n.error?{ok:!1,error:n.error==="timeout"?i("adapter.requestTimeout"):n.error}:{ok:!0}}async reconnectMcpServer(t){const s=await this.controlRoundTrip({subtype:"mcp_reconnect",serverName:t},2e4);return s.error?{ok:!1,error:s.error==="timeout"?i("adapter.requestTimeout"):s.error}:{ok:!0}}async getRemoteSettings(){const s=(await this.controlRoundTrip({subtype:"get_settings"})).data;if(!s)return null;const n=s.applied,a=s.effective&&typeof s.effective=="object"&&!Array.isArray(s.effective)?s.effective:{},u=s.sources,c=[];if(Array.isArray(u))for(const d of u){if(!d||typeof d!="object")continue;const f=d;typeof f.source=="string"&&c.push({source:f.source,settings:f.settings&&typeof f.settings=="object"&&!Array.isArray(f.settings)?f.settings:{}})}return{applied:{model:typeof(n==null?void 0:n.model)=="string"?n.model:null,effort:typeof(n==null?void 0:n.effort)=="string"?n.effort:null,tokenMode:typeof(n==null?void 0:n.tokenMode)=="string"?n.tokenMode:null},effective:a,sources:c}}async applyFlagSettings(t){const s=await this.controlRoundTrip({subtype:"apply_flag_settings",settings:t},15e3);return s.error?{ok:!1,error:s.error==="timeout"?i("adapter.requestTimeout"):s.error}:{ok:!0}}async rewindToMessage(t){await _n(this.sessionId,t)}async endSession(t){await X(this.sessionId,{type:"control_request",request_id:je(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function oa(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function lt({onBack:r,title:t,meta:s,actions:n}){return se(),e.jsx("div",{className:"flex-shrink-0 border-b border-nav-rule bg-surface-1/80 backdrop-blur-md",children:e.jsxs("div",{className:"mx-auto flex h-12 w-full page-measure items-center gap-2 px-4 sm:px-8",children:[e.jsx("button",{type:"button",onClick:r,"aria-label":i("nav.dashboard"),title:i("nav.dashboard"),className:"-mx-2 flex-shrink-0 rounded-md px-2 py-1 text-xs text-text-muted transition hover:-translate-x-0.5 hover:bg-surface-2 hover:text-text-primary",children:i("nav.dashboard")}),e.jsx("span",{className:"mx-1 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t,s&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-2",children:s})]}),n&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:n}),e.jsx("span",{className:"mx-0.5 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsx(Tn,{className:"h-7 w-7"}),e.jsx(En,{compact:!0,onSettingsClick:()=>{window.history.pushState(null,"","/settings"),window.dispatchEvent(new PopStateEvent("popstate"))}})]})})}const vs="rcs:subagent-panel:collapsed";function ia(r){if(r<1e3)return"0s";const t=Math.floor(r/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60),n=t%60;if(s<60)return n?`${s}m${n}s`:`${s}m`;const a=Math.floor(s/60),u=s%60;return u?`${a}h${u}m`:`${a}h`}function la(r){return r===void 0||r<=0?"":r<1e3?`${r}`:r<1e6?`${(r/1e3).toFixed(r<1e4?1:0)}k`:`${(r/1e6).toFixed(1)}M`}function ca({status:r}){return r==="running"?e.jsx(Ye,{className:"h-3 w-3 animate-spin text-brand-text"}):r==="completed"?e.jsx(zr,{className:"h-3 w-3 text-status-success"}):r==="failed"||r==="stopped"?e.jsx(Mn,{className:"h-3 w-3 text-status-error"}):null}function Ws({task:r,onStopTask:t,fullText:s}){const n=r.status==="running",a=n?r.durationMs??Date.now()-r.startTime:(r.endTime??Date.now())-r.startTime,u=la(r.tokenCount),c=r.toolUseCount!==void 0&&r.toolUseCount>0?`${r.toolUseCount} tool${r.toolUseCount>1?"s":""}`:"",d=r.summary||r.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(ca,{status:r.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:r.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:ia(a)})]}),e.jsx("div",{className:`mt-0.5 text-text-secondary ${s?"line-clamp-2 break-words":"truncate"}`,children:d}),(u||c||r.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-x-2 overflow-hidden whitespace-nowrap font-mono text-[10px] text-text-muted",children:[u&&e.jsxs("span",{className:"flex-shrink-0",children:["↕ ",u," tok"]}),c&&e.jsxs("span",{className:"flex-shrink-0",children:["· ",c]}),r.lastToolName&&e.jsxs("span",{className:"min-w-0 truncate",children:["· last: ",r.lastToolName]})]}),!n&&r.finalSummary&&e.jsx("div",{className:"mt-1 line-clamp-2 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:r.finalSummary})]}),n&&t&&e.jsx("button",{type:"button",onClick:()=>t(r.taskId),title:i("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(Ds,{className:"h-3.5 w-3.5"})})]})}function da({state:r,onStopTask:t}){const[s,n]=l.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(vs)==="1"}catch{return!1}}),a=()=>{n(g=>{const S=!g;try{window.localStorage.setItem(vs,S?"1":"0")}catch{}return S})},u=Object.values(r.tasks).some(g=>g.status==="running"),c=Object.values(r.tasks).some(g=>g.status!=="running"&&g.evictAfter!==void 0),[,d]=l.useState(0);l.useEffect(()=>{if(!u&&!c)return;const g=setInterval(()=>{d(S=>S+1)},1e3);return()=>clearInterval(g)},[u,c]);const f=Qs(r);if(f.length===0)return null;const p=f.filter(g=>g.status==="running").length,y=p>0?`${p} running`:`${f.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":!s,"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(Ks,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:y})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:f.map(g=>e.jsx(Ws,{task:g,onStopTask:t},g.taskId))})]})})}function ua(r){if(!r)return"never";const t=Math.max(0,Date.now()-r);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 ma(r){return r?Date.now()-r<6e4:!1}function xa({onClose:r,session:t,liveStatus:s,pendingPermissions:n,onInterrupt:a,onDelete:u,subagentState:c,onStopTask:d,onEndSession:f}){const[p,y]=l.useState(!1),g=async()=>{await navigator.clipboard.writeText(t.id),y(!0),setTimeout(()=>y(!1),1500)},[S,E]=l.useState(!1),T=async()=>{if(!(!f||S)&&window.confirm(i("task.endConfirm"))){E(!0);try{await f(),r()}catch{E(!1)}}},m=n.length,h=t.worker,w=t.work_item,N=t.environment;return e.jsx(ve,{open:!0,onOpenChange:M=>{M||r()},children:e.jsxs(we,{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(Ae,{children:e.jsx(Ne,{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(mr,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rn,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:h&&(ma(h.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[h&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ss,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ua(h.last_heartbeat_at)})]}),(t.environment_id||N)&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Ls,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:(N==null?void 0:N.machine_name)||t.environment_id||(N==null?void 0:N.id)})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ss,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:An(t.created_at)})]})]})]}),e.jsx(ha,{state:c,onStopTask:d}),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(Ye,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),m>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[m," permission request",m>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(Gr,{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"}),f&&e.jsx("button",{onClick:T,disabled:S,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:i("task.endHint"),children:S?"Ending…":"End session"}),e.jsxs("button",{onClick:u,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(In,{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(Fr,{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:g,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:p?"✓":"⧉"})]})]}),w&&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:w.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:w.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})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Fs(t.source==="acp"?"acp":N==null?void 0:N.worker_type).fullLabel})]})]})]})]})]})})}const pa={in_process_teammate:"task.type.teammates",local_bash:"task.type.shells",monitor_mcp:"task.type.monitors",remote_agent:"task.type.remoteAgents",local_agent:"task.type.localAgents"},fa=new Set(["dream"]);function ha({state:r,onStopTask:t}){const s=Object.values(r.tasks).some(f=>f.status==="running"),n=Object.values(r.tasks).some(f=>f.status!=="running"&&f.evictAfter!==void 0),[,a]=l.useState(0);l.useEffect(()=>{if(!s&&!n)return;const f=setInterval(()=>{a(p=>p+1)},1e3);return()=>clearInterval(f)},[s,n]);const u=Qs(r),c=u.filter(f=>f.status==="running").length,d=u.length-c;return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Lr,{className:"h-3.5 w-3.5"}),i("task.backgroundTasks")]}),u.length>0&&e.jsx("span",{className:"font-mono text-[10px] text-text-muted",children:c>0&&d>0?U("task.mixedCount",{running:c,recent:d}):c>0?U("task.runningCount",{count:c}):U("task.recentCount",{count:u.length})})]}),u.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:i("task.noBackgroundTasks")}):e.jsx("div",{className:"max-h-[38vh] space-y-2 overflow-y-auto overscroll-contain pr-1",children:sa(u).map(f=>{const p=!fa.has(f.taskType),y=pa[f.taskType]??"task.type.tasks";return e.jsxs("div",{className:"space-y-1",children:[p&&e.jsxs("div",{className:"pl-1 text-[10px] font-medium uppercase tracking-wide text-text-muted/80",children:[i(y)," (",f.tasks.length,")"]}),f.tasks.map(g=>e.jsx(Ws,{task:g,onStopTask:t,fullText:!0},g.taskId))]},f.taskType)})})]})}const ya={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"},ga={connected:"mcp.status.connected",failed:"mcp.status.failed","needs-auth":"mcp.status.needsAuth",pending:"mcp.status.pending",disabled:"mcp.status.disabled"};function ba({onClose:r,fetchServers:t,onToggle:s,onReconnect:n}){se();const[a,u]=l.useState(null),[c,d]=l.useState(null),[f,p]=l.useState(null),[y,g]=l.useState(null),S=l.useCallback(async()=>{p(null),g(null);try{const m=await t();u(m),d(null)}catch(m){xt("[McpPanel] fetch failed",m),d(i("mcp.loadFailed"))}},[t]);l.useEffect(()=>{S()},[S]);const E=async m=>{const h=m.status==="disabled";p(`toggle:${m.name}`),g(null);try{const w=await s(m.name,h);w.ok||g(w.error||i("mcp.toggleFailed"))}finally{await S()}},T=async m=>{p(`reconnect:${m.name}`),g(null);try{const h=await n(m.name);h.ok||g(h.error||i("mcp.reconnectFailed"))}finally{await S()}};return e.jsx(ve,{open:!0,onOpenChange:m=>{m||r()},children:e.jsxs(we,{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(Ae,{children:e.jsxs(Ne,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Bs,{className:"h-4 w-4"}),i("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&&!c&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Ye,{className:"h-3.5 w-3.5 animate-spin"}),i("mcp.loading")]}),c&&e.jsx("p",{className:"text-xs text-status-error",children:c}),a!==null&&a.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:i("mcp.empty")}),a==null?void 0:a.map(m=>{const h=f===`toggle:${m.name}`,w=f===`reconnect:${m.name}`,N=m.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:m.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${ya[m.status]}`,children:i(ga[m.status])})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[m.serverInfo?`${m.serverInfo.name} v${m.serverInfo.version}`:m.url||"stdio",m.toolCount!==void 0&&` · ${U("mcp.toolCount",{n:m.toolCount})}`]}),m.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:m.error,children:m.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void T(m),disabled:w||N,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:i("mcp.reconnect"),children:e.jsx(pr,{className:`h-3.5 w-3.5 ${w?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!N,onClick:()=>void E(m),disabled:h,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${N?"bg-surface-3":"bg-brand"}`,title:N?i("mcp.enable"):i("mcp.disable"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${N?"left-0.5":"left-4.5"}`})})]})]})},m.name)})]})]})})}const zs=[{key:"autoMemoryEnabled",labelKey:"settings.autoMemory",defaultValue:!0},{key:"teamMemoryEnabled",labelKey:"settings.teamMemory",defaultValue:!1}],ja=new Set(zs.map(r=>r.key));function va(r){if(r==null)return i("settings.unset");if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function ws(r){if(r==null)return i("settings.unset");if(typeof r=="object")try{return JSON.stringify(r,null,2)}catch{return String(r)}return String(r)}function wa({onClose:r,fetchSettings:t,onApply:s}){se();const[n,a]=l.useState(null),[u,c]=l.useState(null),[d,f]=l.useState(""),[p,y]=l.useState(null),[g,S]=l.useState(null),[E,T]=l.useState(null),[m,h]=l.useState(!1),w=l.useCallback(async()=>{y(null),S(null),T(null),h(!1);try{const _=await t();a(_),c(_?null:i("settings.loadFailed"))}catch(_){xt("[SettingsDrawer] fetch failed",_),c(i("settings.loadFailed"))}},[t]);l.useEffect(()=>{w()},[w]);const N=l.useMemo(()=>n?Object.entries(n.effective).filter(([,_])=>_!==void 0).filter(([_])=>!_.startsWith("memoryV2")).sort(([_],[q])=>_.localeCompare(q)):[],[n]),M=l.useMemo(()=>{const _=d.trim().toLowerCase();return _?N.filter(([q,K])=>`${q} ${va(K)}`.toLowerCase().includes(_)):N},[N,d]),j=_=>typeof _[1]=="boolean",v=l.useMemo(()=>M.filter(j).filter(([_])=>!ja.has(_)),[M]),P=l.useMemo(()=>M.filter(_=>!j(_)),[M]),k=l.useMemo(()=>E===null?null:N.find(([_])=>_===E)??null,[N,E]),F=async()=>{if(k)try{await navigator.clipboard.writeText(ws(k[1])),h(!0),window.setTimeout(()=>h(!1),1500)}catch(_){xt("[SettingsDrawer] copy failed",_)}},D=async(_,q)=>{y(_),S(null);try{const K=await s({[_]:!q});K.ok||S(K.error||i("settings.writeFailed"))}finally{await w()}};return e.jsx(ve,{open:!0,onOpenChange:_=>{_||r()},children:e.jsxs(we,{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(Ae,{children:e.jsxs(Ne,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Hs,{className:"h-4 w-4"}),i("session.settings.title")]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[g&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:g}),n===null&&!u&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Ye,{className:"h-3.5 w-3.5 animate-spin"}),i("settings.loading")]}),u&&e.jsx("p",{className:"text-xs text-status-error",children:u}),n&&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:i("settings.model")}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.model||i("settings.defaultModel")})]}),n.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:n.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-text-muted",children:i("settings.hint")})]}),k?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>{T(null),h(!1)},className:"flex items-center gap-1.5 text-xs text-text-muted transition-colors hover:text-text-primary",children:[e.jsx(fr,{className:"h-3.5 w-3.5"}),i("settings.back")]}),e.jsx("div",{className:"break-all font-mono text-xs font-medium text-text-primary",children:k[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-[10px] leading-relaxed text-text-secondary",children:ws(k[1])}),e.jsxs("button",{type:"button",onClick:()=>void F(),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:[m?e.jsx(ft,{className:"h-3.5 w-3.5 text-status-success"}):e.jsx(yr,{className:"h-3.5 w-3.5"}),m?i("settings.copied"):i("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(pt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:d,onChange:_=>f(_.target.value),placeholder:i("settings.searchPlaceholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),M.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:i("settings.noMatch")}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:i("settings.memorySection")}),zs.map(_=>{const q=n.effective[_.key],K=typeof q=="boolean"?q:_.defaultValue,V=p===_.key;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 text-xs text-text-primary",children:i(_.labelKey)}),e.jsx("button",{type:"button",role:"switch","aria-checked":K,disabled:V,onClick:()=>void D(_.key,K),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${K?"bg-brand":"bg-surface-3"}`,title:K?i("settings.turnOff"):i("settings.turnOn"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${K?"left-4.5":"left-0.5"}`})})]},_.key)}),e.jsx("p",{className:"text-[10px] leading-relaxed text-text-muted",children:i("settings.memoryHint")})]}),v.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:U("settings.togglable",{n:v.length})}),v.map(([_,q])=>{const K=p===_;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.jsx("button",{type:"button",role:"switch","aria-checked":q,disabled:K,onClick:()=>void D(_,q),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${q?"bg-brand":"bg-surface-3"}`,title:q?i("settings.turnOff"):i("settings.turnOn"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${q?"left-4.5":"left-0.5"}`})})]},_)})]}),P.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:U("settings.readOnly",{n:P.length})}),P.map(([_])=>e.jsxs("button",{type:"button",onClick:()=>T(_),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:i("settings.viewDetail"),children:[e.jsx("span",{className:"truncate font-mono text-xs text-text-primary",children:_}),e.jsx(Ks,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},_))]})]})]})]})]})})}function Na({onClose:r,onAsk:t}){se();const[s,n]=l.useState([]),[a,u]=l.useState(""),[c,d]=l.useState(!1),f=async()=>{const p=a.trim();if(!p||c)return;const y=Date.now();n(g=>[...g,{id:y,question:p,answer:null}]),u(""),d(!0);try{const g=await t(p);n(S=>S.map(E=>E.id===y?{...E,answer:g??i("sideQuestion.noAnswer"),error:g===null}:E))}finally{d(!1)}};return e.jsx(ve,{open:!0,onOpenChange:p=>{p||r()},children:e.jsxs(we,{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(Ae,{children:e.jsxs(Ne,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Us,{className:"h-4 w-4"}),i("sideQuestion.title")]})}),e.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-text-muted",children:i("sideQuestion.desc")}),e.jsxs("div",{className:"mt-3 flex-1 space-y-4 overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:i("sideQuestion.empty")}),s.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($n,{children:p.answer})})})]})]},p.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:a,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&!p.nativeEvent.isComposing&&(p.preventDefault(),f())},rows:Math.min(4,Math.max(1,a.split(`
|
|
81
|
+
`).length)),placeholder:i("sideQuestion.placeholder"),disabled:c,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 f(),disabled:c||!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:i("sideQuestion.send"),children:c?e.jsx(Ye,{className:"h-4 w-4 animate-spin"}):e.jsx(Dn,{className:"h-4 w-4"})})]})]})})}const Tt="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-1";function Ns(r,t){var a;const s=(a=t==null?void 0:t.find(u=>u.type==="addRules"||u.type==="replaceRules"))==null?void 0:a.rules,n=s==null?void 0:s[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:r}function ka({requestId:r,toolName:t,toolInput:s,description:n,suggestions:a,onApprove:u,onApproveAlways:c,onReject:d}){se();const f=s&&typeof s=="object"&&!Array.isArray(s)?s:{},p=qn(Pn(t),f,{writeUnknownLabel:i("permission.writeUnknown")}),y=typeof s=="string"?s:JSON.stringify(s,null,2),g=Array.isArray(a)&&a.length>0;return e.jsxs("div",{role:"group","aria-label":U("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(On,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold font-display text-approve-text",children:i("permission.title")})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:Z(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:Z(t)}),t!=="AskUserQuestion"&&(p?e.jsx("div",{className:"mb-3 space-y-2",children:p.map((S,E)=>e.jsx(Fn,{filePath:S.filePath,oldString:S.oldString,newString:S.newString,label:S.label},E))}):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:ns(y,500)})),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:u,className:xe("rounded-lg bg-approve px-4 py-2 text-sm font-medium font-display text-white hover:bg-approve-hover transition-colors",Tt),children:i("permission.approve")}),g&&c&&e.jsxs("button",{onClick:c,className:xe("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",Tt),title:i("permission.alwaysAllowHint").replace("{rule}",Ns(t,a)),children:[e.jsx(ta,{className:"h-3.5 w-3.5"}),i("permission.alwaysAllow")," ",ns(Ns(t,a),40)]}),e.jsx("button",{onClick:d,className:xe("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",Tt),children:i("permission.reject")})]})]})}function Sa({questions:r,description:t,onSubmit:s,onSkip:n}){const[a,u]=l.useState({}),[c,d]=l.useState({}),[f,p]=l.useState(0),y=(T,m,h)=>{if(h){const w=a[T]||[],N=w.includes(m)?w.filter(M=>M!==m):[...w,m];u({...a,[T]:N})}else u({...a,[T]:m})},g=T=>{var h;const m=(h=c[T])==null?void 0:h.trim();m&&(u({...a,[T]:m}),d({...c,[T]:""}))},S=()=>{var m,h;const T={};for(const[w,N]of Object.entries(a)){const M=r[parseInt(w,10)];M&&(typeof N=="number"?T[w]=((h=(m=M.options)==null?void 0:m[N])==null?void 0:h.label)||String(N):Array.isArray(N)?T[w]=N.map(j=>{var v,P;return((P=(v=M.options)==null?void 0:v[j])==null?void 0:P.label)||String(j)}):T[w]=N)}s(T)};if(r.length<=1){const T=r[0]||{question:t,options:[],multiSelect:!1},m=T.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:Z(t||T.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(T.options||[]).map((h,w)=>{const N=m?(a[0]||[]).includes(w):a[0]===w;return e.jsxs("button",{onClick:()=>y(0,w,m),className:xe("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",N?"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:Z(h.label)}),h.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:Z(h.description)})]},w)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:c[0]||"",onChange:h=>d({...c,0:h.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:h=>h.key==="Enter"&&g(0)}),e.jsx("button",{onClick:()=>g(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:S,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:n,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 E=r[f];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:Z(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:r.map((T,m)=>e.jsx("button",{onClick:()=>p(m),className:xe("rounded-md px-3 py-1.5 text-xs font-display whitespace-nowrap transition-colors",f===m?"bg-brand/20 text-brand-text":"text-text-muted hover:bg-surface-2"),children:T.header||`Q${m+1}`},m))}),E&&e.jsx(_a,{question:E,qIdx:f,answers:a,otherTexts:c,onSelect:y,onOtherTextChange:(T,m)=>d({...c,[T]:m}),onOtherSubmit:g}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-display text-text-muted",children:[f+1," / ",r.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:S,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:n,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 _a({question:r,qIdx:t,answers:s,otherTexts:n,onSelect:a,onOtherTextChange:u,onOtherSubmit:c}){const d=r.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:Z(r.question)}),e.jsxs("div",{className:"space-y-2",children:[(r.options||[]).map((f,p)=>{const y=d?(s[t]||[]).includes(p):s[t]===p;return e.jsxs("button",{onClick:()=>a(t,p,d),className:xe("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:Z(f.label)}),f.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:Z(f.description)})]},p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:f=>u(t,f.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:f=>f.key==="Enter"&&c(t)}),e.jsx("button",{onClick:()=>c(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 Ca({planContent:r,description:t,onSubmit:s}){const[n,a]=l.useState(null),[u,c]=l.useState(""),d=!r||!r.trim(),f=()=>{n&&s(n,n==="no"?u: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(ft,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold font-display text-text-primary",children:d?"Exit plan mode?":"Ready to code?"})]}),!d&&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:Ta(r)}}),e.jsx("div",{className:"space-y-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(We,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes"}),e.jsx(We,{selected:n==="no",onClick:()=>a("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{selected:n==="yes-accept-edits",onClick:()=>a("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(We,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(We,{selected:n==="no",onClick:()=>a("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:u,onChange:p=>c(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:f,disabled:!n,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 We({selected:r,onClick:t,label:s,desc:n}){return e.jsxs("button",{onClick:t,className:xe("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",r?"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:xe("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",r?"border-brand bg-brand text-white":"border-border"),children:r&&"✓"}),e.jsx("span",{className:"font-medium font-display",children:s})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs font-sans text-text-muted",children:n})]})}function Ta(r){let t=Z(r);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(s,n,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 Ea({request:r,onSubmit:t}){se();const s=Ma(r.requestedSchema),n=Ra(r.requestedSchema),[a,u]=l.useState({}),c=s.length===0||n.every(d=>(a[d]??"").trim()!=="");return r.mode==="url"&&r.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(ks,{serverName:r.serverName,message:r.message}),e.jsxs("a",{href:r.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:r.url}),e.jsx(gr,{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:i("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:i("common.cancel")})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(ks,{serverName:r.serverName,message:r.message}),s.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:s.map(({name:d,prop:f})=>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:d}),n.includes(d)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:i("elicitation.required")})]}),f.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:Z(f.description)}),e.jsx("input",{type:f.type==="number"?"number":"text",value:a[d]??"",onChange:p=>u(y=>({...y,[d]: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"})]},d))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const d={};for(const{name:f,prop:p}of s){const y=(a[f]??"").trim();y&&(d[f]=p.type==="number"?Number(y):y)}t("accept",d)},disabled:!c,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:i("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:i("elicitation.decline")})]})]})}function ks({serverName:r,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(Qr,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:[i("elicitation.title")," ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:Z(r)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:Z(t)})]})}function Ma(r){const t=r==null?void 0:r.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,s])=>s&&typeof s=="object").map(([s,n])=>({name:s,prop:n}))}function Ra(r){const t=r==null?void 0:r.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Aa(r){const[t,s]=l.useState([]),[n,a]=l.useState(!0),[u,c]=l.useState(null),d=l.useCallback(async()=>{a(!0),c(null);try{const y=await Kn(r);s(y)}catch(y){c(y instanceof Error?y.message:"Failed to load shares")}finally{a(!1)}},[r]);l.useEffect(()=>{d()},[d]);const f=l.useCallback(async y=>{c(null);try{const g=await Ln(r,y);return await d(),g}catch(g){throw c(g instanceof Error?g.message:"Failed to create share"),g}},[r,d]),p=l.useCallback(async y=>{c(null);try{await Un(r,y),await d()}catch(g){throw c(g instanceof Error?g.message:"Failed to revoke share"),g}},[r,d]);return{shares:t,isLoading:n,error:u,createShare:f,revokeShare:p,refresh:d}}function Ia({open:r,onClose:t,sessionId:s,sessionTitle:n}){se();const{shares:a,isLoading:u,error:c,createShare:d,revokeShare:f}=Aa(s),[p,y]=l.useState("user"),[g,S]=l.useState(""),[E,T]=l.useState(""),[m,h]=l.useState("read"),[w,N]=l.useState(""),[M,j]=l.useState(!1),[v,P]=l.useState(null),[k,F]=l.useState(""),[D,_]=l.useState(!1),[q,K]=l.useState(!1);l.useEffect(()=>{r&&(y("user"),S(""),T(""),h("read"),N(""),j(!1),P(null),F(""),_(!1),K(!1))},[r]);const V=async()=>{j(!0),F(""),P(null);try{const $={grantedTo:p==="user"?{userId:g.trim()}:{teamId:E.trim()},permission:m};w.trim()&&($.expiresAt=w.trim());const ke=await d($);P(`${window.location.origin}/code/s/${ke.shareToken}`)}catch($){F($ instanceof Error?$.message:"Failed to create share")}finally{j(!1)}},pe=async $=>{try{await f($)}catch{}},oe=async()=>{if(!v)return;K(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(v),_(!0),setTimeout(()=>_(!1),2e3);return}}catch{}const $=document.createElement("textarea");$.value=v,$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select();try{document.execCommand("copy"),_(!0),setTimeout(()=>_(!1),2e3)}catch{K(!0)}document.body.removeChild($)};return e.jsx(ve,{open:r,onOpenChange:$=>{$||t()},children:e.jsxs(we,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ae,{children:e.jsxs(Ne,{className:"font-display text-lg font-semibold text-text-primary",children:[i("share.title"),n?`: ${n}`:""]})}),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:i("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:i("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:i("share.team")})]}),p==="user"?e.jsx(hr,{onSelect:S,placeholder:i("share.userIdPlaceholder"),actionLabel:i("share.selectUser")}):e.jsx("input",{type:"text",value:E,onChange:$=>T($.target.value),placeholder:i("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"&&g&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[i("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:g})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:i("share.permission")}),e.jsxs("select",{value:m,onChange:$=>h($.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:i("share.permissionRead")}),e.jsx("option",{value:"write",children:i("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:i("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:w,onChange:$=>N($.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"})]}),(k||c)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:k||c}),v&&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:i("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:v}),e.jsx("button",{onClick:oe,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:D?i("share.copied"):i("share.copy")})]}),q&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:i("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:i("share.existingShares")}),u?e.jsx("p",{className:"text-sm text-text-muted",children:i("share.loading")}):a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:i("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:a.map($=>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:$.granted_to_user||$.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[$.permission==="write"?i("share.permissionWrite"):i("share.permissionRead"),$.expires_at?` · expires ${$.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>pe($.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:i("share.revoke")})]},$.id))})]})]}),e.jsxs(xr,{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:i("common.close")}),e.jsx("button",{onClick:V,disabled:M||(p==="user"?!g.trim():!E.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:M?i("common.creating"):i("share.createShare")})]})]})})}function $a(r){const t=new Date,s=new Date(t.getTime()-1440*60*1e3),n=(c,d)=>c.getFullYear()===d.getFullYear()&&c.getMonth()===d.getMonth()&&c.getDate()===d.getDate(),a={today:[],yesterday:[],earlier:[]};for(const c of r){const d=new Date(c.modified||0);n(d,t)?a.today.push(c):n(d,s)?a.yesterday.push(c):a.earlier.push(c)}return[["today",i("resume.today")],["yesterday",i("resume.yesterday")],["earlier",i("resume.earlier")]].map(([c,d])=>({label:d,items:a[c]})).filter(c=>c.items.length>0)}function Da(r){return r?new Date(r).toLocaleString():""}function qa({open:r,onClose:t,adapter:s,onResume:n}){const a=se(),[u,c]=l.useState([]),[d,f]=l.useState(!1),[p,y]=l.useState("");l.useEffect(()=>{if(!r)return;let S=!1;return f(!0),y(""),c([]),s.listResumableSessions().then(E=>{S||c(E)}).catch(E=>{S||y(E instanceof Error?E.message:String(E))}).finally(()=>{S||f(!1)}),()=>{S=!0}},[r,s]);const g=l.useMemo(()=>$a(u),[u,a]);return e.jsx(ve,{open:r,onOpenChange:S=>{S||t()},children:e.jsxs(we,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ae,{children:e.jsx(Ne,{className:"font-display text-lg font-semibold text-text-primary",children:i("session.resume.title")})}),e.jsxs("div",{className:"max-h-96 min-w-0 space-y-4 overflow-y-auto",children:[d&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:i("resume.loading")}),!d&&p&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:p}),!d&&!p&&u.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:i("resume.empty")}),!d&&!p&&g.map(S=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-text-muted",children:S.label}),e.jsx("div",{className:"space-y-1",children:S.items.map(E=>e.jsxs("button",{type:"button",onClick:()=>n(E),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:E.title}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[Da(E.modified),E.gitBranch?` · ${E.gitBranch}`:""]})]},E.sessionId))})]},S.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:i("common.cancel")})})]})})}const Ss=["working","episodic","semantic","procedural"],Pa=["user","feedback","project","reference"];function Oa({refreshTick:r,recall:t,dreaming:s,onDreamTrigger:n}){se();const{myTeams:a}=Bn(),[u,c]=l.useState(null),[d,f]=l.useState("memories"),[p,y]=l.useState("personal"),[g,S]=l.useState([]),[E,T]=l.useState(!1),[m,h]=l.useState(""),[w,N]=l.useState(""),[M,j]=l.useState(null),[v,P]=l.useState(null),[k,F]=l.useState(!1),[D,_]=l.useState(St),q=wr(),[K,V]=l.useState(""),[pe,oe]=l.useState(null),[$,ke]=l.useState(!1),fe=l.useRef(null);l.useEffect(()=>{qs().then(c).catch(()=>c(null))},[]);const ee=l.useCallback(async()=>{T(!0),h("");try{S(await Hn(p))}catch{h(i("memorySidebar.loadFailed"))}finally{T(!1)}},[p]);l.useEffect(()=>{ee()},[ee,r]),l.useEffect(()=>{const b=()=>void ee();return window.addEventListener("focus",b),()=>window.removeEventListener("focus",b)},[ee]),l.useEffect(()=>{d==="governance"&&Qn().then(P).catch(()=>P(null))},[d,r]),l.useEffect(()=>{fe.current&&clearTimeout(fe.current);const b=w.trim();if(!b){j(null);return}return fe.current=setTimeout(()=>{Wn(b).then(j).catch(()=>j([]))},300),()=>{fe.current&&clearTimeout(fe.current)}},[w]);const te=b=>q.expandedKey===b?e.jsx("pre",{className:"mt-1 max-h-48 overflow-y-auto whitespace-pre-wrap rounded bg-surface-3 p-2 text-[10px] leading-relaxed text-text-secondary",children:q.fileContent[b]??"…"}):null,H=(u==null?void 0:u.mode)==="sqlite",[ne,re]=l.useState(!1),[ae,z]=l.useState(""),[Se,Ie]=l.useState(""),[Ve,W]=l.useState("project"),[$e,he]=l.useState(""),[De,Ge]=l.useState(""),[qe,_e]=l.useState(!1),Pe=()=>{var b;re(!0),z(""),Ie(""),W("project"),he(""),Ge(((b=a[0])==null?void 0:b.id)??"")},Oe=H&&p==="team",Je=ae.trim().length>0&&$e.trim().length>0&&!qe&&(!Oe||!!De),Ce=async()=>{if(Je){_e(!0),h("");try{await Gn({scope:p,name:ae.trim(),description:Se.trim()||void 0,type:Ve,content:$e,...Oe?{teamId:De}:{}}),re(!1),await ee()}catch(b){h(b instanceof Error?b.message:i("memorySidebar.createFailed"))}finally{_e(!1)}}},Xe=()=>{n==null||n()},ye=l.useCallback(async()=>{const b=K.trim();if(!(!b||$)){ke(!0),oe(null);try{oe(await zn(b,5))}catch{oe([])}finally{ke(!1)}}},[K,$]),ie=(u==null?void 0:u.teamEnabled)===!0,Fe=u==null?void 0:u.automation,Ke=ie&&d==="memories"&&!w,Te=l.useMemo(()=>Nr(g,D),[g,D]),Ze=l.useMemo(()=>kr(g),[g]),ge=(D.types.size>0?1:0)+(D.layers.size>0?1:0)+(D.days!==null?1:0)+(D.minConfidence>0?1:0)+(D.minAccessCount>0?1:0);return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>f("memories"),className:`rounded-md px-2 py-1 text-xs font-medium ${d==="memories"?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2"}`,children:i("memorySidebar.memoriesTab")}),e.jsx("button",{type:"button",onClick:()=>f("governance"),className:`rounded-md px-2 py-1 text-xs font-medium ${d==="governance"?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2"}`,children:i("memorySidebar.governanceTab")}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[d==="memories"&&!w&&e.jsx("button",{type:"button",onClick:ne?()=>re(!1):Pe,disabled:p==="team"&&!ie,className:"rounded p-1 text-text-secondary hover:bg-surface-2 hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50",title:i("memorySidebar.new"),children:ne?e.jsx(Yn,{className:"h-3 w-3"}):e.jsx(Vn,{className:"h-3 w-3"})}),d==="memories"&&!w&&e.jsxs("button",{type:"button",onClick:()=>F(b=>!b),"data-testid":"memory-filter-toggle",className:`relative rounded p-1 transition-colors ${k||ge>0?"bg-brand-light text-white":"text-text-secondary hover:bg-surface-2 hover:text-text-primary"}`,title:i("memorySidebar.filters"),children:[e.jsx(is,{className:"h-3 w-3"}),ge>0&&!k&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3 min-w-3 items-center justify-center rounded-full bg-brand px-0.5 text-[9px] font-bold text-white",children:ge})]}),e.jsx(pt,{className:"h-3 w-3 text-text-muted"}),e.jsx("input",{value:w,onChange:b=>N(b.target.value),placeholder:i("memorySidebar.searchPlaceholder"),title:i("memorySidebar.searchHint"),className:"w-28 bg-transparent text-xs text-text-primary placeholder:text-text-muted focus:outline-none"})]})]}),m&&e.jsx("p",{className:"px-3 py-1 text-xs text-status-error",children:m}),k&&d==="memories"&&!w&&e.jsxs("div",{className:"space-y-2 border-b border-border px-2 py-2","data-testid":"memory-filter-panel",children:[e.jsx(Sr,{filters:D,onChange:_}),e.jsx(_r,{filters:D,onChange:_,counts:Ze}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-text-muted",children:i("memories.filter.time")}),e.jsx("div",{className:"flex rounded-md bg-surface-2 p-0.5 text-[10px]",children:Cr.map(b=>e.jsx("button",{type:"button",onClick:()=>_(Y=>({...Y,days:b.value})),className:`rounded px-1.5 py-0.5 ${D.days===b.value?"bg-brand-light text-white":"text-text-muted hover:text-text-secondary"}`,children:i(b.labelKey)},String(b.value)))})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:i("memories.filter.confidence"),children:[e.jsx("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:i("memories.filter.confidence")}),e.jsx("input",{type:"range",min:0,max:100,step:10,value:D.minConfidence*100,onChange:b=>_(Y=>({...Y,minConfidence:Number(b.target.value)/100})),className:"h-1 min-w-16 flex-1 accent-brand"}),e.jsx("span",{className:`flex-shrink-0 font-mono text-[10px] ${D.minConfidence>0?"text-brand-text":"text-text-muted"}`,children:U("memories.filter.minConfidence",{pct:D.minConfidence*100})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:i("memories.filter.access"),children:[e.jsx("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:i("memories.filter.access")}),e.jsx("input",{type:"range",min:0,max:10,step:1,value:D.minAccessCount,onChange:b=>_(Y=>({...Y,minAccessCount:Number(b.target.value)})),className:"h-1 min-w-12 flex-1 accent-brand"}),e.jsx("span",{className:`flex-shrink-0 font-mono text-[10px] ${D.minAccessCount>0?"text-brand-text":"text-text-muted"}`,children:U("memories.filter.minAccess",{n:D.minAccessCount})}),Tr(D)&&e.jsx("button",{type:"button",onClick:()=>_(St),className:"flex-shrink-0 rounded px-1 py-0.5 text-[10px] text-text-muted hover:bg-surface-2 hover:text-text-primary",children:i("memories.filter.clear")})]})]}),Fe&&Fe.mode!=="normal"&&e.jsx("div",{className:"border-b border-status-warning/30 bg-status-warning/10 px-3 py-1.5 text-xs text-status-warning",children:Fe.mode==="sa"?i("memorySidebar.saModeBanner"):i("memorySidebar.poorModeBanner")}),M!==null&&e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:M.length===0?e.jsx("p",{className:"py-8 text-center text-xs text-text-muted",children:i("memorySidebar.noResults")}):e.jsx("ul",{className:"space-y-1",children:M.map(b=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>void q.toggleExpand({path:b.path}),className:"w-full rounded-md px-2 py-1.5 text-left hover:bg-surface-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-xs font-medium text-text-primary",children:b.name}),e.jsx(Er,{layer:b.layer})]}),e.jsx("ul",{className:"mt-0.5 space-y-0.5",children:b.matches.map((Y,Ee)=>e.jsxs("li",{className:"flex gap-1.5 text-[10px] leading-relaxed",children:[e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:Y.line===0?"file":`L${Y.line}`}),e.jsx("span",{className:"truncate text-text-secondary",children:Y.text})]},Ee))})]}),te(b.path)]},b.path))})}),M===null&&d==="memories"&&e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[t&&t.hits.length>0&&e.jsxs("div",{className:"mb-2 rounded-md border border-brand/30 bg-brand/5 p-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-brand-text",children:i("memorySidebar.recallTitle")}),e.jsxs("p",{className:"mb-1 truncate text-[10px] text-text-muted",title:t.query,children:[i("memorySidebar.recallQuery"),": ",t.query]}),e.jsx("ul",{className:"space-y-0.5",children:t.hits.slice(0,5).map(b=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>void q.toggleExpand({path:b.path}),className:"flex w-full items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-xs hover:bg-surface-2",title:b.path,children:[e.jsx("span",{className:"truncate text-text-secondary",children:b.path.replace(/^team\//,"").replace(/\.md$/,"")}),b.score!==void 0&&e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:[(b.score*100).toFixed(0),"%"]})]}),te(b.path)]},b.path))})]}),Ke&&e.jsx("div",{className:"mb-2 flex rounded-md bg-surface-2 p-0.5 text-xs",children:["personal","team"].map(b=>e.jsx("button",{type:"button",onClick:()=>y(b),className:`flex-1 rounded px-2 py-1 ${p===b?"bg-brand-light text-white":"text-text-muted"}`,children:b==="personal"?i("memorySidebar.personal"):i("memorySidebar.team")},b))}),p==="team"&&ie&&!ne&&e.jsx("p",{className:"mb-2 px-1 text-[10px] leading-relaxed text-text-muted",children:i("memorySidebar.teamHint")}),ne&&e.jsxs("div",{className:"mb-2 space-y-1.5 rounded-md border border-border bg-surface-2 p-2",children:[e.jsx("input",{value:ae,onChange:b=>z(b.target.value),placeholder:i("memorySidebar.create.namePlaceholder"),className:"w-full rounded bg-surface-3 px-2 py-1 text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsx("input",{value:Se,onChange:b=>Ie(b.target.value),placeholder:i("memorySidebar.create.descriptionPlaceholder"),className:"w-full rounded bg-surface-3 px-2 py-1 text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("select",{value:Ve,onChange:b=>W(b.target.value),className:"flex-shrink-0 rounded bg-surface-3 px-1.5 py-1 text-xs text-text-primary focus:outline-none",children:Pa.map(b=>e.jsx("option",{value:b,children:b},b))}),Oe?e.jsxs("select",{value:De,onChange:b=>Ge(b.target.value),"aria-label":i("memories.scope.team"),className:"min-w-0 flex-1 rounded bg-surface-3 px-1.5 py-1 text-xs text-text-primary focus:outline-none",children:[a.length===0&&e.jsx("option",{value:"",children:"—"}),a.map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))]}):e.jsx("span",{className:"truncate text-[10px] text-text-muted",children:p==="team"?i("memorySidebar.team"):i("memorySidebar.personal")})]}),e.jsx("textarea",{value:$e,onChange:b=>he(b.target.value),placeholder:i("memorySidebar.create.contentPlaceholder"),rows:6,className:"w-full rounded bg-surface-3 p-2 text-[10px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void Ce(),disabled:!Je,className:"rounded bg-accent px-2 py-0.5 text-[10px] font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50",children:qe?"…":i("memorySidebar.new")}),e.jsx("button",{type:"button",onClick:()=>re(!1),className:"rounded px-2 py-0.5 text-[10px] text-text-muted hover:bg-surface-3",children:i("memorySidebar.cancel")})]})]}),E?e.jsx("div",{className:"space-y-2",children:[0,1,2].map(b=>e.jsx("div",{className:"h-12 animate-pulse rounded-md bg-surface-2"},b))}):g.length===0?e.jsxs("div",{className:"py-10 text-center",children:[e.jsx(Ps,{className:"mx-auto h-6 w-6 text-text-muted/40"}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:i("memorySidebar.empty")})]}):Te.length===0?e.jsxs("div",{className:"py-10 text-center",children:[e.jsx(is,{className:"mx-auto h-6 w-6 text-text-muted/40"}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:i("memories.filter.empty")}),e.jsx("button",{type:"button",onClick:()=>_(St),className:"mt-2 rounded-md border border-border px-2.5 py-1 text-[11px] text-text-secondary hover:bg-surface-2",children:i("memories.filter.clear")})]}):e.jsx(Mr,{files:Te,teamEnabled:ie,teams:H?a:void 0,onChanged:ee,expandedKey:q.expandedKey,fileContent:q.fileContent,onToggleExpand:q.toggleExpand})]}),M===null&&d==="governance"&&e.jsx("div",{className:"flex-1 overflow-y-auto p-3 text-xs",children:v?e.jsxs("div",{className:"space-y-4",children:[n&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:s||!v.automation.autoDream,onClick:Xe,className:"inline-flex w-full items-center justify-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(br,{className:"h-3.5 w-3.5"}),s?i("memorySidebar.dreaming"):i("memorySidebar.dream")]}),!v.automation.autoDream&&e.jsx("p",{className:"mt-1 text-center text-[10px] text-text-muted",children:i("memorySidebar.dreamDisabled")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:i("memorySidebar.recallTest.title")}),e.jsx("p",{className:"mb-1.5 text-[10px] leading-relaxed text-text-muted",children:i("memorySidebar.recallTest.hint")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{value:K,onChange:b=>V(b.target.value),onKeyDown:b=>{b.key==="Enter"&&!b.nativeEvent.isComposing&&ye()},placeholder:i("memorySidebar.recallTest.placeholder"),className:"min-w-0 flex-1 rounded-md bg-surface-2 px-2 py-1 text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsx("button",{type:"button",onClick:()=>void ye(),disabled:$||!K.trim(),className:"flex-shrink-0 rounded-md bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50",children:$?i("memorySidebar.recallTest.running"):i("memorySidebar.recallTest.run")})]}),pe!==null&&e.jsx("ul",{className:"mt-1.5 space-y-0.5 rounded-md bg-surface-2 p-2",children:pe.length===0?e.jsx("li",{className:"text-[10px] text-text-muted",children:i("memorySidebar.recallTest.noResults")}):pe.map(b=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>void q.toggleExpand({path:b.path}),className:"flex w-full items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-xs hover:bg-surface-3",title:b.path,children:[e.jsx("span",{className:"truncate text-text-secondary",children:b.path.replace(/^team\//,"").replace(/\.md$/,"")}),e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:[(b.score*100).toFixed(0),"%",b.confidence!==void 0?` · conf ${b.confidence.toFixed(2)}`:""]})]}),te(b.path)]},b.path))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:i("memorySidebar.layers")}),e.jsx("ul",{className:"space-y-1",children:Ss.map(b=>{const Y=v.layers[b],Ee=Math.max(...Ss.map(et=>v.layers[et]),1);return e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-16 flex-shrink-0 text-text-secondary",children:b}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-surface-2",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Y/Ee*100}%`}})}),e.jsx("span",{className:"w-6 text-right text-text-muted",children:Y})]},b)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:i("memorySidebar.health")}),e.jsxs("div",{className:"rounded-md bg-surface-2 p-2 text-[10px] text-text-secondary",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:i("memorySidebar.total")}),e.jsx("span",{children:v.health.totalMemories})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:i("memorySidebar.capacity")}),e.jsxs("span",{className:v.health.capacity.tier==="critical"?"text-status-error":v.health.capacity.tier==="warning"?"text-status-warning":"text-status-active",children:[v.health.capacity.utilizationPct.toFixed(0),"% · ",v.health.capacity.tier]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:i("memorySidebar.avgConfidence")}),e.jsx("span",{children:v.health.avgConfidence.toFixed(2)})]})]})]}),v.alerts.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:[i("memorySidebar.alerts")," (",v.alerts.length,")"]}),e.jsx("ul",{className:"space-y-1 rounded-md bg-status-warning/5 p-2",children:v.alerts.slice(-8).reverse().map((b,Y)=>e.jsx("li",{className:"text-[10px] leading-relaxed text-text-secondary",children:b},Y))})]}),v.conflicts&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-status-warning",children:i("memorySidebar.conflicts")}),e.jsx("pre",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap rounded-md bg-surface-2 p-2 text-[10px] leading-relaxed text-text-secondary",children:v.conflicts})]})]}):e.jsx("p",{className:"py-10 text-center text-text-muted",children:i("memorySidebar.loadFailed")})})]})}class Fa{constructor(t,s,n,a){I(this,"pending",null);this.current=t,this.apply=s,this.send=n,this.onError=a}set(t){if(t===this.current)return;const s=this.current;this.current=t,this.pending={requestId:null,previous:s},this.apply(t);try{Promise.resolve(this.send(t)).then(n=>{this.pending&&(this.pending.requestId=n)}).catch(n=>{this.rollback(s,_s(n),"send")})}catch(n){this.rollback(s,_s(n),"send")}}handleControlResponse(t){const s=this.pending;if(!s||s.requestId!==t.requestId)return!1;const{previous:n}=s;return this.pending=null,t.subtype==="error"&&this.rollback(n,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,s,n){var a;this.pending=null,this.current=t,this.apply(t),s&&((a=this.onError)==null||a.call(this,s,n))}}function _s(r){return r instanceof Error?r.message:String(r)}function ct(r){const t=l.useRef(r);t.current=r;const s=l.useRef(null);s.current||(s.current=new Fa(r.value,a=>t.current.apply(a),a=>t.current.send(a),(a,u)=>{var c,d;return(d=(c=t.current).onError)==null?void 0:d.call(c,a,u)}));const n=s.current;return l.useEffect(()=>{n.adoptExternal(r.value)}),l.useMemo(()=>({set:a=>n.set(a),handleControlResponse:a=>n.handleControlResponse(a),sync:a=>n.sync(a)}),[n])}const Ys="rcs_context_usage_";function Vs(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function Cs(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function Ka(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,{totalTokens:s,rawMaxTokens:n,percentage:a}=t;if(typeof s!="number"||typeof n!="number"||typeof a!="number")return null;const u=t.categories,c=Array.isArray(u)?u.filter(d=>!!d&&typeof d=="object"&&typeof d.name=="string").map(d=>({name:d.name,tokens:typeof d.tokens=="number"?d.tokens:0,...d.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:a,...typeof t.model=="string"&&t.model?{model:t.model}:{},...c&&c.length>0?{categories:c}:{}}}function La(r,t=Vs()){if(!t||!r)return null;try{const s=t.getItem(Ys+r);return s?Ka(JSON.parse(s)):null}catch{return null}}function Ua(r,t,s=Vs()){if(!(!s||!r))try{s.setItem(Ys+r,JSON.stringify(t))}catch{}}function Ba(r){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${r}`}function Ha(r){const t=Ba(r),s=Xn(),n=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new Jn(n)}const Re=[{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"}],Ts="rcs_permission_mode";function dt(r){return r<1e3?String(r):r<1e6?`${(r/1e3).toFixed(1)}k`:`${(r/1e6).toFixed(1)}M`}function Qa(r){const t=Re.findIndex(s=>s.value===r);return Re[(t+1+Re.length)%Re.length].value}const ze=[{value:"off",labelKey:"session.thinking.off",descKey:"session.thinking.offDesc",label:void 0,description:void 0,tokens:0},{value:"on",labelKey:"session.thinking.on",descKey:"session.thinking.onDesc",label:void 0,description:void 0,tokens:null},{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}],Es="rcs_thinking_budget",mt=[{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"}],Wa=r=>r.labelKey?i(r.labelKey):r.label,za=r=>r.labelKey?i(r.labelKey):r.label,Ms="rcs_effort",Rs=[{value:"normal",descKey:"session.tokenMode.normalDesc"},{value:"poor",descKey:"session.tokenMode.poorDesc"},{value:"sa",descKey:"session.tokenMode.saDesc"}],As="rcs_token_mode";function Ya(r){return r!=null&&r.capabilities?r.capabilities:r?{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,set_token_mode:!1,side_question:!0}:{file_search:!1,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!1,stop_task:!0,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,set_token_mode:!1,side_question:!1}}function Is({icon:r,label:t,levels:s,index:n,onChange:a,disabled:u}){const c=Math.max(s.length-1,0),d=Math.min(Math.max(n,0),c),[f,p]=l.useState(null),y=f??d,g=s[y],S=c>0?y/c*100:0,E=()=>{f!==null&&(f!==d&&a(f),p(null))};return e.jsxs("div",{className:u?"opacity-55":void 0,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-brand/10 text-brand-text",children:e.jsx(r,{className:"h-3 w-3",strokeWidth:2})}),e.jsx("span",{className:"truncate font-display text-[11px] font-semibold text-text-primary",children:t})]}),e.jsx("span",{className:"shrink-0 rounded-full border border-brand/20 bg-brand/10 px-1.5 py-0.5 font-mono text-[10px] font-medium tabular-nums text-brand-text",children:g.label})]}),e.jsxs("div",{className:"relative mt-2 h-6",children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-[7px] top-1/2 h-[3px] -translate-y-1/2 overflow-hidden rounded-full bg-surface-3",children:e.jsx("div",{className:"h-full rounded-full bg-brand transition-[width] duration-200 ease-out",style:{width:`${S}%`}})}),e.jsx("div",{className:"pointer-events-none absolute inset-x-[7px] top-1/2 h-[7px] -translate-y-1/2",children:s.map((T,m)=>e.jsx("span",{className:`absolute top-0 h-full w-[1.5px] -translate-x-1/2 rounded-full ${m<=y?"bg-primary-foreground/55":"bg-text-muted/25"}`,style:{left:c>0?`${m/c*100}%`:"50%"}},T.value))}),e.jsx("input",{type:"range",min:0,max:c,step:1,value:y,disabled:u,"aria-label":t,"aria-valuetext":g.label,onChange:T=>p(Number(T.target.value)),onPointerUp:E,onKeyUp:E,onBlur:E,className:"rcs-range relative z-10"})]}),e.jsx("div",{className:"mt-1 flex items-start justify-between gap-1",children:s.map((T,m)=>e.jsx("button",{type:"button",disabled:u,onClick:()=>{p(null),a(m)},className:`min-w-0 truncate font-mono text-[9px] leading-4 tabular-nums transition-colors disabled:cursor-not-allowed ${m===y?"font-semibold text-brand-text":"text-text-muted/70 hover:text-text-primary"}`,children:T.label},T.value))}),e.jsx("p",{className:"mt-0.5 min-h-4 text-[11px] leading-4 text-text-muted",children:g.description})]})}function Va({mode:r,onModeChange:t,disabled:s}){const[n,a]=l.useState(!1),u=Rs.find(c=>c.value===r);return e.jsxs(Mt,{open:n,onOpenChange:a,children:[e.jsx(Rt,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,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:i("session.tokenMode.title"),children:[e.jsx(Dr,{className:"h-3 w-3"}),e.jsx("span",{className:`max-w-24 truncate ${r!=="normal"?"font-medium text-brand-text":""}`,children:u?i(`session.tokenMode.${u.value}`):i("session.tokenMode.fallback")}),n?e.jsx(At,{className:"h-3 w-3"}):e.jsx(It,{className:"h-3 w-3"})]})}),e.jsx($t,{className:"w-64 p-1",align:"start",children:Rs.map(c=>e.jsxs("button",{type:"button",onClick:()=>{t(c.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:r===c.value&&e.jsx(ft,{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:i(`session.tokenMode.${c.value}`)}),e.jsx("div",{className:"text-xs text-text-muted",children:i(c.descKey)})]})]},c.value))})]})}const Ga=new Set(["Free space","Autocompact buffer","Compact buffer"]),$s=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function Ja({usage:r}){const t=Math.min(100,Math.max(0,r.percentage)),s=t>=80,n=(r.categories??[]).filter(d=>!d.isDeferred&&!Ga.has(d.name)),a=(r.categories??[]).filter(d=>d.isDeferred),u=n.reduce((d,f)=>d+f.tokens,0),c=[`${U("session.context.tooltip",{used:dt(r.totalTokens),max:dt(r.rawMaxTokens)})}${r.model?` · ${r.model}`:""}`,...n.slice(0,8).map(d=>`${d.name}: ${dt(d.tokens)}`),...a.slice(0,3).map(d=>`${d.name}${i("session.context.deferredSuffix")}: ${dt(d.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-text-muted font-mono",title:c.join(`
|
|
82
|
+
`),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:n.length>0?n.map((d,f)=>e.jsx("span",{className:s&&f===0?"bg-status-warning":$s[f%$s.length],style:{width:`${Math.min(100,Math.max(0,u>0?d.tokens/u*t:0))}%`}},d.name)):e.jsx("span",{className:`absolute inset-y-0 left-0 rounded-full transition-all ${s?"bg-status-warning":"bg-brand/70"}`,style:{width:`${t}%`}})}),e.jsxs("span",{children:[t,"%"]})]})}function Xa({models:r,currentModelId:t,onSelect:s,showThinking:n,thinkingBudget:a,onThinkingChange:u,showEffort:c,effort:d,onEffortChange:f,disabled:p}){const[y,g]=l.useState(!1),S=r.find(k=>k.modelId===t)??null,E=r.length>0,T=n||c,m=E||T,h=ze.findIndex(k=>k.value===a),w=h>=0?h:1,N=mt.findIndex(k=>k.value===d),M=N>=0?N:0,j=ze.map(k=>({value:k.value,label:za(k),description:k.descKey?i(k.descKey):k.description??""})),v=mt.map(k=>({value:k.value,label:Wa(k),description:i(k.descKey)})),P=[i("session.model.title"),n?j[w].label:null,c?v[M].label:null].filter(Boolean).join(" · ");return e.jsxs(Mt,{open:y,onOpenChange:m?g:void 0,children:[e.jsx(Rt,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:p||!m,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:P,children:[e.jsx(Ls,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(S==null?void 0:S.name)??t??i("session.model.title")}),T&&e.jsxs("span",{className:"ml-0.5 flex items-center gap-1 border-l border-border/70 pl-1.5",children:[n&&e.jsx(cs,{className:"h-3 w-3"}),c&&e.jsx(ls,{className:"h-3 w-3"})]}),y?e.jsx(At,{className:"h-3 w-3"}):e.jsx(It,{className:"h-3 w-3"})]})}),e.jsxs($t,{className:"w-[21rem] max-w-[calc(100vw-2rem)] max-h-[calc(100dvh-2rem)] overflow-y-auto overflow-x-hidden p-0",align:"start",children:[e.jsxs("div",{className:"px-3 pt-3 pb-1.5",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1",children:[e.jsx("span",{className:"font-display text-[10px] font-semibold uppercase tracking-[0.16em] text-text-muted",children:i("session.model.section")}),E&&e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-text-muted",children:r.length})]}),E?e.jsx("div",{className:"[&_[data-slot=command-list]]:max-h-[min(15rem,38vh)]",children:e.jsx(ur,{models:r,currentModelId:t,onSelect:k=>{s(k.modelId),g(!1)},showSearch:r.length>5})}):e.jsx("p",{className:"px-1 py-2 text-xs text-text-muted",children:i("session.model.unavailable")})]}),T&&e.jsxs("div",{className:"border-t border-border/60 bg-surface-2/35 px-3 pt-2.5 pb-3",children:[e.jsx("div",{className:"mb-2.5 px-1",children:e.jsx("span",{className:"font-display text-[10px] font-semibold uppercase tracking-[0.16em] text-text-muted",children:i("session.model.tuning")})}),e.jsxs("div",{className:"space-y-3.5",children:[n&&e.jsx(Is,{icon:cs,label:i("session.thinking.title"),levels:j,index:w,onChange:k=>u(ze[k].value),disabled:p}),c&&e.jsx(Is,{icon:ls,label:i("session.effort.title"),levels:v,index:M,onChange:k=>f(mt[k].value),disabled:p})]})]})]})]})}function Za({mode:r,onModeChange:t,disabled:s}){const[n,a]=l.useState(!1),u=Re.find(c=>c.value===r);return e.jsxs(Mt,{open:n,onOpenChange:a,children:[e.jsx(Rt,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,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:i("session.mode.title"),children:[e.jsx(dr,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:u?i(u.labelKey):r}),n?e.jsx(At,{className:"h-3 w-3"}):e.jsx(It,{className:"h-3 w-3"})]})}),e.jsx($t,{className:"w-64 p-1",align:"start",children:Re.map(c=>e.jsxs("button",{type:"button",onClick:()=>{t(c.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:r===c.value&&e.jsx(ft,{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:i(c.labelKey)}),e.jsx("div",{className:"text-xs text-text-muted",children:i(c.descKey)})]})]},c.value))})]})}function yo({sessionId:r,onBack:t}){se();const[s,n]=l.useState(null),[a,u]=l.useState(null),[c,d]=l.useState(""),[f,p]=l.useState(!1),[y,g]=l.useState(!1),[S,E]=l.useState(!1),[T,m]=l.useState(!1),[h,w]=l.useState(!1),[N,M]=l.useState(!1),[j,v]=l.useState(""),[P,k]=l.useState(0),F=l.useRef(null),[D,_]=l.useState({text:"",nonce:0}),[q,K]=l.useState(!1),[V,pe]=l.useState(!1),[oe,$]=l.useState(0),[ke,fe]=l.useState(0),[ee,te]=l.useState([]),[H,ne]=l.useState(!1),[re,ae]=l.useState([]),[z,Se]=l.useState(null),[Ie,Ve]=l.useState(()=>Et()),[W,$e]=l.useState(null),[he,De]=l.useState(()=>localStorage.getItem(Es)||"off"),[Ge,qe]=l.useState(()=>La(r)),[_e,Pe]=l.useState(!0),[Oe,Je]=l.useState(null),[Ce,Xe]=l.useState(null),[ye,ie]=l.useState([]),[Fe,Ke]=l.useState(!1),[Te,Ze]=l.useState(""),ge=l.useRef(null),[b,Y]=l.useState(()=>localStorage.getItem(Ts)||"default"),[Ee,et]=l.useState(null),Le=l.useRef(null),[Dt,qt]=l.useState(null),Ue=l.useRef(null),le=l.useRef(null),Pt=l.useRef(ee);Pt.current=ee;const tt=l.useRef(null);tt.current||(tt.current=new Rr(Ar()));const Ot=l.useRef(r);Ot.current=(s==null?void 0:s.title)||r,l.useEffect(()=>{var o;(o=tt.current)==null||o.reset()},[r]);const ce=l.useCallback(o=>{et(o),Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>et(null),5e3)},[]),de=l.useCallback(o=>{qt(o),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>qt(null),5e3)},[]),st=ct({value:b,apply:o=>{Y(o);try{localStorage.setItem(Ts,o)}catch{}},send:o=>{const x=le.current;return x?x.setPermissionMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,x)=>{console.error("[SessionDetail] set permission mode failed:",o),ce(x==="send"?U("session.mode.switchFailedRequest",{message:o}):o||i("session.mode.switchFailed"))}}),ht=l.useCallback(o=>st.set(o),[st]),[Ft,Gs]=l.useState(()=>localStorage.getItem(As)||"normal"),nt=ct({value:Ft,apply:o=>{Gs(o);try{localStorage.setItem(As,o)}catch{}},send:o=>{const x=le.current;return x?x.setTokenMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,x)=>{console.error("[SessionDetail] set token mode failed:",o),ce(x==="send"?U("session.tokenMode.failedRequest",{message:o}):o||i("session.tokenMode.failed"))}}),yt=ct({value:he,apply:o=>{De(o);try{localStorage.setItem(Es,o)}catch{}},send:o=>{var R;const x=le.current;if(!x)return Promise.reject(new Error("adapter not ready"));const C=((R=ze.find(A=>A.value===o))==null?void 0:R.tokens)??null;return x.setThinkingBudget(C)},onError:(o,x)=>{console.error("[SessionDetail] set thinking budget failed:",o),ce(x==="send"?U("session.thinking.failedRequest",{message:o}):o||i("session.thinking.failed"))}}),O=l.useMemo(()=>new aa(r,te,{onStatusChange:o=>{var x;u(o),ne(o==="running"||o==="requires_action"),(x=tt.current)==null||x.onStatus(o,Ot.current)},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{ae(x=>x.some(C=>C.requestId===o.requestId)?x:[...x,o])},onModelsStateChange:o=>{Se(o)},onSubagentUpdate:o=>{Ve(o)},onControlResponse:o=>{yt.handleControlResponse(o)||nt.handleControlResponse(o)||Ht.handleControlResponse(o)||st.handleControlResponse(o)},onPermissionModeChange:o=>{st.sync(o)},onWorkerInfoChange:o=>{$e(x=>JSON.stringify(x)===JSON.stringify(o)?x:o)},onTurnStart:o=>{Je(o)},onElicitationRequest:o=>{Xe(o)}}),[r,ce]);l.useEffect(()=>(le.current=O,()=>{O.disconnect()}),[O]);const L=l.useMemo(()=>Ya(W),[W]),Kt=l.useRef(!1);l.useEffect(()=>{var C;if(!L.set_max_thinking_tokens||Kt.current)return;const o=le.current;if(!o)return;const x=((C=ze.find(R=>R.value===he))==null?void 0:C.tokens)??null;o.setThinkingBudget(x).then(()=>{Kt.current=!0}).catch(R=>console.error("[SessionDetail] reconcile thinking budget failed:",R))},[L.set_max_thinking_tokens,he,W]);const Lt=L.stop_task?o=>{O.stopSubagent(o).then(x=>{x.ok||de(x.error||i("session.stopTask.failed"))})}:void 0,Ut=l.useRef(!1);l.useEffect(()=>{if(!L.set_token_mode||Ut.current)return;const o=le.current;o&&(Ut.current=!0,o.getRemoteSettings().then(x=>{const C=x==null?void 0:x.applied.tokenMode;(C==="normal"||C==="poor"||C==="sa")&&nt.sync(C)}).catch(x=>console.error("[SessionDetail] reconcile token mode failed:",x)))},[L.set_token_mode,nt]);const Js=se(),gt=l.useMemo(()=>Zn((W==null?void 0:W.commands)??[],(W==null?void 0:W.skills)??[]),[W,Js]),Be=l.useMemo(()=>er(ee,j),[ee,j]),Xs=l.useCallback(o=>yt.set(o),[yt]),[Bt,Zs]=l.useState(()=>localStorage.getItem(Ms)||"auto"),Ht=ct({value:Bt,apply:o=>{Zs(o);try{localStorage.setItem(Ms,o)}catch{}},send:o=>{var R;const x=le.current;if(!x)return Promise.reject(new Error("adapter not ready"));const C=(R=mt.find(A=>A.value===o))==null?void 0:R.effort;return x.setEffort(C)},onError:(o,x)=>{console.error("[SessionDetail] set effort failed:",o),ce(x==="send"?U("session.effort.failedRequest",{message:o}):o||i("session.effort.failed"))}}),bt=l.useCallback(()=>{var o;L.get_context_usage&&((o=le.current)==null||o.getContextUsage().then(x=>{x&&(qe(x),Ua(r,x))}).catch(()=>{}).finally(()=>Pe(!1)))},[L,r]);l.useEffect(()=>{if(!L.get_context_usage)return;bt();const o=setInterval(bt,6e4);return()=>clearInterval(o)},[L,H,bt]),l.useEffect(()=>{W&&!L.get_context_usage&&Pe(!1)},[W,L]),l.useEffect(()=>{if(!_e)return;const o=setTimeout(()=>Pe(!1),1e4);return()=>clearTimeout(o)},[_e]);const Qt=l.useRef(V);Qt.current=V,l.useEffect(()=>me.onEvent(x=>{x.type!=="artifact_created"&&x.type!=="artifact_updated"||(Qt.current&&fe(C=>C+1),$(C=>C+1))}),[]);const[en,rt]=l.useState(0),[at,Wt]=l.useState(null),[ue,jt]=l.useState(!1),[vt,zt]=l.useState(0),[tn,sn]=l.useState(void 0),ot=l.useRef(ue);ot.current=ue,l.useEffect(()=>me.onEvent(x=>{x.type==="memory_synced"&&ot.current&&rt(C=>C+1)}),[]),l.useEffect(()=>{qs().then(o=>Wt(o.mode)).catch(()=>Wt("sqlite"))},[]),l.useEffect(()=>me.onEvent(x=>{var C,R;if(x.type==="memory_changed")ot.current?rt(A=>A+1):zt(A=>A+1);else if(x.type==="memory_recall"){const A=Array.isArray((C=x.payload)==null?void 0:C.hits)?x.payload.hits:void 0;A&&sn({query:typeof((R=x.payload)==null?void 0:R.query)=="string"?x.payload.query:"",hits:A}),ot.current&&rt(Q=>Q+1)}}),[]),l.useEffect(()=>{ue&&zt(0)},[ue]);const[He,nn]=l.useState("idle");l.useEffect(()=>me.onStateChange(x=>nn(x)),[]),l.useEffect(()=>{V&&$(0)},[V]),l.useEffect(()=>{let o=!1;async function x(){d("");try{const C=await os(r);if(o)return;n(C),u(C.status),ut(C.status)&&O.markClosed(),ne(C.status==="running"||C.status==="requires_action")}catch(C){if(o)return;d(C instanceof Error?C.message:i("session.loadFailed"));return}try{await O.init()}catch(C){console.warn("Failed to init adapter:",C)}}return x(),()=>{o=!0}},[r,O]);const B=ut(a),Yt=l.useRef(a);Yt.current=a,l.useEffect(()=>{if(B)return;let o=!1;const C=setInterval(async()=>{try{const R=await os(r);if(o||R.status===Yt.current)return;ut(R.status)&&O.markClosed(),u(R.status),ne(R.status==="running"||R.status==="requires_action")}catch{}},6e4);return()=>{o=!0,clearInterval(C)}},[r,B,O]);const G=(s==null?void 0:s.access_level)==="read",Vt=Ge??(_e&&!B&&!G?Cs():null),wt=l.useCallback(()=>{te([]),qe(Cs()),rs(r).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[r]),Qe=l.useCallback(async(o,x)=>{const C=le.current;if(!C||B)return;if(o.sessionId===r){te(A=>[...A,{type:"command_output",id:`cmd-resume-${Date.now()}`,commandName:"resume",inputText:x??"/resume",title:"Resume",subtitle:i("session.resume.title"),outputText:i("session.resume.currentBlocked"),variant:"error"}]);return}const R=(A,Q="default")=>te(be=>[...be,{type:"command_output",id:`cmd-resume-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,commandName:"resume",inputText:x??`/resume ${o.sessionId.slice(0,8)}`,title:"Resume",subtitle:i("session.resume.title"),outputText:A,variant:Q}]);R(U("session.resume.restoring",{title:o.title??""}));try{await rs(r),te([]);const A=await C.resumeSession(o.sessionId);R(A.title?U("session.resume.restoredWithTitle",{count:A.messageCount,title:A.title}):U("session.resume.restored",{count:A.messageCount}))}catch(A){R(U("session.resume.failed",{message:A instanceof Error?A.message:String(A)}),"error")}},[B,r]),rn=l.useCallback(async()=>{if(s!=null&&s.environment_id)try{const o=await tr({environment_id:s.environment_id});window.location.href=`/code/${o.id}?resumeFrom=${r}`}catch(o){de(U("session.createFailedWithReason",{message:o instanceof Error?o.message:String(o)}))}},[s,r,de]),an=l.useRef(new URLSearchParams(window.location.search).get("resumeFrom")),Gt=l.useRef(!1);l.useEffect(()=>{const o=an.current;!o||Gt.current||!W||!L.resume||(Gt.current=!0,window.history.replaceState({},"",window.location.pathname),Qe({sessionId:o,title:o.slice(0,8),modified:0},null))},[W,L.resume,Qe]);const Me=l.useCallback(async o=>{const x=o.text.trim(),C=o.images&&o.images.length>0||o.attachments&&o.attachments.length>0;if(!x&&!C||B)return;const R=/^\/resume(?:\s+(.*))?$/.exec(x);if(R){const Q=(R[1]??"").trim();if(!L.resume){te(be=>[...be,{type:"user_message",id:`user-${Date.now()}`,content:x},{type:"command_output",id:`cmd-${Date.now()}`,commandName:"resume",inputText:x,title:"Resume",subtitle:i("session.resume.title"),outputText:i("session.resume.unsupported"),variant:"error"}]);return}Q?await Qe({sessionId:Q,title:Q,modified:0},x):w(!0);return}const A=await sr(x,{sessionId:r,availableCommands:gt,availableModels:(z==null?void 0:z.availableModels)??[],currentModel:z?{modelId:z.currentModelId,name:z.currentModelId}:null,supportsImages:!0,entries:Pt.current,setModel:async Q=>{await X(r,{type:"control_request",request:{subtype:"set_model",model:Q}}),Se(be=>be&&{...be,currentModelId:Q})},onNewSession:()=>{te([])}}).catch(()=>null);if(A){if(xt("[SessionDetail] local command result",A),"clearEntries"in A&&A.clearEntries){wt();return}if("newSession"in A&&A.newSession){wt();return}if("userEntry"in A){te(Q=>[...Q,A.userEntry,A.cmdEntry]);return}}ne(!0);try{await O.sendMessage(x,o.images,o.attachments)}catch(Q){if(console.error("Send failed:",Q),Q instanceof nr&&Q.type==="session_closed"){u("archived"),O.markClosed(),de(i("session.closedSendBlocked"));return}de(`${i("session.sendFailed")}${Q instanceof Error?`: ${Q.message}`:""}`)}},[O,B,r,z,gt,wt,de,Qe,L]),on=l.useCallback(o=>{if(H){ie(x=>[...x,o]);return}Me(o)},[H,Me]),[Nt,Jt]=l.useState(!1),ln=l.useCallback(()=>{H||(Jt(!0),Me({text:"/dream"}))},[H,Me]);l.useEffect(()=>{!H&&Nt&&(Jt(!1),rt(o=>o+1))},[H,Nt]);const kt=l.useRef(!1);l.useEffect(()=>{if(B){ie(x=>x.length>0?[]:x);return}if(H||ye.length===0||kt.current)return;const o=ye[0];o&&(kt.current=!0,ie(x=>x.slice(1)),Me(o).finally(()=>{kt.current=!1}))},[H,ye,Me,B]);const cn=l.useCallback((o,x)=>{if(H)return;const C=x==="edit"?i("session.rewind.confirmEdit"):i("session.rewind.confirm");window.confirm(`${C}
|
|
83
|
+
${i("session.rewind.confirmBody")}`)&&O.rewindToMessage(o.id).then(()=>{x==="edit"&&o.content&&_(R=>({text:o.content,nonce:R.nonce+1}))}).catch(R=>{console.error("[SessionDetail] rewind failed:",R),de(U("session.rewind.failed",{message:R instanceof Error?R.message:String(R)}))})},[H,de]),dn=l.useCallback(o=>{const x=Be.orderedMatchIds;if(x.length===0)return;const C=(o%x.length+x.length)%x.length;k(C);const R=x[C],A=document.querySelector(`[data-entry-id="${CSS.escape(R)}"]`);A==null||A.scrollIntoView({block:"center",behavior:"smooth"})},[Be]),Xt=l.useCallback(async()=>{try{await O.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{ne(!1)}},[O]),un=l.useCallback(()=>{ht(Qa(b))},[ht,b]);l.useEffect(()=>()=>{Le.current&&clearTimeout(Le.current),Ue.current&&clearTimeout(Ue.current)},[]);const mn=l.useCallback(async()=>{if(s&&window.confirm(i("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await as(s.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:i("dashboard.deleteFailed"))}},[s]),xn=l.useCallback(async o=>{try{await O.respondPermission(o,!0)}catch(x){console.error("Failed to approve:",x)}ae(x=>x.filter(C=>C.requestId!==o))},[O]),pn=l.useCallback(async(o,x)=>{try{await O.respondPermission(o,!0,{updated_permissions:x})}catch(C){console.error("Failed to approve with rules:",C)}ae(C=>C.filter(R=>R.requestId!==o))},[O]),fn=l.useCallback(async(o,x)=>{const C=Ce;if(Xe(null),!!C)try{await O.respondElicitation(C.requestId,o,x)}catch(R){console.error("Failed to submit elicitation:",R)}},[Ce,O]),hn=l.useCallback(()=>{!s||G||(Ze(s.title||""),Ke(!0),setTimeout(()=>{var o,x;(o=ge.current)==null||o.focus(),(x=ge.current)==null||x.select()},0))},[s,G]),Zt=l.useCallback(async()=>{const o=Te.trim();if(Ke(!1),!(!s||!o||o===s.title))try{const x=await rr(s.id,o);n(C=>C&&{...C,title:x.title??o})}catch(x){console.error("Rename failed:",x),alert(x instanceof Error?x.message:i("session.rename.failed"))}},[s,Te]),yn=l.useCallback(async o=>{try{await O.respondPermission(o,!1)}catch(x){console.error("Failed to reject:",x)}ae(x=>x.filter(C=>C.requestId!==o))},[O]),gn=l.useCallback(async(o,x,C)=>{try{await X(r,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:C,answers:x}})}catch(R){console.error("Failed to submit answers:",R)}ae(R=>R.filter(A=>A.requestId!==o))},[r]),bn=l.useCallback(async(o,x,C)=>{try{x==="no"?await X(r,{type:"permission_response",approved:!1,request_id:o,...C?{message:C}:{}}):await X(r,{type:"permission_response",approved:!0,request_id:o,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[x]||"default",destination:"session"}]})}catch(R){console.error("Failed to submit plan response:",R)}ae(R=>R.filter(A=>A.requestId!==o))},[r]);return c?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(lt,{onBack:t,title:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:i("session.loadFailed")})}),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:c}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand-text hover:underline",children:i("session.backToDashboard")})]})})]}):s?s.source==="acp"&&s.environment_id?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx(lt,{onBack:t,title:e.jsx("span",{className:"truncate text-xs font-semibold text-text-primary",children:s.title||s.id}),meta:e.jsx("span",{className:"rounded-full bg-brand/15 px-2 py-0.5 text-[10px] font-medium text-brand-text",children:"ACP"})}),e.jsx(to,{sessionId:r,agentId:s.environment_id})]}):e.jsx(Os,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx(lt,{onBack:t,title:Fe?e.jsx("input",{ref:ge,value:Te,onChange:o=>Ze(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Zt()):o.key==="Escape"&&(o.preventDefault(),Ke(!1))},onBlur:()=>void Zt(),maxLength:200,className:"w-full max-w-xs rounded-md border border-brand/50 bg-surface-2 px-2 py-0.5 text-xs font-semibold text-text-primary focus:outline-none focus:ring-2 focus:ring-brand/30"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex min-w-0 items-center gap-2 text-xs font-semibold text-text-primary",children:!G&&!B?e.jsx("button",{type:"button",onClick:hn,title:i("session.rename.title"),className:"truncate text-left transition-colors hover:text-text-secondary",children:s.title||s.id}):e.jsx("span",{className:"truncate",children:s.title||s.id})}),s.visibility&&e.jsx(vr,{visibility:s.visibility||"private",className:"hidden flex-shrink-0 text-[10px] sm:inline-flex"})]}),meta:e.jsx(e.Fragment,{children:(()=>{var C;const o=s.source==="acp"?"acp":(C=s.environment)==null?void 0:C.worker_type,x=Fs(o);return e.jsx("span",{className:`hidden items-center rounded-full px-2 py-0.5 text-[10px] font-medium sm:inline-flex ${x.colorClass}`,children:x.fullLabel})})()}),actions:e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs("button",{onClick:()=>pe(!V),className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${V?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("artifacts.title"),children:[e.jsx(ar,{className:"h-3.5 w-3.5"}),oe>0&&!V&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-brand px-0.5 text-[10px] font-bold text-white",children:oe>9?"9+":oe})]}),e.jsxs("button",{onClick:()=>jt(!ue),className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${ue?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("memories.title"),children:[e.jsx(Ps,{className:"h-3.5 w-3.5"}),vt>0&&!ue&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-brand px-0.5 text-[10px] font-bold text-white",children:vt>9?"9+":vt})]}),L.side_question&&!B&&!G&&e.jsx("button",{onClick:()=>m(!T),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${T?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.sideQuestion.title"),children:e.jsx(Us,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const o=!N;M(o),o?setTimeout(()=>{var x;return(x=F.current)==null?void 0:x.focus()},0):(v(""),k(0))},className:`flex h-7 w-7 items-center justify-center rounded-md transition-colors ${N?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.search.title"),children:e.jsx(pt,{className:"h-3.5 w-3.5"})}),L.mcp_management&&!B&&!G&&e.jsx("button",{onClick:()=>g(!y),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${y?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.mcp.title"),children:e.jsx(Bs,{className:"h-3.5 w-3.5"})}),L.remote_settings&&!B&&!G&&e.jsx("button",{onClick:()=>E(!S),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${S?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.settings.title"),children:e.jsx(Hs,{className:"h-3.5 w-3.5"})}),!G&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>K(!0),className:"flex h-7 w-7 items-center justify-center rounded-md text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:i("session.share"),children:e.jsx(Zr,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>p(!f),className:"ml-0.5 flex items-center gap-1 rounded-md px-2 py-1 text-xs font-semibold text-text-primary hover:bg-brand-light hover:text-white transition-colors",title:i("session.info"),children:[i("session.tasks"),re.length>0&&e.jsx("span",{className:"rounded-full bg-status-warning/15 px-1.5 py-0.5 text-[10px] font-medium text-status-warning",children:re.length})]})]})})}),(He==="reconnecting"||He==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${He==="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 ${He==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),He==="failed"?i("session.sseFailed"):i("session.sseReconnecting")]}),V&&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(jr,{sessionId:r,embedded:!0,refreshTick:ke})})}),N&&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(pt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:F,value:j,onChange:o=>{v(o.target.value),k(0)},onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),dn(j&&o.shiftKey?P-1:P+1)):o.key==="Escape"&&(o.preventDefault(),M(!1),v(""))},placeholder:i("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-[10px] text-text-muted",children:Be.orderedMatchIds.length===0?i("session.search.noResults"):`${P+1}/${Be.orderedMatchIds.length}`})]})}),e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(or,{entries:ee,isLoading:H,turnStartedAt:Oe,emptyTitle:i("session.emptyTitle"),emptyDescription:i("session.emptyDescription"),searchMatchIds:j.trim()?Be.matchIds:void 0,onRewindEntry:L.rewind&&!B&&!G&&!H?(o,x)=>cn(o,x):void 0})}),at!==null&&e.jsx(ve,{open:ue,onOpenChange:jt,children:e.jsxs(we,{showCloseButton:!1,"data-testid":"memory-sidebar",className:"fixed inset-y-0 left-0 top-auto right-auto translate-x-0 translate-y-0 flex h-full w-full flex-col overflow-hidden rounded-none border-r border-border bg-surface-1 p-0 max-w-none max-h-none sm:w-96 sm:max-w-md",children:[e.jsx(Ne,{className:"sr-only",children:i("memorySidebar.title")}),e.jsx("div",{className:"flex flex-shrink-0 items-center justify-end px-2 pt-2 sm:hidden",children:e.jsx("button",{type:"button",onClick:()=>jt(!1),className:"flex h-8 w-8 items-center justify-center rounded-md text-text-muted hover:bg-surface-2 hover:text-text-primary","aria-label":i("common.close"),title:i("common.close"),children:e.jsx(Ds,{className:"h-4 w-4"})})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(Oa,{refreshTick:en,recall:at==="memdir"?tn:void 0,dreaming:at==="memdir"?H&&Nt:void 0,onDreamTrigger:at==="memdir"?ln:void 0})})]})}),e.jsx(da,{state:Ie,onStopTask:Lt}),re.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:re.map(o=>e.jsx(eo,{request:o,onApprove:()=>xn(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>pn(o.requestId,o.suggestions??[]):void 0,onReject:()=>yn(o.requestId),onSubmitAnswers:gn,onSubmitPlan:bn},o.requestId))})}),Ce&&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(Ea,{request:Ce,onSubmit:fn})})}),Dt&&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:Dt})}),Ee&&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:Ee})}),e.jsxs("div",{className:"page-measure mx-auto w-full px-4 sm:px-8 pb-1 flex flex-wrap items-center justify-between gap-x-1 gap-y-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsx(Za,{mode:b,onModeChange:ht,disabled:B||G}),e.jsx(Xa,{models:(z==null?void 0:z.availableModels)??[],currentModelId:(z==null?void 0:z.currentModelId)??null,onSelect:o=>{X(r,{type:"control_request",request:{subtype:"set_model",model:o}}),Se(x=>x&&{...x,currentModelId:o})},showThinking:L.set_max_thinking_tokens,thinkingBudget:he,onThinkingChange:Xs,showEffort:L.set_effort,effort:Bt,onEffortChange:o=>Ht.set(o),disabled:B||G}),L.set_token_mode&&e.jsx(Va,{mode:Ft,onModeChange:o=>nt.set(o),disabled:B||G})]}),e.jsx("div",{className:"flex flex-shrink-0 items-center gap-3",children:Vt&&e.jsx(Ja,{usage:Vt})})]}),B&&(s==null?void 0:s.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 rn(),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:i("session.resumeInNew")})}),e.jsx(ir,{onSubmit:on,isLoading:H,onInterrupt:Xt,onCycleMode:un,disabled:B||G,placeholder:B?i("session.closed"):G?i("session.readOnly"):i("session.inputPlaceholder"),supportsAttachments:!0,commands:gt,queueWhileLoading:!0,queuedCount:ye.length,onDequeue:o=>ie(x=>x.filter((C,R)=>R!==o)),onSearchFiles:L.file_search?o=>O.searchFiles(o):void 0,historyKey:r,draftOverride:D}),y&&e.jsx(ba,{onClose:()=>g(!1),fetchServers:()=>O.getMcpServers(),onToggle:(o,x)=>O.toggleMcpServer(o,x),onReconnect:o=>O.reconnectMcpServer(o)}),S&&e.jsx(wa,{onClose:()=>E(!1),fetchSettings:()=>O.getRemoteSettings(),onApply:o=>O.applyFlagSettings(o)}),T&&e.jsx(Na,{onClose:()=>m(!1),onAsk:o=>O.askSideQuestion(o)}),f&&s&&e.jsx(xa,{onClose:()=>p(!1),session:s,liveStatus:a,pendingPermissions:re,subagentState:Ie,onStopTask:Lt,onInterrupt:Xt,onDelete:mn,onEndSession:L.end_session&&!B&&!G?async()=>{await O.endSession("ended from web"),await as(s.id),window.location.href="/code/"}:void 0}),e.jsx(Ia,{open:q,onClose:()=>K(!1),sessionId:s.id,sessionTitle:s.title||void 0}),e.jsx(qa,{open:h,onClose:()=>w(!1),adapter:O,onResume:o=>{w(!1),Qe(o,null)}})]})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(lt,{onBack:t,title:e.jsx("span",{className:"h-3.5 w-40 animate-pulse rounded bg-surface-2"})}),e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:i("session.loading")})})]})}function eo({request:r,onApprove:t,onApproveAlways:s,onReject:n,onSubmitAnswers:a,onSubmitPlan:u}){const c=r.toolName,d=r.toolInput,f=r.description||"";if(c==="AskUserQuestion"){const p=d.questions||[];return e.jsx(Sa,{requestId:r.requestId,questions:p,description:f,onSubmit:y=>a(r.requestId,y,p),onSkip:n})}if(c==="ExitPlanMode"){const p=d.plan||"";return e.jsx(Ca,{requestId:r.requestId,planContent:p,description:f,onSubmit:(y,g)=>u(r.requestId,y,g)})}return e.jsx(ka,{requestId:r.requestId,toolName:c,toolInput:d,description:f,suggestions:r.suggestions,onApprove:t,onApproveAlways:s,onReject:n})}function to({sessionId:r,agentId:t}){const[s,n]=l.useState(null),[a,u]=l.useState("disconnected"),[c,d]=l.useState(null),f=l.useRef(null);return l.useEffect(()=>{const p=Ha(t);return p.setConnectionStateHandler((y,g)=>{u(y),d(g||null)}),f.current=p,n(p),p.connect().catch(y=>{y instanceof lr||(d(y.message),u("error"))}),()=>{p.disconnect(),f.current=null,n(null),u("disconnected")}},[t]),e.jsx(Os,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[c&&a==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:c}),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:i("session.connectingAgent")})]})}),a==="error"&&!s&&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:i("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:c})]})}),s&&a==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(cr,{client:s,agentId:t})})]})})}export{yo as SessionDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{aA as c,V as n,ay as i}from"./main-
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{aA as c,V as n,ay as i}from"./main-AdFlZL5H.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aV as v,c as N,aO as t}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aV as v,c as N,aO as t}from"./main-AdFlZL5H.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function E({onSuccess:p,onAlreadyDone:b}){const{setup:h}=v(),[d,f]=r.useState(""),[l,y]=r.useState(""),[a,g]=r.useState(""),[u,w]=r.useState(""),[i,o]=r.useState(""),[c,m]=r.useState(!1),j=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==u){o(t("auth.setup.passwordMismatch"));return}m(!0);try{await h(d,l,a),p()}catch(x){const n=x instanceof Error?x.message:"Setup failed";if(n.includes("already")||n.includes("409")){b();return}o(n)}finally{m(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"hero-enter w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(N,{className:"mx-auto mb-5 h-10 w-10"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.setup.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.setup.description")})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.apiKey")}),e.jsx("input",{type:"password",value:d,onChange:s=>f(s.target.value),required:!0,autoComplete:"off",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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.username")}),e.jsx("input",{type:"text",value:l,onChange:s=>y(s.target.value),required:!0,autoComplete:"username",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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.confirmPassword")}),e.jsx("input",{type:"password",value:u,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",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&&e.jsx("p",{className:"text-sm text-status-error",children:i}),e.jsx("button",{type:"submit",disabled:c,className:"w-full rounded-lg bg-brand px-4 py-2.5 font-display text-sm font-medium text-white shadow-lg shadow-brand/25 transition-all hover:-translate-y-0.5 hover:bg-brand-light hover:shadow-brand/40 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:translate-y-0 disabled:hover:shadow-none",children:c?t("common.loading"):t("auth.setup.submit")})]})]})})}export{E as Setup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{an as m,b as h}from"./main-
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{an as m,b as h}from"./main-AdFlZL5H.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function j(){const[t,r]=d.useState("loading"),[i,a]=d.useState(""),l=(typeof window<"u"?window.location.pathname:"").match(/\/code\/s\/([^/?]+)/),o=l?l[1]:null;return d.useEffect(()=>{if(!o){r("invalid"),a("Share link is invalid — no token found.");return}if(!o.startsWith("shr_")){r("invalid"),a("Invalid share token format.");return}let n=!1;async function c(){try{const s=await m(o);if(n)return;window.location.href=`/code/${s.id}`}catch(s){if(n)return;s instanceof h?s.status===401&&s.message.toLowerCase().includes("expired")?(r("expired"),a("This share has expired.")):s.status===404?s.message.toLowerCase().includes("session")?(r("not_found"),a("Session not found.")):(r("invalid"),a("Share not found or has been revoked.")):s.status===403?(r("invalid"),a("You do not have permission to access this share.")):(r("error"),a(s.message||"Failed to resolve share.")):(r("error"),a(s instanceof Error?s.message:"Failed to resolve share."))}}return c(),()=>{n=!0}},[o]),d.useEffect(()=>{if(t!=="loading"&&t!=="error"){const n=setTimeout(()=>{window.location.href="/code"},3e3);return()=>clearTimeout(n)}},[t]),t==="loading"?e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-muted",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",{children:"Resolving share link..."})]})}):e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-primary",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Share Expired"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share has expired."})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Invalid Share"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share link is invalid or has been revoked."})]}),t==="not_found"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Not Found"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"The session could not be found."})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Error"}),e.jsx("p",{className:"text-status-error mb-4",children:i})]}),e.jsx("a",{href:"/code",className:"text-brand-text hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aA as q,W as T,aW as M,aO as t,e as B,X as F,aP as W,ay as G,U as V,aE as X,a8 as Y,av as J,au as K,aV as Q,z as Z,m as ee,r as te,P as se,n as ae,p as ne,o as H,q as re,N as ie}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aA as q,W as T,aW as M,aO as t,e as B,X as F,aP as W,ay as G,U as V,aE as X,a8 as Y,av as J,au as K,aV as Q,z as Z,m as ee,r as te,P as se,n as ae,p as ne,o as H,q as re,N as ie}from"./main-AdFlZL5H.js";import{R as U,E as oe}from"./RegisterEmpty-CRUB4yEZ.js";import{U as le,A as O}from"./UserSearchInput-BC4G8fqt.js";import{C as D}from"./copy-DC3pycaX.js";import{g as ce}from"./workerType-CGf9PPvL.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{aW as b,aX as v,aO as a,aV as C,aP as f,N as D,W as S}from"./main-
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{aW as b,aX as v,aO as a,aV as C,aP as f,N as D,W as S}from"./main-AdFlZL5H.js";import{D as E,a as T,d as k}from"./dialog-FXbBrT_y.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function L({open:c,onClose:n,onCreated:m}){b();const{createTeam:N}=v(),[l,h]=d.useState(""),[i,o]=d.useState(""),[x,p]=d.useState(""),[s,r]=d.useState(""),[u,j]=d.useState(!1);d.useEffect(()=>{c&&(h(""),o(""),p(""),r(""),j(!1))},[c]);const w=t=>{h(t),i||o(t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"))},y=async t=>{t.preventDefault(),r(""),j(!0);try{const g=await N({name:l,slug:i,description:x||void 0});m(g)}catch(g){r(g instanceof Error?g.message:a("team.create.failed"))}finally{j(!1)}};return e.jsx(E,{open:c,onOpenChange:t=>{t||n()},children:e.jsx(T,{className:"nsd-shell max-w-md",children:e.jsxs("form",{className:"nsd-box nsd-box--single",onSubmit:y,children:[e.jsx(k,{className:"nsd-h",children:a("team.create.title")}),e.jsxs("label",{className:"nsd-field",children:[e.jsx("span",{className:"nsd-lab",children:a("team.create.name")}),e.jsx("input",{type:"text",required:!0,value:l,onChange:t=>w(t.target.value),placeholder:"Engineering",className:"nsd-title"}),e.jsx("span",{className:"text-xs text-text-muted",children:a("team.create.nameHint")})]}),e.jsxs("label",{className:"nsd-field",children:[e.jsx("span",{className:"nsd-lab",children:a("team.create.slug")}),e.jsx("input",{type:"text",required:!0,value:i,onChange:t=>o(t.target.value),pattern:"^[a-z0-9-]{3,32}$",placeholder:"engineering",className:"nsd-title"}),e.jsx("span",{className:"text-xs text-text-muted",children:a("team.create.slugHint")})]}),e.jsxs("label",{className:"nsd-field",children:[e.jsx("span",{className:"nsd-lab",children:a("team.create.description")}),e.jsx("textarea",{value:x,onChange:t=>p(t.target.value),rows:3,className:"nsd-title nsd-area"})]}),s&&e.jsx("p",{className:"nsd-error",children:s}),e.jsxs("div",{className:"nsd-foot",children:[e.jsx("button",{type:"button",onClick:n,className:"nsd-cancel",children:a("common.cancel")}),e.jsx("button",{type:"submit",disabled:u||!l||!i,className:"btn-ticket nsd-create",children:u?a("common.creating"):a("team.create.submit")})]})]})})})}function z(c,n){const m=new Date(c);return Number.isNaN(m.getTime())?"":new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en-US",{year:"numeric",month:"short"}).format(m)}function I(){const c=b(),{myTeams:n,isLoading:m,refetch:N}=v(),{user:l}=C(),[h,i]=d.useState(!1),o=s=>{i(!1),window.history.pushState(null,"",`/teams/${s.slug}`),window.dispatchEvent(new PopStateEvent("popstate"))},x=s=>(l==null?void 0:l.role)==="admin"||s.created_by===(l==null?void 0:l.userId),p=async s=>{if(window.confirm(f("team.list.deleteConfirm",{name:s.name})))try{await S("DELETE",`/web/teams/${s.id}`),await N()}catch(r){alert(r instanceof Error?r.message:a("team.list.deleteFailed"))}};return m?e.jsxs("div",{className:"ds-page",children:[e.jsxs("header",{className:"ds-page-head",children:[e.jsx("div",{className:"ds-page-runhead",children:e.jsx("div",{className:"h-2.5 w-20 animate-pulse rounded bg-surface-2"})}),e.jsxs("div",{className:"ds-page-titlerow",children:[e.jsx("div",{className:"h-12 w-44 animate-pulse rounded bg-surface-2"}),e.jsxs("div",{className:"ds-page-titlerow-end",children:[e.jsx("div",{className:"h-2.5 w-14 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"h-7 w-24 animate-pulse rounded-sm bg-surface-2"})]})]}),e.jsx("div",{className:"h-4 w-72 animate-pulse rounded bg-surface-2"})]}),e.jsx("div",{className:"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:"ds-page",children:[e.jsxs("header",{className:"ds-page-head",children:[e.jsx("div",{className:"ds-page-runhead",children:e.jsx("span",{className:"ds-page-runhead-label",children:a("team.list.kicker")})}),e.jsxs("div",{className:"ds-page-titlerow",children:[e.jsx("h1",{className:"ds-page-title font-display font-semibold tracking-tight text-text-primary",children:a("team.list.title")}),e.jsxs("div",{className:"ds-page-titlerow-end",children:[n.length>0&&e.jsx("span",{className:"ds-page-count",children:f("team.list.count",{n:n.length})}),e.jsx("button",{type:"button",onClick:()=>i(!0),className:"btn-ticket",children:a("team.list.create")})]})]}),e.jsx("p",{className:"ds-page-lede",children:n.length===0?a("team.list.empty"):a("team.list.lede")})]}),n.length>0&&e.jsx("ul",{className:"space-y-10",children:n.map((s,r)=>{const u=z(s.created_at,c);return e.jsxs("li",{className:"ds-team-item group",children:[e.jsxs("a",{href:`/teams/${s.slug}`,className:"ds-team-link",children:[e.jsxs("div",{className:"ds-team-name",children:[e.jsx("span",{className:"ds-team-idx","aria-hidden":"true",children:String(r+1).padStart(2,"0")}),e.jsx("h2",{className:"font-display text-lg 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:a("team.list.noDescription")})]}),e.jsxs("div",{className:"ds-team-aside",children:[u&&e.jsxs("span",{className:"ds-team-date",children:[a("team.list.founded")," ",u]}),x(s)&&e.jsx("button",{type:"button",onClick:()=>p(s),className:"ds-team-delete rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100 focus-visible:opacity-100",title:a("team.list.delete"),"aria-label":a("team.list.delete"),children:e.jsx(D,{className:"h-4 w-4"})})]})]},s.id)})}),e.jsx(L,{open:h,onClose:()=>i(!1),onCreated:o})]})}export{I as TeamList};
|