termdock 1.4.343 → 1.4.345
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/client/assets/{App-DCcTIZdf.js → App-BN_iuuvE.js} +43 -43
- package/dist/client/assets/App-BN_iuuvE.js.br +0 -0
- package/dist/client/assets/App-BN_iuuvE.js.gz +0 -0
- package/dist/client/assets/{ArchitecturePanel-CcBSZoe8.js → ArchitecturePanel-sTwptDpa.js} +2 -2
- package/dist/client/assets/ArchitecturePanel-sTwptDpa.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-sTwptDpa.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-CVL-Eoqi.js → ChangeWalkthroughPanel-DvOSOwLu.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-DvOSOwLu.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DvOSOwLu.js.gz +0 -0
- package/dist/client/assets/{CollaborationMainWorkspace-BNR6meXy.js → CollaborationMainWorkspace-DseFwFSR.js} +1 -1
- package/dist/client/assets/CollaborationMainWorkspace-DseFwFSR.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DseFwFSR.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-DL4Im2wQ.js +2 -0
- package/dist/client/assets/{ComputerControlView-D1cRpjbf.js → ComputerControlView-CWlfdXhY.js} +3 -3
- package/dist/client/assets/ComputerControlView-CWlfdXhY.js.br +0 -0
- package/dist/client/assets/ComputerControlView-CWlfdXhY.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-BjtiPvYD.js → DagPlayground-B1IytHVy.js} +1 -1
- package/dist/client/assets/DagPlayground-B1IytHVy.js.br +0 -0
- package/dist/client/assets/DagPlayground-B1IytHVy.js.gz +0 -0
- package/dist/client/assets/{DiffLab-L76RA6ma.js → DiffLab-B6gSsPoJ.js} +1 -1
- package/dist/client/assets/DiffLab-B6gSsPoJ.js.br +0 -0
- package/dist/client/assets/DiffLab-B6gSsPoJ.js.gz +0 -0
- package/dist/client/assets/{DiffReview-BZ6uHzt1.js → DiffReview-BYI8gVYo.js} +1 -1
- package/dist/client/assets/DiffReview-BYI8gVYo.js.br +0 -0
- package/dist/client/assets/DiffReview-BYI8gVYo.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-B0tXcqaf.js → DiffReviewLab-BYUQFzsG.js} +1 -1
- package/dist/client/assets/DiffReviewLab-BYUQFzsG.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BYUQFzsG.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-ClFGIsxM.js → DiffViewer-P1mbq4LM.js} +1 -1
- package/dist/client/assets/DiffViewer-P1mbq4LM.js.br +0 -0
- package/dist/client/assets/DiffViewer-P1mbq4LM.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-B3ETe5f9.js → ModelPreview-BpIynSeJ.js} +1 -1
- package/dist/client/assets/ModelPreview-BpIynSeJ.js.br +0 -0
- package/dist/client/assets/ModelPreview-BpIynSeJ.js.gz +0 -0
- package/dist/client/assets/{RightSidebar-BSp4sFCm.js → RightSidebar-DyX2uyW6.js} +47 -45
- package/dist/client/assets/RightSidebar-DyX2uyW6.js.br +0 -0
- package/dist/client/assets/RightSidebar-DyX2uyW6.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-BYfyqXgQ.js → abnfDiagram-VCTEODGH-Cjq0zd9z.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-Cjq0zd9z.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-Cjq0zd9z.js.gz +0 -0
- package/dist/client/assets/app-HTVDUkx-.js +35 -0
- package/dist/client/assets/app-HTVDUkx-.js.br +0 -0
- package/dist/client/assets/app-HTVDUkx-.js.gz +0 -0
- package/dist/client/assets/{arc-DYMjtzAT.js → arc-DkPjbARe.js} +1 -1
- package/dist/client/assets/arc-DkPjbARe.js.br +0 -0
- package/dist/client/assets/arc-DkPjbARe.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-937uLJdY.js → architectureDiagram-5GKGNRK7-DvErYV6b.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DvErYV6b.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DvErYV6b.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-BjMVJVHv.js → blockDiagram-I7D4REHJ-Bds9HO1o.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-Bds9HO1o.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-Bds9HO1o.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-DKr1q3YZ.js → c4Diagram-7LVT6UL2-C2OH1wSt.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-C2OH1wSt.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-C2OH1wSt.js.gz +0 -0
- package/dist/client/assets/channel-CdhDWMew.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-Cmbm422D.js → chunk-2Q5K7J3B-DVaF1NsT.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-Dlrrt5X6.js → chunk-5VM5RSS4-Dkbpeqfb.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-Brplur9W.js → chunk-F27PBJKO-CRPAOyuh.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-CRPAOyuh.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-CRPAOyuh.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-DDH-xTd_.js → chunk-IMKFNOWR-CphgPwod.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-CphgPwod.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-CphgPwod.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-C-fazXnV.js → chunk-JWPE2WC7-CWlXUB6G.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-BpvA5JQ8.js → chunk-POPQ4Y6H-BAAz8QH8.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-DEGdY0iE.js → chunk-SVP7TREG-C9qRACkp.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-C9qRACkp.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-C9qRACkp.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-q48VhB5_.js → chunk-TICWLB2K-CAn30A5F.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-CAn30A5F.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-CAn30A5F.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-BUnK03xP.js → chunk-XXDRQBXY-i2tZFJ9V.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-_NMbO90f.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-_NMbO90f.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CwORdR-o.js → cose-bilkent-JH36ORCC-_ejU8hPT.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-_ejU8hPT.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-_ejU8hPT.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-C8zwrcdC.js → cynefin-OW5HDTMX-BkzgMwVY.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-BkzgMwVY.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BkzgMwVY.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-9TA7e2Jg.js → cynefinDiagram-5FMLGOSQ-f623ycDk.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-f623ycDk.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-f623ycDk.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-ozLbKQvR.js → dagre-GXQ25YYZ-CZKJoNzx.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-CZKJoNzx.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-CZKJoNzx.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-Bn4XhpI7.js → diagram-S7CK7UJ4-C4Sjb6W8.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-C4Sjb6W8.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-C4Sjb6W8.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-tKpUsiXZ.js → diagram-UQ7AKVKN-Buov_WHB.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-Buov_WHB.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-Buov_WHB.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-0N9YA_4l.js → diagram-VSXAHHWV-B3v-ZnXu.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-B3v-ZnXu.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-B3v-ZnXu.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-V2WFvWL0.js → diagram-VX7I27RA-DCEWE8mj.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-DCEWE8mj.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-DCEWE8mj.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-50ixVRGU.js → diagram-Z3DM3KII-bK4WKBJF.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-bK4WKBJF.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-bK4WKBJF.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-DYdiLGfv.js → ebnfDiagram-PWID7BFC-wOu6iW76.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-wOu6iW76.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-wOu6iW76.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-Bglt3tsq.js → erDiagram-RLTQ6QDP-D83VmrYf.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-D83VmrYf.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-D83VmrYf.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-QHE7V70K.js → flowDiagram-HODETNUW-DCxfJLXu.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-DCxfJLXu.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-DCxfJLXu.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-BiI1Cl0h.js → ganttDiagram-EL5Y4UJY-CF9XnXOS.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CF9XnXOS.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CF9XnXOS.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-DMJfCd7R.js → gestureArbiter-DOugsAle.js} +1 -1
- package/dist/client/assets/gestureArbiter-DOugsAle.js.br +0 -0
- package/dist/client/assets/gestureArbiter-DOugsAle.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-BDh5xzL0.js → gitGraphDiagram-WWUBYQGX-jT8-SkeT.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-jT8-SkeT.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-jT8-SkeT.js.gz +0 -0
- package/dist/client/assets/{index-A-ZC9mbr.css → index-DtPsPZ7W.css} +1 -1
- package/dist/client/assets/index-DtPsPZ7W.css.br +0 -0
- package/dist/client/assets/{index-A-ZC9mbr.css.gz → index-DtPsPZ7W.css.gz} +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-BwRQvwVT.js → infoDiagram-27XIBGKW-B-LDzk7Q.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-D-XGlyHD.js → ishikawaDiagram-5VMMS53U-CsosD6UL.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CsosD6UL.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CsosD6UL.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-TVJdFmZO.js → journeyDiagram-3NMN7TZE-Bv5RcxaN.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Bv5RcxaN.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Bv5RcxaN.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-BNKbii3u.js → kanban-definition-UXKFOSKX-D1ukvOoH.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-D1ukvOoH.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-D1ukvOoH.js.gz +0 -0
- package/dist/client/assets/{layout-BnxQZMpY.js → layout-VC45eUZy.js} +1 -1
- package/dist/client/assets/layout-VC45eUZy.js.br +0 -0
- package/dist/client/assets/layout-VC45eUZy.js.gz +0 -0
- package/dist/client/assets/{linear-99NBGeCC.js → linear-C3VBb8xa.js} +1 -1
- package/dist/client/assets/linear-C3VBb8xa.js.br +0 -0
- package/dist/client/assets/linear-C3VBb8xa.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-CmwfcYZ2.js → mermaid.core-DG2QUI-L.js} +5 -5
- package/dist/client/assets/mermaid.core-DG2QUI-L.js.br +0 -0
- package/dist/client/assets/mermaid.core-DG2QUI-L.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-BZI6wimw.js → mindmap-definition-YA3MSWOX-CpA9V0iU.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-CpA9V0iU.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-CpA9V0iU.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-cQk2qdyF.js → passwordBootstrap-DILrqabi.js} +1 -1
- package/dist/client/assets/passwordBootstrap-DILrqabi.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-DILrqabi.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-Ck6_UJCc.js → pegDiagram-XKGWAZYB-C7OQC7uD.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-C7OQC7uD.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-C7OQC7uD.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-uSt3JkUn.js → pieDiagram-E7YTZNPT-Ot6_RqeC.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-Ot6_RqeC.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-Ot6_RqeC.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BRXYZ2tD.js → quadrantDiagram-AXDQQJYC-Bf7jut-u.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Bf7jut-u.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Bf7jut-u.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-D6_tYmbg.js → railroadDiagram-O6MQD6OU-WrpZgg8t.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-WrpZgg8t.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-WrpZgg8t.js.gz +0 -0
- package/dist/client/assets/{rdpSession-rdarsKgF.js → rdpSession-D5nvZxrU.js} +1 -1
- package/dist/client/assets/rdpSession-D5nvZxrU.js.br +0 -0
- package/dist/client/assets/rdpSession-D5nvZxrU.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-DttwS3Pz.js → referenceLongPress-C6YZh55M.js} +1 -1
- package/dist/client/assets/referenceLongPress-C6YZh55M.js.br +0 -0
- package/dist/client/assets/referenceLongPress-C6YZh55M.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-CLY6zGmG.js → requirementDiagram-BXWQKSXE-DSDgL_p4.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DSDgL_p4.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DSDgL_p4.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CiFyFj6p.js → sankeyDiagram-P5KCCOFB-C_ytO8Ty.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-C_ytO8Ty.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-C_ytO8Ty.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DgI6wvE8.js → sequenceDiagram-WJ2MYXX4-DhZKcw8h.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DhZKcw8h.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DhZKcw8h.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-D89Tnq0d.js → sizeCapture-INFHLROL-BM1PVyhM.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-BM1PVyhM.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-BM1PVyhM.js.gz +0 -0
- package/dist/client/assets/{sparkles-BpY-2ThK.js → sparkles-BONmCbTi.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-DSRJvuE3.js → stateDiagram-D77RDMKH-BJ9RE6YD.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-BJ9RE6YD.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-BJ9RE6YD.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BMIQgRVo.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-D4d-t4OI.js → swimlanes-42K2YHIH-CM-hxgek.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-CM-hxgek.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-CM-hxgek.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BS47Goc0.js +8 -0
- package/dist/client/assets/terminal-Dea8wJF3.js +10 -0
- package/dist/client/assets/terminal-Dea8wJF3.js.br +0 -0
- package/dist/client/assets/terminal-Dea8wJF3.js.gz +0 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-BfC0WOSw.js → timeline-definition-24CTP7MA--ZFOA2ds.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA--ZFOA2ds.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA--ZFOA2ds.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-Bzc3OC00.js → triangle-alert-B-7heGu-.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-DV39_9aM.js → vennDiagram-4TSXK5OY-CAKGCM6V.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-CAKGCM6V.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CAKGCM6V.js.gz +0 -0
- package/dist/client/assets/{videoCompression-uaFA6Wsb.js → videoCompression-D8Kt2prC.js} +1 -1
- package/dist/client/assets/videoCompression-D8Kt2prC.js.br +0 -0
- package/dist/client/assets/videoCompression-D8Kt2prC.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-9l8pnAY8.js → wardleyDiagram-VM6X3IG4-5g9ZJdVF.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-5g9ZJdVF.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-5g9ZJdVF.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BnOVO5Js.js → xychartDiagram-S5SC5T6Z-CJ1hIdXS.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CJ1hIdXS.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CJ1hIdXS.js.gz +0 -0
- package/dist/client/index.html +3 -3
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/dist/server/federation/invitations.js +15 -1
- package/dist/server/federation/runtime.js +5 -1
- package/dist/server/routes/terminal.js +15 -2
- package/dist/server/utils/tmuxRecovery.js +22 -15
- package/package.json +5 -3
- package/runtime-manifest.json +4 -4
- package/dist/client/assets/App-DCcTIZdf.js.br +0 -0
- package/dist/client/assets/App-DCcTIZdf.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-CcBSZoe8.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-CcBSZoe8.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-CVL-Eoqi.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-CVL-Eoqi.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BNR6meXy.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BNR6meXy.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-CJBA3EUR.js +0 -2
- package/dist/client/assets/ComputerControlView-D1cRpjbf.js.br +0 -0
- package/dist/client/assets/ComputerControlView-D1cRpjbf.js.gz +0 -0
- package/dist/client/assets/DagPlayground-BjtiPvYD.js.br +0 -0
- package/dist/client/assets/DagPlayground-BjtiPvYD.js.gz +0 -0
- package/dist/client/assets/DiffLab-L76RA6ma.js.br +0 -0
- package/dist/client/assets/DiffLab-L76RA6ma.js.gz +0 -0
- package/dist/client/assets/DiffReview-BZ6uHzt1.js.br +0 -0
- package/dist/client/assets/DiffReview-BZ6uHzt1.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-B0tXcqaf.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-B0tXcqaf.js.gz +0 -0
- package/dist/client/assets/DiffViewer-ClFGIsxM.js.br +0 -0
- package/dist/client/assets/DiffViewer-ClFGIsxM.js.gz +0 -0
- package/dist/client/assets/ModelPreview-B3ETe5f9.js.br +0 -0
- package/dist/client/assets/ModelPreview-B3ETe5f9.js.gz +0 -0
- package/dist/client/assets/RightSidebar-BSp4sFCm.js.br +0 -0
- package/dist/client/assets/RightSidebar-BSp4sFCm.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-BYfyqXgQ.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-BYfyqXgQ.js.gz +0 -0
- package/dist/client/assets/app-C0jo989F.js +0 -35
- package/dist/client/assets/app-C0jo989F.js.br +0 -0
- package/dist/client/assets/app-C0jo989F.js.gz +0 -0
- package/dist/client/assets/arc-DYMjtzAT.js.br +0 -0
- package/dist/client/assets/arc-DYMjtzAT.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-937uLJdY.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-937uLJdY.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BjMVJVHv.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BjMVJVHv.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DKr1q3YZ.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DKr1q3YZ.js.gz +0 -0
- package/dist/client/assets/channel-CxYS0D6E.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-Brplur9W.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-Brplur9W.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-DDH-xTd_.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-DDH-xTd_.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-DEGdY0iE.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-DEGdY0iE.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-q48VhB5_.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-q48VhB5_.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-C7BzKXcX.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-C7BzKXcX.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-CwORdR-o.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-CwORdR-o.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-C8zwrcdC.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-C8zwrcdC.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-9TA7e2Jg.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-9TA7e2Jg.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-ozLbKQvR.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-ozLbKQvR.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Bn4XhpI7.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Bn4XhpI7.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-tKpUsiXZ.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-tKpUsiXZ.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-0N9YA_4l.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-0N9YA_4l.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-V2WFvWL0.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-V2WFvWL0.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-50ixVRGU.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-50ixVRGU.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DYdiLGfv.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DYdiLGfv.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Bglt3tsq.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Bglt3tsq.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-QHE7V70K.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-QHE7V70K.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BiI1Cl0h.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BiI1Cl0h.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-DMJfCd7R.js.br +0 -0
- package/dist/client/assets/gestureArbiter-DMJfCd7R.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BDh5xzL0.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BDh5xzL0.js.gz +0 -0
- package/dist/client/assets/index-A-ZC9mbr.css.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-D-XGlyHD.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-D-XGlyHD.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-TVJdFmZO.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-TVJdFmZO.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BNKbii3u.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BNKbii3u.js.gz +0 -0
- package/dist/client/assets/layout-BnxQZMpY.js.br +0 -0
- package/dist/client/assets/layout-BnxQZMpY.js.gz +0 -0
- package/dist/client/assets/linear-99NBGeCC.js.br +0 -0
- package/dist/client/assets/linear-99NBGeCC.js.gz +0 -0
- package/dist/client/assets/mermaid.core-CmwfcYZ2.js.br +0 -0
- package/dist/client/assets/mermaid.core-CmwfcYZ2.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BZI6wimw.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BZI6wimw.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-cQk2qdyF.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-cQk2qdyF.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-Ck6_UJCc.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-Ck6_UJCc.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-uSt3JkUn.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-uSt3JkUn.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BRXYZ2tD.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BRXYZ2tD.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-D6_tYmbg.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-D6_tYmbg.js.gz +0 -0
- package/dist/client/assets/rdpSession-rdarsKgF.js.br +0 -0
- package/dist/client/assets/rdpSession-rdarsKgF.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-DttwS3Pz.js.br +0 -0
- package/dist/client/assets/referenceLongPress-DttwS3Pz.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CLY6zGmG.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CLY6zGmG.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CiFyFj6p.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CiFyFj6p.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DgI6wvE8.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DgI6wvE8.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-D89Tnq0d.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-D89Tnq0d.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DSRJvuE3.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DSRJvuE3.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-D2I-nExx.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-D4d-t4OI.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-D4d-t4OI.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BGk-TIBO.js +0 -8
- package/dist/client/assets/terminal-C7X98Amf.js +0 -10
- package/dist/client/assets/terminal-C7X98Amf.js.br +0 -0
- package/dist/client/assets/terminal-C7X98Amf.js.gz +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BfC0WOSw.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BfC0WOSw.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DV39_9aM.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DV39_9aM.js.gz +0 -0
- package/dist/client/assets/videoCompression-uaFA6Wsb.js.br +0 -0
- package/dist/client/assets/videoCompression-uaFA6Wsb.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-9l8pnAY8.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-9l8pnAY8.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BnOVO5Js.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BnOVO5Js.js.gz +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
2
|
-
import{ah as Br,dg as ht,bA as e,h as $o,cv as zd,ar as Ju,_ as Ln,bI as Qu,L as ut,e as hs,X as Lt,dm as V,du as At,bV as gt,a as ca,b3 as Zu,C as Po,d as da,dc as ra,dd as bl,U as Wd,c_ as Km,cA as qm,bl as Vm,O as Vs,aA as Ym,bs as Xm,bu as Bl,bv as Jm,bw as ef,bt as Ys,aQ as Qm,E as Zm,k as ep,bp as tp,bX as rp,bZ as np,b_ as sp,bg as ap,bY as Gd,N as jt,g as op,j as qi,I as ip,b as lp,de as Vi,bf as Kd,aK as qd,aG as cp,aU as Yi,aV as Vd,dv as aa,ax as Xs,aW as dp,bN as up,cX as Yd,aN as fp,da as hp,cq as mp,dn as Qr,aZ as pp,a2 as Xd,a1 as gp,aH as Jd,aM as bp,aS as Qd,cs as xp,z as Zd,l as eu,r as tu,J as tf,av as rf,ci as vp,ds as yp,n as wp}from"./app-C0jo989F.js";import{b as a,r as wr}from"./dnd-BCFAPC0L.js";import{i as Ol,F as kp,O as nf,y as Sp,s as ru,Q as nu,W as jo,m as jp,aj as sf,Z as Rp,x as Np,I as Cp,t as Ep,M as Mp,R as Ro,a6 as af,a7 as $p,S as ms,n as of,g as Pp,ap as lf,A as Xi,am as Ap,aa as Ji,ak as Pn,a8 as Lp,a9 as su,an as Tp,ac as au,r as ou,k as iu,E as Qi,B as ho,h as Ip,T as Dp,z as Fp,N as lu,Y as _p,q as Bp,U as Op,o as cu,C as Up,c as Hp,G as zp,f as Wp}from"./App-DCcTIZdf.js";import{F as xl,a as du,S as uu,b as cf,c as vl}from"./gestureArbiter-DMJfCd7R.js";import{D as yl,C as oa,L as df,f as Gp,n as Kp}from"./DiffReview-BZ6uHzt1.js";import{T as qp,L as Ao,M as uf,G as xr}from"./triangle-alert-Bzc3OC00.js";import{S as ua}from"./sparkles-BpY-2ThK.js";import{C as ff,M as hf}from"./ChangeWalkthroughPanel-CVL-Eoqi.js";import{r as mf,s as pf,l as gf,a as fu,h as wl,u as Vp,g as kl,b as bf}from"./DiffViewer-ClFGIsxM.js";import{u as xf,G as vf}from"./referenceLongPress-DttwS3Pz.js";const Yp=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Xp=Br("case-sensitive",Yp);const Jp=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Qp=Br("eye-off",Jp);const Zp=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Sl=Br("eye",Zp);const eg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],jl=Br("file-text",eg);const tg=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],rg=Br("funnel",tg);const ng=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],sg=Br("image-plus",ng);const ag=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],og=Br("regex",ag);const ig=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],lg=Br("scan",ig);const cg=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],dg=Br("whole-word",cg),ug=100,fg=5e5,hg=1e4,hu=16384,mg=32,pg=1e5;class cs extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class gg{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>pg)throw new cs("complexity");if(performance.now()-this.startedAt>=ug)throw new cs("timeout")}validateLines(n){if(n.length>hg)throw new cs("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>fg||l.length>hu)throw new cs("size")}validateInline(n){if(this.check(),n.length>hu)throw new cs("size")}nested(n){if(this.check(),this.depth>=mg)throw new cs("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const mu=new RegExp(`(\\\\\\([^)]*\\\\\\)|\\$[^$\\n]+\\$|<br\\s*\\/?>|<\\s*img\\b[^>]*>|<\\s*video\\b[^>]*>[\\s\\S]*?<\\/video\\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\\b[\\s\\S]*?<\\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\\[[^\\]]*\\]\\((?:<[^>]+>|(?:[^\\s()]|\\([^()\\s]*\\))+)(?:\\s+(?:"[^"]*"|'[^']*'|\\([^)]*\\)))?\\)|!?\\[[^\\]]+\\]\\[[^\\]]*\\]|!?\\[[^\\]]+\\]|\\[\\^[^\\]]+\\]|~~[^~]+~~|\\*\\*[^*]+\\*\\*|(?<![\\p{L}\\p{N}_])__[^_]+__(?![\\p{L}\\p{N}_])|\\*[^*\\s][^*]*\\*|(?<![\\p{L}\\p{N}_])_[^_\\s][^_]*_(?![\\p{L}\\p{N}_])|<https?:\\/\\/[^>\\s]+>|<[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+>|https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+|[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+)`,"iyu");function bg(r,n,s){let l=n;for(;r[l]==="`";)l+=1;const d=l-n;let c=l;for(;c<r.length;){s.check();const m=r.indexOf("`",c);if(m<0)return null;for(c=m;r[c]==="`";)c+=1;if(c-m===d)return c}return null}function*xg(r,n){n.validateInline(r);const s=new RegExp(mu.source,mu.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=bg(r,l,n);if(c!==null)yield{index:l,token:r.slice(l,c)},l=c;else for(;r[l]==="`";)l+=1;continue}s.lastIndex=l;const d=s.exec(r);n.check(),d?(yield{index:l,token:d[0]},l=s.lastIndex):l+=(r.codePointAt(l)??0)>65535?2:1}}function pu({children:r,actions:n}){const{t:s}=ht(),[l,d]=a.useState(!1),c=a.useId(),m=a.useRef(null),g=a.useRef(null),f=()=>{d(!1),m.current?.focus({preventScroll:!0})};return a.useLayoutEffect(()=>{if(!l)return;const p=m.current,x=g.current;if(!p||!x)return;const h=window.visualViewport,b=()=>{const S=p.getBoundingClientRect(),T=(h?.offsetLeft??0)+8,D=(h?.offsetTop??0)+8,F=Math.max(0,(h?.width??window.innerWidth)-16),$=D+(h?.height??window.innerHeight)-16,C=Math.min(240,F),A=Math.max(0,S.top-D-6),O=Math.max(0,$-S.bottom-6),q=x.scrollHeight>O&&A>O;Object.assign(x.style,{width:`${C}px`,left:`${Math.max(T,Math.min(S.right-C,T+F-C))}px`,top:`${q?S.top-6:S.bottom+6}px`,maxHeight:`${q?A:O}px`,transform:q?"translateY(-100%)":"none"})};b();const E=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return E?.observe(p),E?.observe(x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),h?.addEventListener("resize",b),h?.addEventListener("scroll",b),()=>{E?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),h?.removeEventListener("resize",b),h?.removeEventListener("scroll",b)}},[l]),a.useEffect(()=>{if(!l)return;g.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const p=x=>{x.target instanceof Node&&!m.current?.contains(x.target)&&!g.current?.contains(x.target)&&d(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[l]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:m,type:"button","aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?c:void 0,onClick:()=>d(p=>!p),onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),d(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${l?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx($o,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&wr.createPortal(e.jsx("div",{ref:g,id:c,hidden:!l,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":s("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:p=>{if(!p.currentTarget.contains(p.target))return;const x=[...p.currentTarget.querySelectorAll("button:not(:disabled)")],h=x.indexOf(document.activeElement);let b;if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),f();return}if(p.key==="Tab"){f();return}if(p.key==="ArrowDown")b=(h+1)%x.length;else if(p.key==="ArrowUp")b=(h-1+x.length)%x.length;else if(p.key==="Home")b=0;else if(p.key==="End")b=x.length-1;else return;p.preventDefault(),x[b]?.focus({preventScroll:!0})},children:n(f)}),document.body)]})}const Zi="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",ds=a.memo(function({active:n,mounted:s=!0,fallback:l=null,children:d}){const c=a.useRef(null);return a.useLayoutEffect(()=>{const m=c.current;if(!m||n)return;const g=new Map,f=h=>{g.has(h)||(g.set(h,h.inert),h.inert=!0)},p=h=>{h instanceof HTMLElement&&h.matches(Zi)&&f(h),h.querySelectorAll(Zi).forEach(f)};p(m);const x=new MutationObserver(h=>{for(const b of h)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Zi)&&f(b.target):b.addedNodes.forEach(E=>{E instanceof Element&&p(E)})});return x.observe(m,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{x.disconnect();for(const[h,b]of g)h.inert=b}},[n,s]),e.jsx("div",{ref:c,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:n?void 0:{clipPath:"inset(100%)"},"aria-hidden":!n,children:s?typeof d=="function"?d():d:l})},(r,n)=>!r.active&&!n.active&&r.mounted===n.mounted);async function vg(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function yg({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!r||!n||s||d.current===n)return;const m=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(m)},[r,n,s,l,d,c])}async function wg(r){if(r.kind==="mermaid"){await zd(new Blob([r.svg],{type:"image/svg+xml"}),"mermaid.svg");return}const n=new URL(r.src,window.location.href);if(n.origin===window.location.origin&&n.pathname==="/api/terminal/fs/blob"){const c=n.searchParams.get("path");if(!c)throw new Error("Missing image path");await Ju(c);return}const s=await fetch(r.src);if(!s.ok)throw new Error(`HTTP ${s.status}`);const l=await s.blob(),d=decodeURIComponent(n.pathname.split("/").pop()||"")||`image.${{"image/svg+xml":"svg","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[l.type]||"png"}`;await zd(l,d)}let mo=null,gu=!1;function kg(){return mo||(mo=Ln(()=>import("./mermaid.core-CmwfcYZ2.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw mo=null,r})),mo}function Sg(r){gu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),gu=!0)}function jg({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:d}=ht(),[c,m]=a.useState(""),[g,f]=a.useState(0),[p,x]=a.useState(null),[h,b]=a.useState(!1),[E,S]=a.useState(!1),T=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const C=new AbortController;return x(null),b(!1),Qu(T,C.signal,!0,"pick_git_ignore_exception").then(A=>{C.signal.aborted||x({directory:c,entries:A.entries,truncated:!!A.truncated})}).catch(()=>{C.signal.aborted||b(!0)}),()=>C.abort()},[T,c,g]);const D=C=>{x(null),b(!1),m(C)},F=p?.directory===c,$=C=>{if(C.length>200){S(!0);return}S(!1),l(C)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":d("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(Ol,{size:14})}),e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(""),"aria-label":d("rightSidebar.backToProjectRoot"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(xl,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:T,children:c||"./"})]}),e.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":d("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!F&&!h,children:[h?e.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[e.jsx("p",{role:"alert",className:"text-destructive",children:d("rightSidebar.gitIgnoreExceptionsLoadFailed")}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{b(!1),f(C=>C+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:d("common.retry")})]}):F?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(C=>{const A=c?`${c}/${C.name}`:C.name,O=A+(C.type==="directory"?"/":""),q=n.includes(O)||n.includes(A),j=n.some(_=>_.endsWith("/")&&A.startsWith(_)),o=C.type==="directory"?xl:kp;return e.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[e.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:q||j,disabled:s||j,onChange:()=>$(q?n.filter(_=>_!==O&&_!==A):[...n,O]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),e.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",title:C.name,children:C.name})]}),C.type==="directory"&&e.jsx("button",{type:"button",disabled:s,onClick:()=>D(A),"aria-label":d("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:C.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:e.jsx(hs,{size:15})})]},C.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ut,{size:18})}),F&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:d("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>$([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:d("rightSidebar.gitIgnoreExceptionsClear")})]}),n.length>0&&e.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:n.map(C=>e.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:C,children:C}),e.jsx("button",{type:"button",disabled:s,onClick:()=>$(n.filter(A=>A!==C)),"aria-label":d("rightSidebar.gitIgnoreExceptionsRemove",{path:C}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:13})})]},C))}),E&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function Rg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:d}){const{t:c}=ht(),m=a.useId(),g=a.useRef(null),f=a.useRef(null),p=a.useRef(null),x=a.useRef(null),h=a.useRef(!1),[b,E]=a.useState(!1),[S,T]=a.useState([]),[D,F]=a.useState(!1),[$,C]=a.useState(null),A=V(I=>I.setGitIgnoreExceptions),O=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,x.current=null},q=()=>{O(),!(n||D||!r)&&(T([...V.getState().gitIgnoreExceptions[r]??[]]),C(null),E(!0))},j=()=>{D||E(!1)},o=I=>{O(),h.current=!1,!(I.button!==0||!I.isPrimary||n)&&(I.currentTarget.setPointerCapture(I.pointerId),x.current={x:I.clientX,y:I.clientY},p.current=setTimeout(()=>{h.current=!0,q()},450))};a.useEffect(()=>(E(!1),O(),O),[r]),a.useEffect(()=>{if(b)return f.current?.focus(),()=>g.current?.focus()},[b]);const _=c(s?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",disabled:n||D,"aria-pressed":s,"aria-label":_,"aria-description":c("rightSidebar.gitIgnoreConfigureHint"),title:`${_} · ${c("rightSidebar.gitIgnoreConfigureHint")}`,onClick:I=>{if(h.current&&I.detail!==0){h.current=!1,I.preventDefault();return}d()},onContextMenu:I=>{I.preventDefault(),h.current=!0,b||q()},onPointerDown:o,onPointerMove:I=>{const Y=x.current;Y&&Math.hypot(I.clientX-Y.x,I.clientY-Y.y)>10&&O()},onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${s?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:l?e.jsx(ut,{size:14}):e.jsx(rg,{size:14})}),b&&wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:j,children:e.jsxs("form",{ref:f,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:I=>I.stopPropagation(),onKeyDown:I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),j()),I.key==="Tab"){const Y=Array.from(f.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!Y.length){I.preventDefault(),f.current?.focus();return}const H=Y[0],U=Y[Y.length-1];I.shiftKey&&document.activeElement===H&&(I.preventDefault(),U?.focus()),document.activeElement===f.current?(I.preventDefault(),(I.shiftKey?U:H)?.focus()):!I.shiftKey&&document.activeElement===U&&(I.preventDefault(),H?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||D)){if(S.length>200){C(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}F(!0),C(null),A(r,S).then(()=>E(!1)).catch(()=>C(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>F(!1))}},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:`${m}-title`,className:"text-sm font-medium",children:c("rightSidebar.gitIgnoreExceptionsTitle")}),e.jsx("button",{type:"button",disabled:D,onClick:j,"aria-label":c("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:16})})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),e.jsx("p",{id:`${m}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:c("rightSidebar.gitIgnoreExceptionsHint")}),e.jsx("p",{className:"text-xs font-medium",children:c("rightSidebar.gitIgnoreExceptionsPaths")}),r&&e.jsx(jg,{rootPath:r,paths:S,onChange:T,disabled:D}),$&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:$}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:D,onClick:j,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:c("common.cancel")}),e.jsxs("button",{type:"submit",disabled:D,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[D&&e.jsx(ut,{size:13}),c("common.save")]})]})]})}),document.body)]})}function Ng(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,d=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!d)return Promise.resolve(null);const c=r instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),m=document.createElement("canvas");m.width=Math.max(1,Math.round(l*c)),m.height=Math.max(1,Math.round(d*c));const g=m.getContext("2d");if(!g)return Promise.resolve(null);const f=getComputedStyle(document.documentElement);if(g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,m.height),g.drawImage(r,0,0,m.width,m.height),s){const p=Math.max(10,Math.min(16,m.width/35));g.font=`${p}px sans-serif`;const x=[];let h="";for(const b of s.split(" "))h&&g.measureText(`${h} ${b}`).width>m.width-20?(x.push(h),h=b):h=h?`${h} ${b}`:b;h&&x.push(h),g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,x.length*(p+4)+12),g.fillStyle=f.getPropertyValue("--foreground").trim()||"black",x.forEach((b,E)=>g.fillText(b,10,8+p+E*(p+4)))}if(n){const p=n.xPercent*m.width/100,x=n.yPercent*m.height/100,h=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),b=h*1.6;g.strokeStyle=f.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,h/3),g.beginPath(),g.arc(p,x,h,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(p-b,x),g.lineTo(p+b,x),g.moveTo(p,x-b),g.lineTo(p,x+b),g.stroke()}return new Promise(p=>m.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function Cg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
-
`)}function
|
|
4
|
-
`),
|
|
5
|
-
`);T&&!d.has(D)&&(l.push(...E),d.add(D)),x=
|
|
6
|
-
`)}function
|
|
7
|
-
`)[0]??"",z=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>(
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DG2QUI-L.js","assets/app-HTVDUkx-.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-Dea8wJF3.js","assets/index-DtPsPZ7W.css","assets/purify.es-4eNOHKSq.js","assets/ModelPreview-BpIynSeJ.js","assets/App-BN_iuuvE.js","assets/gestureArbiter-DOugsAle.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-B-7heGu-.js","assets/referenceLongPress-C6YZh55M.js","assets/DiffReview-BYI8gVYo.js","assets/sparkles-BONmCbTi.js","assets/DiffViewer-P1mbq4LM.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-DvOSOwLu.js","assets/ArchitecturePanel-sTwptDpa.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-CWlfdXhY.js","assets/katex-55ZPZeOF.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ah as Br,dg as ht,bA as e,h as Po,cv as Gd,ar as Zu,_ as Ln,bI as ef,L as ft,e as hs,X as Lt,dm as V,du as At,bV as gt,a as ca,b3 as tf,C as Ao,d as da,dc as ra,dd as vl,U as Kd,c_ as Xm,cA as Jm,bl as Qm,O as Vs,aA as Zm,bs as ep,bu as Ul,bv as tp,bw as Hl,bt as Ys,aQ as rp,E as np,k as sp,bp as ap,bX as op,bZ as ip,b_ as lp,bg as cp,bY as qd,N as jt,g as dp,j as Yi,I as up,b as fp,de as Xi,bf as Vd,aK as Yd,aG as hp,aU as Ji,aV as Xd,dv as aa,ax as Xs,aW as mp,bN as pp,cX as Jd,aN as gp,da as bp,cq as xp,dn as Qr,aZ as vp,a2 as Qd,a1 as wp,aH as Zd,aM as yp,aS as eu,cs as kp,z as tu,l as ru,r as nu,J as rf,av as nf,ci as Sp,ds as jp,n as Rp}from"./app-HTVDUkx-.js";import{b as a,r as yr}from"./dnd-BCFAPC0L.js";import{i as zl,F as Np,O as sf,y as Cp,s as su,Q as au,W as Ro,m as Ep,aj as af,Z as Mp,x as $p,I as Pp,t as Ap,M as Lp,R as No,a6 as of,a7 as Tp,S as ms,n as lf,g as Ip,ap as cf,A as Qi,am as Dp,aa as Zi,ak as Pn,a8 as Fp,a9 as ou,an as _p,ac as iu,r as lu,k as cu,E as el,B as mo,h as Bp,T as Op,z as Up,N as du,Y as Hp,q as zp,U as Wp,o as uu,C as Gp,c as Kp,G as qp,f as Vp}from"./App-BN_iuuvE.js";import{F as wl,a as fu,S as hu,b as df,c as yl}from"./gestureArbiter-DOugsAle.js";import{D as kl,C as oa,L as uf,f as Yp,n as Xp}from"./DiffReview-BYI8gVYo.js";import{T as Jp,L as Lo,M as ff,G as xr}from"./triangle-alert-B-7heGu-.js";import{S as ua}from"./sparkles-BONmCbTi.js";import{C as hf,M as mf}from"./ChangeWalkthroughPanel-DvOSOwLu.js";import{r as pf,s as gf,l as bf,a as mu,h as Sl,u as Qp,g as jl,b as xf}from"./DiffViewer-P1mbq4LM.js";import{u as vf,G as wf}from"./referenceLongPress-C6YZh55M.js";const Zp=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],eg=Br("case-sensitive",Zp);const tg=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],rg=Br("eye-off",tg);const ng=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Rl=Br("eye",ng);const sg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Nl=Br("file-text",sg);const ag=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],og=Br("funnel",ag);const ig=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],lg=Br("image-plus",ig);const cg=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],dg=Br("regex",cg);const ug=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],fg=Br("scan",ug);const hg=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],mg=Br("whole-word",hg),pg=100,gg=5e5,bg=1e4,pu=16384,xg=32,vg=1e5;class cs extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class wg{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>vg)throw new cs("complexity");if(performance.now()-this.startedAt>=pg)throw new cs("timeout")}validateLines(n){if(n.length>bg)throw new cs("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>gg||l.length>pu)throw new cs("size")}validateInline(n){if(this.check(),n.length>pu)throw new cs("size")}nested(n){if(this.check(),this.depth>=xg)throw new cs("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const gu=new RegExp(`(\\\\\\([^)]*\\\\\\)|\\$[^$\\n]+\\$|<br\\s*\\/?>|<\\s*img\\b[^>]*>|<\\s*video\\b[^>]*>[\\s\\S]*?<\\/video\\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\\b[\\s\\S]*?<\\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\\[[^\\]]*\\]\\((?:<[^>]+>|(?:[^\\s()]|\\([^()\\s]*\\))+)(?:\\s+(?:"[^"]*"|'[^']*'|\\([^)]*\\)))?\\)|!?\\[[^\\]]+\\]\\[[^\\]]*\\]|!?\\[[^\\]]+\\]|\\[\\^[^\\]]+\\]|~~[^~]+~~|\\*\\*[^*]+\\*\\*|(?<![\\p{L}\\p{N}_])__[^_]+__(?![\\p{L}\\p{N}_])|\\*[^*\\s][^*]*\\*|(?<![\\p{L}\\p{N}_])_[^_\\s][^_]*_(?![\\p{L}\\p{N}_])|<https?:\\/\\/[^>\\s]+>|<[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+>|https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+|[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+)`,"iyu");function yg(r,n,s){let l=n;for(;r[l]==="`";)l+=1;const d=l-n;let c=l;for(;c<r.length;){s.check();const m=r.indexOf("`",c);if(m<0)return null;for(c=m;r[c]==="`";)c+=1;if(c-m===d)return c}return null}function*kg(r,n){n.validateInline(r);const s=new RegExp(gu.source,gu.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=yg(r,l,n);if(c!==null)yield{index:l,token:r.slice(l,c)},l=c;else for(;r[l]==="`";)l+=1;continue}s.lastIndex=l;const d=s.exec(r);n.check(),d?(yield{index:l,token:d[0]},l=s.lastIndex):l+=(r.codePointAt(l)??0)>65535?2:1}}function bu({children:r,actions:n}){const{t:s}=ht(),[l,d]=a.useState(!1),c=a.useId(),m=a.useRef(null),g=a.useRef(null),h=()=>{d(!1),m.current?.focus({preventScroll:!0})};return a.useLayoutEffect(()=>{if(!l)return;const p=m.current,x=g.current;if(!p||!x)return;const f=window.visualViewport,b=()=>{const j=p.getBoundingClientRect(),T=(f?.offsetLeft??0)+8,D=(f?.offsetTop??0)+8,F=Math.max(0,(f?.width??window.innerWidth)-16),M=D+(f?.height??window.innerHeight)-16,N=Math.min(240,F),A=Math.max(0,j.top-D-6),_=Math.max(0,M-j.bottom-6),q=x.scrollHeight>_&&A>_;Object.assign(x.style,{width:`${N}px`,left:`${Math.max(T,Math.min(j.right-N,T+F-N))}px`,top:`${q?j.top-6:j.bottom+6}px`,maxHeight:`${q?A:_}px`,transform:q?"translateY(-100%)":"none"})};b();const E=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return E?.observe(p),E?.observe(x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),f?.addEventListener("resize",b),f?.addEventListener("scroll",b),()=>{E?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),f?.removeEventListener("resize",b),f?.removeEventListener("scroll",b)}},[l]),a.useEffect(()=>{if(!l)return;g.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const p=x=>{x.target instanceof Node&&!m.current?.contains(x.target)&&!g.current?.contains(x.target)&&d(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[l]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:m,type:"button","aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?c:void 0,onClick:()=>d(p=>!p),onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),d(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${l?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx(Po,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&yr.createPortal(e.jsx("div",{ref:g,id:c,hidden:!l,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":s("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:p=>{if(!p.currentTarget.contains(p.target))return;const x=[...p.currentTarget.querySelectorAll("button:not(:disabled)")],f=x.indexOf(document.activeElement);let b;if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),h();return}if(p.key==="Tab"){h();return}if(p.key==="ArrowDown")b=(f+1)%x.length;else if(p.key==="ArrowUp")b=(f-1+x.length)%x.length;else if(p.key==="Home")b=0;else if(p.key==="End")b=x.length-1;else return;p.preventDefault(),x[b]?.focus({preventScroll:!0})},children:n(h)}),document.body)]})}const tl="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",ds=a.memo(function({active:n,mounted:s=!0,fallback:l=null,children:d}){const c=a.useRef(null);return a.useLayoutEffect(()=>{const m=c.current;if(!m||n)return;const g=new Map,h=f=>{g.has(f)||(g.set(f,f.inert),f.inert=!0)},p=f=>{f instanceof HTMLElement&&f.matches(tl)&&h(f),f.querySelectorAll(tl).forEach(h)};p(m);const x=new MutationObserver(f=>{for(const b of f)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(tl)&&h(b.target):b.addedNodes.forEach(E=>{E instanceof Element&&p(E)})});return x.observe(m,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{x.disconnect();for(const[f,b]of g)f.inert=b}},[n,s]),e.jsx("div",{ref:c,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:n?void 0:{clipPath:"inset(100%)"},"aria-hidden":!n,children:s?typeof d=="function"?d():d:l})},(r,n)=>!r.active&&!n.active&&r.mounted===n.mounted);async function Sg(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function jg({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!r||!n||s||d.current===n)return;const m=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(m)},[r,n,s,l,d,c])}async function Rg(r){if(r.kind==="mermaid"){await Gd(new Blob([r.svg],{type:"image/svg+xml"}),"mermaid.svg");return}const n=new URL(r.src,window.location.href);if(n.origin===window.location.origin&&n.pathname==="/api/terminal/fs/blob"){const c=n.searchParams.get("path");if(!c)throw new Error("Missing image path");await Zu(c);return}const s=await fetch(r.src);if(!s.ok)throw new Error(`HTTP ${s.status}`);const l=await s.blob(),d=decodeURIComponent(n.pathname.split("/").pop()||"")||`image.${{"image/svg+xml":"svg","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[l.type]||"png"}`;await Gd(l,d)}let po=null,xu=!1;function Ng(){return po||(po=Ln(()=>import("./mermaid.core-DG2QUI-L.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw po=null,r})),po}function Cg(r){xu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),xu=!0)}function Eg({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:d}=ht(),[c,m]=a.useState(""),[g,h]=a.useState(0),[p,x]=a.useState(null),[f,b]=a.useState(!1),[E,j]=a.useState(!1),T=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const N=new AbortController;return x(null),b(!1),ef(T,N.signal,!0,"pick_git_ignore_exception").then(A=>{N.signal.aborted||x({directory:c,entries:A.entries,truncated:!!A.truncated})}).catch(()=>{N.signal.aborted||b(!0)}),()=>N.abort()},[T,c,g]);const D=N=>{x(null),b(!1),m(N)},F=p?.directory===c,M=N=>{if(N.length>200){j(!0);return}j(!1),l(N)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":d("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(zl,{size:14})}),e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(""),"aria-label":d("rightSidebar.backToProjectRoot"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(wl,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:T,children:c||"./"})]}),e.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":d("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!F&&!f,children:[f?e.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[e.jsx("p",{role:"alert",className:"text-destructive",children:d("rightSidebar.gitIgnoreExceptionsLoadFailed")}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{b(!1),h(N=>N+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:d("common.retry")})]}):F?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(N=>{const A=c?`${c}/${N.name}`:N.name,_=A+(N.type==="directory"?"/":""),q=n.includes(_)||n.includes(A),S=n.some(B=>B.endsWith("/")&&A.startsWith(B)),o=N.type==="directory"?wl:Np;return e.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[e.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:q||S,disabled:s||S,onChange:()=>M(q?n.filter(B=>B!==_&&B!==A):[...n,_]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),e.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",title:N.name,children:N.name})]}),N.type==="directory"&&e.jsx("button",{type:"button",disabled:s,onClick:()=>D(A),"aria-label":d("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:N.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:e.jsx(hs,{size:15})})]},N.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{size:18})}),F&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:d("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>M([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:d("rightSidebar.gitIgnoreExceptionsClear")})]}),n.length>0&&e.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:n.map(N=>e.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:N,children:N}),e.jsx("button",{type:"button",disabled:s,onClick:()=>M(n.filter(A=>A!==N)),"aria-label":d("rightSidebar.gitIgnoreExceptionsRemove",{path:N}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:13})})]},N))}),E&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function Mg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:d}){const{t:c}=ht(),m=a.useId(),g=a.useRef(null),h=a.useRef(null),p=a.useRef(null),x=a.useRef(null),f=a.useRef(!1),[b,E]=a.useState(!1),[j,T]=a.useState([]),[D,F]=a.useState(!1),[M,N]=a.useState(null),A=V(I=>I.setGitIgnoreExceptions),_=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,x.current=null},q=()=>{_(),!(n||D||!r)&&(T([...V.getState().gitIgnoreExceptions[r]??[]]),N(null),E(!0))},S=()=>{D||E(!1)},o=I=>{_(),f.current=!1,!(I.button!==0||!I.isPrimary||n)&&(I.currentTarget.setPointerCapture(I.pointerId),x.current={x:I.clientX,y:I.clientY},p.current=setTimeout(()=>{f.current=!0,q()},450))};a.useEffect(()=>(E(!1),_(),_),[r]),a.useEffect(()=>{if(b)return h.current?.focus(),()=>g.current?.focus()},[b]);const B=c(s?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",disabled:n||D,"aria-pressed":s,"aria-label":B,"aria-description":c("rightSidebar.gitIgnoreConfigureHint"),title:`${B} · ${c("rightSidebar.gitIgnoreConfigureHint")}`,onClick:I=>{if(f.current&&I.detail!==0){f.current=!1,I.preventDefault();return}d()},onContextMenu:I=>{I.preventDefault(),f.current=!0,b||q()},onPointerDown:o,onPointerMove:I=>{const Y=x.current;Y&&Math.hypot(I.clientX-Y.x,I.clientY-Y.y)>10&&_()},onPointerUp:_,onPointerCancel:_,onLostPointerCapture:_,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${s?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:l?e.jsx(ft,{size:14}):e.jsx(og,{size:14})}),b&&yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:S,children:e.jsxs("form",{ref:h,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:I=>I.stopPropagation(),onKeyDown:I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),S()),I.key==="Tab"){const Y=Array.from(h.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!Y.length){I.preventDefault(),h.current?.focus();return}const H=Y[0],U=Y[Y.length-1];I.shiftKey&&document.activeElement===H&&(I.preventDefault(),U?.focus()),document.activeElement===h.current?(I.preventDefault(),(I.shiftKey?U:H)?.focus()):!I.shiftKey&&document.activeElement===U&&(I.preventDefault(),H?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||D)){if(j.length>200){N(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}F(!0),N(null),A(r,j).then(()=>E(!1)).catch(()=>N(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>F(!1))}},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:`${m}-title`,className:"text-sm font-medium",children:c("rightSidebar.gitIgnoreExceptionsTitle")}),e.jsx("button",{type:"button",disabled:D,onClick:S,"aria-label":c("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:16})})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),e.jsx("p",{id:`${m}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:c("rightSidebar.gitIgnoreExceptionsHint")}),e.jsx("p",{className:"text-xs font-medium",children:c("rightSidebar.gitIgnoreExceptionsPaths")}),r&&e.jsx(Eg,{rootPath:r,paths:j,onChange:T,disabled:D}),M&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:M}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:D,onClick:S,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:c("common.cancel")}),e.jsxs("button",{type:"submit",disabled:D,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[D&&e.jsx(ft,{size:13}),c("common.save")]})]})]})}),document.body)]})}function $g(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,d=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!d)return Promise.resolve(null);const c=r instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),m=document.createElement("canvas");m.width=Math.max(1,Math.round(l*c)),m.height=Math.max(1,Math.round(d*c));const g=m.getContext("2d");if(!g)return Promise.resolve(null);const h=getComputedStyle(document.documentElement);if(g.fillStyle=h.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,m.height),g.drawImage(r,0,0,m.width,m.height),s){const p=Math.max(10,Math.min(16,m.width/35));g.font=`${p}px sans-serif`;const x=[];let f="";for(const b of s.split(" "))f&&g.measureText(`${f} ${b}`).width>m.width-20?(x.push(f),f=b):f=f?`${f} ${b}`:b;f&&x.push(f),g.fillStyle=h.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,x.length*(p+4)+12),g.fillStyle=h.getPropertyValue("--foreground").trim()||"black",x.forEach((b,E)=>g.fillText(b,10,8+p+E*(p+4)))}if(n){const p=n.xPercent*m.width/100,x=n.yPercent*m.height/100,f=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),b=f*1.6;g.strokeStyle=h.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,f/3),g.beginPath(),g.arc(p,x,f,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(p-b,x),g.lineTo(p+b,x),g.moveTo(p,x-b),g.lineTo(p,x+b),g.stroke()}return new Promise(p=>m.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function Pg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
+
`)}function T0(r,n,s){const l=n*Math.PI/360,d=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(r,1e-6)/Math.sin(d)*1.15}async function Ag(r,n,s,l){if(!s?.snapshot)return l.isCurrent()?await l.insert(r,n):!1;const d=new Date().toISOString(),c=new AbortController;let m,g;try{g=await Promise.race([(async()=>{const h=await s.snapshot;if(!(!h||c.signal.aborted||!l.isCurrent()))return l.upload(new File([h],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(h=>{m=setTimeout(()=>{c.abort(),h(void 0)},3e3)})])}catch{}finally{clearTimeout(m),c.abort()}return l.isCurrent()?await l.insert(g?Pg(r,"",d,g):r,n):!1}function Lg(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function vu(r,n){return`${r??""}\0${n}`}function Tg(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=vu(n,s);let d=0,c=0;for(const m of r){const g=[m.filePath,m.newPath,m.oldPath].filter(p=>typeof p=="string"&&p.length>0);(g.some(p=>vu(m.repoRoot,p)===l)||g.some(p=>Lg(p,s)))&&(d+=1)}return{explained:d,stale:c}}function Ig({status:r}){if(!r)return null;const n=r.stale>0&&r.explained===0;if(!(r.explained>0||r.stale>0))return null;const l=n?"AI audit explanation is stale":"AI audit explanation available";return e.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${n?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:l,"aria-label":l,children:n?e.jsx(Jp,{size:10}):e.jsx(ua,{size:10})})}function Cl({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(Ig,{status:n})]})}const yf="termdock:right-sidebar:diff-change-list-mode:v1";function Dg(r){return r==="list"||r==="tree"}function Fg(){return gt(yf,Dg)??"tree"}function _g(r){for(const n of r){const s=n.hunk;if(s.oldPath&&s.newPath&&s.oldPath!==s.newPath)return"renamed";if(s.oldPath===null&&s.newPath)return"added";if(s.oldPath&&s.newPath===null)return"deleted"}return"modified"}function Bg(r){const n=new Map;for(const l of r){const d=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(l),d.additions+=l.hunk.additions,d.deletions+=l.hunk.deletions,l.current&&(d.explained+=1),l.stale&&(d.stale+=1),n.set(l.hunk.filePath,d)}const s=Array.from(n.values()).sort((l,d)=>l.filePath.localeCompare(d.filePath));for(const l of s)l.changeType=_g(l.items);return s}function Og(r){const n=r.filePath.split("/").pop()??r.filePath;return{key:r.key,path:r.filePath,displayName:n,displayDir:r.filePath.includes("/")?r.filePath.slice(0,-n.length-1):"",status:r.changeType,title:r.filePath}}function Ug(r,n){const s=r.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],d=new Set;for(const[c,m]of s.entries()){const g=m.split(`
|
|
4
|
+
`),h=g.findIndex(f=>f.startsWith("@@ "));if(h<0){l.push(...g);continue}c===0&&l.push(...g.slice(0,h));const p=n[c];let x=h;for(;x>=0&&x<g.length;){const f=g.findIndex((F,M)=>M>x&&F.startsWith("@@ ")),b=f>=0?f:g.length,E=g.slice(x,b),j=E[0]??"",T=p?j===p:!0,D=j||p||E.join(`
|
|
5
|
+
`);T&&!d.has(D)&&(l.push(...E),d.add(D)),x=f}}return l.join(`
|
|
6
|
+
`)}function Hg({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Ug(s.items.map(h=>h.hunk.diff||h.current?.diff||h.stale?.diff||""),s.items.map(h=>h.hunk.hunkHeader)),d=s.items.map(h=>h.current??h.stale).filter(h=>!!h).map(h=>({id:h.id,repoRoot:h.repoRoot,filePath:h.filePath,oldPath:h.oldPath,newPath:h.newPath,hunkHeader:h.hunkHeader,hunkIndex:h.hunkIndex,fingerprint:h.fingerprint,diff:h.diff,explanation:h.explanation,summary:h.summary,workspaceRoot:h.workspaceRoot,generatedBy:h.generatedBy,injectedAt:h.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,m=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"",g=s.items[0]?.repoRoot??d[0]?.repoRoot??null;return{key:s.key,path:s.filePath,oldPath:s.items[0]?.hunk.oldPath??void 0,absolutePath:g?`${g}/${s.items[0]?.repositoryPath??s.filePath}`:s.filePath,status:s.changeType,repoRoot:g,displayName:c,displayDir:m,diffOverride:l,oldSourceRef:s.items[0]?.current?.headRef?`${s.items[0].current.baseRef}...${s.items[0].current.headRef}`:s.items[0]?.stale?.headRef?`${s.items[0].stale.baseRef}...${s.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(s.items.flatMap(h=>h.hunk.previewRevert?[[h.hunk.hunkHeader,h.hunk.previewRevert]]:[])),auditRecords:d,onInsertDiffReference:n}})}function zg(r,n,s){const l=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=r.getBoundingClientRect().top+48;let m=null,g=Number.POSITIVE_INFINITY;for(const p of l){const x=p.getBoundingClientRect();if(x.bottom<c)continue;const f=Math.abs(x.top-c);f<g&&(m=p,g=f)}const h=m?.dataset.diffSelectionPath??m?.dataset.diffStreamItem??null;return!h||h===n||s(h),h}function wu({items:r,selectedKey:n,onSelect:s,emptyText:l,mobile:d=!1,backLabel:c="Back",headerTitle:m,headerMeta:g,onClose:h,closeLabel:p="Back",wrap:x=!0,diffViewType:f,inlineMode:b,viewControls:E,onToggleWrap:j,wrapTitle:T,wrapOnLabel:D="Wrap on",wrapOffLabel:F="Wrap off",desktopLayout:M="split",onInsertDiffReference:N,onReferenceCopied:A,renderPathReference:_,insertedReferenceKey:q,copiedReferenceKey:S,onClearAuditRecord:o,onRefresh:B,localOptions:I,onHunkGitAction:Y,error:H,refreshing:U,actionsBusy:R,refreshLabel:z,refreshTitle:Z,walkthroughs:P=[],onWalkthroughNavigate:G,initialDetailScrollTop:J,onDetailScrollPositionChange:ie,scrollToKey:pe,scrollToKeyNonce:Se,externalSwiperRef:ke,onMobileSlideChange:Me}){const{t:Q}=ht(),ge=a.useMemo(()=>Bg(r),[r]),ue=a.useMemo(()=>new Map(ge.map(te=>[te.key,te])),[ge]),[_e,Ue]=a.useState(()=>Fg()),[W,ye]=a.useState(()=>new Set),[we,He]=a.useState({key:null,nonce:0}),Ke=ge.find(te=>te.explained>0||te.stale>0)?.key??ge[0]?.key??null,$=n&&ge.some(te=>te.key===n)?n:Ke,he=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ge.map(Og)}],[ge]),fe=a.useMemo(()=>Hg({groups:ge,onInsertDiffReference:N}),[ge,N]),Ne=a.useRef(Ke),$e=a.useRef(s);Ne.current=Ke,$e.current=s,a.useEffect(()=>{!n&&Ne.current&&$e.current(Ne.current)},[n]);const rt=j?e.jsxs("button",{type:"button",onClick:j,"aria-pressed":x,title:T,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${x?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:x?D:F})]}):null,ce=I?.map(te=>e.jsxs("label",{title:te.disabled?Q("rightSidebar.includeUncommittedCurrentBranchOnly"):te.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:te.checked,disabled:U||R||te.disabled&&!te.checked,onChange:je=>te.onChange(je.target.checked),className:"accent-primary"}),e.jsxs("span",{children:[te.label," · ",Q("rightSidebar.includeUncommitted"),te.disabled&&e.jsx("span",{className:"block text-[10px]",children:Q("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},te.key)),Te=H?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:H}):null,qe=B?e.jsxs("button",{type:"button",onClick:B,disabled:U||R,title:Z??z,"aria-label":Z??z,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx(sf,{size:12,className:U?"animate-spin":""}),z&&e.jsx("span",{children:z})]}):null,Ie=te=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[m&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:m}),g&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:g})]}),h&&e.jsxs("button",{type:"button",onClick:h,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[e.jsx(ca,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[te,ce,qe,E,rt,Te]})]});if(r.length===0){const te=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!m&&!h?te:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ie(null),te]})}const De=j||B?({slideToList:te})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:te,children:[e.jsx(ca,{size:14}),c]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[ce,qe,E,j&&e.jsxs("button",{type:"button",onClick:j,"aria-pressed":x,title:T,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${x?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:x?D:F})]})]}),Te]}):void 0;return e.jsx(kl,{mobile:d,preserveScrollOnUpdate:!!I?.length,desktopLayout:M,backLabel:c,groups:he,selectedKey:$,mode:_e,onModeChange:te=>{Ue(te),te!=="ai"&&At(yf,te)},compact:d,collapsedDirectoryKeys:W,onToggleDirectory:te=>{ye(je=>{const nt=new Set(je);return nt.has(te)?nt.delete(te):nt.add(te),nt})},onSelectFile:te=>{s(te.key),He(je=>({key:te.key,nonce:je.nonce+1}))},renderLeading:te=>{const je=ue.get(te.key);return e.jsx(Cl,{changeStatus:te.status,auditStatus:je,renderChangeBadge:nt=>e.jsx(oa,{status:nt})})},renderTrailing:te=>{const je=ue.get(te.key);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[je&&e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",je.additions," -",je.deletions]}),_?.(te.path,"file")]})},renderDirectoryTrailing:te=>_?.(te,"directory"),renderListHeader:Ie,aiContent:({slideToDetail:te,fullscreen:je,toggleFullscreen:nt})=>P.length>0&&G?e.jsx(hf,{walkthroughs:P,repoRoot:P[0]?.repoRoot,fullscreen:je,onToggleFullscreen:nt,onNavigate:Rt=>{d&&window.requestAnimationFrame(te),G(Rt)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:Q("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:De,externalSwiperRef:ke,onMobileSlideChange:Me,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:J,scrollToKey:pe??we.key,scrollToKeyNonce:pe==null?we.nonce:Se,onDetailScroll:te=>{zg(te,$,s),ie?.(te.scrollTop)},files:fe,activePane:!0,wrap:x,diffViewType:f,inlineMode:b,renderStreamBadge:(te,je)=>{const nt=ue.get(je.key);return e.jsx(Cl,{changeStatus:te,auditStatus:nt,renderChangeBadge:Rt=>e.jsx(oa,{status:Rt})})},onInsertDiffReference:N,onReferenceCopied:A,insertedReferenceKey:q,copiedReferenceKey:S,onClearAuditRecord:o,onHunkGitAction:U?void 0:Y,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function Wg(r){return r.replace(/\/+$/,"")||"/"}function Gg(r){return[...new Set(Array.from(r,Wg))].sort((n,s)=>n.localeCompare(s))}function Kg(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function qg(r){let n=null;return{applicableEvents:r.filter(l=>{const d=l.type==="rescan-required"&&!Kg(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const Vg=1400,Yg=1200,kf=44,Xg=.7;function rl(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function El(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Jg(r){try{const n=window.localStorage.getItem(El(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=kf?s:null}catch{return null}}function yu(r,n){try{n===null?window.localStorage.removeItem(El(r)):window.localStorage.setItem(El(r),String(n))}catch{}}function go(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Qg({value:r,collapsed:n,labels:s,focusRequest:l,insertError:d,autoCollapseAfterSend:c,onChange:m,onCollapsedChange:g,onAutoCollapseAfterSendChange:h,onDisable:p,onClear:x,onInsert:f,onInsertAndSend:b}){const[E,j]=a.useState(null),[T,D]=a.useState(!1),F=a.useRef(!1),M=a.useRef(!0),[N,A]=a.useState(!1),[_,q]=a.useState(()=>Jg(rl())),S=a.useRef(_),o=a.useRef(null),B=a.useRef(null),I=a.useRef(r),Y=a.useRef(null),H=a.useRef(null),U=!!r.trim(),R=r.trim().split(`
|
|
7
|
+
`)[0]??"",z=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>(M.current=!0,()=>{M.current=!1,o.current!==null&&window.clearTimeout(o.current),B.current!==null&&window.clearTimeout(B.current)}),[]),a.useEffect(()=>{let W=!1;const ye=rl();return tf().then(we=>{if(W)return;const He=we.contextDraftHeight?.[ye]??null;yu(ye,He),S.current=He,q(He)}).catch(()=>{}),()=>{W=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const W=Y.current;if(!W)return;go()||W.focus(),W.setSelectionRange(W.value.length,W.value.length),W.scrollTop=W.scrollHeight}},[l]),a.useEffect(()=>{const W=I.current;I.current=r,!(!n||r.length<=W.length)&&(A(!0),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,A(!1)},Yg))},[r,n]),a.useEffect(()=>{if(n)return;const W=Y.current;W&&(W.style.height=_!==null?`${_}px`:"")},[r,n,_]),a.useEffect(()=>{if(n)return;const W=Y.current;!W||document.activeElement===W||(W.scrollTop=W.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||go())return;const W=Y.current;!W||document.activeElement===W||(W.focus(),W.setSelectionRange(W.value.length,W.value.length))},[n]);const Z=a.useRef(null);a.useLayoutEffect(()=>{if(!go())return;const W=window.visualViewport;if(!W)return;const ye=()=>{const we=Z.current;if(!we)return;if(W.height>=window.innerHeight*.75){we.style.transform="";return}const He=we.getBoundingClientRect(),Ke=Math.round(W.height-He.bottom);we.style.transform=Ke!==0?`translateY(${Ke}px)`:""};return ye(),W.addEventListener("resize",ye),W.addEventListener("scroll",ye),()=>{W.removeEventListener("resize",ye),W.removeEventListener("scroll",ye),Z.current&&(Z.current.style.transform="")}},[n]);const P=W=>{j(W),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,j(null)},Vg)},G=W=>{g(!1),go()&&window.requestAnimationFrame(()=>{const ye=Y.current;if(!ye)return;ye.focus();const we=ye.value.length;ye.setSelectionRange(we,we),window.requestAnimationFrame(()=>{ye.setSelectionRange(we,we)})})},J=async(W,ye)=>{if(!(!U||F.current)){F.current=!0,D(!0),j(null);try{await(W==="sent"?b(ye):f(ye))&&M.current&&P(W)}catch{}finally{F.current=!1,M.current&&D(!1)}}},ie=W=>{J("inserted",W.currentTarget)},pe=W=>{J("sent",W.currentTarget)},Se=W=>{if(W.key==="Escape"){W.preventDefault(),g(!0);return}W.nativeEvent.isComposing||W.keyCode===229||W.key!=="Enter"||!W.metaKey&&!W.ctrlKey||(W.preventDefault(),pe(W))},ke=W=>{W.preventDefault()},Me=W=>{W.preventDefault();const ye=Y.current;ye&&(H.current={startY:W.clientY,startHeight:ye.getBoundingClientRect().height},W.currentTarget.setPointerCapture?.(W.pointerId))},Q=W=>{const ye=H.current;if(!ye)return;const we=window.visualViewport?.height??window.innerHeight,He=Math.round(Math.min(Math.max(ye.startHeight+(ye.startY-W.clientY),kf),we*Xg));S.current=He,q(He)},ge=W=>{const ye=rl();yu(ye,W),ra({contextDraftHeight:{[ye]:W}}).catch(()=>{})},ue=()=>{H.current&&(H.current=null,S.current!==null&&ge(S.current))},_e=()=>{S.current=null,q(null),ge(null)},Ue=r.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(r.length)});return n?e.jsx("section",{ref:Z,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:e.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[e.jsxs("button",{type:"button",onClick:()=>G(),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!1,"aria-label":s.expand,title:s.expand,children:[e.jsx(Cp,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:`truncate text-[11px] ${d?"text-destructive":N?"text-primary":U?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(N?s.appended:U?R:s.title)})]}),Ue,e.jsx("button",{type:"button",onClick:pe,disabled:!U||T,"aria-busy":T,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${U?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:T?e.jsx(su,{size:12,className:"animate-spin"}):E==="sent"?e.jsx(Ao,{size:12}):e.jsx(au,{size:12})})]})}):e.jsxs("section",{ref:Z,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[e.jsx("div",{className:"group absolute left-1/2 top-0 z-10 flex h-3 w-16 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize touch-none items-center justify-center",onPointerDown:Me,onPointerMove:Q,onPointerUp:ue,onPointerCancel:ue,onDoubleClick:_e,title:s.resize,"aria-hidden":"true",children:e.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),e.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[e.jsxs("button",{type:"button",onPointerDown:ke,onClick:()=>g(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[e.jsx(da,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:s.title}),Ue]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:ke,onClick:()=>h(!c),className:"inline-flex h-6 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-surface/70 hover:text-foreground","aria-label":s.autoCollapseAfterSend,title:s.autoCollapseAfterSend,children:e.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${c?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${c?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:ke,onClick:p,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:e.jsx(Lt,{size:11})})]}),e.jsx("div",{className:"px-2 pb-2",children:e.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[e.jsx("textarea",{ref:Y,value:r,onChange:W=>m(W.target.value),onKeyDown:Se,placeholder:s.title,rows:1,className:"block min-h-11 w-full resize-none bg-transparent px-2.5 py-2 font-mono text-[12px] leading-relaxed text-foreground placeholder:text-muted-foreground/30 focus:outline-none",autoCapitalize:"sentences",spellCheck:!0,"data-context-draft-input":!0}),e.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[e.jsx("button",{type:"button",onPointerDown:ke,onClick:x,disabled:!U,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(Ro,{size:11})}),d?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:d}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:ke,onClick:ie,disabled:!U||T,"aria-busy":T,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[e.jsx(Ep,{size:11}),e.jsx("span",{children:T?s.pending??s.insert:E==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:ke,onClick:pe,disabled:!U||T,"aria-busy":T,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${z}`,children:[T?e.jsx(su,{size:11,className:"animate-spin"}):E==="sent"?e.jsx(Ao,{size:11}):e.jsx(au,{size:11}),e.jsx("span",{children:E==="sent"?s.sent:s.send})]})]})]})})]})}function Zg(r,n){const s=n.trim();if(!s)return r;if(!r.trim())return s;const l=r.endsWith(`
|
|
8
8
|
|
|
9
9
|
`)?"":r.endsWith(`
|
|
10
10
|
`)?`
|
|
11
11
|
`:`
|
|
12
12
|
|
|
13
|
-
`;return`${r}${l}${s}`}function Xg(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}function Jg(r,n){return{text:Xg(r,n),options:{paste:/[\r\n]/.test(r),submitAfterPaste:n}}}function Qg(r){const[n,s]=a.useState(null),l=a.useRef(null),d=a.useRef(null),c=a.useRef(!0),m=a.useRef(r);m.current=r,a.useEffect(()=>(c.current=!0,()=>{c.current=!1,l.current?.controller.abort()}),[]);const g=a.useCallback(async b=>{if(l.current)return!1;l.current=b,d.current=b;const E=S=>{b.task={...b.task,...S},c.current&&l.current===b&&s(b.task)};E({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const S=await bl(b.task.directory,b.task.retryFiles,b.controller.signal);if(E({uploaded:[...b.task.uploaded,...S.files]}),m.current(b.task.directory),S.files.length!==b.task.retryFiles.length){const T=new Set(S.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw E({retryFiles:S.results?b.task.retryFiles.filter((D,F)=>!T.has(F)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}E({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){E({status:"inserting"});const S=b.task.uploaded[0]?.path;if(!S||!b.isCurrent?.()||!await b.insert(S)||!b.isCurrent?.()||b.controller.signal.aborted)return E({status:"error",error:"reference"}),!1}return E({status:"done"}),!0}catch(S){if(S instanceof Wd&&S.result?.files.length){const T=new Set(S.result.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);E({uploaded:[...b.task.uploaded,...S.result.files],retryFiles:S.result.results?b.task.retryFiles.filter((D,F)=>!T.has(F)):[]}),m.current(b.task.directory)}return E({status:b.controller.signal.aborted?"canceled":"error",error:S instanceof Wd&&S.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":S instanceof Error?S.message:String(S)}),!1}finally{l.current===b&&(l.current=null)}},[]),f=a.useCallback((b,E,S,T)=>E.length?g({task:{kind:S?"image":"files",directory:b,files:E,retryFiles:E,uploaded:[],status:"uploading"},controller:new AbortController,insert:S,isCurrent:T}):Promise.resolve(!1),[g]),p=a.useCallback(()=>{const b=d.current;if(!b||l.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const E={...b,controller:new AbortController,task:{...b.task}};return g(E)},[g]),x=a.useCallback(()=>{const b=l.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),h=a.useCallback(()=>{l.current||(d.current=null,s(null))},[]);return{task:n,start:f,retry:p,cancel:x,dismiss:h,busy:n?.status==="uploading"||n?.status==="inserting"}}function Zg({task:r,labels:n,onCancel:s,onRetry:l,onDismiss:d}){const c=r.status==="uploading"||r.status==="inserting",m=r.error==="reference"?n.referenceRejected:r.error==="UPLOAD_LIMIT"?n.limit:r.status==="error"?`${n.failed}: ${r.error??""}`:n[r.status],g=r.status==="error"&&(r.kind==="image"&&r.uploaded.length>0||r.retryFiles.length>0&&r.retryFiles.length<=50);return e.jsxs("section",{className:"shrink-0 border-t border-border/20 bg-surface/80 px-3 py-2 text-xs","data-sidebar-upload-status":!0,"aria-busy":c,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`min-w-0 flex-1 break-words ${r.status==="error"?"text-destructive":"text-foreground"}`,role:r.status==="error"?"alert":"status",children:m}),r.status==="uploading"&&e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:s,children:n.cancel}),g&&e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:l,children:n.retry}),!c&&e.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-muted-foreground hover:bg-surface-2",onClick:d,"aria-label":n.dismiss,children:"×"})]}),e.jsx("div",{className:"mt-1 truncate text-muted-foreground",title:r.directory,children:r.directory}),e.jsxs("details",{className:"mt-1 min-w-0 text-muted-foreground",children:[e.jsxs("summary",{className:"cursor-pointer truncate",children:[n.files," · ",r.files[0]?.name]}),e.jsxs("ul",{className:"mt-1 max-h-24 overflow-y-auto font-mono text-[10px]",children:[r.files.map((f,p)=>e.jsx("li",{className:"break-all",children:f.name},`${p}:${f.name}`)),r.uploaded.map(f=>e.jsx("li",{className:"break-all text-foreground",children:f.path},f.path))]})]})]})}function eb(r){const n=a.useRef(r),s=a.useRef(0);(n.current.text!==r.text||n.current.sessionId!==r.sessionId||n.current.active!==r.active)&&(s.current+=1),n.current=r;const l=a.useRef(!0),d=a.useRef(!1);return a.useEffect(()=>(l.current=!0,()=>{l.current=!1,s.current+=1}),[]),a.useCallback(async(c,m)=>{if(d.current||!n.current.active)return!1;const g=n.current,f=s.current,{text:p,options:x}=Jg(g.text,c);if(!p)return!1;d.current=!0;try{const h=await sf(p,g.sessionId,()=>l.current&&n.current.active&&n.current.sessionId===g.sessionId,m,x),b=l.current&&f===s.current;return b&&(h?n.current.onAccepted():n.current.onRejected()),h&&b}finally{d.current=!1}},[])}const yu={status:"idle",error:null,result:null};function tb(r,n=!0){const[s,l]=a.useState(yu),d=a.useRef(null);a.useEffect(()=>Km(g=>{const f=d.current;!f||f.targetPeerId===g?.targetPeerId||(d.current=null,f.controller.abort(new DOMException("Download target changed","AbortError")),l({status:"canceled",error:null,result:"canceled"}))}),[]),a.useLayoutEffect(()=>(l(yu),()=>{const g=d.current;d.current=null,g?.controller.abort()}),[r,n]);const c=a.useCallback(()=>{const g=d.current;g&&(d.current=null,g.controller.abort(),l({status:"canceled",error:null,result:"canceled"}))},[]),m=a.useCallback(async()=>{if(!n||!r||d.current)return;const g=new AbortController,f=qm()?.targetPeerId;d.current={controller:g,targetPeerId:f},l({status:"pending",error:null,result:null});try{const p=await Ju(r,g.signal);if(d.current?.controller!==g)return;d.current=null;const x=g.signal.aborted?"canceled":p;l({status:x,error:null,result:x})}catch(p){if(d.current?.controller!==g)return;d.current=null,g.signal.aborted?l({status:"canceled",error:null,result:"canceled"}):l({status:"error",error:p instanceof Error?p.message:String(p),result:null})}},[r,n]);return{...s,start:m,cancel:c}}const Cl="termdock:right-sidebar:html-view-mode-by-file:v1";function rb(r){return r==="preview"||r==="source"}function kf(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(rb)}function Sf(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function wu(r,n){const s=Sf(r,n);return s?gt(Cl,kf)?.[s]??"source":"source"}function nb(r,n,s){const l=Sf(r,n);if(!l)return;const d=gt(Cl,kf)??{};At(Cl,{...d,[l]:s})}function jf(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const sb=1500,ku=256*1024*1024;async function ab(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",d=s.body?.getReader();if(!d){const g=await s.blob();if(g.size>ku)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(g)}const c=[];let m=0;try{for(;;){const{done:g,value:f}=await d.read();if(g)break;if(m+=f.byteLength,m>ku)throw new Error("Media too large for encrypted fallback");c.push(f)}}catch(g){throw await d.cancel().catch(()=>{}),g}return URL.createObjectURL(new Blob(c,{type:l}))}function Ho(r,n){const s=jf(r),[l,d]=a.useState(()=>!!navigator.serviceWorker?.controller),[c,m]=a.useState(void 0),g=a.useRef(n);return g.current=n,a.useEffect(()=>{if(!s||l)return;const f=navigator.serviceWorker,p=()=>d(!!f?.controller);return f?.addEventListener("controllerchange",p),p(),()=>f?.removeEventListener("controllerchange",p)},[s,l]),a.useEffect(()=>{if(!s||l){m(void 0);return}let f=!1,p;const x=new AbortController,h=window.setTimeout(()=>{ab(r,x.signal).then(b=>{if(f){URL.revokeObjectURL(b);return}p=b,m(b)}).catch(()=>{f||x.signal.aborted||g.current?.()})},sb);return()=>{f=!0,window.clearTimeout(h),x.abort(),p&&URL.revokeObjectURL(p)}},[s,l,r]),!s||l?r:c}function tl(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),d=n%60,c=String(l).padStart(2,"0"),m=String(d).padStart(2,"0");return s>0?`${s}:${c}:${m}`:`${c}:${m}`}function ob(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const Zr=2,ib=8,lb=60,go=5,Su=.05,cb=900;function db(r){return!Number.isFinite(r)||r<=0?Zr:Math.min(ib,Zr+Math.floor(r/lb))}const ub=350,fb=6,hb=90;function mb({url:r,onLoadError:n}){const s=Ho(r,n),{t:l}=ht(),d=a.useRef(null),c=a.useRef(null),m=a.useRef(null),g=a.useRef(null),f=a.useRef(!1),p=a.useRef(null),x=a.useRef(null),h=a.useRef(0),b=a.useRef(!1),E=a.useRef(!1),S=a.useRef(!1),T=a.useRef(null),D=a.useRef(null),F=a.useRef(!1),$=a.useRef(1),C=a.useRef(!1),[A,O]=a.useState(0),[q,j]=a.useState(0),[o,_]=a.useState(!1),[I,Y]=a.useState(!1),[H,U]=a.useState(null),[R,z]=a.useState(!1),[Z,P]=a.useState(0),[G,J]=a.useState(!1),[ie,pe]=a.useState({width:0,height:0}),[Se,ke]=a.useState(Zr),[Me,Q]=a.useState(1),[ge,ue]=a.useState(null),_e=a.useRef(Zr),Ue=a.useRef(null),W=a.useCallback(()=>{T.current!==null&&(clearTimeout(T.current),T.current=null)},[]),we=a.useCallback(()=>{W();const B=D.current;if(D.current=null,!F.current)return!1;const ae=m.current;if(ae&&(ae.playbackRate=$.current,B))try{ae.releasePointerCapture?.(B.id)}catch{}return F.current=!1,_e.current=Zr,z(!1),!0},[W]);a.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),x.current!==null&&clearTimeout(x.current),Ue.current!==null&&clearTimeout(Ue.current),W();const B=m.current;B&&F.current&&(B.playbackRate=$.current)},[W]),a.useEffect(()=>{const B=c.current;if(!B||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(([Ce])=>{Ce&&pe({width:Ce.contentRect.width,height:Ce.contentRect.height})});return ae.observe(B),()=>ae.disconnect()},[]),a.useEffect(()=>{const B=()=>J(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",B),()=>document.removeEventListener("fullscreenchange",B)},[]);const ye=a.useCallback((B,ae=!1)=>{const Ce=m.current;if(!Ce)return!1;const et=Number.isFinite(Ce.duration)?Ce.duration:B,xt=Math.min(Math.max(B,0),et);if(j(xt),Math.abs(Ce.currentTime-xt)<1/120)return!1;const kr=Ce.fastSeek;return ae&&typeof kr=="function"?kr.call(Ce,xt):Ce.currentTime=xt,!0},[]),He=a.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const B=m.current;if(!B||!b.current||E.current||B.seeking)return;const ae=S.current;S.current=!1,E.current=ye(h.current,!ae)}))},[ye]),Ke=a.useCallback(B=>{const ae=g.current,Ce=m.current;if(!ae||!Ce)return;const et=ae.getBoundingClientRect(),xt=ob(B,et,Ce.duration);h.current=xt,U(xt),S.current=!1,He(),x.current!==null&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,S.current=!0,He()},hb)},[He]),M=a.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),x.current!==null&&(clearTimeout(x.current),x.current=null),S.current=!1,E.current=!1,ye(h.current)},[ye]),he=a.useCallback(B=>{const ae=m.current;if(!(!ae||!Number.isFinite(ae.duration)||ae.duration<=0)){f.current=!ae.paused,ae.pause(),b.current=!0,Y(!0);try{B.currentTarget.setPointerCapture(B.pointerId)}catch{}Ke(B.clientX)}},[Ke]),fe=a.useCallback(()=>{b.current=!1,M(),Y(!1),U(null);const B=m.current;B&&f.current&&!B.ended&&B.play().catch(()=>{}),f.current=!1},[M]),Ne=a.useCallback(()=>{const B=m.current;if(B){if(C.current){C.current=!1;return}B.paused?B.play().catch(()=>{}):B.pause()}},[]),$e=a.useCallback(B=>{const ae=m.current;if(!ae)return;const Ce=Math.min(1,Math.max(0,Math.round((ae.volume+B)*100)/100));ae.volume=Ce,Ce>0&&(ae.muted=!1),Q(Ce),ue(Ce),Ue.current!==null&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>{Ue.current=null,ue(null)},cb)},[]),rt=a.useCallback(B=>{const ae=m.current;if(ae){if(B.key==="ArrowLeft"){B.preventDefault(),ye(ae.currentTime-(B.shiftKey?go*2:go));return}if(B.key==="ArrowRight"){B.preventDefault(),ye(ae.currentTime+(B.shiftKey?go*2:go));return}if(B.key==="ArrowUp"){B.preventDefault(),$e(Su);return}if(B.key==="ArrowDown"){B.preventDefault(),$e(-Su);return}(B.key===" "||B.key==="Spacebar"||B.key==="k"||B.key==="K")&&(B.preventDefault(),ae.paused?ae.play().catch(()=>{}):ae.pause())}},[ye,$e]),ce=a.useCallback(B=>{const ae=m.current;!ae||ae.paused||B.button!==0||(W(),D.current={id:B.pointerId,x:B.clientX,y:B.clientY},T.current=setTimeout(()=>{T.current=null;const Ce=D.current;if($.current=ae.playbackRate,ae.playbackRate=Zr,_e.current=Zr,ke(Zr),F.current=!0,z(!0),Ce)try{ae.setPointerCapture?.(Ce.id)}catch{}},ub))},[W]),Te=a.useCallback(B=>{const ae=D.current;if(!ae||ae.id!==B.pointerId)return;if(!F.current){Math.hypot(B.clientX-ae.x,B.clientY-ae.y)>fb&&(W(),D.current=null);return}const Ce=db(B.clientX-ae.x);if(Ce===_e.current)return;_e.current=Ce,ke(Ce);const et=m.current;et&&(et.playbackRate=Ce)},[W]),qe=a.useCallback(()=>{we()&&(C.current=!0)},[we]);a.useEffect(()=>(window.addEventListener("pointerup",qe),window.addEventListener("pointercancel",qe),window.addEventListener("blur",qe),()=>{window.removeEventListener("pointerup",qe),window.removeEventListener("pointercancel",qe),window.removeEventListener("blur",qe)}),[qe]);const Ie=a.useCallback(async()=>{const B=d.current,ae=m.current;if(!(!B||!ae))try{document.fullscreenElement===B?await document.exitFullscreen():B.requestFullscreen?await B.requestFullscreen():ae.webkitEnterFullscreen?.()}catch{ae.webkitEnterFullscreen?.()}},[]),De=a.useCallback(()=>P(B=>(B+90)%360),[]),te=a.useCallback(B=>{const ae=m.current;if(!ae||!Number.isFinite(ae.duration))return;const Ce=B.shiftKey?10:5;let et=null;B.key==="ArrowLeft"?et=ae.currentTime-Ce:B.key==="ArrowRight"?et=ae.currentTime+Ce:B.key==="Home"?et=0:B.key==="End"&&(et=ae.duration),et!==null&&(B.preventDefault(),ye(et))},[ye]),je=I&&H!==null?H:q,nt=A>0?Math.min(1,Math.max(0,je/A)):0,lr=(Z===90||Z===270)&&ie.width>0&&ie.height>0?{width:`${ie.height}px`,height:`${ie.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:d,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":Z,children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:m,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${R?` ${du}`:""}`,style:{...lr,transform:`translate(-50%, -50%) rotate(${Z}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...R?{[uu]:""}:{},onClick:Ne,onKeyDown:rt,onVolumeChange:B=>Q(B.currentTarget.volume),onPointerDown:ce,onPointerMove:Te,onPointerUp:qe,onPointerCancel:qe,onContextMenu:B=>{F.current&&B.preventDefault()},onPlay:()=>_(!0),onPause:()=>_(!1),onTimeUpdate:B=>j(B.currentTarget.currentTime),onSeeked:B=>{const ae=B.currentTarget;if(j(ae.currentTime),E.current=!1,!b.current)return;const Ce=ae.requestVideoFrameCallback;typeof Ce=="function"?Ce.call(ae,()=>{b.current&&He()}):requestAnimationFrame(()=>{b.current&&He()})},onLoadedMetadata:B=>O(Number.isFinite(B.currentTarget.duration)?B.currentTarget.duration:0),onDurationChange:B=>O(Number.isFinite(B.currentTarget.duration)?B.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),R&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(Se)})}),ge!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(Rp,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Me*100)})]}),I&&H!==null&&e.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${nt*100}%`},"data-testid":"file-preview-video-scrub-time",children:tl(H)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${du}`,[uu]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Ne,"aria-label":l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:o?e.jsx(Np,{size:14}):e.jsx(Cp,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(A),"aria-valuenow":Math.floor(je),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:he,onPointerMove:B=>{I&&Ke(B.clientX)},onPointerUp:fe,onPointerCancel:fe,onKeyDown:te,children:[e.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),e.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${nt*100}%`}}),e.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${nt*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[tl(je)," / ",tl(A)]}),e.jsx("button",{type:"button",onClick:De,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(nf,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Ie()},"aria-label":l(G?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(G?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:G?e.jsx(Ep,{size:14}):e.jsx(Mp,{size:14})})]})})]})}function pb(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function zo({anchor:r,children:n,disabled:s=!1,onClick:l,title:d}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l(c.currentTarget)},title:d,style:pb(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(Ao,{size:11}),n]})}function gb(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const d=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(d)||d<=0)return null;const c=l.width*d,m=l.height*d,g=s.left+(s.width-c)/2,f=s.top+(s.height-m)/2,p=r-g,x=n-f;if(p<0||x<0||p>c||x>m)return null;const h=p/c*100,b=x/m*100;return{x:l.x+l.width*h/100,y:l.y+l.height*b/100,xPercent:h,yPercent:b}}function bb(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function xb(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const d of Array.from(l.attributes)){const c=d.name.toLowerCase(),m=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&m&&!m.startsWith("#"))&&l.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function vb(r,n,s){let l=null;for(const d of Array.from(r.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const m=Number(d.getAttribute("x")),g=Number(d.getAttribute("y"));if(!Number.isFinite(m)||!Number.isFinite(g))continue;const f=Math.hypot(m-n,g-s);(!l||f<l.distance)&&(l={text:c,distance:f})}return l?.text.slice(0,120)}function Rf({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=a.useRef(null),c=a.useRef(null),[m,g]=a.useState(null),[f,p]=a.useState(null),[x,h]=a.useState(1),[b,E]=a.useState(!1),[S,T]=a.useState(null),D=a.useRef(new Map),F=a.useRef(null),$=a.useRef(!1),C=a.useRef(null),A=a.useRef(x);A.current=x,a.useEffect(()=>{const P=new AbortController;return g(null),p(null),T(null),h(1),fetch(r,{signal:P.signal}).then(G=>G.text()).then(G=>g(xb(G))).catch(G=>{P.signal.aborted||p(G instanceof Error?G.message:"SVG preview failed")}),()=>P.abort()},[r]),a.useEffect(()=>{if(!b)return;const P=G=>{G.key==="Escape"&&E(!1)};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[b]),a.useLayoutEffect(()=>{const P=c.current,G=P?.querySelector("[data-svg-document] > svg");if(!P||!G)return;let J;try{J=G.getBBox()}catch{return}if(!J.width||!J.height)return;const ie=Math.max(2,Math.min(J.width,J.height)*.025);G.setAttribute("viewBox",`${J.x-ie} ${J.y-ie} ${J.width+2*ie} ${J.height+2*ie}`),G.style.width=`${x*100}%`,G.style.height=`${x*100}%`,G.style.minWidth=`${x*100}%`,G.style.minHeight=`${x*100}%`,G.style.display="block"},[m,x]);const O=a.useMemo(()=>S?bb(n,s,S):null,[n,S,s]),q=P=>{if($.current){$.current=!1;return}const G=c.current,J=G?.querySelector("[data-svg-document] > svg"),ie=d.current;if(!G||!J||!ie)return;const pe=J.viewBox.baseVal,Se=gb(P.clientX,P.clientY,J.getBoundingClientRect(),pe);if(!Se)return;const ke=ie.getBoundingClientRect();T({...Se,nearestText:vb(J,Se.x,Se.y),stageX:P.clientX-ke.left,stageY:P.clientY-ke.top,stageXPercent:(P.clientX-ke.left)/ke.width*100,stageYPercent:(P.clientY-ke.top)/ke.height*100})},j=P=>Math.max(1,Math.min(12,P)),o=(P,G)=>{const J=j(G),ie=P.querySelector("[data-svg-document] > svg");if(!ie)return J;const pe=`${J*100}%`;return ie.style.width=pe,ie.style.height=pe,ie.style.minWidth=pe,ie.style.minHeight=pe,A.current=J,J},_=(P,G,J,ie)=>{const pe=A.current,Se=P.getBoundingClientRect(),ke=J-Se.left,Me=ie-Se.top,Q=(P.scrollLeft+ke)/pe,ge=(P.scrollTop+Me)/pe,ue=o(P,G);return P.scrollLeft=Q*ue-ke,P.scrollTop=ge*ue-Me,ue},I=()=>{const P=Array.from(D.current.values());return P.length>=2?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0},Y=P=>{if(P.pointerType==="mouse"&&P.button!==0)return;const G=c.current;G&&(D.current.set(P.pointerId,{x:P.clientX,y:P.clientY}),G.setPointerCapture?.(P.pointerId),D.current.size>=2?(F.current={kind:"pinch",startX:P.clientX,startY:P.clientY,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startDistance:I(),startZoom:A.current,moved:!1},$.current=!0):A.current>1&&(F.current={kind:"pan",startX:P.clientX,startY:P.clientY,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startZoom:A.current,moved:!1}))},H=P=>{if(!D.current.has(P.pointerId))return;D.current.set(P.pointerId,{x:P.clientX,y:P.clientY});const G=c.current,J=F.current;if(!(!G||!J)){if(D.current.size>=2&&J.kind==="pinch"){const ie=I();if(!J.startDistance||!ie)return;const pe=j(J.startZoom*ie/J.startDistance);if(Math.abs(pe-A.current)<.01)return;const Se=Array.from(D.current.values()),ke=(Se[0].x+Se[1].x)/2,Me=(Se[0].y+Se[1].y)/2;J.moved=!0,$.current=!0,_(G,pe,ke,Me),P.preventDefault();return}if(J.kind==="pan"&&D.current.size===1){const ie=P.clientX-J.startX,pe=P.clientY-J.startY;if(!J.moved&&Math.hypot(ie,pe)<6)return;J.moved=!0,$.current=!0,G.scrollLeft=J.startScrollLeft-ie,G.scrollTop=J.startScrollTop-pe,P.preventDefault()}}},U=P=>{const G=c.current,J=F.current,ie=D.current.size===1&&!J?.moved;D.current.delete(P.pointerId);try{G?.releasePointerCapture?.(P.pointerId)}catch{}if(D.current.size===1&&J?.kind==="pinch"){const ke=Array.from(D.current.values())[0];F.current=G?{kind:"pan",startX:ke.x,startY:ke.y,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startZoom:A.current,moved:!1}:null;return}if(D.current.size>0||(F.current=null,J?.kind==="pinch"&&h(A.current),!ie||$.current))return;const pe=Date.now(),Se=C.current;Se&&pe-Se.time<350&&Math.hypot(P.clientX-Se.x,P.clientY-Se.y)<24?(C.current=null,$.current=!0,h(ke=>ke>1?1:2.5)):C.current={time:pe,x:P.clientX,y:P.clientY}},R=P=>{if(!P.ctrlKey&&!P.metaKey)return;const G=c.current;if(!G)return;P.preventDefault();const J=_(G,A.current*Math.exp(-P.deltaY*.01),P.clientX,P.clientY);h(J)},z=()=>{h(1),A.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},Z=e.jsxs("div",{className:b?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:q,onDoubleClick:P=>{P.preventDefault(),h(G=>G>1?1:2.5)},onPointerDown:Y,onPointerMove:H,onPointerUp:U,onPointerCancel:U,onWheel:R,onScroll:()=>T(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:f?e.jsx("div",{className:"p-4 text-sm text-destructive",children:f}):m?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:m}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),S&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:S.stageX,top:S.stageY}}),S&&O&&e.jsx(zo,{anchor:{xPercent:S.stageXPercent,yPercent:S.stageYPercent},title:"引用 SVG 标注",onClick:async P=>{await l?.(O,`svg:${S.x.toFixed(2)}:${S.y.toFixed(2)}`,void 0,P)!==!1&&T(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[x>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:P=>{P.stopPropagation(),z()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(lg,{size:14})}),e.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:P=>{P.stopPropagation(),E(G=>!G)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:b?e.jsx(hf,{size:14}):e.jsx(uf,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:S?`SVG (${S.x.toFixed(2)}, ${S.y.toFixed(2)}) · ${S.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return b?wr.createPortal(Z,document.body):Z}function No(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function yb(r,n,s,l){const d=[`电子标注: ${r}`,`视图: ${No(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(d.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&d.push(`显示层: ${l.layer}`),l.nearest)){const c=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");d.push(`最近对象: ${l.nearest.label}${c?`(${c})`:""}`)}return`"${d.join(" / ")}"`}function wb({blobUrl:r,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:m,interactive3d:g}){const{t:f}=ht(),p=a.useRef(null),x=a.useRef(null),h=a.useRef(null),[b,E]=a.useState(null),[S,T]=a.useState(!1);a.useEffect(()=>(h.current?.abort(),E(null),T(!1),()=>h.current?.abort()),[r,s]);const D=a.useMemo(()=>b?yb(n,s,b,b.inspection):null,[n,b,s]),F=C=>{const A=p.current,O=x.current;if(!A||!O||!O.naturalWidth||!O.naturalHeight)return;const q=A.getBoundingClientRect(),j=O.getBoundingClientRect(),o=Math.min(j.width/O.naturalWidth,j.height/O.naturalHeight),_=O.naturalWidth*o,I=O.naturalHeight*o,Y=j.left+(j.width-_)/2,H=j.top+(j.height-I)/2,U=C.clientX-Y,R=C.clientY-H;if(U<0||R<0||U>_||R>I)return;const z={xPercent:Math.max(0,Math.min(100,U/_*100)),yPercent:Math.max(0,Math.min(100,R/I*100)),stageXPercent:(C.clientX-q.left)/q.width*100,stageYPercent:(C.clientY-q.top)/q.height*100,inspecting:l&&s!=="pcb-3d"};if(E(z),h.current?.abort(),!z.inspecting)return;const Z=new AbortController;h.current=Z,Vm(n,s,z.xPercent,z.yPercent,Z.signal).then(P=>E(G=>G===z?{...G,inspection:P,inspecting:!1}:G)).catch(()=>{Z.signal.aborted||E(P=>P===z?{...P,inspection:{available:!1},inspecting:!1}:P)})},$=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:$.map(C=>e.jsx("button",{type:"button",onClick:()=>d(C),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${C===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:No(C)},C))}),e.jsx("button",{type:"button",onClick:m,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:f("rightSidebar.edaRefresh"),"aria-label":f("rightSidebar.edaRefresh"),children:e.jsx(Ro,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:p,role:"button",tabIndex:0,onClick:F,onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),E({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:f("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:x,src:r,alt:`${n} ${No(s)}`,onLoad:()=>T(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${S?"opacity-100":"opacity-0"}`}),b&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${b.stageXPercent}%`,top:`${b.stageYPercent}%`}}),b&&D&&e.jsx(zo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:f("rightSidebar.edaInsertAnnotation"),onClick:async C=>{await c?.(D,`eda:${s}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:x.current?Ng(x.current,b):Promise.resolve(null)},C)!==!1&&E(null)},children:f("rightSidebar.edaInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:b?b.inspecting?f("rightSidebar.edaInspecting"):b.inspection?.available?f("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??f("rightSidebar.edaNoNearbyObject")}):f("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):f("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Rf,{blobUrl:r,filePath:n,viewLabel:No(s),onInsertAnnotation:c})})]})}function kb(r){const n=[];let s=[],l="",d=!1;for(let c=0;c<r.length;c+=1){const m=r[c];d?m==='"'&&r[c+1]==='"'?(l+='"',c+=1):m==='"'?d=!1:l+=m:m==='"'?d=!0:m===","?(s.push(l),l=""):m===`
|
|
14
|
-
`?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=m}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function
|
|
13
|
+
`;return`${r}${l}${s}`}function eb(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}function tb(r,n){return{text:eb(r,n),options:{paste:/[\r\n]/.test(r),submitAfterPaste:n}}}function rb(r){const[n,s]=a.useState(null),l=a.useRef(null),d=a.useRef(null),c=a.useRef(!0),m=a.useRef(r);m.current=r,a.useEffect(()=>(c.current=!0,()=>{c.current=!1,l.current?.controller.abort()}),[]);const g=a.useCallback(async b=>{if(l.current)return!1;l.current=b,d.current=b;const E=j=>{b.task={...b.task,...j},c.current&&l.current===b&&s(b.task)};E({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const j=await vl(b.task.directory,b.task.retryFiles,b.controller.signal);if(E({uploaded:[...b.task.uploaded,...j.files]}),m.current(b.task.directory),j.files.length!==b.task.retryFiles.length){const T=new Set(j.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw E({retryFiles:j.results?b.task.retryFiles.filter((D,F)=>!T.has(F)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}E({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){E({status:"inserting"});const j=b.task.uploaded[0]?.path;if(!j||!b.isCurrent?.()||!await b.insert(j)||!b.isCurrent?.()||b.controller.signal.aborted)return E({status:"error",error:"reference"}),!1}return E({status:"done"}),!0}catch(j){if(j instanceof Kd&&j.result?.files.length){const T=new Set(j.result.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);E({uploaded:[...b.task.uploaded,...j.result.files],retryFiles:j.result.results?b.task.retryFiles.filter((D,F)=>!T.has(F)):[]}),m.current(b.task.directory)}return E({status:b.controller.signal.aborted?"canceled":"error",error:j instanceof Kd&&j.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":j instanceof Error?j.message:String(j)}),!1}finally{l.current===b&&(l.current=null)}},[]),h=a.useCallback((b,E,j,T)=>E.length?g({task:{kind:j?"image":"files",directory:b,files:E,retryFiles:E,uploaded:[],status:"uploading"},controller:new AbortController,insert:j,isCurrent:T}):Promise.resolve(!1),[g]),p=a.useCallback(()=>{const b=d.current;if(!b||l.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const E={...b,controller:new AbortController,task:{...b.task}};return g(E)},[g]),x=a.useCallback(()=>{const b=l.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),f=a.useCallback(()=>{l.current||(d.current=null,s(null))},[]);return{task:n,start:h,retry:p,cancel:x,dismiss:f,busy:n?.status==="uploading"||n?.status==="inserting"}}function nb({task:r,labels:n,onCancel:s,onRetry:l,onDismiss:d}){const c=r.status==="uploading"||r.status==="inserting",m=r.error==="reference"?n.referenceRejected:r.error==="UPLOAD_LIMIT"?n.limit:r.status==="error"?`${n.failed}: ${r.error??""}`:n[r.status],g=r.status==="error"&&(r.kind==="image"&&r.uploaded.length>0||r.retryFiles.length>0&&r.retryFiles.length<=50);return e.jsxs("section",{className:"shrink-0 border-t border-border/20 bg-surface/80 px-3 py-2 text-xs","data-sidebar-upload-status":!0,"aria-busy":c,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`min-w-0 flex-1 break-words ${r.status==="error"?"text-destructive":"text-foreground"}`,role:r.status==="error"?"alert":"status",children:m}),r.status==="uploading"&&e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:s,children:n.cancel}),g&&e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:l,children:n.retry}),!c&&e.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-muted-foreground hover:bg-surface-2",onClick:d,"aria-label":n.dismiss,children:"×"})]}),e.jsx("div",{className:"mt-1 truncate text-muted-foreground",title:r.directory,children:r.directory}),e.jsxs("details",{className:"mt-1 min-w-0 text-muted-foreground",children:[e.jsxs("summary",{className:"cursor-pointer truncate",children:[n.files," · ",r.files[0]?.name]}),e.jsxs("ul",{className:"mt-1 max-h-24 overflow-y-auto font-mono text-[10px]",children:[r.files.map((h,p)=>e.jsx("li",{className:"break-all",children:h.name},`${p}:${h.name}`)),r.uploaded.map(h=>e.jsx("li",{className:"break-all text-foreground",children:h.path},h.path))]})]})]})}function sb(r){const n=a.useRef(r),s=a.useRef(0);(n.current.text!==r.text||n.current.sessionId!==r.sessionId||n.current.active!==r.active)&&(s.current+=1),n.current=r;const l=a.useRef(!0),d=a.useRef(!1);return a.useEffect(()=>(l.current=!0,()=>{l.current=!1,s.current+=1}),[]),a.useCallback(async(c,m)=>{if(d.current||!n.current.active)return!1;const g=n.current,h=s.current,{text:p,options:x}=tb(g.text,c);if(!p)return!1;d.current=!0;try{const f=await af(p,g.sessionId,()=>l.current&&n.current.active&&n.current.sessionId===g.sessionId,m,x),b=l.current&&h===s.current;return b&&(f?n.current.onAccepted():n.current.onRejected()),f&&b}finally{d.current=!1}},[])}const ku={status:"idle",error:null,result:null};function ab(r,n=!0){const[s,l]=a.useState(ku),d=a.useRef(null);a.useEffect(()=>Xm(g=>{const h=d.current;!h||h.targetPeerId===g?.targetPeerId||(d.current=null,h.controller.abort(new DOMException("Download target changed","AbortError")),l({status:"canceled",error:null,result:"canceled"}))}),[]),a.useLayoutEffect(()=>(l(ku),()=>{const g=d.current;d.current=null,g?.controller.abort()}),[r,n]);const c=a.useCallback(()=>{const g=d.current;g&&(d.current=null,g.controller.abort(),l({status:"canceled",error:null,result:"canceled"}))},[]),m=a.useCallback(async()=>{if(!n||!r||d.current)return;const g=new AbortController,h=Jm()?.targetPeerId;d.current={controller:g,targetPeerId:h},l({status:"pending",error:null,result:null});try{const p=await Zu(r,g.signal);if(d.current?.controller!==g)return;d.current=null;const x=g.signal.aborted?"canceled":p;l({status:x,error:null,result:x})}catch(p){if(d.current?.controller!==g)return;d.current=null,g.signal.aborted?l({status:"canceled",error:null,result:"canceled"}):l({status:"error",error:p instanceof Error?p.message:String(p),result:null})}},[r,n]);return{...s,start:m,cancel:c}}const Ml="termdock:right-sidebar:html-view-mode-by-file:v1";function ob(r){return r==="preview"||r==="source"}function Sf(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(ob)}function jf(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Su(r,n){const s=jf(r,n);return s?gt(Ml,Sf)?.[s]??"source":"source"}function ib(r,n,s){const l=jf(r,n);if(!l)return;const d=gt(Ml,Sf)??{};At(Ml,{...d,[l]:s})}function Rf(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const lb=1500,ju=256*1024*1024;async function cb(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",d=s.body?.getReader();if(!d){const g=await s.blob();if(g.size>ju)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(g)}const c=[];let m=0;try{for(;;){const{done:g,value:h}=await d.read();if(g)break;if(m+=h.byteLength,m>ju)throw new Error("Media too large for encrypted fallback");c.push(h)}}catch(g){throw await d.cancel().catch(()=>{}),g}return URL.createObjectURL(new Blob(c,{type:l}))}function fa(r,n){const s=Rf(r),[l,d]=a.useState(()=>!!navigator.serviceWorker?.controller),[c,m]=a.useState(void 0),g=a.useRef(n);return g.current=n,a.useEffect(()=>{if(!s||l)return;const h=navigator.serviceWorker,p=()=>d(!!h?.controller);return h?.addEventListener("controllerchange",p),p(),()=>h?.removeEventListener("controllerchange",p)},[s,l]),a.useEffect(()=>{if(!s||l){m(void 0);return}let h=!1,p;const x=new AbortController,f=window.setTimeout(()=>{cb(r,x.signal).then(b=>{if(h){URL.revokeObjectURL(b);return}p=b,m(b)}).catch(()=>{h||x.signal.aborted||g.current?.()})},lb);return()=>{h=!0,window.clearTimeout(f),x.abort(),p&&URL.revokeObjectURL(p)}},[s,l,r]),!s||l?r:c}function nl(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),d=n%60,c=String(l).padStart(2,"0"),m=String(d).padStart(2,"0");return s>0?`${s}:${c}:${m}`:`${c}:${m}`}function db(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const Zr=2,ub=8,fb=60,bo=5,Ru=.05,hb=900;function mb(r){return!Number.isFinite(r)||r<=0?Zr:Math.min(ub,Zr+Math.floor(r/fb))}const pb=350,gb=6,bb=90;function xb({url:r,onLoadError:n}){const s=fa(r,n),{t:l}=ht(),d=a.useRef(null),c=a.useRef(null),m=a.useRef(null),g=a.useRef(null),h=a.useRef(!1),p=a.useRef(null),x=a.useRef(null),f=a.useRef(0),b=a.useRef(!1),E=a.useRef(!1),j=a.useRef(!1),T=a.useRef(null),D=a.useRef(null),F=a.useRef(!1),M=a.useRef(1),N=a.useRef(!1),[A,_]=a.useState(0),[q,S]=a.useState(0),[o,B]=a.useState(!1),[I,Y]=a.useState(!1),[H,U]=a.useState(null),[R,z]=a.useState(!1),[Z,P]=a.useState(0),[G,J]=a.useState(!1),[ie,pe]=a.useState({width:0,height:0}),[Se,ke]=a.useState(Zr),[Me,Q]=a.useState(1),[ge,ue]=a.useState(null),_e=a.useRef(Zr),Ue=a.useRef(null),W=a.useCallback(()=>{T.current!==null&&(clearTimeout(T.current),T.current=null)},[]),ye=a.useCallback(()=>{W();const O=D.current;if(D.current=null,!F.current)return!1;const ae=m.current;if(ae&&(ae.playbackRate=M.current,O))try{ae.releasePointerCapture?.(O.id)}catch{}return F.current=!1,_e.current=Zr,z(!1),!0},[W]);a.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),x.current!==null&&clearTimeout(x.current),Ue.current!==null&&clearTimeout(Ue.current),W();const O=m.current;O&&F.current&&(O.playbackRate=M.current)},[W]),a.useEffect(()=>{const O=c.current;if(!O||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(([Ce])=>{Ce&&pe({width:Ce.contentRect.width,height:Ce.contentRect.height})});return ae.observe(O),()=>ae.disconnect()},[]),a.useEffect(()=>{const O=()=>J(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",O),()=>document.removeEventListener("fullscreenchange",O)},[]);const we=a.useCallback((O,ae=!1)=>{const Ce=m.current;if(!Ce)return!1;const et=Number.isFinite(Ce.duration)?Ce.duration:O,xt=Math.min(Math.max(O,0),et);if(S(xt),Math.abs(Ce.currentTime-xt)<1/120)return!1;const kr=Ce.fastSeek;return ae&&typeof kr=="function"?kr.call(Ce,xt):Ce.currentTime=xt,!0},[]),He=a.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const O=m.current;if(!O||!b.current||E.current||O.seeking)return;const ae=j.current;j.current=!1,E.current=we(f.current,!ae)}))},[we]),Ke=a.useCallback(O=>{const ae=g.current,Ce=m.current;if(!ae||!Ce)return;const et=ae.getBoundingClientRect(),xt=db(O,et,Ce.duration);f.current=xt,U(xt),j.current=!1,He(),x.current!==null&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,j.current=!0,He()},bb)},[He]),$=a.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),x.current!==null&&(clearTimeout(x.current),x.current=null),j.current=!1,E.current=!1,we(f.current)},[we]),he=a.useCallback(O=>{const ae=m.current;if(!(!ae||!Number.isFinite(ae.duration)||ae.duration<=0)){h.current=!ae.paused,ae.pause(),b.current=!0,Y(!0);try{O.currentTarget.setPointerCapture(O.pointerId)}catch{}Ke(O.clientX)}},[Ke]),fe=a.useCallback(()=>{b.current=!1,$(),Y(!1),U(null);const O=m.current;O&&h.current&&!O.ended&&O.play().catch(()=>{}),h.current=!1},[$]),Ne=a.useCallback(()=>{const O=m.current;if(O){if(N.current){N.current=!1;return}O.paused?O.play().catch(()=>{}):O.pause()}},[]),$e=a.useCallback(O=>{const ae=m.current;if(!ae)return;const Ce=Math.min(1,Math.max(0,Math.round((ae.volume+O)*100)/100));ae.volume=Ce,Ce>0&&(ae.muted=!1),Q(Ce),ue(Ce),Ue.current!==null&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>{Ue.current=null,ue(null)},hb)},[]),rt=a.useCallback(O=>{const ae=m.current;if(ae){if(O.key==="ArrowLeft"){O.preventDefault(),we(ae.currentTime-(O.shiftKey?bo*2:bo));return}if(O.key==="ArrowRight"){O.preventDefault(),we(ae.currentTime+(O.shiftKey?bo*2:bo));return}if(O.key==="ArrowUp"){O.preventDefault(),$e(Ru);return}if(O.key==="ArrowDown"){O.preventDefault(),$e(-Ru);return}(O.key===" "||O.key==="Spacebar"||O.key==="k"||O.key==="K")&&(O.preventDefault(),ae.paused?ae.play().catch(()=>{}):ae.pause())}},[we,$e]),ce=a.useCallback(O=>{const ae=m.current;!ae||ae.paused||O.button!==0||(W(),D.current={id:O.pointerId,x:O.clientX,y:O.clientY},T.current=setTimeout(()=>{T.current=null;const Ce=D.current;if(M.current=ae.playbackRate,ae.playbackRate=Zr,_e.current=Zr,ke(Zr),F.current=!0,z(!0),Ce)try{ae.setPointerCapture?.(Ce.id)}catch{}},pb))},[W]),Te=a.useCallback(O=>{const ae=D.current;if(!ae||ae.id!==O.pointerId)return;if(!F.current){Math.hypot(O.clientX-ae.x,O.clientY-ae.y)>gb&&(W(),D.current=null);return}const Ce=mb(O.clientX-ae.x);if(Ce===_e.current)return;_e.current=Ce,ke(Ce);const et=m.current;et&&(et.playbackRate=Ce)},[W]),qe=a.useCallback(()=>{ye()&&(N.current=!0)},[ye]);a.useEffect(()=>(window.addEventListener("pointerup",qe),window.addEventListener("pointercancel",qe),window.addEventListener("blur",qe),()=>{window.removeEventListener("pointerup",qe),window.removeEventListener("pointercancel",qe),window.removeEventListener("blur",qe)}),[qe]);const Ie=a.useCallback(async()=>{const O=d.current,ae=m.current;if(!(!O||!ae))try{document.fullscreenElement===O?await document.exitFullscreen():O.requestFullscreen?await O.requestFullscreen():ae.webkitEnterFullscreen?.()}catch{ae.webkitEnterFullscreen?.()}},[]),De=a.useCallback(()=>P(O=>(O+90)%360),[]),te=a.useCallback(O=>{const ae=m.current;if(!ae||!Number.isFinite(ae.duration))return;const Ce=O.shiftKey?10:5;let et=null;O.key==="ArrowLeft"?et=ae.currentTime-Ce:O.key==="ArrowRight"?et=ae.currentTime+Ce:O.key==="Home"?et=0:O.key==="End"&&(et=ae.duration),et!==null&&(O.preventDefault(),we(et))},[we]),je=I&&H!==null?H:q,nt=A>0?Math.min(1,Math.max(0,je/A)):0,lr=(Z===90||Z===270)&&ie.width>0&&ie.height>0?{width:`${ie.height}px`,height:`${ie.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:d,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":Z,children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:m,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${R?` ${fu}`:""}`,style:{...lr,transform:`translate(-50%, -50%) rotate(${Z}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...R?{[hu]:""}:{},onClick:Ne,onKeyDown:rt,onVolumeChange:O=>Q(O.currentTarget.volume),onPointerDown:ce,onPointerMove:Te,onPointerUp:qe,onPointerCancel:qe,onContextMenu:O=>{F.current&&O.preventDefault()},onPlay:()=>B(!0),onPause:()=>B(!1),onTimeUpdate:O=>S(O.currentTarget.currentTime),onSeeked:O=>{const ae=O.currentTarget;if(S(ae.currentTime),E.current=!1,!b.current)return;const Ce=ae.requestVideoFrameCallback;typeof Ce=="function"?Ce.call(ae,()=>{b.current&&He()}):requestAnimationFrame(()=>{b.current&&He()})},onLoadedMetadata:O=>_(Number.isFinite(O.currentTarget.duration)?O.currentTarget.duration:0),onDurationChange:O=>_(Number.isFinite(O.currentTarget.duration)?O.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),R&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(Se)})}),ge!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(Mp,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Me*100)})]}),I&&H!==null&&e.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${nt*100}%`},"data-testid":"file-preview-video-scrub-time",children:nl(H)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${fu}`,[hu]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Ne,"aria-label":l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:o?e.jsx($p,{size:14}):e.jsx(Pp,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(A),"aria-valuenow":Math.floor(je),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:he,onPointerMove:O=>{I&&Ke(O.clientX)},onPointerUp:fe,onPointerCancel:fe,onKeyDown:te,children:[e.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),e.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${nt*100}%`}}),e.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${nt*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[nl(je)," / ",nl(A)]}),e.jsx("button",{type:"button",onClick:De,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(sf,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Ie()},"aria-label":l(G?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(G?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:G?e.jsx(Ap,{size:14}):e.jsx(Lp,{size:14})})]})})]})}function vb(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function Wo({anchor:r,children:n,disabled:s=!1,onClick:l,title:d}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l(c.currentTarget)},title:d,style:vb(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(Lo,{size:11}),n]})}function wb(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const d=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(d)||d<=0)return null;const c=l.width*d,m=l.height*d,g=s.left+(s.width-c)/2,h=s.top+(s.height-m)/2,p=r-g,x=n-h;if(p<0||x<0||p>c||x>m)return null;const f=p/c*100,b=x/m*100;return{x:l.x+l.width*f/100,y:l.y+l.height*b/100,xPercent:f,yPercent:b}}function yb(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function kb(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const d of Array.from(l.attributes)){const c=d.name.toLowerCase(),m=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&m&&!m.startsWith("#"))&&l.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function Sb(r,n,s){let l=null;for(const d of Array.from(r.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const m=Number(d.getAttribute("x")),g=Number(d.getAttribute("y"));if(!Number.isFinite(m)||!Number.isFinite(g))continue;const h=Math.hypot(m-n,g-s);(!l||h<l.distance)&&(l={text:c,distance:h})}return l?.text.slice(0,120)}function Nf({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=a.useRef(null),c=a.useRef(null),[m,g]=a.useState(null),[h,p]=a.useState(null),[x,f]=a.useState(1),[b,E]=a.useState(!1),[j,T]=a.useState(null),D=a.useRef(new Map),F=a.useRef(null),M=a.useRef(!1),N=a.useRef(null),A=a.useRef(x);A.current=x,a.useEffect(()=>{const P=new AbortController;return g(null),p(null),T(null),f(1),fetch(r,{signal:P.signal}).then(G=>G.text()).then(G=>g(kb(G))).catch(G=>{P.signal.aborted||p(G instanceof Error?G.message:"SVG preview failed")}),()=>P.abort()},[r]),a.useEffect(()=>{if(!b)return;const P=G=>{G.key==="Escape"&&E(!1)};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[b]),a.useLayoutEffect(()=>{const P=c.current,G=P?.querySelector("[data-svg-document] > svg");if(!P||!G)return;let J;try{J=G.getBBox()}catch{return}if(!J.width||!J.height)return;const ie=Math.max(2,Math.min(J.width,J.height)*.025);G.setAttribute("viewBox",`${J.x-ie} ${J.y-ie} ${J.width+2*ie} ${J.height+2*ie}`),G.style.width=`${x*100}%`,G.style.height=`${x*100}%`,G.style.minWidth=`${x*100}%`,G.style.minHeight=`${x*100}%`,G.style.display="block"},[m,x]);const _=a.useMemo(()=>j?yb(n,s,j):null,[n,j,s]),q=P=>{if(M.current){M.current=!1;return}const G=c.current,J=G?.querySelector("[data-svg-document] > svg"),ie=d.current;if(!G||!J||!ie)return;const pe=J.viewBox.baseVal,Se=wb(P.clientX,P.clientY,J.getBoundingClientRect(),pe);if(!Se)return;const ke=ie.getBoundingClientRect();T({...Se,nearestText:Sb(J,Se.x,Se.y),stageX:P.clientX-ke.left,stageY:P.clientY-ke.top,stageXPercent:(P.clientX-ke.left)/ke.width*100,stageYPercent:(P.clientY-ke.top)/ke.height*100})},S=P=>Math.max(1,Math.min(12,P)),o=(P,G)=>{const J=S(G),ie=P.querySelector("[data-svg-document] > svg");if(!ie)return J;const pe=`${J*100}%`;return ie.style.width=pe,ie.style.height=pe,ie.style.minWidth=pe,ie.style.minHeight=pe,A.current=J,J},B=(P,G,J,ie)=>{const pe=A.current,Se=P.getBoundingClientRect(),ke=J-Se.left,Me=ie-Se.top,Q=(P.scrollLeft+ke)/pe,ge=(P.scrollTop+Me)/pe,ue=o(P,G);return P.scrollLeft=Q*ue-ke,P.scrollTop=ge*ue-Me,ue},I=()=>{const P=Array.from(D.current.values());return P.length>=2?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0},Y=P=>{if(P.pointerType==="mouse"&&P.button!==0)return;const G=c.current;G&&(D.current.set(P.pointerId,{x:P.clientX,y:P.clientY}),G.setPointerCapture?.(P.pointerId),D.current.size>=2?(F.current={kind:"pinch",startX:P.clientX,startY:P.clientY,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startDistance:I(),startZoom:A.current,moved:!1},M.current=!0):A.current>1&&(F.current={kind:"pan",startX:P.clientX,startY:P.clientY,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startZoom:A.current,moved:!1}))},H=P=>{if(!D.current.has(P.pointerId))return;D.current.set(P.pointerId,{x:P.clientX,y:P.clientY});const G=c.current,J=F.current;if(!(!G||!J)){if(D.current.size>=2&&J.kind==="pinch"){const ie=I();if(!J.startDistance||!ie)return;const pe=S(J.startZoom*ie/J.startDistance);if(Math.abs(pe-A.current)<.01)return;const Se=Array.from(D.current.values()),ke=(Se[0].x+Se[1].x)/2,Me=(Se[0].y+Se[1].y)/2;J.moved=!0,M.current=!0,B(G,pe,ke,Me),P.preventDefault();return}if(J.kind==="pan"&&D.current.size===1){const ie=P.clientX-J.startX,pe=P.clientY-J.startY;if(!J.moved&&Math.hypot(ie,pe)<6)return;J.moved=!0,M.current=!0,G.scrollLeft=J.startScrollLeft-ie,G.scrollTop=J.startScrollTop-pe,P.preventDefault()}}},U=P=>{const G=c.current,J=F.current,ie=D.current.size===1&&!J?.moved;D.current.delete(P.pointerId);try{G?.releasePointerCapture?.(P.pointerId)}catch{}if(D.current.size===1&&J?.kind==="pinch"){const ke=Array.from(D.current.values())[0];F.current=G?{kind:"pan",startX:ke.x,startY:ke.y,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startZoom:A.current,moved:!1}:null;return}if(D.current.size>0||(F.current=null,J?.kind==="pinch"&&f(A.current),!ie||M.current))return;const pe=Date.now(),Se=N.current;Se&&pe-Se.time<350&&Math.hypot(P.clientX-Se.x,P.clientY-Se.y)<24?(N.current=null,M.current=!0,f(ke=>ke>1?1:2.5)):N.current={time:pe,x:P.clientX,y:P.clientY}},R=P=>{if(!P.ctrlKey&&!P.metaKey)return;const G=c.current;if(!G)return;P.preventDefault();const J=B(G,A.current*Math.exp(-P.deltaY*.01),P.clientX,P.clientY);f(J)},z=()=>{f(1),A.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},Z=e.jsxs("div",{className:b?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:q,onDoubleClick:P=>{P.preventDefault(),f(G=>G>1?1:2.5)},onPointerDown:Y,onPointerMove:H,onPointerUp:U,onPointerCancel:U,onWheel:R,onScroll:()=>T(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:h?e.jsx("div",{className:"p-4 text-sm text-destructive",children:h}):m?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:m}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),j&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:j.stageX,top:j.stageY}}),j&&_&&e.jsx(Wo,{anchor:{xPercent:j.stageXPercent,yPercent:j.stageYPercent},title:"引用 SVG 标注",onClick:async P=>{await l?.(_,`svg:${j.x.toFixed(2)}:${j.y.toFixed(2)}`,void 0,P)!==!1&&T(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[x>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:P=>{P.stopPropagation(),z()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(fg,{size:14})}),e.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:P=>{P.stopPropagation(),E(G=>!G)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:b?e.jsx(mf,{size:14}):e.jsx(ff,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:j?`SVG (${j.x.toFixed(2)}, ${j.y.toFixed(2)}) · ${j.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return b?yr.createPortal(Z,document.body):Z}function Co(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function jb(r,n,s,l){const d=[`电子标注: ${r}`,`视图: ${Co(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(d.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&d.push(`显示层: ${l.layer}`),l.nearest)){const c=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");d.push(`最近对象: ${l.nearest.label}${c?`(${c})`:""}`)}return`"${d.join(" / ")}"`}function Rb({blobUrl:r,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:m,interactive3d:g}){const{t:h}=ht(),p=a.useRef(null),x=a.useRef(null),f=a.useRef(null),[b,E]=a.useState(null),[j,T]=a.useState(!1);a.useEffect(()=>(f.current?.abort(),E(null),T(!1),()=>f.current?.abort()),[r,s]);const D=a.useMemo(()=>b?jb(n,s,b,b.inspection):null,[n,b,s]),F=N=>{const A=p.current,_=x.current;if(!A||!_||!_.naturalWidth||!_.naturalHeight)return;const q=A.getBoundingClientRect(),S=_.getBoundingClientRect(),o=Math.min(S.width/_.naturalWidth,S.height/_.naturalHeight),B=_.naturalWidth*o,I=_.naturalHeight*o,Y=S.left+(S.width-B)/2,H=S.top+(S.height-I)/2,U=N.clientX-Y,R=N.clientY-H;if(U<0||R<0||U>B||R>I)return;const z={xPercent:Math.max(0,Math.min(100,U/B*100)),yPercent:Math.max(0,Math.min(100,R/I*100)),stageXPercent:(N.clientX-q.left)/q.width*100,stageYPercent:(N.clientY-q.top)/q.height*100,inspecting:l&&s!=="pcb-3d"};if(E(z),f.current?.abort(),!z.inspecting)return;const Z=new AbortController;f.current=Z,Qm(n,s,z.xPercent,z.yPercent,Z.signal).then(P=>E(G=>G===z?{...G,inspection:P,inspecting:!1}:G)).catch(()=>{Z.signal.aborted||E(P=>P===z?{...P,inspection:{available:!1},inspecting:!1}:P)})},M=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:M.map(N=>e.jsx("button",{type:"button",onClick:()=>d(N),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${N===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Co(N)},N))}),e.jsx("button",{type:"button",onClick:m,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:h("rightSidebar.edaRefresh"),"aria-label":h("rightSidebar.edaRefresh"),children:e.jsx(No,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:p,role:"button",tabIndex:0,onClick:F,onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),E({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:h("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:x,src:r,alt:`${n} ${Co(s)}`,onLoad:()=>T(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${j?"opacity-100":"opacity-0"}`}),b&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${b.stageXPercent}%`,top:`${b.stageYPercent}%`}}),b&&D&&e.jsx(Wo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:h("rightSidebar.edaInsertAnnotation"),onClick:async N=>{await c?.(D,`eda:${s}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:x.current?$g(x.current,b):Promise.resolve(null)},N)!==!1&&E(null)},children:h("rightSidebar.edaInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:b?b.inspecting?h("rightSidebar.edaInspecting"):b.inspection?.available?h("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??h("rightSidebar.edaNoNearbyObject")}):h("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):h("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Nf,{blobUrl:r,filePath:n,viewLabel:Co(s),onInsertAnnotation:c})})]})}function Nb(r){const n=[];let s=[],l="",d=!1;for(let c=0;c<r.length;c+=1){const m=r[c];d?m==='"'&&r[c+1]==='"'?(l+='"',c+=1):m==='"'?d=!1:l+=m:m==='"'?d=!0:m===","?(s.push(l),l=""):m===`
|
|
14
|
+
`?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=m}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function Cb(r,n,s,l,d){const c=n[d]||`第${d+1}列`,m=s[d]??"",g=n.map((h,p)=>`${h||`第${p+1}列`}=${s[p]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${l+1} / 列: ${c} / 值: ${m} / 记录: ${g}"`}function Eb({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=ht(),d=a.useMemo(()=>Nb(r),[r]),c=d[0]??[],m=d.slice(1),g=a.useRef(null),[h,p]=a.useState(null),x=h?m[h.row]:null,f=h&&x?Cb(n,c,x,h.row+1,h.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:g,className:"relative min-h-0 flex-1",children:[e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),c.map((b,E)=>e.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:b||l("rightSidebar.csvUnnamedColumn",{index:E+1})},`${b}:${E}`))]})}),e.jsx("tbody",{children:m.map((b,E)=>e.jsxs("tr",{className:"hover:bg-surface-2",children:[e.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:E+1}),c.map((j,T)=>{const D=h?.row===E&&h.column===T;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${D?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:F=>{const M=g.current?.getBoundingClientRect(),N=F.currentTarget.getBoundingClientRect();if(!M?.width||!M.height)return;const A=F.clientX||N.left+N.width/2,_=F.clientY||N.top+N.height/2;p({row:E,column:T,xPercent:(A-M.left)/M.width*100,yPercent:(_-M.top)/M.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:b[T]||" "})},`cell:${E}:${T}`)})]},`row:${E}`))})]})}),h&&f&&e.jsx(Wo,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:async b=>{await s?.(f,`csv:${n}:${h.row+1}:${h.column+1}`,void 0,b)!==!1&&p(null)},children:l("rightSidebar.csvInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:h&&x?l("rightSidebar.csvSelectedCell",{row:h.row+1,column:c[h.column]||h.column+1}):l("rightSidebar.csvPickHint",{rows:m.length,columns:c.length})})})]})}function us(r,n){let s=r;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function Mb(r,n){const s=JSON.parse(r),l=us(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(us(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(us(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:us(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=us(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(g=>g&&typeof g=="object"&&g.name==="Default"):void 0,m=us(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(d)?d.length:0)},{label:"默认间距",value:c?.clearance!==void 0?`${c.clearance} mm`:"未设置"},{label:"默认线宽",value:c?.track_width!==void 0?`${c.track_width} mm`:"未设置"},{label:"默认过孔",value:c?.via_diameter!==void 0?`${c.via_diameter} / ${c.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(m)?m.length:0)}]}function $b(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function Pb({content:r,filePath:n,localState:s,onInsertAnnotation:l}){const{t:d}=ht(),c=a.useRef(null),[m,g]=a.useState(null),h=a.useMemo(()=>{try{return{items:Mb(r,s),error:null}}catch(x){return{items:[],error:x instanceof Error?x.message:String(x)}}},[r,s]),p=m===null?null:h.items[m.index];return h.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:d("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[e.jsx("div",{className:"divide-y divide-border/15",children:h.items.map((x,f)=>e.jsxs("button",{type:"button",onClick:b=>{const E=c.current?.getBoundingClientRect(),j=b.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const T=b.clientX||j.left+j.width/2,D=b.clientY||j.top+j.height/2;g({index:f,xPercent:(T-E.left)/E.width*100,yPercent:(D-E.top)/E.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${m?.index===f?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:x.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:x.value})]},x.label))}),e.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:d("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),p&&m&&e.jsx(Wo,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:async x=>{await l?.($b(n,p),`kicad-project:${n}:${p.label}`,void 0,x)!==!1&&g(null)},children:d("rightSidebar.kicadInsertSetting")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:p?`${p.label}: ${p.value}`:d("rightSidebar.kicadProjectPickHint")})})]})}const Ab=`/** ES Module Shims Wasm @version 2.8.4 */
|
|
15
15
|
(function () {
|
|
16
16
|
|
|
17
17
|
const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
@@ -1497,7 +1497,7 @@ import{ah as Br,dg as ht,bA as e,h as $o,cv as zd,ar as Ju,_ as Ln,bI as Qu,L as
|
|
|
1497
1497
|
};
|
|
1498
1498
|
|
|
1499
1499
|
})();
|
|
1500
|
-
`,
|
|
1500
|
+
`,Lb=`/* Runs only in the opaque preview frame. All local reads use its directory capability. */
|
|
1501
1501
|
function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
1502
1502
|
const external = new Set(externalOrigins);
|
|
1503
1503
|
const report = () => parent.postMessage({ type: 'preview-error', capability }, '*');
|
|
@@ -1632,46 +1632,48 @@ function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
|
1632
1632
|
window.addEventListener('error', report, true);
|
|
1633
1633
|
window.addEventListener('unhandledrejection', report);
|
|
1634
1634
|
}
|
|
1635
|
-
`,
|
|
1636
|
-
installPreviewRuntime(`+[d,c,[...x],Z].map(
|
|
1637
|
-
`+P.documentElement.outerHTML;return{html:Me,shellUrl:`/preview-shell.html#${d}`,errors:m,attach(Q,ge){const ue=new Set,_e=W=>{if(W.source!==Q.contentWindow||W.data?.capability!==d)return;if(W.data.type==="preview-ready"){Q.contentWindow?.postMessage({type:"preview-init",capability:d,html:Me,resources:p},"*");return}if(W.data.type==="preview-error"){ge("部分动态内容被安全预览限制");return}if(W.data.type==="preview-navigate"){(async()=>{const
|
|
1638
|
-
`);const b=d.length;d+=x.data,l.push({node:x,start:b,end:d.length,group:h}),c=h}const g=d.toLocaleLowerCase(),f=[];let p=0;for(;p<=g.length-s.length;){const x=g.indexOf(s,p);if(x<0)break;const h=x+s.length,b=l.find(S=>S.start<=x&&S.end>x),E=l.find(S=>S.start<h&&S.end>=h);if(b&&E&&b.group===E.group){const S=document.createRange();S.setStart(b.node,x-b.start),S.setEnd(E.node,h-E.start),f.push(S)}p=x+Math.max(s.length,1)}return f}function Ef(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let Lo;function Ru(r){return Lo===r}function xo(r){if(r&&Lo!==r)return;const n=Ef();n?.delete(Cf),n?.delete(El),Lo=void 0}function rl(r,n,s){const l=Ef();if(!l||typeof Highlight>"u")return;Lo=s,l.set(Cf,new Highlight(...r));const d=r[n];d?l.set(El,new Highlight(d)):l.delete(El)}function Nu(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Ob(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Ub(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Hb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Mf(r,n,s){return n?r:wr.createPortal(r,s)}const Ul="termdock:right-sidebar:file-tree-scroll:v1",Hl="termdock:right-sidebar:file-preview-reading-state:v1",na="termdock:right-sidebar:file-tree-width:v1",$f="termdock:right-sidebar:markdown-view-mode:v1",Pf="termdock:right-sidebar:diff-change-list-mode:v1",Af="termdock:right-sidebar:diff-wrap:v1",Lf="termdock:diff-viewer:view-type:v1",Tf="termdock:right-sidebar:file-search-mode:v1",nl="termdock:right-sidebar:collapsed-git-repo-groups:v1",Cu="termdock:right-sidebar:collapsed-diff-directories:v1",sl="termdock:right-sidebar:branch-audit-module-open:v1",If="termdock:right-sidebar:branch-audit-module:v1",zb=150,Eu="termdock:right-sidebar:context-draft-enabled:v1",Mu="termdock:right-sidebar:context-draft-collapsed:v1",$u="termdock:right-sidebar:context-draft-auto-collapse:v1",al="termdock:right-sidebar:context-draft-text:v1",Wb=300,Gb=20,Kb=120,qb=250,Vb=250,Yb=120,Xb=700,ol=600,Jb=6e4;function Js(r){return!!(r&&V.getState().nestedGitScanRoots[r])}const Pu=[2e3,5e3,15e3,3e4],Qb=320,Zb=500,ex=20,tx=12e3,Ml=300,Au=240,rx=560,Df="border-r px-2 py-1.5 sm:px-3 sm:py-2",To="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Ff=`${Df} border-b border-border/15 font-semibold last:border-r-0`,_f=`${Df} border-border/10 align-top text-muted-foreground last:border-r-0`,zl="termdock-file-preview-horizontal-scroll",Lu=a.lazy(()=>Ln(()=>import("./ModelPreview-B3ETe5f9.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),nx=a.lazy(()=>Ln(()=>import("./ArchitecturePanel-CcBSZoe8.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,10,11,12,15,16,6,14,13,17,19])).then(r=>({default:r.ArchitecturePanel}))),sx=a.lazy(()=>Ln(()=>import("./ComputerControlView-D1cRpjbf.js").then(r=>r.a),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),Bf=`${zl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Of(r,n,s){return r&&!n?"unified":s}const ax=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function ox(r){return r==="preview"||r==="source"}function ix(r){return r==="list"||r==="tree"||r==="ai"}function Tu(){return gt($f,ox)??"preview"}function lx(){return gt(Pf,ix)??"tree"}function sa(r){return typeof r=="boolean"}function cx(r){return typeof r=="string"}function dx(){return gt(Af,sa)??!0}function ux(r){return r==="unified"||r==="split"}function fx(){return gt(Lf,ux)??"unified"}function hx(r){return r==="name"||r==="content"||r==="regex"}function mx(){return gt(Tf,hx)??"name"}function Uf(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:wt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function px(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function $l(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Hf(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Pl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Iu(r){const n=gt(r,Pl);return n?new Set(n):new Set}function il(r,n){At(r,[...n])}function gx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function bx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Pl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(gx))&&(n.commits===void 0||Pl(n.commits))&&(n.commitCount===void 0||typeof n.commitCount=="number")&&(n.diff===void 0||typeof n.diff=="string")&&(n.truncated===void 0||typeof n.truncated=="boolean")&&(n.error===void 0||typeof n.error=="string")}function xx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&bx(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function vx(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(xx))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Du(){return gt(If,vx)??{}}function Fu(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function _u(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function zf(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||_u(s)===_u(l)}function Bu(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!zf(l,n))??""}function Al(r,n){const s=Math.max(Au,n-320),l=Math.min(rx,s);return Math.min(l,Math.max(Au,r))}function yx(r){return typeof r=="number"&&Number.isFinite(r)}function wx(r){return Al(gt(na,yx)??Ml,r)}function Wf(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Qs(r){return ax.has(Wf(r))}function Gf(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Ll(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Gf(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Kf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const qf=a.createContext(null);function Co(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Vf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Yf(r){return r.replace(/\s+#+\s*$/,"").trim()}function Tl(r,n){const l=Vf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function Ou(r){return Vf(r)||r.trim()}function Io(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Dl(n[2]);return s?{id:Co(n[1]),definition:{href:s.href,title:s.title}}:null}function kx(r){const n=new Map;for(const s of r){const l=Io(s);l&&n.set(l.id,l.definition)}return n}function Xf(r){return r.trim().toLowerCase()}function Jf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Xf(n[1]),text:n[2]}:null}function Sx(r){const n=new Map;let s=null;for(const l of r){const d=Jf(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function Qf(r){const n=new Set;let s=!1;return r.forEach((l,d)=>{if(Jf(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function jx(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const d=r[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Zf(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function ia(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Wl(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,m=d>=0?l.slice(d+1):"",g=c.split("?",1)[0];if(!g)return null;let f,p=null;try{f=decodeURIComponent(g),p=m?decodeURIComponent(m):null}catch{return null}const x=s?ia(s):null;let h;if(f.startsWith("/")){const b=x&&(f===x||f.startsWith(`${x}/`));h=ia(x&&!b?`${x}/${f.slice(1)}`:f)}else{if(!n)return null;h=ia(`${Zf(n)}/${f}`)}return x&&h!==x&&!h.startsWith(`${x}/`)?null:{path:h,fragment:p,directory:/\/$/.test(g)}}function Gl(r,n,s,l,d){const c=r.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!l(c.split(/[?#]/,1)[0]))return null;let m;if(c.startsWith("/")){const g=s&&(c===s||c.startsWith(`${s}/`));m=ia(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=ia(`${Zf(n)}/${c}`)}return d(m)}function Rx(r,n,s){return Gl(r,n,s,Bl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Nx(r,n,s){return Gl(r,n,s,ef,tf)}const Il=128,Cx=360,ll=480;function pa(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function eh(r,n,s,l,d=0){if(!n||!s)return null;let c,m;return d>0?(c=l>0?Math.min(d,l):d,m=s*c/n):pa(r)?(m=Math.min(Math.max(s,Il),Cx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>ll&&(c=c*ll/m,m=ll),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function Ex(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function th(r){const n=Ex(r),s=V(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function Mx({src:r,alt:n,title:s,requestedWidthPx:l}){const d=pa(r),c=th(r),m=Ho(c),g=a.useRef(null),[f,p]=a.useState(!1),[x,h]=a.useState(0),[b,E]=a.useState({status:"loading"}),[S,T]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current;let C=$?.parentElement?.parentElement??$?.parentElement;for(;C;){const j=window.getComputedStyle(C).display;if(j!=="inline"&&j!=="contents")break;C=C.parentElement}if(!C)return;const A=C,O=()=>{const j=window.getComputedStyle(A),o=(parseFloat(j.paddingLeft)||0)+(parseFloat(j.paddingRight)||0);h(Math.max(0,A.clientWidth-o))};if(O(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(O);return q.observe(A),()=>q.disconnect()},[]),a.useEffect(()=>{if(f)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const C=new IntersectionObserver(A=>{A.some(O=>O.isIntersecting)&&(p(!0),C.disconnect())},{rootMargin:"400px"});return C.observe($),()=>C.disconnect()},[f]),a.useEffect(()=>{if(!f)return;const $=new AbortController;let C=null;E({status:"loading"});const A=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return rf(c,{signal:$.signal}).then(async O=>{if(!O.ok)throw new Error(`HTTP ${O.status}`);const q=Number(O.headers.get("X-Image-Width"))||0,j=Number(O.headers.get("X-Image-Height"))||0;return{blob:await O.blob(),width:q,height:j}}).then(({blob:O,width:q,height:j})=>{$.signal.aborted||(C=URL.createObjectURL(O),q>0&&j>0&&T({width:q,height:j}),E({status:"ready",objectUrl:C}))}).catch(()=>{const O=$.signal.reason;$.signal.aborted&&!(O instanceof DOMException&&O.name==="TimeoutError")||E({status:"fallback"})}).finally(()=>{window.clearTimeout(A)}),()=>{window.clearTimeout(A),$.abort(),C&&URL.revokeObjectURL(C)}},[f,c]);const D=eh(r,S?.width??0,S?.height??0,x,l??0),F=D??(l?{width:x>0?Math.min(l,x):l,height:Math.round(l*.75)}:{width:Il*2,height:Il});return e.jsx("div",{ref:g,className:"block max-w-full",style:D?{width:D.width,height:D.height}:void 0,children:b.status==="ready"?e.jsx("img",{src:b.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const C=$.currentTarget;C.naturalWidth>0&&C.naturalHeight>0&&(S?.width!==C.naturalWidth||S?.height!==C.naturalHeight)&&T({width:C.naturalWidth,height:C.naturalHeight})}}):b.status==="fallback"?e.jsx("img",{src:m,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const C=$.currentTarget;C.naturalWidth>0&&C.naturalHeight>0&&(S?.width!==C.naturalWidth||S?.height!==C.naturalHeight)&&T({width:C.naturalWidth,height:C.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:F.width,height:F.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function la(r,n,s,l,d,c){const m=Rx(s,d.markdownFilePath,d.rootPath);if(!m)return c?.fallbackText??``;const g=d.images.length;d.images.push({kind:"image",src:m,alt:n,title:l});const f=e.jsx(Mx,{src:m,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:p=>{p.stopPropagation(),d.onImageOpen?.(g)},children:f},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:f},r)}function cl(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Uu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function Dl(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const rh="",$x=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Px(r){return r.replace($x,(n,s)=>`${rh}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Hu(r){return r.replace(new RegExp(`${rh}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Ax(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const nh={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let vo=null;function sh(){return vo||(vo=Ln(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw vo=null,r})),vo}function ah({html:r}){const{t:n}=ht(),[s,l]=a.useState(null);return a.useEffect(()=>{let d=!1;return l(null),sh().then(c=>{d||l(c.sanitize(r,nh))}).catch(()=>{d||l("")}),()=>{d=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function Lx({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),sh().then(d=>{l||s(d.sanitize(r,nh))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function oh(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let yo=null;function Tx(){return yo||(yo=Promise.all([Ln(()=>import("./katex-DnlPpQZa.js"),[]),Ln(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw yo=null,r})),yo}function fa({tex:r,display:n=!1}){const[s,l]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),c(!1),Tx().then(f=>{g||l(f.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||c(!0)}),()=>{g=!0}},[n,r]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const m=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:m,dangerouslySetInnerHTML:{__html:s}})}function Kl(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function zu(r){const n=Kl(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function Ix(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Kl(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),m=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),g=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:g,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(m)}}function Dx({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=ht(),[c,m]=a.useState(!1),g=Ho(r,()=>m(!0));return g?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||d("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:g,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>m(!0)})}):null}function Fx(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const m=r.slice(0,r.indexOf(">")+1),g=Kl(m).get("href")?.trim()??"",f=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:x,title:h,widthPx:b}=zu(f);if(!p)return null;const E=Gl(p,s.markdownFilePath,s.rootPath,Bl,$=>$);if(!E)return null;const S=g?Wl(g,s.markdownFilePath,s.rootPath):null,D=!!!(S&&S.path===E)&&g?Kf(g):null,F=la(n,x??"",p,h,s,{requestedWidthPx:b,interactive:D?!1:void 0});return D?e.jsx("a",{href:D,target:"_blank",rel:"noreferrer",children:F},n):F}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:m,alt:g,title:f,widthPx:p}=zu(r);return m?la(n,g??"",m,f,s,{fallbackText:r,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:m,fallbackText:g,widthPx:f,controls:p}=Ix(r);if(!m)return null;const x=Nx(m,s.markdownFilePath,s.rootPath);return x?e.jsx(Dx,{url:x,fallbackText:g,widthPx:f,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx(Lx,{html:r},n):null;const d=l[1].toLowerCase(),c=ft(l[2],`${n}-${d}`,!0,s);return d==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:c},n):d==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):d==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function ft(r,n,s=!0,l){return l.budget.nested(()=>_x(r,n,s,l))}function _x(r,n,s=!0,l){l.budget.validateInline(r);const d=Px(r),c=[];let m=0;for(const{index:g,token:f}of xg(d,l.budget)){g>m&&c.push(Hu(d.slice(m,g)));const p=`${n}-${g}`,x=f.startsWith("<")?Fx(f,p,l):null;if(x)c.push(x);else if(f.startsWith("\\(")&&f.endsWith("\\)"))c.push(e.jsx(fa,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))c.push(e.jsx(fa,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const h=f.match(/^`+/)?.[0].length??1;c.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Ax(f.slice(h,-h))},p))}else if(f.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ft(f.slice(2,-2),`${p}-del`,s,l)},p));else if(f.startsWith("**")||f.startsWith("__"))c.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ft(f.slice(2,-2),`${p}-strong`,s,l)},p));else if(f.startsWith("*")||f.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ft(f.slice(1,-1),`${p}-em`,s,l)},p));else if(f.startsWith("![")){const h=f.match(/^!\[([^\]]*)\]\((.*)\)$/),b=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^!\[([^\]]+)\]$/);if(h){const S=Dl(h[2]);c.push(S?la(p,h[1],S.href,S.title,l):f)}else if(b){const S=b[2]||b[1],T=l.referenceDefinitions.get(Co(S));c.push(T?la(p,b[1],T.href,T.title,l):f)}else if(E){const S=l.referenceDefinitions.get(Co(E[1]));c.push(S?la(p,E[1],S.href,S.title,l):f)}else c.push(f)}else if(f.startsWith("[^")){const h=Xf(f.slice(2,-1)),b=l.footnoteDefinitions.get(h);c.push(b?e.jsx("sup",{id:`fnref-${b.id}`,title:b.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${b.id}`,className:"text-primary no-underline",children:b.index})},p):f)}else if(f.startsWith("<http")){const h=f.slice(1,-1);c.push(e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(f.startsWith("<")&&f.endsWith(">")&&Uu(f.slice(1,-1))){const h=f.slice(1,-1);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(Uu(cl(f).linkText)){const{linkText:h,suffix:b}=cl(f);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:h,suffix:b}=cl(f),E=h.startsWith("www.")?`https://${h}`:h;c.push(e.jsx("a",{href:E,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else{const h=f.match(/^\[([^\]]+)\]\((.*)\)$/),b=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^\[([^\]]+)\]$/),S=b?b[2]||b[1]:E?.[1]??null,T=S?l.referenceDefinitions.get(Co(S)):null,D=h?Dl(h[2]):null,F=D?.href??T?.href??null,$=F?Kf(F):null,C=h?.[1]??b?.[1]??E?.[1]??"";c.push($?e.jsx("a",{href:$,title:D?.title??T?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ft(C,`${p}-link`,s,l)},p):f)}m=g+f.length}return m<d.length&&c.push(Hu(d.slice(m))),c.length>0?c:[r]}function ih(r){return/(?: {2,}|\\)$/.test(r)}function lh(r){return r.replace(/(?: {2,}|\\)$/,"")}function Do(r){return/^(?: {4}|\t)/.test(r)}function ch(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function dh(r,n,s){const l=[];return r.forEach((d,c)=>{const m=ih(d);l.push(...ft(lh(d),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Fl(r,n,s){const l=[],d=[];return r.forEach((c,m)=>{d.push(ih(c)),l.push(ft(lh(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function _l(r,n,s,l,d){const c=[];return r.forEach((m,g)=>{const f=s[g]??0,p=!!(d&&f>=d.start&&f<=d.end);c.push(e.jsx("span",{"data-md-ref-start":f,"data-md-ref-end":f,"data-selected":p?"true":void 0,children:m},`${l}-ref-${g}`)),g<r.length-1&&c.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),c}function ha(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,m=0;for(let g=0;g<n.length;g+=1){const f=n[g];if(d){l+=f,d=!1;continue}if(f==="\\"){d=!0;continue}if(f==="`"){const p=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const x=g-p+1;l+="`".repeat(x),c===0?c=x:c===x&&(c=0);continue}if(c===0&&f==="["?m+=1:c===0&&f==="]"&&m>0&&(m-=1),f==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=f}return d&&(l+="\\"),s.push(l.trim()),s}function uh(r){return ha(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Fo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function _o(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function fh(r,n){return r>96||r>44&&n>.35}function Wo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function ma(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function ql(r,n,s,l,d,c=new Set){const m=[],g=[];let f=n;for(;f<r.length;){const p=r[f];if(d&&(Io(p)||c.has(f))){f+=1;continue}const x=ma(p),h=Wo(p);if(!x){if(h>s&&g.length>0){([...g].reverse().find(T=>T.indent<h)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const T of g)T.item.lineEnd=f+1;f+=1;continue}break}if(h<s||h===s&&x.ordered!==l)break;const b={content:x.content,ordered:x.ordered,start:x.start,children:[],paragraphs:[],lineStart:f+1,lineEnd:f+1};for(;g.length>0&&g[g.length-1].indent>=h;)g.pop();const E=g[g.length-1]?.item??null;E?E.children.push(b):m.push(b),g.push({indent:h,item:b});for(const S of g)S.item.lineEnd=f+1;f+=1}return{items:m,nextIndex:f}}function Bx(r){const n=r.find(l=>ma(l));if(!n)return[];const s=ma(n);return s?ql(r,0,Wo(n),s.ordered,!0,Qf(r)).items:[]}function Vl(r,n,s,l=0){return s.budget.nested(()=>Ox(r,n,s,l))}function Ox(r,n,s,l=0){return r.map((d,c)=>{const m=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!m,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[m?e.jsx("input",{type:"checkbox",checked:m[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ft(m?.[2]??d.content,`li-${n}-${c}`,!0,s),d.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((g,f)=>e.jsx("p",{children:ft(g,`li-${n}-${c}-p-${f}`,!0,s)},`paragraph-${f}`))})]}),groups:Ux(d.children,`${n}-${c}`,s,l)}})}function Ux(r,n,s,l=0){const d=[];for(const c of r){const m=d[d.length-1];m&&m.ordered===c.ordered?m.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,m)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:Vl(c.items,`${n}-g${m}`,s,l)}))}function Yl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&Hx(s.groups,n)]},s.key)})}function Hx(r,n){return r.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Yl(s.items,n)},`nested-${l}`)})}function zx(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ft(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Wx(r,n,s,l){const d=[];let c=0;const m=g=>l?.[g]??g+1;for(;c<r.length;){s.budget.check();const g=r[c],f=g.trim();if(!f){c+=1;continue}if(/^<details>\s*$/i.test(f)){const F=c;let $="Details";const C=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const A=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);A?$=A[1].trim()||$:C.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ft($,`${n}-details-${F}-summary`,!0,s)}),C.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:dh(C,`${n}-details-${F}`,s)})]},`${n}-details-${F}`)});continue}const p=oh(g);if(p){const F=[g],$=c;for(c+=1;c<r.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(r[c]);)F.push(r[c]),c+=1;c<r.length&&!p.selfContained&&(F.push(r[c]),c+=1),d.push({kind:"static",node:e.jsx(ah,{html:F.join(`
|
|
1639
|
-
`)},`${n}-
|
|
1640
|
-
`)
|
|
1635
|
+
`,xo="/api/terminal/fs/preview/",Tb=8*1024*1024,Ib=32*1024*1024,Db=128,Fb="data:,";function Pt(r){throw new Error(r)}function _b(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Nu(r,n,s){let l="",d=0;for(const c of r.matchAll(n))l+=r.slice(d,c.index)+await s(c),d=c.index+c[0].length;return l+r.slice(d)}async function Cf(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!Vs(l.pathname)?.startsWith(xo))&&Pt("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,m=[],g=z=>{!m.includes(z)&&m.length<20&&m.push(z)},h=new Set,p=[],x=new Set,f=new Map,b=new Map;let E=0,j=!1;const T=new Set,D=()=>{j=!0;for(const z of[...T])z();h.clear(),p.length=0};async function F(z){z.ok||Pt(`预览资源读取失败(${z.status})`);const Z=z.body?.getReader(),P=[];let G=0;try{if(Z)for(;;){const pe=await Z.read();if(pe.done)break;G+=pe.value.byteLength,E+=pe.value.byteLength,(G>Tb||E>Ib)&&Pt("预览资源超出大小限制"),P.push(pe.value)}}catch(pe){throw await Z?.cancel().catch(()=>{}),pe}finally{Z?.releaseLock()}const J=new Uint8Array(G);let ie=0;for(const pe of P)J.set(pe,ie),ie+=pe.length;return{bytes:J,type:z.headers.get("content-type")??"application/octet-stream",status:z.status}}let M=l,N;for(let z=0;z<4;z++){const Z=await n.fetch(M.pathname+M.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(Z.status)){N=Z;break}const P=Z.headers.get("location");await Z.body?.cancel(),P||Pt("预览重定向缺少目标");const G=new URL(P,M);(G.origin!==s||!Vs(G.pathname)?.startsWith(xo))&&Pt("预览重定向越出文件范围"),M=G}N||Pt("预览重定向次数过多");const A=Vs(M.pathname),_=A.slice(xo.length).split("/");/^[a-f0-9]{32}$/.test(_[0])||Pt("服务未提供有效的预览资源授权");const q=Vs(l.pathname).slice(xo.length).split("/");/^[a-f0-9]{32}$/.test(q[0])&&q.shift(),q.join("/").replace(/\/$/,"")!==_.slice(1).join("/").replace(/\/$/,"")&&Pt("预览重定向改变了文件范围");const S=A.endsWith("/")?A:A.slice(0,A.lastIndexOf("/")+1),o=new URL(M.pathname.endsWith("/")?M.pathname:M.pathname.slice(0,M.pathname.lastIndexOf("/")+1),s);function B(z,Z){const P=new URL(z,Z);return P.origin!==s?null:(Vs(P.pathname)?.startsWith(S)||Pt("已阻止预览访问目录之外的资源"),P)}function I(z){const Z=new URL(z,c);(Z.origin!==new URL(c).origin||!Z.pathname.startsWith(new URL(c).pathname))&&Pt("已阻止预览访问服务接口或目录之外的资源");const P=Z.pathname.slice(new URL(c).pathname.length)+Z.search;return B(P,o)??Pt("预览资源无效")}function Y(z){const Z=z.pathname+z.search,P=f.get(Z);if(P)return P;if(j||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(f.size>=Db)return Promise.reject(new Error("预览资源数量超出限制"));const G=n.fetch(Z,{signal:n.signal,redirect:"manual"}).then(F);return f.set(Z,G),G}function H(z,Z){j&&Pt("预览已关闭");const P=`termdock-resource-${d}-${p.length}`;return p.push({token:P,data:z,type:Z}),h.add(P),P}async function U(z,Z,P,G=new Set){if(!z||z.startsWith("#")||/^data:(?:image|font)\//i.test(z)&&P==="resource")return z;try{const J=B(z,Z);if(!J){const Me=new URL(z,Z);return(Me.protocol!=="https:"||Me.username||Me.password||Me.origin===new URL(c).origin)&&Pt("已阻止不安全的外部资源"),x.add(Me.origin),Me.href}const ie=`${P}:${J.href}`;(G.has(ie)||G.size>=8)&&Pt("预览资源存在循环或过深引用");const pe=b.get(ie);if(pe)return pe;const Se=new Set(G);Se.add(ie);const ke=(async()=>{const Me=await Y(J);return P==="css"?H(await R(new TextDecoder().decode(Me.bytes),J,Se),"text/css"):P==="script"?H(Me.bytes,"text/javascript"):H(Me.bytes,Me.type)})();return b.set(ie,ke),await ke}catch(J){return g(J instanceof Error?J.message:"部分预览资源未能加载"),Fb}}async function R(z,Z,P){return z=await Nu(z,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async G=>`@import url("${await U(G[1],Z,"css",P)}")${G[2]};`),Nu(z,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async G=>{const J=(G[1]??G[2]??G[3]).trim();return h.has(J)?G[0]:`url("${await U(J,Z,"resource",P)}")`})}try{const z=await F(N),Z=H(Ab,"text/javascript"),P=new DOMParser().parseFromString(new TextDecoder().decode(z.bytes),"text/html");P.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(Q=>Q.remove());for(const Q of P.querySelectorAll("*")){if(Q.removeAttribute("ping"),Q.removeAttribute("srcdoc"),Q.hasAttribute("style")&&Q.setAttribute("style",await R(Q.getAttribute("style"),M,new Set)),Q.tagName==="STYLE"&&(Q.textContent=await R(Q.textContent??"",M,new Set)),Q.tagName==="A"||Q.tagName==="AREA"){const ge=Q.getAttribute("href");try{if(ge&&!ge.startsWith("#")){const ue=B(ge,M);if(ue)Q.setAttribute("href",new URL(ue.pathname.slice(o.pathname.length)+ue.search+ue.hash,c).href);else{const _e=new URL(ge,M);if(_e.protocol!=="https:"){Q.removeAttribute("href");continue}x.add(_e.origin),Q.setAttribute("href",_e.href)}}}catch(ue){Q.removeAttribute("href"),g(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const ge of["data","manifest"])Q.removeAttribute(ge);if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="module"){Q.setAttribute("type","module-shim");const ge=Q.getAttribute("src");if(ge){const ue=B(ge,M);if(ue)Q.setAttribute("src",new URL(ue.pathname.slice(o.pathname.length)+ue.search,c).href);else{const _e=new URL(ge,M);if(_e.protocol!=="https:"){Q.remove();continue}x.add(_e.origin),Q.setAttribute("src",_e.href)}}continue}if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="importmap"){Q.setAttribute("type","importmap-shim");continue}if(Q.tagName==="LINK"){const ge=(Q.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ge)){Q.remove();continue}const ue=Q.getAttribute("href");ue&&Q.setAttribute("href",await U(ue,M,ge==="stylesheet"?"css":"resource"))}if(Q.hasAttribute("src")&&Q.setAttribute("src",await U(Q.getAttribute("src"),M,Q.tagName==="SCRIPT"?"script":"resource")),Q.hasAttribute("poster")&&Q.setAttribute("poster",await U(Q.getAttribute("poster"),M,"resource")),Q.hasAttribute("srcset")){const ge=Q.getAttribute("srcset");/data:/i.test(ge)?(Q.removeAttribute("srcset"),g("混合内嵌图片候选暂不支持安全预览")):Q.setAttribute("srcset",(await Promise.all(ge.split(",").map(async ue=>{const[_e,...Ue]=ue.trim().split(/\s+/);return`${await U(_e,M,"resource")} ${Ue.join(" ")}`}))).join(", "))}Q.setAttribute("referrerpolicy","no-referrer"),Q.removeAttribute("integrity"),Q.removeAttribute("crossorigin")}const G=[...x].join(" "),J=P.createElement("meta");J.httpEquiv="Content-Security-Policy",J.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${G}; style-src 'unsafe-inline' blob: ${G}; img-src blob: data: ${G}; font-src blob: data: ${G}; media-src blob: data: ${G}; connect-src blob: ${G} ${[...x].map(Q=>Q.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ie=P.createElement("base");ie.href=c;const pe=P.createElement("meta");pe.name="referrer",pe.content="no-referrer";const Se=P.createElement("script");Se.textContent=Lb+`
|
|
1636
|
+
installPreviewRuntime(`+[d,c,[...x],Z].map(_b).join(",")+");";const ke=P.createElement("script");ke.src=Z,P.head.prepend(J,pe,ie,Se,ke);const Me=`<!doctype html>
|
|
1637
|
+
`+P.documentElement.outerHTML;return{html:Me,shellUrl:`/preview-shell.html#${d}`,errors:m,attach(Q,ge){const ue=new Set,_e=W=>{if(W.source!==Q.contentWindow||W.data?.capability!==d)return;if(W.data.type==="preview-ready"){Q.contentWindow?.postMessage({type:"preview-init",capability:d,html:Me,resources:p},"*");return}if(W.data.type==="preview-error"){ge("部分动态内容被安全预览限制");return}if(W.data.type==="preview-navigate"){(async()=>{const we=I(String(W.data.url)),He=await Cf(we.pathname+we.search,n);if(j){He.dispose();return}const Ke=He.attach(Q,ge);T.add(()=>{Ke(),He.dispose()}),Q.src=He.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(we=>ge(we instanceof Error?we.message:"无法打开预览页面"));return}if(W.data.type==="preview-external"){try{const we=new URL(String(W.data.url));we.protocol==="https:"&&x.has(we.origin)&&window.open(we.href,"_blank","noopener,noreferrer")}catch{}return}if(W.data.type!=="preview-fetch"||W.ports.length!==1)return;const ye=W.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(W.data.method)){ye.postMessage({error:"预览仅允许读取已授权目录资源"}),ye.close();return}ue.add(ye),(async()=>{const we=I(String(W.data.url)),He=await Y(we);if(!ue.has(ye)||j)return;const Ke=W.data.method==="HEAD"?new Uint8Array:He.bytes.slice();ye.postMessage({status:He.status,headers:{"content-type":He.type},data:Ke.buffer},[Ke.buffer])})().catch(()=>{ye.postMessage({error:"预览资源不在授权范围或无法加载"}),ge("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(ye),ye.close()})};window.addEventListener("message",_e);const Ue=()=>{window.removeEventListener("message",_e);for(const W of ue)W.close();ue.clear(),T.delete(Ue)};return T.add(Ue),Ue},dispose:D}}catch(z){throw D(),z}}const Bb=a.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const m=a.useRef(null),[g,h]=a.useState(null),[p,x]=a.useState(),[f,b]=a.useState("");a.useEffect(()=>{const A=new AbortController;let _;return x(void 0),b(""),(async()=>{const q=await Zm();if(_=await Cf(n,{fetch:(S,o)=>q.fetch(S,o),signal:A.signal}),A.signal.aborted){_.dispose();return}x(_),_.errors.length&&b(_.errors.join(";"))})().catch(q=>{A.signal.aborted||b(q instanceof Error?q.message:"安全预览加载失败")}),()=>{A.abort(),_?.dispose()}},[n]),a.useEffect(()=>{if(!(!p||!g))return p.attach(g,b)},[p,g]);const[E,j]=a.useState(!1),[T,D]=a.useState(!1),F=E||T;a.useEffect(()=>{d?.(F)},[F,d]),a.useEffect(()=>{const A=()=>{j(document.fullscreenElement===m.current)};return document.addEventListener("fullscreenchange",A),()=>document.removeEventListener("fullscreenchange",A)},[]),a.useEffect(()=>{if(!T)return;const A=_=>{_.key==="Escape"&&D(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[T]);const M=a.useCallback(async()=>{const A=m.current;if(A){if(T){D(!1);return}if(document.fullscreenElement===A){await document.exitFullscreen();return}if(A.requestFullscreen&&document.fullscreenEnabled!==!1)try{await A.requestFullscreen();return}catch{}D(!0)}},[T]);a.useImperativeHandle(c,()=>({toggleFullscreen:M}),[M]);const N=e.jsxs("div",{ref:m,"data-html-preview-frame":!0,className:F?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[F&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{M()},"aria-label":l,title:`${l} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:e.jsx(mf,{size:15})})]}),f&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:f}),!p&&!f&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:h,src:p?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return T?yr.createPortal(N,document.body):N}),Ef="termdock-file-search-match",$l="termdock-file-search-current";function Ob(r,n,s){return!!(n&&r?.isConnected&&!s.defaultPrevented&&!r.closest('[inert], [aria-hidden="true"], [hidden]')&&s.target instanceof Node&&r.contains(s.target))}function Ub(r){const n=r.metaKey||r.ctrlKey,s=r.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||r.key==="F3"?r.shiftKey?"previous":"next":r.key==="Escape"?"close":null}function Hb(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function zb(r,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let x=m.nextNode();x;x=m.nextNode()){if(!(x instanceof Text)||!x.data)continue;const f=Hb(x);if(!f)continue;c&&c!==f&&(d+=`
|
|
1638
|
+
`);const b=d.length;d+=x.data,l.push({node:x,start:b,end:d.length,group:f}),c=f}const g=d.toLocaleLowerCase(),h=[];let p=0;for(;p<=g.length-s.length;){const x=g.indexOf(s,p);if(x<0)break;const f=x+s.length,b=l.find(j=>j.start<=x&&j.end>x),E=l.find(j=>j.start<f&&j.end>=f);if(b&&E&&b.group===E.group){const j=document.createRange();j.setStart(b.node,x-b.start),j.setEnd(E.node,f-E.start),h.push(j)}p=x+Math.max(s.length,1)}return h}function Mf(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let To;function Cu(r){return To===r}function vo(r){if(r&&To!==r)return;const n=Mf();n?.delete(Ef),n?.delete($l),To=void 0}function sl(r,n,s){const l=Mf();if(!l||typeof Highlight>"u")return;To=s,l.set(Ef,new Highlight(...r));const d=r[n];d?l.set($l,new Highlight(d)):l.delete($l)}function Eu(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Wb(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Gb(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Kb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function $f(r,n,s){return n?r:yr.createPortal(r,s)}const Wl="termdock:right-sidebar:file-tree-scroll:v1",Gl="termdock:right-sidebar:file-preview-reading-state:v1",na="termdock:right-sidebar:file-tree-width:v1",Pf="termdock:right-sidebar:markdown-view-mode:v1",Af="termdock:right-sidebar:diff-change-list-mode:v1",Lf="termdock:right-sidebar:diff-wrap:v1",Tf="termdock:diff-viewer:view-type:v1",If="termdock:right-sidebar:file-search-mode:v1",al="termdock:right-sidebar:collapsed-git-repo-groups:v1",Mu="termdock:right-sidebar:collapsed-diff-directories:v1",ol="termdock:right-sidebar:branch-audit-module-open:v1",Df="termdock:right-sidebar:branch-audit-module:v1",qb=150,$u="termdock:right-sidebar:context-draft-enabled:v1",Pu="termdock:right-sidebar:context-draft-collapsed:v1",Au="termdock:right-sidebar:context-draft-auto-collapse:v1",il="termdock:right-sidebar:context-draft-text:v1",Vb=300,Yb=20,Xb=120,Jb=250,Qb=250,Zb=120,ex=700,ll=600,tx=6e4;function Js(r){return!!(r&&V.getState().nestedGitScanRoots[r])}const Lu=[2e3,5e3,15e3,3e4],rx=320,nx=500,sx=20,ax=12e3,Pl=300,Tu=240,ox=560,Ff="border-r px-2 py-1.5 sm:px-3 sm:py-2",Io="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",_f=`${Ff} border-b border-border/15 font-semibold last:border-r-0`,Bf=`${Ff} border-border/10 align-top text-muted-foreground last:border-r-0`,Kl="termdock-file-preview-horizontal-scroll",Iu=a.lazy(()=>Ln(()=>import("./ModelPreview-BpIynSeJ.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),ix=a.lazy(()=>Ln(()=>import("./ArchitecturePanel-sTwptDpa.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,10,11,12,15,16,6,14,13,17,19])).then(r=>({default:r.ArchitecturePanel}))),lx=a.lazy(()=>Ln(()=>import("./ComputerControlView-CWlfdXhY.js").then(r=>r.a),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),Of=`${Kl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Uf(r,n,s){return r&&!n?"unified":s}const cx=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function dx(r){return r==="preview"||r==="source"}function ux(r){return r==="list"||r==="tree"||r==="ai"}function Du(){return gt(Pf,dx)??"preview"}function fx(){return gt(Af,ux)??"tree"}function sa(r){return typeof r=="boolean"}function hx(r){return typeof r=="string"}function mx(){return gt(Lf,sa)??!0}function px(r){return r==="unified"||r==="split"}function gx(){return gt(Tf,px)??"unified"}function bx(r){return r==="name"||r==="content"||r==="regex"}function xx(){return gt(If,bx)??"name"}function Hf(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:yt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function vx(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function Al(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function zf(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Ll(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Fu(r){const n=gt(r,Ll);return n?new Set(n):new Set}function cl(r,n){At(r,[...n])}function wx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function yx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Ll(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(wx))&&(n.commits===void 0||Ll(n.commits))&&(n.commitCount===void 0||typeof n.commitCount=="number")&&(n.diff===void 0||typeof n.diff=="string")&&(n.truncated===void 0||typeof n.truncated=="boolean")&&(n.error===void 0||typeof n.error=="string")}function kx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&yx(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function Sx(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(kx))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function _u(){return gt(Df,Sx)??{}}function Bu(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Ou(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Wf(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Ou(s)===Ou(l)}function Uu(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Wf(l,n))??""}function Tl(r,n){const s=Math.max(Tu,n-320),l=Math.min(ox,s);return Math.min(l,Math.max(Tu,r))}function jx(r){return typeof r=="number"&&Number.isFinite(r)}function Rx(r){return Tl(gt(na,jx)??Pl,r)}function Gf(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Qs(r){return cx.has(Gf(r))}function Kf(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Il(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Kf(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^<video\b/i.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function qf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const Vf=a.createContext(null);function Eo(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Yf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Xf(r){return r.replace(/\s+#+\s*$/,"").trim()}function Dl(r,n){const l=Yf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function Hu(r){return Yf(r)||r.trim()}function Do(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=_l(n[2]);return s?{id:Eo(n[1]),definition:{href:s.href,title:s.title}}:null}function Nx(r){const n=new Map;for(const s of r){const l=Do(s);l&&n.set(l.id,l.definition)}return n}function Jf(r){return r.trim().toLowerCase()}function Qf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Jf(n[1]),text:n[2]}:null}function Cx(r){const n=new Map;let s=null;for(const l of r){const d=Qf(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function Zf(r){const n=new Set;let s=!1;return r.forEach((l,d)=>{if(Qf(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function Ex(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const d=r[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function eh(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function ia(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Go(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,m=d>=0?l.slice(d+1):"",g=c.split("?",1)[0];if(!g)return null;let h,p=null;try{h=decodeURIComponent(g),p=m?decodeURIComponent(m):null}catch{return null}const x=s?ia(s):null;let f;if(h.startsWith("/")){const b=x&&(h===x||h.startsWith(`${x}/`));f=ia(x&&!b?`${x}/${h.slice(1)}`:h)}else{if(!n)return null;f=ia(`${eh(n)}/${h}`)}return x&&f!==x&&!f.startsWith(`${x}/`)?null:{path:f,fragment:p,directory:/\/$/.test(g)}}function th(r,n,s,l,d){const c=r.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!l(c.split(/[?#]/,1)[0]))return null;let m;if(c.startsWith("/")){const g=s&&(c===s||c.startsWith(`${s}/`));m=ia(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=ia(`${eh(n)}/${c}`)}return d(m)}function rh(r,n,s){return th(r,n,s,Ul,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function ql(r,n,s){if(/^https?:\/\//i.test(r.trim()))return r.trim();const l=Go(r,n,s);return!l||!Hl(l.path)?null:rf(l.path)+(l.fragment?`#${l.fragment}`:"")}function nh(r){try{return Hl(decodeURIComponent(new URL(r,"https://markdown.invalid/").pathname))}catch{return!1}}const Fl=128,Mx=360,dl=480;function ga(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function sh(r,n,s,l,d=0){if(!n||!s)return null;let c,m;return d>0?(c=l>0?Math.min(d,l):d,m=s*c/n):ga(r)?(m=Math.min(Math.max(s,Fl),Mx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>dl&&(c=c*dl/m,m=dl),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function $x(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function ah(r){const n=$x(r),s=V(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function Px({src:r,alt:n,title:s,requestedWidthPx:l}){const d=ga(r),c=ah(r),m=fa(c),g=a.useRef(null),[h,p]=a.useState(!1),[x,f]=a.useState(0),[b,E]=a.useState({status:"loading"}),[j,T]=a.useState(null);a.useLayoutEffect(()=>{const M=g.current;let N=M?.parentElement?.parentElement??M?.parentElement;for(;N;){const S=window.getComputedStyle(N).display;if(S!=="inline"&&S!=="contents")break;N=N.parentElement}if(!N)return;const A=N,_=()=>{const S=window.getComputedStyle(A),o=(parseFloat(S.paddingLeft)||0)+(parseFloat(S.paddingRight)||0);f(Math.max(0,A.clientWidth-o))};if(_(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(_);return q.observe(A),()=>q.disconnect()},[]),a.useEffect(()=>{if(h)return;const M=g.current;if(!M||typeof IntersectionObserver>"u"){p(!0);return}const N=new IntersectionObserver(A=>{A.some(_=>_.isIntersecting)&&(p(!0),N.disconnect())},{rootMargin:"400px"});return N.observe(M),()=>N.disconnect()},[h]),a.useEffect(()=>{if(!h)return;const M=new AbortController;let N=null;E({status:"loading"});const A=window.setTimeout(()=>{M.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return nf(c,{signal:M.signal}).then(async _=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);const q=Number(_.headers.get("X-Image-Width"))||0,S=Number(_.headers.get("X-Image-Height"))||0;return{blob:await _.blob(),width:q,height:S}}).then(({blob:_,width:q,height:S})=>{M.signal.aborted||(N=URL.createObjectURL(_),q>0&&S>0&&T({width:q,height:S}),E({status:"ready",objectUrl:N}))}).catch(()=>{const _=M.signal.reason;M.signal.aborted&&!(_ instanceof DOMException&&_.name==="TimeoutError")||E({status:"fallback"})}).finally(()=>{window.clearTimeout(A)}),()=>{window.clearTimeout(A),M.abort(),N&&URL.revokeObjectURL(N)}},[h,c]);const D=sh(r,j?.width??0,j?.height??0,x,l??0),F=D??(l?{width:x>0?Math.min(l,x):l,height:Math.round(l*.75)}:{width:Fl*2,height:Fl});return e.jsx("div",{ref:g,className:"block max-w-full",style:D?{width:D.width,height:D.height}:void 0,children:b.status==="ready"?e.jsx("img",{src:b.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:D?{width:D.width,height:D.height}:void 0,onLoad:M=>{const N=M.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(j?.width!==N.naturalWidth||j?.height!==N.naturalHeight)&&T({width:N.naturalWidth,height:N.naturalHeight})}}):b.status==="fallback"?e.jsx("img",{src:m,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:D?{width:D.width,height:D.height}:void 0,onLoad:M=>{const N=M.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(j?.width!==N.naturalWidth||j?.height!==N.naturalHeight)&&T({width:N.naturalWidth,height:N.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:F.width,height:F.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function la(r,n,s,l,d,c){if(!c?.fallbackText&&nh(s)){const p=ql(s,d.markdownFilePath,d.rootPath);if(p)return e.jsx(Vl,{url:p,label:n,title:l,hasControls:!0},r)}const m=rh(s,d.markdownFilePath,d.rootPath);if(!m)return c?.fallbackText??``;const g=d.images.length;d.images.push({kind:"image",src:m,alt:n,title:l});const h=e.jsx(Px,{src:m,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:p=>{p.stopPropagation(),d.onImageOpen?.(g)},children:h},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:h},r)}function ul(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function zu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function _l(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const oh="",Ax=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Lx(r){return r.replace(Ax,(n,s)=>`${oh}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Wu(r){return r.replace(new RegExp(`${oh}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Tx(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const ih={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let wo=null;function lh(){return wo||(wo=Ln(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw wo=null,r})),wo}function ch({html:r}){const{t:n}=ht(),[s,l]=a.useState(null);return a.useEffect(()=>{let d=!1;return l(null),lh().then(c=>{d||l(c.sanitize(r,ih))}).catch(()=>{d||l("")}),()=>{d=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function Ix({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),lh().then(d=>{l||s(d.sanitize(r,ih))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function dh(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let yo=null;function Dx(){return yo||(yo=Promise.all([Ln(()=>import("./katex-DnlPpQZa.js"),[]),Ln(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw yo=null,r})),yo}function ha({tex:r,display:n=!1}){const[s,l]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),c(!1),Dx().then(h=>{g||l(h.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||c(!0)}),()=>{g=!0}},[n,r]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const m=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:m,dangerouslySetInnerHTML:{__html:s}})}function Fo(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function Gu(r){const n=Fo(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function Fx(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Fo(s),d=l.get("src")?.trim()??"",c=d?[d]:Array.from(r.slice(n+1).matchAll(/<source\b[^>]*>/gi),x=>Fo(x[0]).get("src")?.trim()??"").filter(Boolean),m=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),g=l.get("style")?.match(/(?:^|;)\s*max-width\s*:\s*(\d+(?:\.\d+)?)px\s*(?:;|$)/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),p=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{sources:c,poster:l.get("poster"),fallbackText:p,widthPx:m?Number(m[1]):void 0,maxWidthPx:g?Number(g[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function Vl({url:r,poster:n,fallbackText:s,widthPx:l,maxWidthPx:d,hasControls:c,label:m,title:g}){const{t:h}=ht(),[p,x]=a.useState(!1),f=fa(r,()=>x(!0)),b=fa(n??"");return a.useEffect(()=>x(!1),[r]),!f&&!p?null:e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:p?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:s?.trim()||h("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:f,poster:b||void 0,"aria-label":m,title:g,style:{width:l?`${l}px`:"100%",maxWidth:d?`${d}px`:void 0},controls:c,preload:"metadata",playsInline:!0,onError:()=>x(!0)})})}function _x(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const m=r.slice(0,r.indexOf(">")+1),g=Fo(m).get("href")?.trim()??"",h=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:x,title:f,widthPx:b}=Gu(h);if(!p)return null;const E=th(p,s.markdownFilePath,s.rootPath,Ul,M=>M);if(!E)return null;const j=g?Go(g,s.markdownFilePath,s.rootPath):null,D=!!!(j&&j.path===E)&&g?qf(g):null,F=la(n,x??"",p,f,s,{requestedWidthPx:b,interactive:D?!1:void 0});return D?e.jsx("a",{href:D,target:"_blank",rel:"noreferrer",children:F},n):F}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:m,alt:g,title:h,widthPx:p}=Gu(r);return m?la(n,g??"",m,h,s,{fallbackText:r,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{sources:m,poster:g,fallbackText:h,widthPx:p,maxWidthPx:x,controls:f}=Fx(r),b=m.map(j=>ql(j,s.markdownFilePath,s.rootPath)).find(Boolean);if(!b)return null;const E=g?rh(g,s.markdownFilePath,s.rootPath):null;return e.jsx(Vl,{url:b,poster:E??void 0,fallbackText:h,widthPx:p,maxWidthPx:x,hasControls:f},n)}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx(Ix,{html:r},n):null;const d=l[1].toLowerCase(),c=ct(l[2],`${n}-${d}`,!0,s);return d==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:c},n):d==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):d==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function ct(r,n,s=!0,l){return l.budget.nested(()=>Bx(r,n,s,l))}function Bx(r,n,s=!0,l){l.budget.validateInline(r);const d=Lx(r),c=[];let m=0;for(const{index:g,token:h}of kg(d,l.budget)){g>m&&c.push(Wu(d.slice(m,g)));const p=`${n}-${g}`,x=h.startsWith("<")?_x(h,p,l):null;if(x)c.push(x);else if(h.startsWith("\\(")&&h.endsWith("\\)"))c.push(e.jsx(ha,{tex:h.slice(2,-2)},p));else if(h.startsWith("$")&&h.endsWith("$"))c.push(e.jsx(ha,{tex:h.slice(1,-1)},p));else if(h.startsWith("`")){const f=h.match(/^`+/)?.[0].length??1;c.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Tx(h.slice(f,-f))},p))}else if(h.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ct(h.slice(2,-2),`${p}-del`,s,l)},p));else if(h.startsWith("**")||h.startsWith("__"))c.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ct(h.slice(2,-2),`${p}-strong`,s,l)},p));else if(h.startsWith("*")||h.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ct(h.slice(1,-1),`${p}-em`,s,l)},p));else if(h.startsWith("![")){const f=h.match(/^!\[([^\]]*)\]\((.*)\)$/),b=h.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),E=h.match(/^!\[([^\]]+)\]$/);if(f){const j=_l(f[2]);c.push(j?la(p,f[1],j.href,j.title,l):h)}else if(b){const j=b[2]||b[1],T=l.referenceDefinitions.get(Eo(j));c.push(T?la(p,b[1],T.href,T.title,l):h)}else if(E){const j=l.referenceDefinitions.get(Eo(E[1]));c.push(j?la(p,E[1],j.href,j.title,l):h)}else c.push(h)}else if(h.startsWith("[^")){const f=Jf(h.slice(2,-1)),b=l.footnoteDefinitions.get(f);c.push(b?e.jsx("sup",{id:`fnref-${b.id}`,title:b.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${b.id}`,className:"text-primary no-underline",children:b.index})},p):h)}else if(h.startsWith("<http")){const f=h.slice(1,-1);c.push(e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p))}else if(h.startsWith("<")&&h.endsWith(">")&&zu(h.slice(1,-1))){const f=h.slice(1,-1);c.push(e.jsx("a",{href:`mailto:${f}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p))}else if(zu(ul(h).linkText)){const{linkText:f,suffix:b}=ul(h);c.push(e.jsx("a",{href:`mailto:${f}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p)),b&&c.push(b)}else if(h.startsWith("http")||h.startsWith("www.")){const{linkText:f,suffix:b}=ul(h),E=f.startsWith("www.")?`https://${f}`:f;c.push(e.jsx("a",{href:E,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p)),b&&c.push(b)}else{const f=h.match(/^\[([^\]]+)\]\((.*)\)$/),b=h.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),E=h.match(/^\[([^\]]+)\]$/),j=b?b[2]||b[1]:E?.[1]??null,T=j?l.referenceDefinitions.get(Eo(j)):null,D=f?_l(f[2]):null,F=D?.href??T?.href??null,M=F?qf(F):null,N=f?.[1]??b?.[1]??E?.[1]??"",A=M&&nh(M)?ql(M,l.markdownFilePath,l.rootPath):null,_=M?e.jsx("a",{href:M,title:D?.title??T?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ct(N,`${p}-link`,s,l)},p):h;c.push(A?e.jsxs("span",{children:[e.jsx(Vl,{url:A,label:N,title:D?.title??T?.title,hasControls:!0}),_]},p):_)}m=g+h.length}return m<d.length&&c.push(Wu(d.slice(m))),c.length>0?c:[r]}function uh(r){return/(?: {2,}|\\)$/.test(r)}function fh(r){return r.replace(/(?: {2,}|\\)$/,"")}function _o(r){return/^(?: {4}|\t)/.test(r)}function hh(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function mh(r,n,s){const l=[];return r.forEach((d,c)=>{const m=uh(d);l.push(...ct(fh(d),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Bl(r,n,s){const l=[],d=[];return r.forEach((c,m)=>{d.push(uh(c)),l.push(ct(fh(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function Ol(r,n,s,l,d){const c=[];return r.forEach((m,g)=>{const h=s[g]??0,p=!!(d&&h>=d.start&&h<=d.end);c.push(e.jsx("span",{"data-md-ref-start":h,"data-md-ref-end":h,"data-selected":p?"true":void 0,children:m},`${l}-ref-${g}`)),g<r.length-1&&c.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),c}function ma(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,m=0;for(let g=0;g<n.length;g+=1){const h=n[g];if(d){l+=h,d=!1;continue}if(h==="\\"){d=!0;continue}if(h==="`"){const p=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const x=g-p+1;l+="`".repeat(x),c===0?c=x:c===x&&(c=0);continue}if(c===0&&h==="["?m+=1:c===0&&h==="]"&&m>0&&(m-=1),h==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=h}return d&&(l+="\\"),s.push(l.trim()),s}function ph(r){return ma(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Bo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function Oo(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function gh(r,n){return r>96||r>44&&n>.35}function Ko(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function pa(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function Yl(r,n,s,l,d,c=new Set){const m=[],g=[];let h=n;for(;h<r.length;){const p=r[h];if(d&&(Do(p)||c.has(h))){h+=1;continue}const x=pa(p),f=Ko(p);if(!x){if(f>s&&g.length>0){([...g].reverse().find(T=>T.indent<f)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const T of g)T.item.lineEnd=h+1;h+=1;continue}break}if(f<s||f===s&&x.ordered!==l)break;const b={content:x.content,ordered:x.ordered,start:x.start,children:[],paragraphs:[],lineStart:h+1,lineEnd:h+1};for(;g.length>0&&g[g.length-1].indent>=f;)g.pop();const E=g[g.length-1]?.item??null;E?E.children.push(b):m.push(b),g.push({indent:f,item:b});for(const j of g)j.item.lineEnd=h+1;h+=1}return{items:m,nextIndex:h}}function Ox(r){const n=r.find(l=>pa(l));if(!n)return[];const s=pa(n);return s?Yl(r,0,Ko(n),s.ordered,!0,Zf(r)).items:[]}function Xl(r,n,s,l=0){return s.budget.nested(()=>Ux(r,n,s,l))}function Ux(r,n,s,l=0){return r.map((d,c)=>{const m=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!m,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[m?e.jsx("input",{type:"checkbox",checked:m[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ct(m?.[2]??d.content,`li-${n}-${c}`,!0,s),d.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((g,h)=>e.jsx("p",{children:ct(g,`li-${n}-${c}-p-${h}`,!0,s)},`paragraph-${h}`))})]}),groups:Hx(d.children,`${n}-${c}`,s,l)}})}function Hx(r,n,s,l=0){const d=[];for(const c of r){const m=d[d.length-1];m&&m.ordered===c.ordered?m.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,m)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:Xl(c.items,`${n}-g${m}`,s,l)}))}function Jl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&zx(s.groups,n)]},s.key)})}function zx(r,n){return r.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Jl(s.items,n)},`nested-${l}`)})}function Wx(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ct(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Gx(r,n,s,l){const d=[];let c=0;const m=g=>l?.[g]??g+1;for(;c<r.length;){s.budget.check();const g=r[c],h=g.trim();if(!h){c+=1;continue}if(/^<details>\s*$/i.test(h)){const F=c;let M="Details";const N=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const A=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);A?M=A[1].trim()||M:N.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ct(M,`${n}-details-${F}-summary`,!0,s)}),N.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:mh(N,`${n}-details-${F}`,s)})]},`${n}-details-${F}`)});continue}if(/^<video\b/i.test(h)){const F=c,M=[g];for(c+=1;!M[M.length-1].match(/<\/video\s*>/i)&&c<r.length&&r[c].trim();)s.budget.check(),M.push(r[c++]);const N=M.join(`
|
|
1639
|
+
`);d.push({kind:"static",node:e.jsx("div",{children:ct(N,`${n}-video-${F}`,!0,s)},`${n}-video-${F}`)});continue}const p=dh(g);if(p){const F=[g],M=c;for(c+=1;c<r.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(r[c]);)F.push(r[c]),c+=1;c<r.length&&!p.selfContained&&(F.push(r[c]),c+=1),d.push({kind:"static",node:e.jsx(ch,{html:F.join(`
|
|
1640
|
+
`)},`${n}-html-${M}`)});continue}const x=h.match(/^(```|~~~)\s*(.*)$/);if(x){const F=[],M=x[1],N=x[2]?.trim(),A=c;for(c+=1;c<r.length&&!r[c].trim().startsWith(M);)F.push(r[c]),c+=1;c<r.length&&(c+=1),N.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(xh,{code:F.join(`
|
|
1641
|
+
`),blockKey:`${n}-code-${A}`},`${n}-code-${A}`)}):["math","latex","tex"].includes(N.toLowerCase())?d.push({kind:"static",node:e.jsx(ha,{tex:F.join(`
|
|
1641
1642
|
`),display:!0},`${n}-code-${A}`)}):d.push({kind:"code",key:`${n}-code-${A}`,code:F.join(`
|
|
1642
|
-
`),lang:
|
|
1643
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${
|
|
1644
|
-
`).map(p=>[p||" "]);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[n&&e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("pre",{className:`${
|
|
1645
|
-
`:null]},`${s}-line-${x}`)})})})]})}function
|
|
1646
|
-
`)})});continue}const
|
|
1647
|
-
`),
|
|
1648
|
-
`),
|
|
1649
|
-
`),
|
|
1650
|
-
`)
|
|
1651
|
-
`),display:!0})});continue}if(h+1<r.length&&S&&!Ll(E)&&/^(=+|-+)\s*$/.test(r[h+1].trim())){const j=r[h+1].trim().startsWith("=")?1:2,o=`h${j}`,_=Tl(S,p),I={level:j,text:Ou(S),id:_};x.push({key:`setext-heading-${h}`,startLine:h+1,endLine:h+2,heading:I,content:e.jsx(o,{id:_,className:`scroll-mt-16 font-semibold text-foreground ${j===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:ft(S,`setext-heading-${h}`,!0,p)})}),h+=2;continue}const F=S.match(/^(#{1,6})\s+(.+)$/);if(F){const j=F[1].length,o=Yf(F[2]),_={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},I=`h${j}`,Y=Tl(o,p),H={level:j,text:Ou(o),id:Y};x.push({key:`heading-${h}`,startLine:h+1,endLine:h+1,heading:H,content:e.jsx(I,{id:Y,className:`scroll-mt-16 font-semibold text-foreground ${_[j]}`,children:ft(o,`heading-${h}`,!0,p)})}),h+=1;continue}if(Gf(E)){x.push({key:`hr-${h}`,startLine:h+1,endLine:h+1,content:e.jsx("hr",{className:"border-border/20"})}),h+=1;continue}if(S.startsWith(">")){const j=[],o=[],_=h;for(;h<r.length&&/^>\s?/.test(r[h].trim());)j.push(r[h].trim().replace(/^>\s?/,"")),o.push(h+1),h+=1;const I=j[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(I){const H=I[1].toUpperCase(),U=I[2]?.trim(),R=[...U?[U]:[],...j.slice(1)],z=[...U?[o[0]]:[],...o.slice(1)],Z=Fl(R,`callout-${_}`,p);x.push({key:`callout-${_}`,startLine:_+1,endLine:h,fineGrained:!0,content:P=>e.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:H}),R.length>0&&e.jsx("div",{children:_l(Z.perLine,Z.hardBreaks,z,`callout-${_}`,P)})]})});continue}const Y=Wx(j,`quote-${_}`,p,o);x.push({key:`quote-${_}`,startLine:_+1,endLine:h,fineGrained:!0,content:H=>e.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:Gx(Y,H)})});continue}if(h+1<r.length&&E.includes("|")&&_o(r[h+1])){const j=ha(E),o=uh(r[h+1]),_=[],I=h;for(h+=2;h<r.length&&r[h].includes("|")&&r[h].trim();)_.push(ha(r[h])),h+=1;const Y=j.map((U,R)=>ft(U,`th-${I}-${R}`,!0,p)),H=_.map((U,R)=>j.map((z,Z)=>ft(U[Z]??"",`td-${I}-${R}-${Z}`,!0,p)));x.push({key:`table-${I}`,startLine:I+1,endLine:h,interactive:!1,kind:"table",content:U=>{const R=z=>!!(U&&z>=U.start&&z<=U.end);return e.jsx("div",{className:Bf,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{"data-markdown-table-row-line":I+1,"data-md-ref-start":I+1,"data-md-ref-end":I+1,"data-selected":R(I+1)?"true":void 0,children:Y.map((z,Z)=>e.jsx("th",{className:`${Ff} ${Fo(o[Z]??null)}`,children:e.jsx("div",{className:To,children:z})},`h-${Z}`))})}),e.jsx("tbody",{children:H.map((z,Z)=>{const P=I+Z+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":P,"data-md-ref-start":P,"data-md-ref-end":P,"data-selected":R(P)?"true":void 0,children:j.map((G,J)=>e.jsx("td",{className:`${_f} ${Fo(o[J]??null)}`,children:e.jsx("div",{className:To,children:z[J]})},`c-${J}`))},`r-${Z}`)})})]})})}});continue}const $=ma(E);if($){const j=$.ordered,o=Wo(E),_=$.start,I=h,Y=ql(r,h,o,j,!0,g);h=Y.nextIndex;const H=j?"ol":"ul",U=Vl(Y.items,`list-${I}`,p);x.push({key:`list-${I}`,startLine:I+1,endLine:h,fineGrained:!0,content:R=>e.jsx(H,{start:j?_:void 0,className:`${j?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:Yl(U,R)})});continue}const C=[E.trimStart()],A=[h+1],O=h;for(h+=1;h<r.length&&r[h].trim()&&!Ll(r[h])&&!(h+1<r.length&&r[h].includes("|")&&_o(r[h+1]));){if(Io(r[h])||g.has(h)){h+=1;continue}C.push(r[h].trimStart()),A.push(h+1),h+=1}const q=Fl(C,`p-${O}`,p);x.push({key:`p-${O}`,startLine:O+1,endLine:h,fineGrained:!0,content:j=>e.jsx("p",{className:"text-muted-foreground",children:_l(q.perLine,q.hardBreaks,A,`p-${O}`,j)})})}const b=zx(p);return b&&x.push({key:"footnotes",startLine:r.length,endLine:r.length,content:b}),c.check(),{blocks:x,images:f}}function Yx(r,n,s){return Xl(r,n,s).blocks}function ph(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function gh(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Xx({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const{t:d}=ht(),c=th(r),m=jf(c),[g,f]=a.useState(null),[p,x]=a.useState(0);a.useEffect(()=>{if(!m)return;const b=new AbortController;let E;return f(null),rf(c,{signal:b.signal}).then(async S=>{if(!S.ok)throw new Error(`HTTP ${S.status}`);const T=await S.blob();b.signal.aborted||(E=URL.createObjectURL(T),f({src:c,objectUrl:E}))}).catch(()=>{b.signal.aborted||f({src:c,failed:!0})}),()=>{b.abort(),E&&URL.revokeObjectURL(E)}},[m,c,p]);const h=g?.src===c?g:null;return m&&!h?.objectUrl?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",role:h?.failed?"alert":"status",children:h?.failed?e.jsxs("div",{className:"flex flex-col items-center gap-3",onClick:b=>b.stopPropagation(),children:[e.jsx("span",{children:d("rightSidebar.imageLoadFailed")}),e.jsx("button",{type:"button",className:"rounded bg-surface-2 px-3 py-2 hover:bg-surface-elevated",onClick:()=>x(b=>b+1),children:d("common.retry")})]}):d("rightSidebar.loadingImage")}):e.jsx(Eh,{src:m?h.objectUrl:c,vector:pa(r),alt:n,onLoad:()=>{},onError:()=>{m&&f({src:c,failed:!0})},onZoomChange:s,onDoubleTap:l})}function bh({images:r,index:n,onChange:s,onClose:l}){const{t:d}=ht(),c=r[n],m=r.length>1,g=a.useRef(null),f=a.useRef(null),p=a.useRef(null),x=a.useRef(0),[h,b]=a.useState(!1),[E,S]=a.useState(0),[T,D]=a.useState(!1),[F,$]=a.useState(!1),[C,A]=a.useState(null),O=a.useRef(!1),q=async()=>{if(!(!c||O.current)){j(),O.current=!0,$(!0),A(null);try{await wg(c)}catch(U){A({image:c,message:U instanceof Error?U.message:d("rightSidebar.downloadFailed")})}finally{O.current=!1,$(!1)}}},j=a.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),o=a.useCallback(()=>{h||Date.now()<x.current||(j(),p.current=window.setTimeout(()=>{p.current=null,l()},450))},[j,h,l]),_=a.useCallback(U=>{if(r.length===0)return;const R=(U+r.length)%r.length;g.current?.slideTo(R),s(R)},[r.length,s]),I=a.useCallback(()=>_(n-1),[_,n]),Y=a.useCallback(()=>_(n+1),[_,n]);if(a.useEffect(()=>{j(),S(0),D(!1),b(!1)},[j,n]),a.useEffect(()=>{const U=g.current;U&&(U.allowTouchMove=m&&!h)},[m,h]),a.useEffect(()=>{const U=g.current;!U||U.activeIndex===n||U.slideTo(n,0)},[n]),a.useEffect(()=>j,[j]),a.useEffect(()=>{const U=R=>{if(R.key==="Escape"){R.preventDefault(),l();return}m&&(R.key==="ArrowLeft"?(R.preventDefault(),I()):R.key==="ArrowRight"&&(R.preventDefault(),Y()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[m,Y,I,l]),lf({onDrag:({movement:[U,R],pinching:z})=>{z||h||Math.abs(R)<Math.abs(U)*1.15&&E===0||(D(!0),Math.abs(R)>8&&(x.current=Date.now()+300),S(Math.max(0,R)))},onDragEnd:({movement:[U,R],velocity:[,z],pinching:Z,canceled:P})=>{if(D(!1),Z||P||h||Math.abs(R)<Math.abs(U)*1.15){S(0);return}if(Math.abs(R)>8&&(x.current=Date.now()+300),fh(R,z)){l();return}S(0)}},{target:f,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const H=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:wr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:H}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[m&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:I,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.previousImage"),title:d("common.previous"),children:e.jsx(ca,{size:17})}),e.jsx("button",{type:"button",onClick:Y,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.nextImage"),title:d("common.next"),children:e.jsx(lp,{size:17})})]}),e.jsx("button",{type:"button",onClick:()=>{q()},disabled:F,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100","aria-label":d("rightSidebar.downloadFile"),title:d("rightSidebar.downloadFile"),"aria-busy":F,children:F?e.jsx(ut,{size:17,className:"animate-spin"}):e.jsx(of,{size:17})}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:e.jsx(Lt,{size:18})})]})]}),C?.image===c&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center justify-between gap-3 bg-surface px-3 py-2 text-xs text-destructive",children:[e.jsxs("span",{className:"min-w-0 break-words",children:[d("rightSidebar.downloadFailed"),": ",C.message]}),e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-3 py-1 text-foreground hover:bg-surface-elevated",onClick:()=>{q()},disabled:F,children:d("common.retry")})]}),e.jsx("div",{ref:f,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:U=>{if(!(Date.now()<x.current)){if(U.target instanceof Element&&U.target.closest('img, [role="img"]')){o();return}j(),l()}},children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${E}px, 0) scale(${Math.max(.86,1-E/900)})`,opacity:Math.max(.35,1-E/360),transition:T?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(cf,{onSwiper:U=>{g.current=U,U.allowTouchMove=m&&!h},onSlideChange:U=>{U.activeIndex!==n&&s(U.activeIndex)},onSliderMove:()=>{j(),x.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((U,R)=>e.jsx(vl,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:U.kind==="image"?e.jsx(Xx,{src:U.src,alt:U.alt||U.title||d("rightSidebar.markdownImage"),onZoomChange:b,onDoubleTap:j}):e.jsx(f0,{svg:U.svg,title:U.title||U.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:b,onDoubleTap:j})})},`${U.kind}-${R}-${U.alt}`))})})})]})]}),document.body)}function xh({referenceLines:r=!0,content:n,filePath:s,rootPath:l,lineRange:d,onLineRangeClick:c,onLineRangeDrag:m,scrollTop:g,outlineOpen:f,outlineCloseSignal:p,onOutlineOpen:x,onOutlineClose:h,lightboxOpen:b,lightboxCloseSignal:E,onLightboxOpen:S,onLightboxClose:T,onLocalLinkOpen:D}){const{t:F}=ht(),[$,C]=a.useState(null),[A,O]=a.useState(null),[q,j]=a.useState(1),[o,_]=a.useState(null),I=a.useRef(null),Y=a.useRef(null),{blocks:H,images:U,parseError:R}=a.useMemo(()=>{try{return{...Xl(n.split(`
|
|
1652
|
-
`),s,l,M=>{O(null),C(M),S?.()},{footnotes:F("rightSidebar.footnotes"),backToFootnote:M=>F("rightSidebar.backToFootnote",{index:M})}),parseError:null}}catch(M){return{blocks:[],images:[],parseError:M instanceof Error?M.message:String(M)}}},[n,s,l,S,F]);a.useEffect(()=>{R&&Mo("markdown_error",{filePath:s,rootPath:l,error:R,fallback:"plain_text"})},[R,s,l]);const z=a.useMemo(()=>A?[...U,A]:U,[U,A]),Z=a.useCallback(M=>{O({kind:"mermaid",svg:M,alt:"Mermaid diagram",title:"Mermaid diagram"}),C(U.length),S?.()},[U.length,S]);a.useEffect(()=>{C(null),O(null)},[n,s]),a.useEffect(()=>{C(null),O(null)},[E]),a.useEffect(()=>{b||(C(null),O(null))},[b]),a.useEffect(()=>{j(1)},[n,s]),a.useLayoutEffect(()=>{const M=I.current;if(!M||H.length===0)return;const he=Array.from(M.querySelectorAll("[data-markdown-preview-block-start]"));let fe=1;const Ne=28;for(const $e of he)if($e.offsetTop-g<=Ne)fe=Number($e.dataset.markdownPreviewBlockStart)||fe;else break;j($e=>$e===fe?$e:fe)},[H,g]);const P=a.useMemo(()=>ph(H,q),[q,H]),G=a.useMemo(()=>gh(H),[H]),J=`${s??""}
|
|
1653
|
-
${n}`,ie=a.useRef(J),pe=a.useRef(null),Se=a.useRef(null),ke=a.useRef(!1);a.useEffect(()=>{ie.current!==J&&(ie.current=J,h?.())},[h,J]),a.useEffect(()=>{p!==void 0&&_(null)},[p]),a.useLayoutEffect(()=>{if(!f){_(null);return}const M=()=>{const he=Y.current;if(!he)return;const fe=he.getBoundingClientRect(),Ne=window.innerWidth;_({top:fe.bottom+6,right:Math.max(8,Ne-fe.right)})};return M(),window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[f,g,P]);const Me=a.useCallback(M=>{const he=I.current,fe=he?.closest("[data-markdown-preview-scroller]"),Ne=he?.querySelector(`[data-markdown-preview-block-start="${M.startLine}"]`);if(!fe||!Ne)return;const $e=fe.getBoundingClientRect(),rt=Ne.getBoundingClientRect(),Te=he?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,qe=rt.top-$e.top+fe.scrollTop;fe.scrollTo({top:Math.max(0,qe-Te-8),behavior:"smooth"}),j(M.startLine),h?.()},[h]),Q=a.useCallback(M=>{M.pointerType==="mouse"&&M.button!==0||pl(M.target)||(pe.current={pointerId:M.pointerId,startX:M.clientX,startY:M.clientY})},[]),ge=a.useCallback((M,he,fe)=>{const Ne=pe.current;if(pe.current=null,!Ne||Ne.pointerId!==M.pointerId)return;const $e=Math.abs(M.clientX-Ne.startX),rt=Math.abs(M.clientY-Ne.startY);if($e>8||rt>8)return;const ce=M.target;if(pl(ce)||wl())return;const Te=Xu(ce,he,fe);c(M,Te.start,Te.end)},[c]),ue=a.useCallback(M=>{pe.current?.pointerId===M.pointerId&&(pe.current=null)},[]),_e=a.useCallback((M,he)=>{const fe=I.current;if(!fe||typeof document.elementFromPoint!="function")return null;const Ne=document.elementFromPoint(M,he);if(!(Ne instanceof HTMLElement)||!fe.contains(Ne))return null;const $e=Ne.closest("[data-md-ref-start]");if($e){const De=Number($e.dataset.mdRefStart);if(Number.isFinite(De)&&De>0)return De}const rt=Ne.closest("[data-markdown-preview-block-start]");if(!rt)return null;const ce=Number(rt.dataset.markdownPreviewBlockStart),Te=H.find(De=>De.startLine===ce);if(!Te)return Number.isFinite(ce)&&ce>0?ce:null;if(Te.endLine<=Te.startLine)return Te.startLine;const qe=rt.getBoundingClientRect(),Ie=qe.height>0?Math.min(1,Math.max(0,(he-qe.top)/qe.height)):0;return Math.round(Te.startLine+Ie*(Te.endLine-Te.startLine))},[H]),Ue=a.useCallback(M=>{if(!m||M.pointerType==="mouse"&&M.button!==0)return;const he=_e(M.clientX+24,M.clientY);if(he!=null){Se.current={pointerId:M.pointerId,anchorLine:he,moved:!1};try{M.currentTarget.setPointerCapture(M.pointerId)}catch{}}},[m,_e]),W=a.useCallback(M=>{const he=Se.current;if(!he||he.pointerId!==M.pointerId||!m)return;const fe=_e(M.clientX+16,M.clientY);fe!=null&&(!he.moved&&fe===he.anchorLine||(he.moved=!0,ke.current=!0,m(M,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"move")))},[m,_e]),we=a.useCallback(M=>{const he=Se.current;if(Se.current=null,!he||he.pointerId!==M.pointerId||!m||!he.moved)return;const fe=_e(M.clientX+16,M.clientY)??he.anchorLine;m(M,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"end")},[m,_e]),ye=a.useCallback(M=>{Se.current?.pointerId===M.pointerId&&(Se.current=null)},[]),He={onPointerDown:Ue,onPointerMove:W,onPointerUp:we,onPointerCancel:ye},Ke=()=>ke.current?(ke.current=!1,!0):!1;return R?e.jsxs("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground","data-markdown-preview-fallback":!0,children:[e.jsx("p",{role:"alert",className:"mb-3 text-destructive",children:F("rightSidebar.markdownParseFailed")}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:n})]}):H.length===0?e.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:e.jsx("p",{className:"text-muted-foreground",children:F("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:I,className:"relative min-w-0 max-w-full",onClickCapture:M=>{const he=M.target instanceof Element?M.target.closest("a[href]"):null;if(!he||!D)return;const fe=he.getAttribute("href");if(!fe)return;const Ne=Wl(fe,s,l);Ne&&(M.preventDefault(),D(Ne))},children:[r&&P.length>0&&e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:P.map(M=>M.text).join(" / "),children:[e.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:P[P.length-1].text}),G.length>1&&e.jsxs("button",{ref:Y,type:"button",onClick:()=>{f?h?.():x?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${f?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":f,"aria-label":F("rightSidebar.markdownOutline"),title:F("rightSidebar.markdownOutline"),children:[e.jsx(df,{size:12}),e.jsx("span",{children:F("rightSidebar.markdownOutlineShort")})]})]})}),f&&typeof document<"u"&&wr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:h}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:o?{top:`${o.top}px`,right:`${o.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:e.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:G.map(M=>{const he=P[P.length-1]?.startLine===M.startLine;return e.jsxs("button",{type:"button",onClick:()=>Me(M),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${he?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(M.level-1,4)*12+8}px`},title:M.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",M.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:M.text})]},`desktop-${M.id}-${M.startLine}`)})})}),e.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F("rightSidebar.markdownOutlineShort")}),e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":F("rightSidebar.closeMarkdownOutline"),title:F("common.close"),children:e.jsx(Lt,{size:14})})]}),e.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:G.map(M=>{const he=P[P.length-1]?.startLine===M.startLine;return e.jsxs("button",{type:"button",onClick:()=>Me(M),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${he?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(M.level-1,4)*12+8}px`},title:M.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",M.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:M.text})]},`${M.id}-${M.startLine}`)})})]})]}),document.body),e.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:e.jsx(qf.Provider,{value:Z,children:H.map(M=>{const he=!!(d&&M.startLine<=d.end&&M.endLine>=d.start),fe=!!(d&&d.start<=M.startLine&&d.end>=M.endLine),Ne=M.kind==="table"?!1:M.fineGrained?fe:he,$e=M.kind==="table"&&d?.start===M.startLine&&d.end===M.endLine;let rt=null;if(M.kind!=="table"&&M.fineGrained&&he&&!fe&&d){const Ie=M.endLine-M.startLine+1,De=Math.max(d.start,M.startLine),te=Math.min(d.end,M.endLine),je=(De-M.startLine)/Ie,nt=(te-De+1)/Ie;rt=e.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${je})`,height:`calc((100% - 0.5rem) * ${nt})`}})}const ce=typeof M.content=="function"?M.content(d):M.content;if(!r)return e.jsx("div",{"data-markdown-preview-block-start":M.startLine,className:"min-w-0 cursor-text select-text py-0.5",children:ce},M.key);const Te=M.startLine===M.endLine?String(M.startLine):`${M.startLine}-${M.endLine}`,qe=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:fl(Ne),"aria-hidden":"true",...He,children:[e.jsx("span",{className:hl(Ne)}),rt]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:ce})]});return M.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":M.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Ne?"bg-primary/10":""}`,title:`Line ${Te}`,"aria-label":`Line ${Te}`,children:[M.kind==="table"?e.jsx("button",{type:"button",className:fl($e,"self"),onClick:Ie=>{Ie.preventDefault(),!Ke()&&c(Ie,M.startLine,M.endLine)},title:`Reference table lines ${Te}`,"aria-label":`Reference table lines ${Te}`,...He,children:e.jsx("span",{className:hl($e,"self")})}):e.jsxs("span",{className:fl(Ne,"none"),"aria-hidden":"true",...He,children:[e.jsx("span",{className:hl(Ne,"none")}),rt]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:Q,onPointerUp:Ie=>ge(Ie,M.startLine,M.endLine),onPointerCancel:ue,onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),c(Ie,M.startLine,M.endLine))},title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:ce})]},M.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":M.startLine,onClick:Ie=>{const De=Ie.target;if(pl(De)||wl()||Ke())return;const te=Xu(De,M.startLine,M.endLine);c(Ie,te.start,te.end)},onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),c(Ie,M.startLine,M.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Ne?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:qe},M.key)})})})]}),b&&$!==null&&z[$]&&e.jsx(bh,{images:z,index:$,onChange:C,onClose:()=>{C(null),O(null),T?.()}})]})}function fs({label:r,value:n,options:s,placeholder:l,searchPlaceholder:d,emptyText:c,disabled:m,onChange:g}){const{t:f}=ht(),[p,x]=a.useState(!1),[h,b]=a.useState(""),[E,S]=a.useState(null),T=a.useRef(null),D=a.useRef(null),F=h.trim().toLowerCase(),$=a.useMemo(()=>F?s.filter(j=>`${j.label} ${j.meta??""}`.toLowerCase().includes(F)):s,[F,s]),C=s.find(j=>j.value===n),A=()=>{const j=h.trim();j&&(g(j),x(!1),b(""))},O=a.useCallback(()=>{const j=T.current?.getBoundingClientRect();if(!j)return!1;const o=12,_=Math.max(220,Math.min(j.width,window.innerWidth-o*2)),I=Math.min(Math.max(o,j.left),window.innerWidth-_-o),Y=window.innerHeight-j.bottom-o,H=j.top-o,U=Y>=180||Y>=H,R=Math.max(96,(U?Y:H)-4),z=Math.min(320,R);return S({left:I,top:U?j.bottom+4:Math.max(o,j.top-z-4),width:_,maxHeight:z}),!0},[]),q=()=>{O(),x(!0)};return a.useEffect(()=>{if(!p)return;let j=0;const o=()=>{j||(j=window.requestAnimationFrame(()=>{j=0,O()}))},_=I=>{const Y=I.target;Y instanceof Node&&(T.current?.contains(Y)||D.current?.contains(Y)||(x(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",_,!0),()=>{j&&window.cancelAnimationFrame(j),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",_,!0)}},[p,O]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:T,type:"button",disabled:m,onClick:()=>{if(!m){if(b(""),p){x(!1);return}q()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:C?.label??(n||l)})]}),e.jsx(da,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${p?"rotate-180":""}`})]}),p&&!m&&typeof document<"u"&&wr.createPortal(e.jsxs("div",{ref:D,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:j=>j.stopPropagation(),style:{left:E?.left??12,top:E?.top??12,width:E?.width??260,maxHeight:E?.maxHeight??320},children:[e.jsx("div",{className:"border-b border-border/10 p-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[e.jsx(ms,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:h,onChange:j=>b(j.target.value),onKeyDown:j=>{if(j.key==="Escape"){j.preventDefault(),x(!1),b("");return}j.key==="Enter"&&(j.preventDefault(),A())},onBlur:()=>{h.trim()&&$.length===0&&A()},placeholder:d,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),e.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(E?.maxHeight??320)-46)},children:[h.trim()&&!s.some(j=>j.value===h.trim())&&e.jsxs("button",{type:"button",onMouseDown:j=>j.preventDefault(),onClick:A,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[e.jsx("span",{className:"min-w-0 truncate",children:h.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:f("common.use")})]}),$.length>0?$.map(j=>e.jsxs("button",{type:"button",onClick:()=>{g(j.value),x(!1),b("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${j.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:j.label}),j.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:j.meta})]},j.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function Wu({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:d,selectedRoots:c,onToggleRepo:m,onGenerate:g,onSecondaryAction:f,disabled:p,generateDisabled:x,secondaryDisabled:h,inserted:b,buttonLabel:E,insertedLabel:S,title:T,ariaLabel:D,scopeTitle:F,scopeLabel:$,allLabel:C,generateLabel:A,secondaryLabel:O,secondaryTitle:q,secondaryLoading:j,loading:o,error:_,statusTitle:I,extraContent:Y,renderRepoExtra:H,menuItem:U=!1}){return e.jsxs("div",{className:U?"relative w-full":"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",role:U?"menuitem":void 0,tabIndex:U?-1:void 0,onClick:R=>{s?n(!r):x||g(R.currentTarget)},disabled:p,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${U?"min-h-10 w-full gap-2.5 px-2.5 text-left text-[12px] focus:bg-surface-2 focus:outline-none [@media(pointer:coarse)]:min-h-11":"h-7 shrink-0 justify-center gap-1 px-2 text-[11px] font-medium active:scale-95"} ${_?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":U?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:I??(s?`${F}: ${$}`:T),children:[o?e.jsx(ut,{size:U?15:13,className:"shrink-0 animate-spin"}):e.jsx(ua,{size:U?15:13,className:U?"shrink-0 text-muted-foreground":void 0}),e.jsx("span",{className:U?"min-w-0 flex-1":void 0,children:b?S:E}),s&&(U?e.jsx(hs,{size:13,className:"shrink-0 text-muted-foreground"}):e.jsx(da,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),_&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:$})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Lt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[Y,e.jsxs("button",{type:"button",onClick:()=>m(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:C}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),d.map(R=>{const z=c.includes(R.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${z?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>m(R.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${z?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:R.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:R.label}),R.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:R.branch})]}),z&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),H&&(l||z)&&e.jsx("div",{className:"px-2 pb-2",children:H(R)})]},R.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${f&&O?"sm:grid-cols-2":""}`,children:[f&&O&&e.jsxs("button",{type:"button",onClick:()=>{h||(n(!1),f())},disabled:h,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:q,children:[j?e.jsx(ut,{size:12,className:"animate-spin"}):e.jsx(vf,{size:12}),O]}),e.jsxs("button",{type:"button",onClick:async R=>{if(x)return;await g(R.currentTarget)!==!1&&n(!1)},disabled:x,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:T,children:[e.jsx(ua,{size:12}),A]})]})]})}),document.body)]})}function Jx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function vh(){return gt(Ul,Jx)??{}}function Qx(r,n){const s=vh(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Gb);aa(Ul,Object.fromEntries(l),qb)}function Zx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function e0(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Zx(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Jl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function yh(){return gt(Hl,e0)??{}}function Gu(r,n){const s=Jl(r,n);return s?yh()[s]??null:null}function dl(r,n,s){const l=Jl(r,n);if(!l)return;const d=yh(),c=d[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},m=Object.entries({...d,[l]:{...c,...s,updatedAt:Date.now()}}).sort(([,g],[,f])=>f.updatedAt-g.updatedAt).slice(0,Kb);aa(Hl,Object.fromEntries(m),Vb)}function ul({slow:r}){return e.jsx(zp,{slow:r})}function ko({message:r,onRetry:n}){const{t:s}=ht();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function Eo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function wt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function So(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function t0(r,n,s){return kl(r,n,s)}function fl(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function hl(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function wh(r){const n=new Map;for(const s of r)n.set(Ql(s),s);return n}function kh(r,n){const s=new Map(r);for(const l of n)s.set(Ql(l),l);return s}function Ku(r,n){let s=0;for(const l of r){const d=bt(l,n);d&&n&&d!==n&&(s+=1)}return s}function r0(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function n0(r,n){return Array.from(kh(wh(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function s0(r,n){const s=r.relativeRoot==="."?wt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||wt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:r0(r.files)}}function Sh(r,n){const s=wt(n??"")||n||"";return r.map(l=>s0(l,n)).sort((l,d)=>s&&l.label===s?-1:s&&d.label===s?1:l.label.localeCompare(d.label))}function jh(r,n,s,l,d){const c=Uf(s),m=c.find(T=>T.root===l)??c[0]??null,g=n.find(T=>T.root===l)??null,f=g?.relativeRoot??m?.relativeRoot??".",p=g?.name??m?.name??(wt(l)||l),x=(m?.files??s.files).map(T=>({...T,repoRoot:l,repoRelativeRoot:f,repoName:p})),h=m?.context??s.context,b={...g??m??{id:l,root:l,relativeRoot:f,name:p,depth:0,nested:!!(d&&l!==d),available:s.available,files:[],context:null},...m??{},id:g?.id??m?.id??l,root:l,displayRoot:g?.displayRoot??m?.displayRoot,relativeRoot:f,name:p,depth:g?.depth??m?.depth??0,nested:g?.nested??m?.nested??!!(d&&l!==d),available:m?.available??s.available,deferred:m?.deferred??!1,files:x,context:h?{...h,root:l,changedFiles:x.map(T=>({path:T.path,absolutePath:T.absolutePath,status:T.status}))}:null,untrackedDeferred:m?.untrackedDeferred??s.untrackedDeferred,error:m?.error??s.error},E=g?n.map(T=>T.root===l?b:T):[...n,b];return{files:Array.from(r).filter(T=>bt(T,d)!==l).concat(x),repositories:E,repoFilters:Sh(E,d)}}function bt(r,n){return r.repoRoot??n}function Ql(r){return`${r.repoRoot??""}\0${r.path}`}function vr(r){return r.absolutePath||r.path}function ml(r){return Ql(r)}function a0(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function qu(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Vu(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Zs(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function ea(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function yr(r){return r instanceof DOMException&&r.name==="AbortError"}function o0(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function Yu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function pl(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function Xu(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,d=Number(l?.dataset.mdRefStart),c=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(d)&&d>0&&Number.isFinite(c)&&c>0?{start:Math.min(d,c),end:Math.max(d,c)}:{start:n,end:s}}function i0({actions:r,running:n,completed:s}){const{t:l}=ht(),[d,c]=a.useState(!1),m=a.useRef(null),g=r.find(p=>n?.action===p.key),f=r.find(p=>s?.action===p.key);return r.length===0?null:(a.useEffect(()=>{if(!d)return;const p=h=>{const b=h.target;b instanceof Node&&m.current?.contains(b)||c(!1)},x=h=>{h.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",x)}},[d]),e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),c(x=>!x)},disabled:r.every(p=>p.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${d?"bg-surface-elevated text-foreground":f?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:g?.label??f?.label??l("rightSidebar.gitQuickActions"),children:g?e.jsx(ut,{size:13,className:"animate-spin"}):f?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx($o,{size:14})}),d&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(p=>{const x=n?.action===p.key,h=s?.action===p.key;return e.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),p.onClick(),c(!1)},disabled:p.disabled||!!n,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${h?"bg-accent/10 text-accent":p.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:x?e.jsx(ut,{size:13,className:"animate-spin"}):h?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.key)})})]}))}function l0(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Rh(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&l0(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function ps(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const gl=new WeakMap;function Oo(r){const n=gl.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),gl.delete(r)},1700);gl.set(r,s)}function c0(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let d=null;for(const g of l){if(!ps(g))continue;const f=g.querySelector(s);if(f&&ps(f)){d=f;break}}if(d??=Array.from(document.querySelectorAll(s)).find(ps)??null,!d)return;const c=Rh(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),Oo(d);return}const m=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,m),behavior:"instant"}),Oo(d)}function An(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,d=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,c=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,m=[s!==null&&d?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null&&d?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"]`:null,l!==null&&c?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${c}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(S=>!!S),g=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let f=null;for(const S of g)if(ps(S)){for(const T of m){const D=S.querySelector(T);if(D&&ps(D)){f=D;break}}if(f)break}if(f??=m.flatMap(S=>Array.from(document.querySelectorAll(S))).find(ps)??null,!f){c0(r.filePath);return}const p=Rh(f);if(!p){f.scrollIntoView({block:"center",behavior:"smooth"}),Oo(f);return}const x=f.getBoundingClientRect(),h=p.getBoundingClientRect(),E=x.top-h.top+p.scrollTop-Math.max(24,(p.clientHeight-x.height)/2);p.scrollTo({top:Math.max(0,E),behavior:"instant"}),Oo(f)}const Nh=1,Zl=8;function d0(r,n=Zl){return Math.min(n,Math.max(Nh,r))}function Ch({resetKey:r,maxScale:n=Zl,onZoomChange:s,onDoubleTap:l,children:d}){const c=a.useRef(null),[m,g]=a.useState({scale:1,x:0,y:0}),[f,p]=a.useState(!1),x=a.useRef(null),h=a.useRef(new Set),b=a.useRef(!1),E=a.useRef(null),S=a.useRef(0),T=a.useRef(m);T.current=m,a.useEffect(()=>{g({scale:1,x:0,y:0})},[r]);const D=a.useCallback((A,O,q)=>{const j=c.current;if(!j)return{x:O,y:q};const o=j.firstElementChild instanceof HTMLElement?j.firstElementChild:null,_=o?.clientWidth||j.clientWidth,I=o?.clientHeight||j.clientHeight,Y=Math.max(0,(_*A-j.clientWidth)/2),H=Math.max(0,(I*A-j.clientHeight)/2);return{x:Math.min(Y,Math.max(-Y,O)),y:Math.min(H,Math.max(-H,q))}},[]),F=a.useCallback((A,O,q)=>{g(j=>{const o=d0(A,n),_=c.current;if(!_||o===1)return{scale:o,x:0,y:0};const I=_.getBoundingClientRect(),Y=(O??I.left+I.width/2)-I.left-I.width/2,H=(q??I.top+I.height/2)-I.top-I.height/2,U=o/j.scale,R=Y-(Y-j.x)*U,z=H-(H-j.y)*U;return{scale:o,...D(o,R,z)}})},[D,n]),$=a.useCallback((A,O)=>{p(!0),T.current.scale>1?g({scale:1,x:0,y:0}):F(2.5,A,O),window.setTimeout(()=>p(!1),220)},[F]);a.useEffect(()=>{const A=c.current;if(!A)return;const O=o=>{if(o.pointerType==="mouse"&&o.button!==0)return;const _=h.current.size===0;if(h.current.add(o.pointerId),_){const I=Date.now(),Y=E.current;if(Y&&I-Y.time<350&&Math.hypot(o.clientX-Y.x,o.clientY-Y.y)<24){E.current=null,S.current=I,l?.(),$(o.clientX,o.clientY);return}}if(h.current.size>1){b.current=!0,x.current=null;return}if(!(T.current.scale<=1)){o.preventDefault(),x.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:T.current.x,originY:T.current.y,moved:!1};try{A.setPointerCapture?.(o.pointerId)}catch{}p(!1)}},q=o=>{const _=x.current;if(!_||_.pointerId!==o.pointerId)return;const I=o.clientX-_.startX,Y=o.clientY-_.startY;if(!_.moved){if(Math.hypot(I,Y)<6)return;_.moved=!0}o.stopPropagation(),o.preventDefault(),g(H=>({...H,...D(H.scale,_.originX+I,_.originY+Y)}))},j=o=>{const _=x.current,I=_?.pointerId===o.pointerId&&_.moved;if(_?.pointerId===o.pointerId){_.moved&&o.stopPropagation(),x.current=null;try{A.releasePointerCapture?.(o.pointerId)}catch{}}h.current.delete(o.pointerId)&&h.current.size===0&&(!b.current&&!I&&(E.current={time:Date.now(),x:o.clientX,y:o.clientY}),b.current=!1)};return A.addEventListener("pointerdown",O,{capture:!0,passive:!1}),window.addEventListener("pointermove",q,{capture:!0,passive:!1}),window.addEventListener("pointerup",j,{capture:!0}),window.addEventListener("pointercancel",j,{capture:!0}),()=>{A.removeEventListener("pointerdown",O,{capture:!0}),window.removeEventListener("pointermove",q,{capture:!0}),window.removeEventListener("pointerup",j,{capture:!0}),window.removeEventListener("pointercancel",j,{capture:!0})}},[D,l,$]),lf({onPinch:({offset:[A],origin:[O,q]})=>{p(!1),F(A,O,q)},onWheel:({event:A,delta:[O,q],ctrlKey:j})=>{if(j){A.preventDefault(),A.stopPropagation(),p(!1),F(T.current.scale*(1-q*.01),A.clientX,A.clientY);return}T.current.scale<=1||(A.preventDefault(),A.stopPropagation(),p(!1),g(o=>({...o,...D(o.scale,o.x-O,o.y-q)})))}},{target:c,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Nh,max:n},from:()=>[T.current.scale,0],rubberband:!0}});const C=m.scale>1;return a.useEffect(()=>{s?.(C)},[s,C]),e.jsx("div",{ref:c,"data-sidebar-gesture-ignore":C?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden","data-image-zoom-viewport":!0,style:{cursor:C?"grab":"zoom-in"},onDoubleClick:A=>{A.stopPropagation(),!(Date.now()-S.current<500)&&(l?.(),$(A.clientX,A.clientY))},children:d({scale:m.scale,zoomed:C,animateTransform:f,transformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0) scale(${m.scale})`,transformOrigin:"center center",transition:f?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0)`,transformOrigin:"center center",transition:f?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Eh({src:r,alt:n,vector:s,onLoad:l,onError:d,onZoomChange:c,onDoubleTap:m}){const g=Ho(r,d),[f,p]=a.useState(null),x=s??pa(r);return a.useEffect(()=>{p(null)},[r]),e.jsx(Ch,{resetKey:r,maxScale:Math.max(Zl,f?.originalScale??1),onZoomChange:c,onDoubleTap:m,children:({vectorTransformStyle:h,scale:b,animateTransform:E})=>e.jsx("div",{"data-image-zoom-surface":!0,"data-vector-zoom-surface":x?"":void 0,className:"relative shrink-0 touch-none select-none",style:f?{...h,width:f.width,height:f.height}:{width:"100%",height:"100%"},children:e.jsx("img",{src:g,alt:n,draggable:!1,className:"touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:{position:"absolute",left:"50%",top:"50%",width:f?f.width*b:void 0,height:f?f.height*b:void 0,maxWidth:f?"none":"100%",maxHeight:f?"none":"100%",transform:"translate(-50%, -50%)",transition:E?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"},onLoad:S=>{const T=S.currentTarget,D=T.closest("[data-image-zoom-viewport]");if(D&&T.naturalWidth>0&&T.naturalHeight>0){const F=Math.max(1,D.clientWidth-2),$=Math.max(1,D.clientHeight-2),C=Math.min(F/T.naturalWidth,$/T.naturalHeight),A=x?C:Math.min(C,1);p({width:T.naturalWidth*A,height:T.naturalHeight*A,originalScale:1/A})}l(S)},onError:d})})})}function u0({svg:r,title:n,scale:s,vectorTransformStyle:l}){const d=a.useRef(null);return a.useLayoutEffect(()=>{const c=d.current,m=c?.querySelector("svg");if(!c||!m)return;const g=()=>{const x=m.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let h=x[2],b=x[3];if((!Number.isFinite(h)||!Number.isFinite(b)||h<=0||b<=0)&&(h=Number(m.getAttribute("width")),b=Number(m.getAttribute("height"))),!Number.isFinite(h)||!Number.isFinite(b)||h<=0||b<=0)return;const E=Math.max(1,c.clientWidth-24),S=Math.max(1,c.clientHeight-24),T=Math.min(E/h,S/b,1);m.style.width=`${Math.max(1,Math.floor(h*T*s))}px`,m.style.height=`${Math.max(1,Math.floor(b*T*s))}px`,m.style.maxWidth="none",m.style.maxHeight="none",m.style.transform=String(l.transform??""),m.style.transformOrigin="center center",m.style.transition=String(l.transition??"none")};g();const f=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return f?.observe(c),()=>f?.disconnect()},[s,r,l]),e.jsx("div",{ref:d,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function f0({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Ch,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:d,scale:c})=>e.jsx(u0,{svg:r,title:n,scale:c,vectorTransformStyle:d})})}let h0=0,m0=0,p0=0,g0=0,b0=0;function Mo(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function dt(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++m0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ta(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++g0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function x0(){return`diff-ui-${Date.now().toString(36)}-${(++b0).toString(36)}`}function v0(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function y0(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function Uo({onReviewReference:r,filePath:n,active:s=!0,onInsertReference:l,onInsertText:d,onInsertFeature:c,onReferenceCopied:m,onClose:g,onDirectoryLinkOpen:f,isMobile:p,markdownOutlineOpen:x,markdownOutlineCloseSignal:h,onOpenMarkdownOutline:b,onCloseMarkdownOutline:E,markdownImageLightboxOpen:S,markdownImageLightboxCloseSignal:T,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:F,lineRange:$,onLineRangeChange:C,insertedReferenceKey:A,copiedReferenceKey:O,scrollToLine:q,onScrollToLineHandled:j}){const{t:o}=ht(),_=a.useRef(null),I=a.useRef({}),Y=a.useRef(s);Y.current=s,a.useEffect(()=>{s||_.current?.querySelectorAll("video").forEach(L=>L.pause())},[s]);const H=V(L=>L.rootPath),U=V(L=>L.selectFile),[R,z]=a.useState({kind:"idle"}),[Z,P]=a.useState("schematic"),[G,J]=a.useState(null),ie=a.useRef(null),[pe,Se]=a.useState(null),ke=a.useRef(new Map),Me=a.useRef(null),[Q,ge]=a.useState(null),[ue,_e]=a.useState(()=>Tu()),[Ue,W]=a.useState(()=>wu(H,n)),we=a.useRef(null),[ye,He]=a.useState(!1),[Ke,M]=a.useState(null),[he,fe]=a.useState(0),[Ne,$e]=a.useState([]),[rt,ce]=a.useState(null),Te=a.useRef(null),qe=a.useRef(n),[Ie,De]=a.useState(null),te=tb(H&&n&&!n.startsWith("/")?`${H}/${n}`:n,s),[je,nt]=a.useState(!1),[Rt,lr]=a.useState(""),[B,ae]=a.useState([]),[Ce,et]=a.useState(0),xt=a.useRef(null),kr=xf(m),Nt=Jl(H,n);a.useEffect(()=>{if(qe.current===n)return;qe.current=n;const L=n&&H&&!n.startsWith("/")?`${H}/${n}`:n;if(Te.current===L){Te.current=null;return}Te.current=null,$e([]),ce(null),nt(!1),lr("")},[n,H]);const Ct=n?H&&!n.startsWith("/")?`${H}/${n}`:n:null,Tn=V(L=>Ct?(L.fileChangeVersions.get(Ct)??0)+L.fileWatchEpoch:L.fileWatchEpoch),gs=a.useRef(null),Sr=a.useRef(null),[zt,en]=a.useState(0),er=a.useCallback(()=>en(L=>L+1),[]);a.useEffect(()=>{const L=ie.current;return ie.current=null,J(null),L&&URL.revokeObjectURL(L.objectUrl),()=>{const K=ie.current;ie.current=null,K&&URL.revokeObjectURL(K.objectUrl)}},[Ct,Tn,zt]),a.useEffect(()=>{if(!n){gs.current=null,z({kind:"idle"});return}const L=H&&!n.startsWith("/")?`${H}/${n}`:n,K=new AbortController,be=++h0,Ee=`right-sidebar-file-preview:${be}`,st=performance.now();let Be=!1;const Ye=(re,Je={})=>{Be||(Be=!0,Mo("end",{loadingId:be,reason:re,durationMs:Math.round(performance.now()-st),filePath:n,fullPath:L,rootPath:H,...Je}))};let Oe=null;const Xe=Xm(L),mt=Xe?L.toLowerCase().endsWith(".kicad_pcb")?Z==="schematic"?"pcb-front":Z:"schematic":Z,_n=!Xe&&Bl(L),dr=!Xe&&!_n&&Jm(L),Ss=!Xe&&!_n&&!dr&&ef(L),on=Qs(L),ln=Ys(L),Kr=Xe?"eda":_n?"image":dr?"model3d":Ss?"video":"text",cn=gs.current!==L;if(gs.current=L,cn){Mo("start",{loadingId:be,filePath:n,fullPath:L,rootPath:H,mode:Kr,externalVersion:Tn}),z({kind:"loading",mode:Kr}),Sr.current=null;const re=Gu(H,n);C(re?.lineRange??null),_e(on?Tu():"source"),W(ln?wu(H,n):"source"),Xe&&P(Qm(L))}cn||z(re=>re.kind==="error"?{kind:"loading",mode:Kr}:re);const dn=window.setTimeout(()=>{Be||K.signal.aborted||Mo("still_active",{loadingId:be,filePath:n,fullPath:L,rootPath:H,mode:Kr,durationMs:Math.round(performance.now()-st),isPathChange:cn})},3e3),js=window.setTimeout(()=>{if(Be||K.signal.aborted)return;const re=Xe?o("rightSidebar.edaTimeout"):dr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";K.abort(new DOMException(re,"TimeoutError")),z({kind:"error",message:re}),Ye("stuck_timeout",{error:re})},Xe?Zm+5e3:dr?ep+5e3:tp(L)?35e3:tx);if(Xe){const re=mt==="pcb-3d"?ie.current:null;re?(z(re),Ye("eda_3d_client_cache_hit",{bytes:re.meta.size,view:re.view,mimeType:re.meta.mimeType})):rp(L,mt,K.signal,"view_file",Ee).then(Je=>{if(K.signal.aborted)return;Oe=URL.createObjectURL(Je.blob);const Dt={kind:"eda",sourcePath:Je.path||L,objectUrl:Oe,view:Je.view,meta:{size:Je.size,mimeType:Je.mimeType,modified:Je.modified}};if(Je.view==="pcb-3d"){const ur=ie.current;ur&&ur.objectUrl!==Oe&&URL.revokeObjectURL(ur.objectUrl),ie.current=Dt,J(Dt),Oe=null}z(Dt),Ye("eda_loaded",{bytes:Je.size,view:Je.view,mimeType:Je.mimeType})}).catch(Je=>{K.signal.aborted||(z({kind:"error",message:Je instanceof Error&&/timed out/i.test(Je.message)?o("rightSidebar.edaTimeout"):Je instanceof Error?Je.message:o("rightSidebar.edaLoadFailed")}),Ye("error",{error:Je instanceof Error?Je.message:String(Je)}))})}else if(_n)np(L,K.signal,"view_file",Ee).then(re=>{Oe=URL.createObjectURL(re.blob),z({kind:"image",objectUrl:Oe,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),Ye("image_loaded",{bytes:re.size,mimeType:re.mimeType})}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error?re.message:o("rightSidebar.imageLoadFailed")}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});else if(dr)sp(L,K.signal,"view_file",Ee).then(re=>{K.signal.aborted||(Oe=URL.createObjectURL(re.blob),z({kind:"model3d",sourcePath:re.path||L,objectUrl:Oe,ext:re.ext,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),Ye("model3d_loaded",{bytes:re.size,ext:re.ext}))}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error&&(re.name==="TimeoutError"||/timed out/i.test(re.message))?o("rightSidebar.model3dTimeout"):re instanceof Error?re.message:o("rightSidebar.model3dLoadFailed")}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});else if(Ss){const re=ap(L)??"",Je=tf(L);z(Dt=>Dt.kind==="video"&&Dt.url===Je?Dt:{kind:"video",url:Je,meta:{size:null,mimeType:re,modified:null}}),Ye("video_ready",{mimeType:re})}else Gd(L,K.signal,"view_file",Ee).then(re=>{if(!K.signal.aborted){if(re.binary){z({kind:"binary"});return}z({kind:"text",content:re.content,sourcePath:re.path||L,meta:{size:re.size,truncated:re.truncated}}),Ye("text_loaded",{bytes:re.size,truncated:!!re.truncated})}}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error?re.message:"Failed to read file"}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});return()=>{K.abort(),jt(Ee),window.clearTimeout(dn),window.clearTimeout(js),Oe&&URL.revokeObjectURL(Oe),Ye("cleanup")}},[n,H,Tn,zt,C,o,Z]),a.useEffect(()=>{if(R.kind!=="model3d"||!n){Se(null);return}let L=!1;const K=n.lastIndexOf("/"),be=K>=0?n.slice(K+1):n,Ee=K>=0?n.slice(0,K):"",st=Ee.lastIndexOf("/"),Be=st>=0?Ee.slice(0,st):"",Ye=be.replace(/\.(stl|glb|gltf)$/i,""),Oe=`${Be?`${Be}/`:""}features/${Ye}.json`;return Gd(Oe).then(Xe=>{if(!L)try{const mt=JSON.parse(Xe.content);Se(mt.version===1&&Array.isArray(mt.features)&&mt.features.length>0?mt.features:null)}catch{Se(null)}}).catch(()=>{L||Se(null)}),()=>{L=!0}},[R,n]),a.useEffect(()=>{if(R.kind!=="text"){De(null);return}const L=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,K=mf(L),be=R.content,Ee=Qs(L??"")&&ue==="preview",st=Ys(L??"")&&Ue==="preview";if(!K||Ee||st||!pf(be)){De(null);return}let Be=!1;const Ye=Oe=>{if(Be||!Oe.registered(K)){Be||De(null);return}try{De(bf(Oe,be,K))}catch{De(null)}};return Ke?Ye(Ke):(De(null),gf().then(Oe=>{Be||(M(Oe),Ye(Oe))}).catch(()=>{})),()=>{Be=!0}},[R,Ke,n,H,ue,Ue]),a.useLayoutEffect(()=>{if(!Nt||R.kind!=="text")return;const L=`${Nt}:${ue}:${Ue}`;if(Sr.current===L)return;const K=Gu(H,n);if(Sr.current=L,!K)return;const be=requestAnimationFrame(()=>{const Ee=Me.current;if(!Ee)return;const st=ue==="preview"?K.markdownTop??K.top:K.top;Ee.scrollTo({top:Math.max(0,st??0),left:Math.max(0,K.left??0)}),fe(ue==="preview"?Math.max(0,st??0):0)});return()=>cancelAnimationFrame(be)},[n,ue,Ue,R.kind,Nt,H]),a.useEffect(()=>{Nt&&dl(H,n,{lineRange:$})},[n,$,Nt,H]),a.useEffect(()=>{if(q==null||R.kind!=="text")return;ge(null),C({start:q,end:q});const L=q,K=requestAnimationFrame(()=>{const be=ke.current.get(L);be&&be.scrollIntoView({block:"center"}),j?.()});return()=>cancelAnimationFrame(K)},[q,R,C,j]);const In=a.useCallback(L=>{const K=Me.current;if(!K)return!1;const be=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(L):L.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Ee=K.querySelector(`#${be}`);return Ee?(Ee.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const L=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,K=R.kind==="text"&&Qs(L??"")&&ue==="preview";if(!rt||!K)return;const be=requestAnimationFrame(()=>{In(rt)&&ce(null)});return()=>cancelAnimationFrame(be)},[n,In,ue,rt,R,H]),a.useLayoutEffect(()=>{const L=Me.current;if(!L||!$){ge(null);return}if(Q)return;const K=R.kind==="image"||R.kind==="loading"&&R.mode==="image",be=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,Ee=R.kind==="text"&&Qs(be??"")&&ue==="preview",st=R.kind==="text"&&Ys(be??"")&&Ue==="preview";if(R.kind!=="text"||K||Ee||st){ge(null);return}const Be=()=>{const Oe=ke.current.get($.end);if(!Oe||!L){ge(null);return}const Xe=Oe.offsetTop+Oe.offsetHeight/2,mt=L.scrollLeft+Math.max(8,L.clientWidth-120);ge({top:Xe,left:mt})};Be();const Ye=new ResizeObserver(()=>Be());return Ye.observe(L),()=>Ye.disconnect()},[$,Q,R,ue,Ue,n,H,Ie]);const jr=R.kind==="text"&&!(Ys(Ct??"")&&Ue==="preview")&&!Ct?.toLowerCase().endsWith(".csv")&&!Ct?.toLowerCase().endsWith(".kicad_pro")&&!Ct?.toLowerCase().endsWith(".kicad_prl"),Dn=a.useCallback(()=>{nt(!1),lr(""),ae([]),et(0),xo(I.current)},[]),tn=a.useCallback(()=>{!s||!jr||(nt(!0),requestAnimationFrame(()=>{const L=_.current;!Y.current||!L?.isConnected||L.closest('[inert], [aria-hidden="true"], [hidden]')||L.getClientRects().length===0||getComputedStyle(L).visibility==="hidden"||!L.contains(document.activeElement)||(xt.current?.focus(),xt.current?.select())}))},[s,jr]),Or=a.useCallback(L=>{et(K=>B.length===0?0:(K+L+B.length)%B.length)},[B.length]),Wt=a.useCallback(L=>{if(L.nativeEvent.isComposing||!Db(_.current,s,L))return;const K=Fb(L);if(K==="open"&&jr){L.preventDefault(),tn();return}je&&(K==="close"?(L.preventDefault(),Dn()):(K==="next"||K==="previous")&&(L.preventDefault(),Or(K==="previous"?-1:1)))},[s,Dn,je,Or,tn,jr]);if(a.useLayoutEffect(()=>{if(xo(I.current),!s||!je||!Rt.trim()||!Me.current){ae([]),et(0);return}const L=Bb(Me.current,Rt);return ae(L),et(0),(_.current?.contains(document.activeElement)||Ru(I.current))&&(rl(L,0,I.current),Nu(L[0])),()=>xo(I.current)},[s,je,Rt,Ie,ue,R]),a.useEffect(()=>{!s||!je||!Rt.trim()||!_.current?.contains(document.activeElement)&&!Ru(I.current)||(rl(B,Ce,I.current),Nu(B[Ce]))},[s,Ce,B,je,Rt]),a.useEffect(()=>()=>xo(I.current),[]),!n)return e.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.selectFilePrompt")});const Ve=H&&!n.startsWith("/")?`${H}/${n}`:n,Tt=Eo(Ve,H),Rr=af(Ve,H),Nr=R.kind==="text"&&R.content?R.content.split(`
|
|
1654
|
-
`):[],ga=Math.max(2,String(Nr.length).length)+1,Cr=R.kind==="text"||R.kind==="image"||R.kind==="model3d"||R.kind==="video"||R.kind==="eda"?R.meta:null,Er=Qs(Ve),ba=Ve.toLowerCase().endsWith(".csv"),It=Ve.toLowerCase().endsWith(".kicad_pro"),bs=Ve.toLowerCase().endsWith(".kicad_prl"),Gt=R.kind==="text"&&Er&&ue==="preview",xa=Ys(Ve),Kt=R.kind==="text"&&xa&&Ue==="preview",va=R.kind==="image"||R.kind==="loading"&&R.mode==="image",Go=R.kind==="model3d"||R.kind==="loading"&&R.mode==="model3d",kt=R.kind==="video"||R.kind==="loading"&&R.mode==="video",rn=R.kind==="eda"||R.kind==="loading"&&R.mode==="eda",xs=R.kind==="text"?R.sourcePath:Ve,Ur=$p(xs,H,$),Hr=(()=>{if(!$||R.kind!=="text"||Nr.length===0)return Ur;const L=[];for(let Ee=$.start;Ee<=$.end;Ee+=1)L.push(`${Ee} ${Nr[Ee-1]??""}`);const K=Wf(Ve).replace(/^\./,""),be="```";return`${Ur}
|
|
1643
|
+
`),lang:N,blockKey:`${n}-code-${A}`,codeStartLine:m(A)+1});continue}if(_o(g)){const F=[],M=c;for(;c<r.length&&(_o(r[c])||!r[c].trim());)F.push(r[c].trim()?hh(r[c]):""),c+=1;d.push({kind:"code",key:`${n}-indented-code-${M}`,code:F.join(`
|
|
1644
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${M}`,codeStartLine:m(M)});continue}const f=h.match(/^(#{1,6})\s+(.+)$/);if(f){const M=`h${Math.min(6,f[1].length+1)}`,N=Xf(f[2]),A=Dl(N,s);d.push({kind:"static",node:e.jsx(M,{id:A,className:"scroll-mt-16 font-semibold text-foreground",children:ct(N,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<r.length&&g.includes("|")&&Oo(r[c+1])){const F=ma(g),M=ph(r[c+1]),N=[],A=c;for(c+=2;c<r.length&&r[c].includes("|")&&r[c].trim();)N.push(ma(r[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:Of,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:F.map((_,q)=>e.jsx("th",{className:`${_f} ${Bo(M[q]??null)}`,children:e.jsx("div",{className:Io,children:ct(_,`${n}-th-${A}-${q}`,!0,s)})},`h-${q}`))})}),e.jsx("tbody",{children:N.map((_,q)=>e.jsx("tr",{className:"border-t border-border/10",children:F.map((S,o)=>e.jsx("td",{className:`${Bf} ${Bo(M[o]??null)}`,children:e.jsx("div",{className:Io,children:ct(_[o]??"",`${n}-td-${A}-${q}-${o}`,!0,s)})},`c-${o}`))},`r-${q}`))})]})},`${n}-table-${A}`)});continue}const b=pa(g);if(b){const F=b.ordered,M=Ko(g),N=b.start,A=c,_=Yl(r,c,M,F,!1);c=_.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${A}`,ordered:F,start:F?N:void 0,renders:Xl(_.items,`${n}-list-${A}`,s,m(0)-1)});continue}const E=[g.trimStart()],j=[m(c)],T=c;for(c+=1;c<r.length&&r[c].trim()&&!Il(r[c])&&!(c+1<r.length&&r[c].includes("|")&&Oo(r[c+1]));)E.push(r[c].trimStart()),j.push(m(c)),c+=1;const D=Bl(E,`${n}-p-${T}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${T}`,perLine:D.perLine,hardBreaks:D.hardBreaks,lineNums:j})}return d}function Kx(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:Ol(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,n)},s.keyPrefix);case"list":{const l=s.ordered?"ol":"ul";return e.jsx(l,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:Jl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Uo,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}const ko=16,bh=192;function qx(r){const n=r.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return r;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=l;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return r;const m=Math.max(bh,Math.ceil(d)),g=Math.ceil(m/d*c);return r.replace(/<svg\b([^>]*)>/i,(h,p)=>`<svg${p.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${m}" height="${g}">`)}function Vx(r){const n=r?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-ko,d=s.y-ko,c=s.width+ko*2,m=s.height+ko*2,g=Math.max(bh,Math.ceil(c)),h=Math.ceil(g/c*m);n.setAttribute("viewBox",`${l} ${d} ${c} ${m}`),n.setAttribute("width",String(g)),n.setAttribute("height",String(h)),n.removeAttribute("style")}function Yx(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return pf(`code.${s}`)??s}function xh({code:r,blockKey:n}){const{t:s}=ht(),[l,d]=a.useState(null),[c,m]=a.useState(!1),g=a.useRef(null),h=a.useContext(Vf);a.useEffect(()=>{let x=!1;return d(null),m(!1),Ng().then(async f=>{Cg(f);const b=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:E}=await f.render(b,r);x||d(qx(E))}).catch(()=>{x||m(!0)}),()=>{x=!0}},[n,r]),a.useLayoutEffect(()=>{l&&Vx(g.current)},[l]);const p=a.useCallback(()=>{const x=g.current?.querySelector("svg")?.outerHTML??l;x&&h?.(x)},[h,l]);return c?e.jsx(Uo,{code:r,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:x=>{x.stopPropagation(),p()},children:e.jsx("span",{ref:g,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:l}})}):e.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function Uo({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Yx(n),[m,g]=a.useState(null);a.useEffect(()=>{if(!c||!gf(r)){g(null);return}let p=!1;return bf().then(x=>{if(p||!x.registered(c)){p||g(null);return}try{g(xf(x,r,c))}catch{p||g(null)}}).catch(()=>{p||g(null)}),()=>{p=!0}},[s,r,c]);const h=m??(r||" ").split(`
|
|
1645
|
+
`).map(p=>[p||" "]);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[n&&e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("pre",{className:`${Kl} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:h.map((p,x)=>{const f=l!=null?l+x:null,b=!!(d&&f!=null&&f>=d.start&&f<=d.end);return e.jsxs("span",{"data-md-ref-start":f??void 0,"data-md-ref-end":f??void 0,"data-selected":b?"true":void 0,children:[p,x<h.length-1?`
|
|
1646
|
+
`:null]},`${s}-line-${x}`)})})})]})}function Ql(r,n,s,l,d){const c=new wg;c.validateLines(r),r=Ex(r);const m=Nx(r),g=Zf(r),h=[],p={budget:c,markdownFilePath:n,rootPath:s,referenceDefinitions:m,footnoteDefinitions:Cx(r),headingSlugCounts:new Map,images:h,onImageOpen:l,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(E=>`Back to footnote ${E}`)},x=[];let f=0;for(;f<r.length;){p.budget.check();const E=r[f],j=E.trim();if(Do(E)||g.has(f)){f+=1;continue}if(!j){f+=1;continue}if(/^<details>\s*$/i.test(j)){const S=f;let o="Details";const B=[];for(f+=1;f<r.length&&!/^<\/details>\s*$/i.test(r[f].trim());){const I=r[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);I?o=I[1].trim()||o:B.push(r[f].trimStart()),f+=1}f<r.length&&(f+=1),x.push({key:`details-${S}`,startLine:S+1,endLine:f,content:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ct(o,`details-${S}-summary`,!0,p)}),B.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:mh(B,`details-${S}`,p)})]})});continue}if(/^<video\b/i.test(j)){const S=f,o=[E];for(f+=1;!/<\/video\s*>/i.test(o[o.length-1])&&f<r.length&&r[f].trim();)p.budget.check(),o.push(r[f++]);x.push({key:`video-${S}`,startLine:S+1,endLine:f,content:e.jsx("div",{children:ct(o.join(`
|
|
1647
|
+
`),`video-${S}`,!0,p)})});continue}const T=dh(E);if(T){const S=[E],o=f;for(f+=1;f<r.length&&!T.selfContained&&!new RegExp(`</${T.tag}>`,"i").test(r[f]);)S.push(r[f]),f+=1;f<r.length&&!T.selfContained&&(S.push(r[f]),f+=1),x.push({key:`html-${o}`,startLine:o+1,endLine:f,content:e.jsx(ch,{html:S.join(`
|
|
1648
|
+
`)})});continue}const D=j.match(/^(```|~~~)\s*(.*)$/);if(D){const S=[],o=D[1],B=D[2]?.trim(),I=f;for(f+=1;f<r.length&&!r[f].trim().startsWith(o);)S.push(r[f]),f+=1;f<r.length&&(f+=1),x.push({key:`code-${I}`,startLine:I+1,endLine:f,fineGrained:B.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(B.toLowerCase()),content:B.toLowerCase()==="mermaid"?e.jsx(xh,{code:S.join(`
|
|
1649
|
+
`),blockKey:`code-${I}`}):["math","latex","tex"].includes(B.toLowerCase())?e.jsx(ha,{tex:S.join(`
|
|
1650
|
+
`),display:!0}):Y=>e.jsx(Uo,{code:S.join(`
|
|
1651
|
+
`),lang:B,blockKey:`code-${I}`,codeStartLine:I+2,lineRange:Y})});continue}if(_o(E)){const S=[],o=f;for(f+=0;f<r.length&&(_o(r[f])||!r[f].trim());)S.push(r[f].trim()?hh(r[f]):""),f+=1;x.push({key:`indented-code-${o}`,startLine:o+1,endLine:f,fineGrained:!0,content:B=>e.jsx(Uo,{code:S.join(`
|
|
1652
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${o}`,codeStartLine:o+1,lineRange:B})});continue}if(j.startsWith("$$")){const S=[],o=f,B=j.replace(/^\$\$\s*/,"");if(B.endsWith("$$")&&B.length>2)S.push(B.replace(/\s*\$\$$/,"")),f+=1;else{for(B&&S.push(B),f+=1;f<r.length&&!r[f].trim().endsWith("$$");)S.push(r[f]),f+=1;if(f<r.length){const I=r[f].trim().replace(/\s*\$\$$/,"");I&&S.push(I),f+=1}}x.push({key:`math-${o}`,startLine:o+1,endLine:f,content:e.jsx(ha,{tex:S.join(`
|
|
1653
|
+
`),display:!0})});continue}if(f+1<r.length&&j&&!Il(E)&&/^(=+|-+)\s*$/.test(r[f+1].trim())){const S=r[f+1].trim().startsWith("=")?1:2,o=`h${S}`,B=Dl(j,p),I={level:S,text:Hu(j),id:B};x.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:I,content:e.jsx(o,{id:B,className:`scroll-mt-16 font-semibold text-foreground ${S===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:ct(j,`setext-heading-${f}`,!0,p)})}),f+=2;continue}const F=j.match(/^(#{1,6})\s+(.+)$/);if(F){const S=F[1].length,o=Xf(F[2]),B={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},I=`h${S}`,Y=Dl(o,p),H={level:S,text:Hu(o),id:Y};x.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:H,content:e.jsx(I,{id:Y,className:`scroll-mt-16 font-semibold text-foreground ${B[S]}`,children:ct(o,`heading-${f}`,!0,p)})}),f+=1;continue}if(Kf(E)){x.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(j.startsWith(">")){const S=[],o=[],B=f;for(;f<r.length&&/^>\s?/.test(r[f].trim());)S.push(r[f].trim().replace(/^>\s?/,"")),o.push(f+1),f+=1;const I=S[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(I){const H=I[1].toUpperCase(),U=I[2]?.trim(),R=[...U?[U]:[],...S.slice(1)],z=[...U?[o[0]]:[],...o.slice(1)],Z=Bl(R,`callout-${B}`,p);x.push({key:`callout-${B}`,startLine:B+1,endLine:f,fineGrained:!0,content:P=>e.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:H}),R.length>0&&e.jsx("div",{children:Ol(Z.perLine,Z.hardBreaks,z,`callout-${B}`,P)})]})});continue}const Y=Gx(S,`quote-${B}`,p,o);x.push({key:`quote-${B}`,startLine:B+1,endLine:f,fineGrained:!0,content:H=>e.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:Kx(Y,H)})});continue}if(f+1<r.length&&E.includes("|")&&Oo(r[f+1])){const S=ma(E),o=ph(r[f+1]),B=[],I=f;for(f+=2;f<r.length&&r[f].includes("|")&&r[f].trim();)B.push(ma(r[f])),f+=1;const Y=S.map((U,R)=>ct(U,`th-${I}-${R}`,!0,p)),H=B.map((U,R)=>S.map((z,Z)=>ct(U[Z]??"",`td-${I}-${R}-${Z}`,!0,p)));x.push({key:`table-${I}`,startLine:I+1,endLine:f,interactive:!1,kind:"table",content:U=>{const R=z=>!!(U&&z>=U.start&&z<=U.end);return e.jsx("div",{className:Of,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{"data-markdown-table-row-line":I+1,"data-md-ref-start":I+1,"data-md-ref-end":I+1,"data-selected":R(I+1)?"true":void 0,children:Y.map((z,Z)=>e.jsx("th",{className:`${_f} ${Bo(o[Z]??null)}`,children:e.jsx("div",{className:Io,children:z})},`h-${Z}`))})}),e.jsx("tbody",{children:H.map((z,Z)=>{const P=I+Z+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":P,"data-md-ref-start":P,"data-md-ref-end":P,"data-selected":R(P)?"true":void 0,children:S.map((G,J)=>e.jsx("td",{className:`${Bf} ${Bo(o[J]??null)}`,children:e.jsx("div",{className:Io,children:z[J]})},`c-${J}`))},`r-${Z}`)})})]})})}});continue}const M=pa(E);if(M){const S=M.ordered,o=Ko(E),B=M.start,I=f,Y=Yl(r,f,o,S,!0,g);f=Y.nextIndex;const H=S?"ol":"ul",U=Xl(Y.items,`list-${I}`,p);x.push({key:`list-${I}`,startLine:I+1,endLine:f,fineGrained:!0,content:R=>e.jsx(H,{start:S?B:void 0,className:`${S?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:Jl(U,R)})});continue}const N=[E.trimStart()],A=[f+1],_=f;for(f+=1;f<r.length&&r[f].trim()&&!Il(r[f])&&!(f+1<r.length&&r[f].includes("|")&&Oo(r[f+1]));){if(Do(r[f])||g.has(f)){f+=1;continue}N.push(r[f].trimStart()),A.push(f+1),f+=1}const q=Bl(N,`p-${_}`,p);x.push({key:`p-${_}`,startLine:_+1,endLine:f,fineGrained:!0,content:S=>e.jsx("p",{className:"text-muted-foreground",children:Ol(q.perLine,q.hardBreaks,A,`p-${_}`,S)})})}const b=Wx(p);return b&&x.push({key:"footnotes",startLine:r.length,endLine:r.length,content:b}),c.check(),{blocks:x,images:h}}function Xx(r,n,s){return Ql(r,n,s).blocks}function vh(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function wh(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Jx({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const{t:d}=ht(),c=ah(r),m=Rf(c),[g,h]=a.useState(null),[p,x]=a.useState(0);a.useEffect(()=>{if(!m)return;const b=new AbortController;let E;return h(null),nf(c,{signal:b.signal}).then(async j=>{if(!j.ok)throw new Error(`HTTP ${j.status}`);const T=await j.blob();b.signal.aborted||(E=URL.createObjectURL(T),h({src:c,objectUrl:E}))}).catch(()=>{b.signal.aborted||h({src:c,failed:!0})}),()=>{b.abort(),E&&URL.revokeObjectURL(E)}},[m,c,p]);const f=g?.src===c?g:null;return m&&!f?.objectUrl?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",role:f?.failed?"alert":"status",children:f?.failed?e.jsxs("div",{className:"flex flex-col items-center gap-3",onClick:b=>b.stopPropagation(),children:[e.jsx("span",{children:d("rightSidebar.imageLoadFailed")}),e.jsx("button",{type:"button",className:"rounded bg-surface-2 px-3 py-2 hover:bg-surface-elevated",onClick:()=>x(b=>b+1),children:d("common.retry")})]}):d("rightSidebar.loadingImage")}):e.jsx(Ah,{src:m?f.objectUrl:c,vector:ga(r),alt:n,onLoad:()=>{},onError:()=>{m&&h({src:c,failed:!0})},onZoomChange:s,onDoubleTap:l})}function yh({images:r,index:n,onChange:s,onClose:l}){const{t:d}=ht(),c=r[n],m=r.length>1,g=a.useRef(null),h=a.useRef(null),p=a.useRef(null),x=a.useRef(0),[f,b]=a.useState(!1),[E,j]=a.useState(0),[T,D]=a.useState(!1),[F,M]=a.useState(!1),[N,A]=a.useState(null),_=a.useRef(!1),q=async()=>{if(!(!c||_.current)){S(),_.current=!0,M(!0),A(null);try{await Rg(c)}catch(U){A({image:c,message:U instanceof Error?U.message:d("rightSidebar.downloadFailed")})}finally{_.current=!1,M(!1)}}},S=a.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),o=a.useCallback(()=>{f||Date.now()<x.current||(S(),p.current=window.setTimeout(()=>{p.current=null,l()},450))},[S,f,l]),B=a.useCallback(U=>{if(r.length===0)return;const R=(U+r.length)%r.length;g.current?.slideTo(R),s(R)},[r.length,s]),I=a.useCallback(()=>B(n-1),[B,n]),Y=a.useCallback(()=>B(n+1),[B,n]);if(a.useEffect(()=>{S(),j(0),D(!1),b(!1)},[S,n]),a.useEffect(()=>{const U=g.current;U&&(U.allowTouchMove=m&&!f)},[m,f]),a.useEffect(()=>{const U=g.current;!U||U.activeIndex===n||U.slideTo(n,0)},[n]),a.useEffect(()=>S,[S]),a.useEffect(()=>{const U=R=>{if(R.key==="Escape"){R.preventDefault(),l();return}m&&(R.key==="ArrowLeft"?(R.preventDefault(),I()):R.key==="ArrowRight"&&(R.preventDefault(),Y()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[m,Y,I,l]),cf({onDrag:({movement:[U,R],pinching:z})=>{z||f||Math.abs(R)<Math.abs(U)*1.15&&E===0||(D(!0),Math.abs(R)>8&&(x.current=Date.now()+300),j(Math.max(0,R)))},onDragEnd:({movement:[U,R],velocity:[,z],pinching:Z,canceled:P})=>{if(D(!1),Z||P||f||Math.abs(R)<Math.abs(U)*1.15){j(0);return}if(Math.abs(R)>8&&(x.current=Date.now()+300),gh(R,z)){l();return}j(0)}},{target:h,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const H=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:yr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:H}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[m&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:I,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.previousImage"),title:d("common.previous"),children:e.jsx(ca,{size:17})}),e.jsx("button",{type:"button",onClick:Y,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.nextImage"),title:d("common.next"),children:e.jsx(fp,{size:17})})]}),e.jsx("button",{type:"button",onClick:()=>{q()},disabled:F,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100","aria-label":d("rightSidebar.downloadFile"),title:d("rightSidebar.downloadFile"),"aria-busy":F,children:F?e.jsx(ft,{size:17,className:"animate-spin"}):e.jsx(lf,{size:17})}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:e.jsx(Lt,{size:18})})]})]}),N?.image===c&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center justify-between gap-3 bg-surface px-3 py-2 text-xs text-destructive",children:[e.jsxs("span",{className:"min-w-0 break-words",children:[d("rightSidebar.downloadFailed"),": ",N.message]}),e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-3 py-1 text-foreground hover:bg-surface-elevated",onClick:()=>{q()},disabled:F,children:d("common.retry")})]}),e.jsx("div",{ref:h,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:U=>{if(!(Date.now()<x.current)){if(U.target instanceof Element&&U.target.closest('img, [role="img"]')){o();return}S(),l()}},children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${E}px, 0) scale(${Math.max(.86,1-E/900)})`,opacity:Math.max(.35,1-E/360),transition:T?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(df,{onSwiper:U=>{g.current=U,U.allowTouchMove=m&&!f},onSlideChange:U=>{U.activeIndex!==n&&s(U.activeIndex)},onSliderMove:()=>{S(),x.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((U,R)=>e.jsx(yl,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:U.kind==="image"?e.jsx(Jx,{src:U.src,alt:U.alt||U.title||d("rightSidebar.markdownImage"),onZoomChange:b,onDoubleTap:S}):e.jsx(h0,{svg:U.svg,title:U.title||U.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:b,onDoubleTap:S})})},`${U.kind}-${R}-${U.alt}`))})})})]})]}),document.body)}function kh({referenceLines:r=!0,content:n,filePath:s,rootPath:l,lineRange:d,onLineRangeClick:c,onLineRangeDrag:m,scrollTop:g,outlineOpen:h,outlineCloseSignal:p,onOutlineOpen:x,onOutlineClose:f,lightboxOpen:b,lightboxCloseSignal:E,onLightboxOpen:j,onLightboxClose:T,onLocalLinkOpen:D}){const{t:F}=ht(),[M,N]=a.useState(null),[A,_]=a.useState(null),[q,S]=a.useState(1),[o,B]=a.useState(null),I=a.useRef(null),Y=a.useRef(null),{blocks:H,images:U,parseError:R}=a.useMemo(()=>{try{return{...Ql(n.split(`
|
|
1654
|
+
`),s,l,$=>{_(null),N($),j?.()},{footnotes:F("rightSidebar.footnotes"),backToFootnote:$=>F("rightSidebar.backToFootnote",{index:$})}),parseError:null}}catch($){return{blocks:[],images:[],parseError:$ instanceof Error?$.message:String($)}}},[n,s,l,j,F]);a.useEffect(()=>{R&&$o("markdown_error",{filePath:s,rootPath:l,error:R,fallback:"plain_text"})},[R,s,l]);const z=a.useMemo(()=>A?[...U,A]:U,[U,A]),Z=a.useCallback($=>{_({kind:"mermaid",svg:$,alt:"Mermaid diagram",title:"Mermaid diagram"}),N(U.length),j?.()},[U.length,j]);a.useEffect(()=>{N(null),_(null)},[n,s]),a.useEffect(()=>{N(null),_(null)},[E]),a.useEffect(()=>{b||(N(null),_(null))},[b]),a.useEffect(()=>{S(1)},[n,s]),a.useLayoutEffect(()=>{const $=I.current;if(!$||H.length===0)return;const he=Array.from($.querySelectorAll("[data-markdown-preview-block-start]"));let fe=1;const Ne=28;for(const $e of he)if($e.offsetTop-g<=Ne)fe=Number($e.dataset.markdownPreviewBlockStart)||fe;else break;S($e=>$e===fe?$e:fe)},[H,g]);const P=a.useMemo(()=>vh(H,q),[q,H]),G=a.useMemo(()=>wh(H),[H]),J=`${s??""}
|
|
1655
|
+
${n}`,ie=a.useRef(J),pe=a.useRef(null),Se=a.useRef(null),ke=a.useRef(!1);a.useEffect(()=>{ie.current!==J&&(ie.current=J,f?.())},[f,J]),a.useEffect(()=>{p!==void 0&&B(null)},[p]),a.useLayoutEffect(()=>{if(!h){B(null);return}const $=()=>{const he=Y.current;if(!he)return;const fe=he.getBoundingClientRect(),Ne=window.innerWidth;B({top:fe.bottom+6,right:Math.max(8,Ne-fe.right)})};return $(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[h,g,P]);const Me=a.useCallback($=>{const he=I.current,fe=he?.closest("[data-markdown-preview-scroller]"),Ne=he?.querySelector(`[data-markdown-preview-block-start="${$.startLine}"]`);if(!fe||!Ne)return;const $e=fe.getBoundingClientRect(),rt=Ne.getBoundingClientRect(),Te=he?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,qe=rt.top-$e.top+fe.scrollTop;fe.scrollTo({top:Math.max(0,qe-Te-8),behavior:"smooth"}),S($.startLine),f?.()},[f]),Q=a.useCallback($=>{$.pointerType==="mouse"&&$.button!==0||bl($.target)||(pe.current={pointerId:$.pointerId,startX:$.clientX,startY:$.clientY})},[]),ge=a.useCallback(($,he,fe)=>{const Ne=pe.current;if(pe.current=null,!Ne||Ne.pointerId!==$.pointerId)return;const $e=Math.abs($.clientX-Ne.startX),rt=Math.abs($.clientY-Ne.startY);if($e>8||rt>8)return;const ce=$.target;if(bl(ce)||Sl())return;const Te=Qu(ce,he,fe);c($,Te.start,Te.end)},[c]),ue=a.useCallback($=>{pe.current?.pointerId===$.pointerId&&(pe.current=null)},[]),_e=a.useCallback(($,he)=>{const fe=I.current;if(!fe||typeof document.elementFromPoint!="function")return null;const Ne=document.elementFromPoint($,he);if(!(Ne instanceof HTMLElement)||!fe.contains(Ne))return null;const $e=Ne.closest("[data-md-ref-start]");if($e){const De=Number($e.dataset.mdRefStart);if(Number.isFinite(De)&&De>0)return De}const rt=Ne.closest("[data-markdown-preview-block-start]");if(!rt)return null;const ce=Number(rt.dataset.markdownPreviewBlockStart),Te=H.find(De=>De.startLine===ce);if(!Te)return Number.isFinite(ce)&&ce>0?ce:null;if(Te.endLine<=Te.startLine)return Te.startLine;const qe=rt.getBoundingClientRect(),Ie=qe.height>0?Math.min(1,Math.max(0,(he-qe.top)/qe.height)):0;return Math.round(Te.startLine+Ie*(Te.endLine-Te.startLine))},[H]),Ue=a.useCallback($=>{if(!m||$.pointerType==="mouse"&&$.button!==0)return;const he=_e($.clientX+24,$.clientY);if(he!=null){Se.current={pointerId:$.pointerId,anchorLine:he,moved:!1};try{$.currentTarget.setPointerCapture($.pointerId)}catch{}}},[m,_e]),W=a.useCallback($=>{const he=Se.current;if(!he||he.pointerId!==$.pointerId||!m)return;const fe=_e($.clientX+16,$.clientY);fe!=null&&(!he.moved&&fe===he.anchorLine||(he.moved=!0,ke.current=!0,m($,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"move")))},[m,_e]),ye=a.useCallback($=>{const he=Se.current;if(Se.current=null,!he||he.pointerId!==$.pointerId||!m||!he.moved)return;const fe=_e($.clientX+16,$.clientY)??he.anchorLine;m($,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"end")},[m,_e]),we=a.useCallback($=>{Se.current?.pointerId===$.pointerId&&(Se.current=null)},[]),He={onPointerDown:Ue,onPointerMove:W,onPointerUp:ye,onPointerCancel:we},Ke=()=>ke.current?(ke.current=!1,!0):!1;return R?e.jsxs("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground","data-markdown-preview-fallback":!0,children:[e.jsx("p",{role:"alert",className:"mb-3 text-destructive",children:F("rightSidebar.markdownParseFailed")}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:n})]}):H.length===0?e.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:e.jsx("p",{className:"text-muted-foreground",children:F("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:I,className:"relative min-w-0 max-w-full",onClickCapture:$=>{const he=$.target instanceof Element?$.target.closest("a[href]"):null;if(!he||!D)return;const fe=he.getAttribute("href");if(!fe)return;const Ne=Go(fe,s,l);Ne&&($.preventDefault(),D(Ne))},children:[r&&P.length>0&&e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:P.map($=>$.text).join(" / "),children:[e.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:P[P.length-1].text}),G.length>1&&e.jsxs("button",{ref:Y,type:"button",onClick:()=>{h?f?.():x?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${h?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":h,"aria-label":F("rightSidebar.markdownOutline"),title:F("rightSidebar.markdownOutline"),children:[e.jsx(uf,{size:12}),e.jsx("span",{children:F("rightSidebar.markdownOutlineShort")})]})]})}),h&&typeof document<"u"&&yr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:f}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:o?{top:`${o.top}px`,right:`${o.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:e.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:G.map($=>{const he=P[P.length-1]?.startLine===$.startLine;return e.jsxs("button",{type:"button",onClick:()=>Me($),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${he?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min($.level-1,4)*12+8}px`},title:$.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",$.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:$.text})]},`desktop-${$.id}-${$.startLine}`)})})}),e.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F("rightSidebar.markdownOutlineShort")}),e.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":F("rightSidebar.closeMarkdownOutline"),title:F("common.close"),children:e.jsx(Lt,{size:14})})]}),e.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:G.map($=>{const he=P[P.length-1]?.startLine===$.startLine;return e.jsxs("button",{type:"button",onClick:()=>Me($),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${he?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min($.level-1,4)*12+8}px`},title:$.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",$.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:$.text})]},`${$.id}-${$.startLine}`)})})]})]}),document.body),e.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:e.jsx(Vf.Provider,{value:Z,children:H.map($=>{const he=!!(d&&$.startLine<=d.end&&$.endLine>=d.start),fe=!!(d&&d.start<=$.startLine&&d.end>=$.endLine),Ne=$.kind==="table"?!1:$.fineGrained?fe:he,$e=$.kind==="table"&&d?.start===$.startLine&&d.end===$.endLine;let rt=null;if($.kind!=="table"&&$.fineGrained&&he&&!fe&&d){const Ie=$.endLine-$.startLine+1,De=Math.max(d.start,$.startLine),te=Math.min(d.end,$.endLine),je=(De-$.startLine)/Ie,nt=(te-De+1)/Ie;rt=e.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${je})`,height:`calc((100% - 0.5rem) * ${nt})`}})}const ce=typeof $.content=="function"?$.content(d):$.content;if(!r)return e.jsx("div",{"data-markdown-preview-block-start":$.startLine,className:"min-w-0 cursor-text select-text py-0.5",children:ce},$.key);const Te=$.startLine===$.endLine?String($.startLine):`${$.startLine}-${$.endLine}`,qe=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:ml(Ne),"aria-hidden":"true",...He,children:[e.jsx("span",{className:pl(Ne)}),rt]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:ce})]});return $.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":$.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Ne?"bg-primary/10":""}`,title:`Line ${Te}`,"aria-label":`Line ${Te}`,children:[$.kind==="table"?e.jsx("button",{type:"button",className:ml($e,"self"),onClick:Ie=>{Ie.preventDefault(),!Ke()&&c(Ie,$.startLine,$.endLine)},title:`Reference table lines ${Te}`,"aria-label":`Reference table lines ${Te}`,...He,children:e.jsx("span",{className:pl($e,"self")})}):e.jsxs("span",{className:ml(Ne,"none"),"aria-hidden":"true",...He,children:[e.jsx("span",{className:pl(Ne,"none")}),rt]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:Q,onPointerUp:Ie=>ge(Ie,$.startLine,$.endLine),onPointerCancel:ue,onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),c(Ie,$.startLine,$.endLine))},title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:ce})]},$.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":$.startLine,onClick:Ie=>{const De=Ie.target;if(bl(De)||Sl()||Ke())return;const te=Qu(De,$.startLine,$.endLine);c(Ie,te.start,te.end)},onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),c(Ie,$.startLine,$.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Ne?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:qe},$.key)})})})]}),b&&M!==null&&z[M]&&e.jsx(yh,{images:z,index:M,onChange:N,onClose:()=>{N(null),_(null),T?.()}})]})}function fs({label:r,value:n,options:s,placeholder:l,searchPlaceholder:d,emptyText:c,disabled:m,onChange:g}){const{t:h}=ht(),[p,x]=a.useState(!1),[f,b]=a.useState(""),[E,j]=a.useState(null),T=a.useRef(null),D=a.useRef(null),F=f.trim().toLowerCase(),M=a.useMemo(()=>F?s.filter(S=>`${S.label} ${S.meta??""}`.toLowerCase().includes(F)):s,[F,s]),N=s.find(S=>S.value===n),A=()=>{const S=f.trim();S&&(g(S),x(!1),b(""))},_=a.useCallback(()=>{const S=T.current?.getBoundingClientRect();if(!S)return!1;const o=12,B=Math.max(220,Math.min(S.width,window.innerWidth-o*2)),I=Math.min(Math.max(o,S.left),window.innerWidth-B-o),Y=window.innerHeight-S.bottom-o,H=S.top-o,U=Y>=180||Y>=H,R=Math.max(96,(U?Y:H)-4),z=Math.min(320,R);return j({left:I,top:U?S.bottom+4:Math.max(o,S.top-z-4),width:B,maxHeight:z}),!0},[]),q=()=>{_(),x(!0)};return a.useEffect(()=>{if(!p)return;let S=0;const o=()=>{S||(S=window.requestAnimationFrame(()=>{S=0,_()}))},B=I=>{const Y=I.target;Y instanceof Node&&(T.current?.contains(Y)||D.current?.contains(Y)||(x(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",B,!0),()=>{S&&window.cancelAnimationFrame(S),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",B,!0)}},[p,_]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:T,type:"button",disabled:m,onClick:()=>{if(!m){if(b(""),p){x(!1);return}q()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:N?.label??(n||l)})]}),e.jsx(da,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${p?"rotate-180":""}`})]}),p&&!m&&typeof document<"u"&&yr.createPortal(e.jsxs("div",{ref:D,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:S=>S.stopPropagation(),style:{left:E?.left??12,top:E?.top??12,width:E?.width??260,maxHeight:E?.maxHeight??320},children:[e.jsx("div",{className:"border-b border-border/10 p-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[e.jsx(ms,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:f,onChange:S=>b(S.target.value),onKeyDown:S=>{if(S.key==="Escape"){S.preventDefault(),x(!1),b("");return}S.key==="Enter"&&(S.preventDefault(),A())},onBlur:()=>{f.trim()&&M.length===0&&A()},placeholder:d,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),e.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(E?.maxHeight??320)-46)},children:[f.trim()&&!s.some(S=>S.value===f.trim())&&e.jsxs("button",{type:"button",onMouseDown:S=>S.preventDefault(),onClick:A,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[e.jsx("span",{className:"min-w-0 truncate",children:f.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:h("common.use")})]}),M.length>0?M.map(S=>e.jsxs("button",{type:"button",onClick:()=>{g(S.value),x(!1),b("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${S.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:S.label}),S.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:S.meta})]},S.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function Ku({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:d,selectedRoots:c,onToggleRepo:m,onGenerate:g,onSecondaryAction:h,disabled:p,generateDisabled:x,secondaryDisabled:f,inserted:b,buttonLabel:E,insertedLabel:j,title:T,ariaLabel:D,scopeTitle:F,scopeLabel:M,allLabel:N,generateLabel:A,secondaryLabel:_,secondaryTitle:q,secondaryLoading:S,loading:o,error:B,statusTitle:I,extraContent:Y,renderRepoExtra:H,menuItem:U=!1}){return e.jsxs("div",{className:U?"relative w-full":"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",role:U?"menuitem":void 0,tabIndex:U?-1:void 0,onClick:R=>{s?n(!r):x||g(R.currentTarget)},disabled:p,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${U?"min-h-10 w-full gap-2.5 px-2.5 text-left text-[12px] focus:bg-surface-2 focus:outline-none [@media(pointer:coarse)]:min-h-11":"h-7 shrink-0 justify-center gap-1 px-2 text-[11px] font-medium active:scale-95"} ${B?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":U?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:I??(s?`${F}: ${M}`:T),children:[o?e.jsx(ft,{size:U?15:13,className:"shrink-0 animate-spin"}):e.jsx(ua,{size:U?15:13,className:U?"shrink-0 text-muted-foreground":void 0}),e.jsx("span",{className:U?"min-w-0 flex-1":void 0,children:b?j:E}),s&&(U?e.jsx(hs,{size:13,className:"shrink-0 text-muted-foreground"}):e.jsx(da,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),B&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:M})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Lt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[Y,e.jsxs("button",{type:"button",onClick:()=>m(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:N}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),d.map(R=>{const z=c.includes(R.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${z?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>m(R.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${z?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:R.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:R.label}),R.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:R.branch})]}),z&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),H&&(l||z)&&e.jsx("div",{className:"px-2 pb-2",children:H(R)})]},R.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${h&&_?"sm:grid-cols-2":""}`,children:[h&&_&&e.jsxs("button",{type:"button",onClick:()=>{f||(n(!1),h())},disabled:f,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:q,children:[S?e.jsx(ft,{size:12,className:"animate-spin"}):e.jsx(wf,{size:12}),_]}),e.jsxs("button",{type:"button",onClick:async R=>{if(x)return;await g(R.currentTarget)!==!1&&n(!1)},disabled:x,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:T,children:[e.jsx(ua,{size:12}),A]})]})]})}),document.body)]})}function Qx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Sh(){return gt(Wl,Qx)??{}}function Zx(r,n){const s=Sh(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Yb);aa(Wl,Object.fromEntries(l),Jb)}function e0(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function t0(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!e0(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Zl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function jh(){return gt(Gl,t0)??{}}function qu(r,n){const s=Zl(r,n);return s?jh()[s]??null:null}function fl(r,n,s){const l=Zl(r,n);if(!l)return;const d=jh(),c=d[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},m=Object.entries({...d,[l]:{...c,...s,updatedAt:Date.now()}}).sort(([,g],[,h])=>h.updatedAt-g.updatedAt).slice(0,Xb);aa(Gl,Object.fromEntries(m),Qb)}function hl({slow:r}){return e.jsx(qp,{slow:r})}function So({message:r,onRetry:n}){const{t:s}=ht();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function Mo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function yt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function jo(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function r0(r,n,s){return jl(r,n,s)}function ml(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function pl(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function Rh(r){const n=new Map;for(const s of r)n.set(ec(s),s);return n}function Nh(r,n){const s=new Map(r);for(const l of n)s.set(ec(l),l);return s}function Vu(r,n){let s=0;for(const l of r){const d=bt(l,n);d&&n&&d!==n&&(s+=1)}return s}function n0(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function s0(r,n){return Array.from(Nh(Rh(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function a0(r,n){const s=r.relativeRoot==="."?yt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||yt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:n0(r.files)}}function Ch(r,n){const s=yt(n??"")||n||"";return r.map(l=>a0(l,n)).sort((l,d)=>s&&l.label===s?-1:s&&d.label===s?1:l.label.localeCompare(d.label))}function Eh(r,n,s,l,d){const c=Hf(s),m=c.find(T=>T.root===l)??c[0]??null,g=n.find(T=>T.root===l)??null,h=g?.relativeRoot??m?.relativeRoot??".",p=g?.name??m?.name??(yt(l)||l),x=(m?.files??s.files).map(T=>({...T,repoRoot:l,repoRelativeRoot:h,repoName:p})),f=m?.context??s.context,b={...g??m??{id:l,root:l,relativeRoot:h,name:p,depth:0,nested:!!(d&&l!==d),available:s.available,files:[],context:null},...m??{},id:g?.id??m?.id??l,root:l,displayRoot:g?.displayRoot??m?.displayRoot,relativeRoot:h,name:p,depth:g?.depth??m?.depth??0,nested:g?.nested??m?.nested??!!(d&&l!==d),available:m?.available??s.available,deferred:m?.deferred??!1,files:x,context:f?{...f,root:l,changedFiles:x.map(T=>({path:T.path,absolutePath:T.absolutePath,status:T.status}))}:null,untrackedDeferred:m?.untrackedDeferred??s.untrackedDeferred,error:m?.error??s.error},E=g?n.map(T=>T.root===l?b:T):[...n,b];return{files:Array.from(r).filter(T=>bt(T,d)!==l).concat(x),repositories:E,repoFilters:Ch(E,d)}}function bt(r,n){return r.repoRoot??n}function ec(r){return`${r.repoRoot??""}\0${r.path}`}function vr(r){return r.absolutePath||r.path}function gl(r){return ec(r)}function o0(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function Yu(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Xu(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Zs(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function ea(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function wr(r){return r instanceof DOMException&&r.name==="AbortError"}function i0(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function Ju(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function bl(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function Qu(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,d=Number(l?.dataset.mdRefStart),c=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(d)&&d>0&&Number.isFinite(c)&&c>0?{start:Math.min(d,c),end:Math.max(d,c)}:{start:n,end:s}}function l0({actions:r,running:n,completed:s}){const{t:l}=ht(),[d,c]=a.useState(!1),m=a.useRef(null),g=r.find(p=>n?.action===p.key),h=r.find(p=>s?.action===p.key);return r.length===0?null:(a.useEffect(()=>{if(!d)return;const p=f=>{const b=f.target;b instanceof Node&&m.current?.contains(b)||c(!1)},x=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",x)}},[d]),e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),c(x=>!x)},disabled:r.every(p=>p.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${d?"bg-surface-elevated text-foreground":h?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:g?.label??h?.label??l("rightSidebar.gitQuickActions"),children:g?e.jsx(ft,{size:13,className:"animate-spin"}):h?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(Po,{size:14})}),d&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(p=>{const x=n?.action===p.key,f=s?.action===p.key;return e.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),p.onClick(),c(!1)},disabled:p.disabled||!!n,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${f?"bg-accent/10 text-accent":p.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:x?e.jsx(ft,{size:13,className:"animate-spin"}):f?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.key)})})]}))}function c0(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Mh(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&c0(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function ps(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const xl=new WeakMap;function Ho(r){const n=xl.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),xl.delete(r)},1700);xl.set(r,s)}function d0(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let d=null;for(const g of l){if(!ps(g))continue;const h=g.querySelector(s);if(h&&ps(h)){d=h;break}}if(d??=Array.from(document.querySelectorAll(s)).find(ps)??null,!d)return;const c=Mh(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),Ho(d);return}const m=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,m),behavior:"instant"}),Ho(d)}function An(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,d=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,c=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,m=[s!==null&&d?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null&&d?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"]`:null,l!==null&&c?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${c}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(j=>!!j),g=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let h=null;for(const j of g)if(ps(j)){for(const T of m){const D=j.querySelector(T);if(D&&ps(D)){h=D;break}}if(h)break}if(h??=m.flatMap(j=>Array.from(document.querySelectorAll(j))).find(ps)??null,!h){d0(r.filePath);return}const p=Mh(h);if(!p){h.scrollIntoView({block:"center",behavior:"smooth"}),Ho(h);return}const x=h.getBoundingClientRect(),f=p.getBoundingClientRect(),E=x.top-f.top+p.scrollTop-Math.max(24,(p.clientHeight-x.height)/2);p.scrollTo({top:Math.max(0,E),behavior:"instant"}),Ho(h)}const $h=1,tc=8;function u0(r,n=tc){return Math.min(n,Math.max($h,r))}function Ph({resetKey:r,maxScale:n=tc,onZoomChange:s,onDoubleTap:l,children:d}){const c=a.useRef(null),[m,g]=a.useState({scale:1,x:0,y:0}),[h,p]=a.useState(!1),x=a.useRef(null),f=a.useRef(new Set),b=a.useRef(!1),E=a.useRef(null),j=a.useRef(0),T=a.useRef(m);T.current=m,a.useEffect(()=>{g({scale:1,x:0,y:0})},[r]);const D=a.useCallback((A,_,q)=>{const S=c.current;if(!S)return{x:_,y:q};const o=S.firstElementChild instanceof HTMLElement?S.firstElementChild:null,B=o?.clientWidth||S.clientWidth,I=o?.clientHeight||S.clientHeight,Y=Math.max(0,(B*A-S.clientWidth)/2),H=Math.max(0,(I*A-S.clientHeight)/2);return{x:Math.min(Y,Math.max(-Y,_)),y:Math.min(H,Math.max(-H,q))}},[]),F=a.useCallback((A,_,q)=>{g(S=>{const o=u0(A,n),B=c.current;if(!B||o===1)return{scale:o,x:0,y:0};const I=B.getBoundingClientRect(),Y=(_??I.left+I.width/2)-I.left-I.width/2,H=(q??I.top+I.height/2)-I.top-I.height/2,U=o/S.scale,R=Y-(Y-S.x)*U,z=H-(H-S.y)*U;return{scale:o,...D(o,R,z)}})},[D,n]),M=a.useCallback((A,_)=>{p(!0),T.current.scale>1?g({scale:1,x:0,y:0}):F(2.5,A,_),window.setTimeout(()=>p(!1),220)},[F]);a.useEffect(()=>{const A=c.current;if(!A)return;const _=o=>{if(o.pointerType==="mouse"&&o.button!==0)return;const B=f.current.size===0;if(f.current.add(o.pointerId),B){const I=Date.now(),Y=E.current;if(Y&&I-Y.time<350&&Math.hypot(o.clientX-Y.x,o.clientY-Y.y)<24){E.current=null,j.current=I,l?.(),M(o.clientX,o.clientY);return}}if(f.current.size>1){b.current=!0,x.current=null;return}if(!(T.current.scale<=1)){o.preventDefault(),x.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:T.current.x,originY:T.current.y,moved:!1};try{A.setPointerCapture?.(o.pointerId)}catch{}p(!1)}},q=o=>{const B=x.current;if(!B||B.pointerId!==o.pointerId)return;const I=o.clientX-B.startX,Y=o.clientY-B.startY;if(!B.moved){if(Math.hypot(I,Y)<6)return;B.moved=!0}o.stopPropagation(),o.preventDefault(),g(H=>({...H,...D(H.scale,B.originX+I,B.originY+Y)}))},S=o=>{const B=x.current,I=B?.pointerId===o.pointerId&&B.moved;if(B?.pointerId===o.pointerId){B.moved&&o.stopPropagation(),x.current=null;try{A.releasePointerCapture?.(o.pointerId)}catch{}}f.current.delete(o.pointerId)&&f.current.size===0&&(!b.current&&!I&&(E.current={time:Date.now(),x:o.clientX,y:o.clientY}),b.current=!1)};return A.addEventListener("pointerdown",_,{capture:!0,passive:!1}),window.addEventListener("pointermove",q,{capture:!0,passive:!1}),window.addEventListener("pointerup",S,{capture:!0}),window.addEventListener("pointercancel",S,{capture:!0}),()=>{A.removeEventListener("pointerdown",_,{capture:!0}),window.removeEventListener("pointermove",q,{capture:!0}),window.removeEventListener("pointerup",S,{capture:!0}),window.removeEventListener("pointercancel",S,{capture:!0})}},[D,l,M]),cf({onPinch:({offset:[A],origin:[_,q]})=>{p(!1),F(A,_,q)},onWheel:({event:A,delta:[_,q],ctrlKey:S})=>{if(S){A.preventDefault(),A.stopPropagation(),p(!1),F(T.current.scale*(1-q*.01),A.clientX,A.clientY);return}T.current.scale<=1||(A.preventDefault(),A.stopPropagation(),p(!1),g(o=>({...o,...D(o.scale,o.x-_,o.y-q)})))}},{target:c,eventOptions:{passive:!1},pinch:{scaleBounds:{min:$h,max:n},from:()=>[T.current.scale,0],rubberband:!0}});const N=m.scale>1;return a.useEffect(()=>{s?.(N)},[s,N]),e.jsx("div",{ref:c,"data-sidebar-gesture-ignore":N?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden","data-image-zoom-viewport":!0,style:{cursor:N?"grab":"zoom-in"},onDoubleClick:A=>{A.stopPropagation(),!(Date.now()-j.current<500)&&(l?.(),M(A.clientX,A.clientY))},children:d({scale:m.scale,zoomed:N,animateTransform:h,transformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0) scale(${m.scale})`,transformOrigin:"center center",transition:h?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0)`,transformOrigin:"center center",transition:h?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Ah({src:r,alt:n,vector:s,onLoad:l,onError:d,onZoomChange:c,onDoubleTap:m}){const g=fa(r,d),[h,p]=a.useState(null),x=s??ga(r);return a.useEffect(()=>{p(null)},[r]),e.jsx(Ph,{resetKey:r,maxScale:Math.max(tc,h?.originalScale??1),onZoomChange:c,onDoubleTap:m,children:({vectorTransformStyle:f,scale:b,animateTransform:E})=>e.jsx("div",{"data-image-zoom-surface":!0,"data-vector-zoom-surface":x?"":void 0,className:"relative shrink-0 touch-none select-none",style:h?{...f,width:h.width,height:h.height}:{width:"100%",height:"100%"},children:e.jsx("img",{src:g,alt:n,draggable:!1,className:"touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:{position:"absolute",left:"50%",top:"50%",width:h?h.width*b:void 0,height:h?h.height*b:void 0,maxWidth:h?"none":"100%",maxHeight:h?"none":"100%",transform:"translate(-50%, -50%)",transition:E?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"},onLoad:j=>{const T=j.currentTarget,D=T.closest("[data-image-zoom-viewport]");if(D&&T.naturalWidth>0&&T.naturalHeight>0){const F=Math.max(1,D.clientWidth-2),M=Math.max(1,D.clientHeight-2),N=Math.min(F/T.naturalWidth,M/T.naturalHeight),A=x?N:Math.min(N,1);p({width:T.naturalWidth*A,height:T.naturalHeight*A,originalScale:1/A})}l(j)},onError:d})})})}function f0({svg:r,title:n,scale:s,vectorTransformStyle:l}){const d=a.useRef(null);return a.useLayoutEffect(()=>{const c=d.current,m=c?.querySelector("svg");if(!c||!m)return;const g=()=>{const x=m.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let f=x[2],b=x[3];if((!Number.isFinite(f)||!Number.isFinite(b)||f<=0||b<=0)&&(f=Number(m.getAttribute("width")),b=Number(m.getAttribute("height"))),!Number.isFinite(f)||!Number.isFinite(b)||f<=0||b<=0)return;const E=Math.max(1,c.clientWidth-24),j=Math.max(1,c.clientHeight-24),T=Math.min(E/f,j/b,1);m.style.width=`${Math.max(1,Math.floor(f*T*s))}px`,m.style.height=`${Math.max(1,Math.floor(b*T*s))}px`,m.style.maxWidth="none",m.style.maxHeight="none",m.style.transform=String(l.transform??""),m.style.transformOrigin="center center",m.style.transition=String(l.transition??"none")};g();const h=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return h?.observe(c),()=>h?.disconnect()},[s,r,l]),e.jsx("div",{ref:d,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function h0({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Ph,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:d,scale:c})=>e.jsx(f0,{svg:r,title:n,scale:c,vectorTransformStyle:d})})}let m0=0,p0=0,g0=0,b0=0,x0=0;function $o(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ut(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++p0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ta(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++b0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function v0(){return`diff-ui-${Date.now().toString(36)}-${(++x0).toString(36)}`}function w0(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function y0(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function zo({onReviewReference:r,filePath:n,active:s=!0,onInsertReference:l,onInsertText:d,onInsertFeature:c,onReferenceCopied:m,onClose:g,onDirectoryLinkOpen:h,isMobile:p,markdownOutlineOpen:x,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:b,onCloseMarkdownOutline:E,markdownImageLightboxOpen:j,markdownImageLightboxCloseSignal:T,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:F,lineRange:M,onLineRangeChange:N,insertedReferenceKey:A,copiedReferenceKey:_,scrollToLine:q,onScrollToLineHandled:S}){const{t:o}=ht(),B=a.useRef(null),I=a.useRef({}),Y=a.useRef(s);Y.current=s,a.useEffect(()=>{s||B.current?.querySelectorAll("video").forEach(L=>L.pause())},[s]);const H=V(L=>L.rootPath),U=V(L=>L.selectFile),[R,z]=a.useState({kind:"idle"}),[Z,P]=a.useState("schematic"),[G,J]=a.useState(null),ie=a.useRef(null),[pe,Se]=a.useState(null),ke=a.useRef(new Map),Me=a.useRef(null),[Q,ge]=a.useState(null),[ue,_e]=a.useState(()=>Du()),[Ue,W]=a.useState(()=>Su(H,n)),ye=a.useRef(null),[we,He]=a.useState(!1),[Ke,$]=a.useState(null),[he,fe]=a.useState(0),[Ne,$e]=a.useState([]),[rt,ce]=a.useState(null),Te=a.useRef(null),qe=a.useRef(n),[Ie,De]=a.useState(null),te=ab(H&&n&&!n.startsWith("/")?`${H}/${n}`:n,s),[je,nt]=a.useState(!1),[Rt,lr]=a.useState(""),[O,ae]=a.useState([]),[Ce,et]=a.useState(0),xt=a.useRef(null),kr=vf(m),Nt=Zl(H,n);a.useEffect(()=>{if(qe.current===n)return;qe.current=n;const L=n&&H&&!n.startsWith("/")?`${H}/${n}`:n;if(Te.current===L){Te.current=null;return}Te.current=null,$e([]),ce(null),nt(!1),lr("")},[n,H]);const Ct=n?H&&!n.startsWith("/")?`${H}/${n}`:n:null,Tn=V(L=>Ct?(L.fileChangeVersions.get(Ct)??0)+L.fileWatchEpoch:L.fileWatchEpoch),gs=a.useRef(null),Sr=a.useRef(null),[zt,en]=a.useState(0),er=a.useCallback(()=>en(L=>L+1),[]);a.useEffect(()=>{const L=ie.current;return ie.current=null,J(null),L&&URL.revokeObjectURL(L.objectUrl),()=>{const K=ie.current;ie.current=null,K&&URL.revokeObjectURL(K.objectUrl)}},[Ct,Tn,zt]),a.useEffect(()=>{if(!n){gs.current=null,z({kind:"idle"});return}const L=H&&!n.startsWith("/")?`${H}/${n}`:n,K=new AbortController,be=++m0,Ee=`right-sidebar-file-preview:${be}`,st=performance.now();let Be=!1;const Ye=(re,Je={})=>{Be||(Be=!0,$o("end",{loadingId:be,reason:re,durationMs:Math.round(performance.now()-st),filePath:n,fullPath:L,rootPath:H,...Je}))};let Oe=null;const Xe=ep(L),mt=Xe?L.toLowerCase().endsWith(".kicad_pcb")?Z==="schematic"?"pcb-front":Z:"schematic":Z,_n=!Xe&&Ul(L),dr=!Xe&&!_n&&tp(L),Ss=!Xe&&!_n&&!dr&&Hl(L),on=Qs(L),ln=Ys(L),Kr=Xe?"eda":_n?"image":dr?"model3d":Ss?"video":"text",cn=gs.current!==L;if(gs.current=L,cn){$o("start",{loadingId:be,filePath:n,fullPath:L,rootPath:H,mode:Kr,externalVersion:Tn}),z({kind:"loading",mode:Kr}),Sr.current=null;const re=qu(H,n);N(re?.lineRange??null),_e(on?Du():"source"),W(ln?Su(H,n):"source"),Xe&&P(rp(L))}cn||z(re=>re.kind==="error"?{kind:"loading",mode:Kr}:re);const dn=window.setTimeout(()=>{Be||K.signal.aborted||$o("still_active",{loadingId:be,filePath:n,fullPath:L,rootPath:H,mode:Kr,durationMs:Math.round(performance.now()-st),isPathChange:cn})},3e3),js=window.setTimeout(()=>{if(Be||K.signal.aborted)return;const re=Xe?o("rightSidebar.edaTimeout"):dr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";K.abort(new DOMException(re,"TimeoutError")),z({kind:"error",message:re}),Ye("stuck_timeout",{error:re})},Xe?np+5e3:dr?sp+5e3:ap(L)?35e3:ax);if(Xe){const re=mt==="pcb-3d"?ie.current:null;re?(z(re),Ye("eda_3d_client_cache_hit",{bytes:re.meta.size,view:re.view,mimeType:re.meta.mimeType})):op(L,mt,K.signal,"view_file",Ee).then(Je=>{if(K.signal.aborted)return;Oe=URL.createObjectURL(Je.blob);const Dt={kind:"eda",sourcePath:Je.path||L,objectUrl:Oe,view:Je.view,meta:{size:Je.size,mimeType:Je.mimeType,modified:Je.modified}};if(Je.view==="pcb-3d"){const ur=ie.current;ur&&ur.objectUrl!==Oe&&URL.revokeObjectURL(ur.objectUrl),ie.current=Dt,J(Dt),Oe=null}z(Dt),Ye("eda_loaded",{bytes:Je.size,view:Je.view,mimeType:Je.mimeType})}).catch(Je=>{K.signal.aborted||(z({kind:"error",message:Je instanceof Error&&/timed out/i.test(Je.message)?o("rightSidebar.edaTimeout"):Je instanceof Error?Je.message:o("rightSidebar.edaLoadFailed")}),Ye("error",{error:Je instanceof Error?Je.message:String(Je)}))})}else if(_n)ip(L,K.signal,"view_file",Ee).then(re=>{Oe=URL.createObjectURL(re.blob),z({kind:"image",objectUrl:Oe,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),Ye("image_loaded",{bytes:re.size,mimeType:re.mimeType})}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error?re.message:o("rightSidebar.imageLoadFailed")}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});else if(dr)lp(L,K.signal,"view_file",Ee).then(re=>{K.signal.aborted||(Oe=URL.createObjectURL(re.blob),z({kind:"model3d",sourcePath:re.path||L,objectUrl:Oe,ext:re.ext,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),Ye("model3d_loaded",{bytes:re.size,ext:re.ext}))}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error&&(re.name==="TimeoutError"||/timed out/i.test(re.message))?o("rightSidebar.model3dTimeout"):re instanceof Error?re.message:o("rightSidebar.model3dLoadFailed")}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});else if(Ss){const re=cp(L)??"",Je=rf(L);z(Dt=>Dt.kind==="video"&&Dt.url===Je?Dt:{kind:"video",url:Je,meta:{size:null,mimeType:re,modified:null}}),Ye("video_ready",{mimeType:re})}else qd(L,K.signal,"view_file",Ee).then(re=>{if(!K.signal.aborted){if(re.binary){z({kind:"binary"});return}z({kind:"text",content:re.content,sourcePath:re.path||L,meta:{size:re.size,truncated:re.truncated}}),Ye("text_loaded",{bytes:re.size,truncated:!!re.truncated})}}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error?re.message:"Failed to read file"}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});return()=>{K.abort(),jt(Ee),window.clearTimeout(dn),window.clearTimeout(js),Oe&&URL.revokeObjectURL(Oe),Ye("cleanup")}},[n,H,Tn,zt,N,o,Z]),a.useEffect(()=>{if(R.kind!=="model3d"||!n){Se(null);return}let L=!1;const K=n.lastIndexOf("/"),be=K>=0?n.slice(K+1):n,Ee=K>=0?n.slice(0,K):"",st=Ee.lastIndexOf("/"),Be=st>=0?Ee.slice(0,st):"",Ye=be.replace(/\.(stl|glb|gltf)$/i,""),Oe=`${Be?`${Be}/`:""}features/${Ye}.json`;return qd(Oe).then(Xe=>{if(!L)try{const mt=JSON.parse(Xe.content);Se(mt.version===1&&Array.isArray(mt.features)&&mt.features.length>0?mt.features:null)}catch{Se(null)}}).catch(()=>{L||Se(null)}),()=>{L=!0}},[R,n]),a.useEffect(()=>{if(R.kind!=="text"){De(null);return}const L=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,K=pf(L),be=R.content,Ee=Qs(L??"")&&ue==="preview",st=Ys(L??"")&&Ue==="preview";if(!K||Ee||st||!gf(be)){De(null);return}let Be=!1;const Ye=Oe=>{if(Be||!Oe.registered(K)){Be||De(null);return}try{De(xf(Oe,be,K))}catch{De(null)}};return Ke?Ye(Ke):(De(null),bf().then(Oe=>{Be||($(Oe),Ye(Oe))}).catch(()=>{})),()=>{Be=!0}},[R,Ke,n,H,ue,Ue]),a.useLayoutEffect(()=>{if(!Nt||R.kind!=="text")return;const L=`${Nt}:${ue}:${Ue}`;if(Sr.current===L)return;const K=qu(H,n);if(Sr.current=L,!K)return;const be=requestAnimationFrame(()=>{const Ee=Me.current;if(!Ee)return;const st=ue==="preview"?K.markdownTop??K.top:K.top;Ee.scrollTo({top:Math.max(0,st??0),left:Math.max(0,K.left??0)}),fe(ue==="preview"?Math.max(0,st??0):0)});return()=>cancelAnimationFrame(be)},[n,ue,Ue,R.kind,Nt,H]),a.useEffect(()=>{Nt&&fl(H,n,{lineRange:M})},[n,M,Nt,H]),a.useEffect(()=>{if(q==null||R.kind!=="text")return;ge(null),N({start:q,end:q});const L=q,K=requestAnimationFrame(()=>{const be=ke.current.get(L);be&&be.scrollIntoView({block:"center"}),S?.()});return()=>cancelAnimationFrame(K)},[q,R,N,S]);const In=a.useCallback(L=>{const K=Me.current;if(!K)return!1;const be=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(L):L.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Ee=K.querySelector(`#${be}`);return Ee?(Ee.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const L=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,K=R.kind==="text"&&Qs(L??"")&&ue==="preview";if(!rt||!K)return;const be=requestAnimationFrame(()=>{In(rt)&&ce(null)});return()=>cancelAnimationFrame(be)},[n,In,ue,rt,R,H]),a.useLayoutEffect(()=>{const L=Me.current;if(!L||!M){ge(null);return}if(Q)return;const K=R.kind==="image"||R.kind==="loading"&&R.mode==="image",be=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,Ee=R.kind==="text"&&Qs(be??"")&&ue==="preview",st=R.kind==="text"&&Ys(be??"")&&Ue==="preview";if(R.kind!=="text"||K||Ee||st){ge(null);return}const Be=()=>{const Oe=ke.current.get(M.end);if(!Oe||!L){ge(null);return}const Xe=Oe.offsetTop+Oe.offsetHeight/2,mt=L.scrollLeft+Math.max(8,L.clientWidth-120);ge({top:Xe,left:mt})};Be();const Ye=new ResizeObserver(()=>Be());return Ye.observe(L),()=>Ye.disconnect()},[M,Q,R,ue,Ue,n,H,Ie]);const jr=R.kind==="text"&&!(Ys(Ct??"")&&Ue==="preview")&&!Ct?.toLowerCase().endsWith(".csv")&&!Ct?.toLowerCase().endsWith(".kicad_pro")&&!Ct?.toLowerCase().endsWith(".kicad_prl"),Dn=a.useCallback(()=>{nt(!1),lr(""),ae([]),et(0),vo(I.current)},[]),tn=a.useCallback(()=>{!s||!jr||(nt(!0),requestAnimationFrame(()=>{const L=B.current;!Y.current||!L?.isConnected||L.closest('[inert], [aria-hidden="true"], [hidden]')||L.getClientRects().length===0||getComputedStyle(L).visibility==="hidden"||!L.contains(document.activeElement)||(xt.current?.focus(),xt.current?.select())}))},[s,jr]),Or=a.useCallback(L=>{et(K=>O.length===0?0:(K+L+O.length)%O.length)},[O.length]),Wt=a.useCallback(L=>{if(L.nativeEvent.isComposing||!Ob(B.current,s,L))return;const K=Ub(L);if(K==="open"&&jr){L.preventDefault(),tn();return}je&&(K==="close"?(L.preventDefault(),Dn()):(K==="next"||K==="previous")&&(L.preventDefault(),Or(K==="previous"?-1:1)))},[s,Dn,je,Or,tn,jr]);if(a.useLayoutEffect(()=>{if(vo(I.current),!s||!je||!Rt.trim()||!Me.current){ae([]),et(0);return}const L=zb(Me.current,Rt);return ae(L),et(0),(B.current?.contains(document.activeElement)||Cu(I.current))&&(sl(L,0,I.current),Eu(L[0])),()=>vo(I.current)},[s,je,Rt,Ie,ue,R]),a.useEffect(()=>{!s||!je||!Rt.trim()||!B.current?.contains(document.activeElement)&&!Cu(I.current)||(sl(O,Ce,I.current),Eu(O[Ce]))},[s,Ce,O,je,Rt]),a.useEffect(()=>()=>vo(I.current),[]),!n)return e.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.selectFilePrompt")});const Ve=H&&!n.startsWith("/")?`${H}/${n}`:n,Tt=Mo(Ve,H),Rr=of(Ve,H),Nr=R.kind==="text"&&R.content?R.content.split(`
|
|
1656
|
+
`):[],ba=Math.max(2,String(Nr.length).length)+1,Cr=R.kind==="text"||R.kind==="image"||R.kind==="model3d"||R.kind==="video"||R.kind==="eda"?R.meta:null,Er=Qs(Ve),xa=Ve.toLowerCase().endsWith(".csv"),It=Ve.toLowerCase().endsWith(".kicad_pro"),bs=Ve.toLowerCase().endsWith(".kicad_prl"),Gt=R.kind==="text"&&Er&&ue==="preview",va=Ys(Ve),Kt=R.kind==="text"&&va&&Ue==="preview",wa=R.kind==="image"||R.kind==="loading"&&R.mode==="image",qo=R.kind==="model3d"||R.kind==="loading"&&R.mode==="model3d",kt=R.kind==="video"||R.kind==="loading"&&R.mode==="video",rn=R.kind==="eda"||R.kind==="loading"&&R.mode==="eda",xs=R.kind==="text"?R.sourcePath:Ve,Ur=Tp(xs,H,M),Hr=(()=>{if(!M||R.kind!=="text"||Nr.length===0)return Ur;const L=[];for(let Ee=M.start;Ee<=M.end;Ee+=1)L.push(`${Ee} ${Nr[Ee-1]??""}`);const K=Gf(Ve).replace(/^\./,""),be="```";return`${Ur}
|
|
1655
1657
|
${be}${K}
|
|
1656
1658
|
${L.join(`
|
|
1657
1659
|
`)}
|
|
1658
1660
|
${be}
|
|
1659
|
-
`})(),Mr=`path:${Ve}`,$r=$?`path:${Ve}:${$.start}-${$.end}`:Mr,zr=A===Mr,Wr=A===$r,Fn=O===Mr,vs=O===$r,nn=Wr||vs,tr=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,Gr=L=>{const K=Me.current;if(!K)return;const be=K.getBoundingClientRect(),Ee=L.currentTarget.getBoundingClientRect(),st=L.clientX||Ee.left+Ee.width/2,Ye=(L.clientY||Ee.top+Ee.height/2)-be.top+K.scrollTop,Oe=p?116:132,Xe=K.scrollLeft+Math.max(8,K.clientWidth-Oe),mt=Math.min(Math.max(8,st-be.left+K.scrollLeft+10),Xe);ge({top:Ye,left:mt})},ys=(L,K)=>{wl()||(Gr(L),C(be=>{const Ee=kl(be,K,K);return Ee||ge(null),Ee}))},ws=(L,K,be)=>{Gr(L),C(Ee=>{const st=kl(Ee,K,be);return st||ge(null),st})},Pr=(L,K,be,Ee)=>{Ee==="end"&&Gr(L),C({start:K,end:be})},cr=L=>{const{scrollTop:K,scrollLeft:be}=L.currentTarget;fe(K),dl(H,n,{top:K,left:be,markdownTop:K})},ve=L=>{if(L.directory){f?.(L.path);return}if(L.path===Ve||R.kind==="text"&&L.path===R.sourcePath){L.fragment&&In(L.fragment);return}$e(K=>[...K,Ve]),Te.current=L.path,ce(L.fragment),C(null),U(L.path)},rr=()=>{const L=Ne[Ne.length-1];L&&($e(K=>K.slice(0,-1)),Te.current=L,ce(null),C(null),U(L))},sn=L=>{const{scrollTop:K,scrollLeft:be}=L.currentTarget;dl(H,n,{top:K,left:be})},an=L=>{if(r){r(Hr,$r,void 0,L.currentTarget);return}$&&d(Hr,$r,L.currentTarget)},ks=()=>{if(!(R.kind==="loading"||R.kind==="error"))return te.start()};return e.jsxs("div",{ref:_,tabIndex:-1,onKeyDown:Wt,onFocusCapture:()=>{s&&je&&Rt.trim()&&rl(B,Ce,I.current)},onPointerDownCapture:L=>{L.target instanceof Element&&!L.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&L.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[kr.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(Gt||Kt)?"py-1.5":"py-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[p&&g&&e.jsx("button",{type:"button",onClick:g,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:e.jsx(df,{size:16})}),Ne.length>0&&e.jsxs("button",{type:"button",onClick:rr,className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-primary/10 text-primary transition hover:bg-primary/15 active:scale-95 ${p?"w-9":"px-2.5"}`,"aria-label":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[e.jsx(ca,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ve,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Tt.name}),Tt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Tt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[jr&&e.jsx("button",{type:"button",onClick:je?Dn:tn,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${je?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(ms,{size:14})}),Er&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{x&&E?.(),_e(L=>{const K=L==="preview"?"source":"preview";return At($f,K),K}),C(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?ue==="preview"?e.jsx(jl,{size:14}):e.jsx(Sl,{size:14}):o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),xa&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{W(L=>{const K=L==="preview"?"source":"preview";return nb(H,n,K),K}),C(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?Ue==="preview"?e.jsx(jl,{size:14}):e.jsx(Sl,{size:14}):o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Kt&&e.jsx("button",{type:"button",onClick:()=>{we.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(uf,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:L=>l(Ve,Mr,L.currentTarget),...kr(Rr,Mr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${zr||Fn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Rr}),children:o(Fn?"rightSidebar.copied":zr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Rr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.copyReference",{reference:Rr}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(op,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ks()},disabled:te.status==="pending"||R.kind==="loading"||R.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:te.status==="error"?te.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(ut,{size:13,className:"animate-spin"}):e.jsx(of,{size:14})}),te.status==="pending"&&e.jsx("button",{type:"button",onClick:te.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),te.status==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",te.error]}),te.status==="canceled"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),te.status==="saved"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),te.status==="started"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),je&&jr&&e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:xt,type:"search",value:Rt,onChange:L=>lr(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),Or(L.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:B.length>0?`${Ce+1}/${B.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Or(-1),disabled:B.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Ol,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Or(1),disabled:B.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Pp,{size:13})}),e.jsx("button",{type:"button",onClick:Dn,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Lt,{size:13})})]}),Cr&&!(p&&(Gt||Kt))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Cr.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Cr.size.toLocaleString()})}),"truncated"in Cr&&Cr.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Cr&&e.jsx("span",{children:Cr.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(Gt||Kt))&&!Go&&R.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:rn?o("rightSidebar.edaPickHint"):ba?o("rightSidebar.csvTablePreview"):It||bs?o("rightSidebar.kicadProjectPickHint"):kt?o("rightSidebar.videoPreviewHint"):va?o("rightSidebar.imagePreviewHint"):Gt?$?o("rightSidebar.selectedLineHint",{lineLabel:tr??""}):o("rightSidebar.markdownPreviewHint"):Kt?o("rightSidebar.htmlPreviewHint"):$?o("rightSidebar.selectedLineHint",{lineLabel:tr??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||Kt)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(qi,{label:R.mode==="eda"?o("rightSidebar.edaLoading"):R.mode==="image"?o("rightSidebar.loadingImage"):R.mode==="model3d"?o("rightSidebar.model3dLoading"):R.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):R.kind==="error"?e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[e.jsx("div",{className:"mx-3 mt-3 border border-destructive/20 bg-destructive/5 px-4 py-4 text-sm text-destructive",children:R.message}),e.jsx("button",{type:"button",onClick:er,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):R.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:o("rightSidebar.binaryPreviewHint")})}):R.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:R.meta.mimeType==="image/svg+xml"?e.jsx(Rf,{blobUrl:R.objectUrl,filePath:Ve,viewLabel:"SVG 文件",onInsertAnnotation:r??c}):e.jsx(Eh,{src:R.objectUrl,alt:Tt.name,vector:!1,onLoad:L=>{const K=L.currentTarget;z(be=>be.kind==="image"?{...be,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:be)},onError:()=>z({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):R.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(mb,{url:R.url,onLoadError:()=>z({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):R.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(wb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Ve.toLowerCase().endsWith(".kicad_pcb"),onViewChange:P,onInsertAnnotation:r??c,onRefresh:er,interactive3d:G?e.jsx(a.Suspense,{fallback:e.jsx(qi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Lu,{blobUrl:G.objectUrl,ext:".glb",fileName:Tt.name,filePath:G.sourcePath,features:null,onInsertFeature:r??c,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:L=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(L)?L:"PCB板体/铜箔/丝印",active:R.view==="pcb-3d"})}):void 0})}):R.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx(qi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Lu,{blobUrl:R.objectUrl,ext:R.ext,fileName:Tt.name,filePath:R.sourcePath,features:pe,onInsertFeature:r??c,onRefresh:er})})}):R.kind==="text"&&ba?e.jsx(jb,{content:R.content,filePath:Ve,onInsertAnnotation:r??c},Ve):R.kind==="text"&&(It||bs)?e.jsx(Cb,{content:R.content,filePath:Ve,localState:bs,onInsertAnnotation:r??c},Ve):Gt?e.jsxs("div",{ref:Me,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:cr,style:{touchAction:"pan-x pan-y"},children:[e.jsx(xh,{content:R.content,filePath:R.sourcePath,rootPath:H,lineRange:$,onLineRangeClick:ws,onLineRangeDrag:Pr,scrollTop:he,outlineOpen:x,outlineCloseSignal:h,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:S,lightboxCloseSignal:T,onLightboxOpen:D,onLightboxClose:F,onLocalLinkOpen:ve}),$&&Q&&e.jsxs("button",{type:"button",onClick:an,...kr(Hr,$r),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:fu(p,nn),title:`Insert markdown reference: ${Ur}`,children:[e.jsx(Ao,{size:p?13:11}),vs?o("rightSidebar.copied"):Wr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:tr??""})]})]}):Kt?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Ib,{ref:we,src:ip(Ve),title:`${Tt.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:He},`${Ve}:${Tn}:${zt}`)}):R.kind==="text"?e.jsxs("div",{ref:Me,onScroll:sn,className:`${zl} termdock-native-select termdock-code relative min-h-0 flex-1 overflow-auto rounded-none bg-surface p-2 font-mono text-[11px] leading-relaxed text-foreground`,children:[Nr.length>0?e.jsx("div",{className:"min-w-full",children:Nr.map((L,K)=>{const be=K+1,Ee=!!($&&be>=$.start&&be<=$.end),st=Ie&&Ie.length===Nr.length?Ie[K]:null;return e.jsxs("div",{ref:Be=>{Be?ke.current.set(be,Be):ke.current.delete(be)},role:"button","data-file-preview-line":be,tabIndex:0,onClick:Be=>ys(Be,be),onKeyDown:Be=>{Be.key!=="Enter"&&Be.key!==" "||(Be.preventDefault(),ys(Be,be))},style:{gridTemplateColumns:`${ga}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Ee?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Rr}:${be}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Ee?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:be}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:st??(L||" ")})]},K)})}):"Empty file.",$&&Q&&e.jsxs("button",{type:"button",onClick:an,...kr(Hr,$r),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:fu(p,nn),title:`Insert code reference: ${Ur}`,children:[e.jsx(Ao,{size:p?13:11}),vs?o("rightSidebar.copied"):Wr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:tr??""})]})]}):null]})}function w0({rootPath:r,file:n,active:s,...l}){const[d,c]=a.useState(null),[m,g]=a.useState(n.line??1),f=a.useCallback(()=>g(null),[]);return e.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:e.jsx(Uo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:d,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:f,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function k0({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:f=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:x,onCloseRightSidebarFilePreview:h,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:E,onOpenRightSidebarRepoPicker:S,onCloseRightSidebarRepoPicker:T,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:C,markdownImageLightboxOpen:A=!1,markdownImageLightboxCloseSignal:O,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j}){const{t:o,locale:_}=ht(),[I,Y]=a.useState(""),H=V(t=>t.pendingTerminalPath),[U,R]=a.useState(null),z=a.useRef(0),Z=V(t=>t.rightSearchOpen),P=V(t=>t.setRightSearchOpen),G=V(t=>t.rightSidebarLayoutPreference),J=V(t=>t.setRightSidebarLayoutPreference),[ie,pe]=a.useState(()=>mx()),[Se,ke]=a.useState("."),[Me,Q]=a.useState(""),[ge,ue]=a.useState(!1),[_e,Ue]=a.useState(!1),[W,we]=a.useState(!1),[ye,He]=a.useState(!1),Ke=a.useDeferredValue(I),[M,he]=a.useState(null),[fe,Ne]=a.useState([]),[$e,rt]=a.useState([]),ce=V(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Te=V(t=>t.setActiveGitRepo),[qe,Ie]=a.useState(null),[De,te]=a.useState(null),[je,nt]=a.useState(null),[Rt,lr]=a.useState(!1),[B,ae]=a.useState(()=>gt(Eu,sa)??!1),[Ce,et]=a.useState(()=>gt(Mu,sa)??!1),[xt,kr]=a.useState(()=>gt($u,sa)??!1),[Nt,Ct]=a.useState(()=>gt(al,cx)??""),[Tn,gs]=a.useState(0),[Sr,zt]=a.useState(!1),[en,er]=a.useState(!1),In=a.useRef(null),jr=a.useRef(null),[Dn,tn]=a.useState(!1),[Or,Wt]=a.useState(null),[Ve,Tt]=a.useState(null),[Rr,Nr]=a.useState(()=>Iu(nl)),[ga,Cr]=a.useState(()=>Iu(Cu)),[Er,ba]=a.useState(()=>lx()),[It,bs]=a.useState(()=>dx()),[Gt,xa]=a.useState(()=>fx()),Kt="words",[va,Go]=a.useState(0),[kt,rn]=a.useState([]),[xs,Ur]=a.useState([]),[Hr,Mr]=a.useState(!1),[$r,zr]=a.useState(null),[Wr,Fn]=a.useState([]),[vs,nn]=a.useState(!1),[tr,Gr]=a.useState([]),[ys,ws]=a.useState([]),[Pr,cr]=a.useState(!1),[ve,rr]=a.useState(null),[sn,an]=a.useState([]),[ks,L]=a.useState({}),K=a.useRef(0),[be,Ee]=a.useState(0),[st,Be]=a.useState(!1),[Ye,Oe]=a.useState(null),[Xe,mt]=a.useState(null),[_n,dr]=a.useState(null),[Ss,on]=a.useState(null),[ln,Kr]=a.useState(!1),[cn,dn]=a.useState(""),js=a.useDeferredValue(cn),[re,Je]=a.useState({}),[Dt,ur]=a.useState([]),[ya,Rs]=a.useState(!1),[wa,Ns]=a.useState(!1),[Ko,Bn]=a.useState(null),[qo,On]=a.useState(!1),fr=a.useRef(null),qr=a.useRef(0),ec=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Mh,ka]=a.useState(null),[Cs,tc]=a.useState(()=>gt(sl,sa)??!1),[Vo,Yo]=a.useState(!1),[Sa,Xo]=a.useState([]),[nr,ja]=a.useState({}),[Et,Ra]=a.useState({}),[un,Jo]=a.useState({}),[rc,nc]=a.useState(()=>new Set),[Qe,fn]=a.useState(null),[Qo,hn]=a.useState(null),[$h,Ar]=a.useState(!1),[Zo,Lr]=a.useState(0),[,ei]=a.useState(0),[ti,Na]=a.useState(!1),[Ph,Ah]=a.useState(()=>V.getState().rightTab==="files"),[sr,ri]=a.useState(!1),[Lh,sc]=a.useState(()=>V.getState().rightTab==="diff"),[ni,ac]=a.useState(()=>V.getState().rightTab==="android"),[Vr,oc]=a.useState(!1),[ar,ic]=a.useState({architecture:!1,computer:!1}),Es=a.useRef(new Set),Ca=Vi(t=>t.docks[Xi]),Th=!!Ca,[We,Ms]=a.useState(null),[Un,$s]=a.useState(null),[vt,mn]=a.useState(null),[lc,qt]=a.useState(null),[Hn,cc]=a.useState(null),[si,Ih]=a.useState(()=>Date.now()),[Dh,Fh]=a.useState(!1),[pn,Ea]=a.useState(!1),[Ma,dc]=a.useState(""),[zn,$a]=a.useState(""),[gn,Pa]=a.useState(""),[bn,Aa]=a.useState(""),[uc,Wn]=a.useState(null),[fc,ai]=a.useState(!1),[hc,mc]=a.useState(!1),[La,_h]=a.useState({key:null,nonce:0}),pc=a.useRef(null),gc=a.useRef(null),se=vp(s,m,G),oi=Of(se,m,Gt),[ii,li]=a.useState(()=>wx(s)),ci=V(t=>t.rightTab),Ft=V(t=>t.setRightTab),v=V(t=>t.rootPath),Gn=V(t=>t.explorerRoot),bc=V(t=>t.pinnedExplorerRootsCache),xc=V(t=>t.hydratePinnedExplorerRoots),vc=V(t=>t.syncPinnedExplorerRoots),_t=V(t=>t.setExplorerRoot),yc=V(t=>t.resetExplorerToProject),Kn=V(t=>t.pinExplorerRoot),xn=V(t=>t.unpinExplorerRoot),ot=V(t=>t.selectedFilePath),it=V(t=>t.selectFile),di=V(t=>t.showHiddenFiles),Bh=V(t=>t.toggleShowHiddenFiles),ui=V(t=>!!(v&&t.nestedGitScanRoots[v])),Fe=V(t=>t.changedFiles),Ta=V(t=>t.setChangedFiles),Ps=V(t=>t.invalidateDirectoryCache),Oh=V(t=>t.setDirectorySortMode),wc=V(t=>t.applyFileWatchEvents),kc=V(t=>t.reconcileDirectoryCache),Sc=V(t=>t.bumpFileWatchEpoch),hr=V(t=>t.gitBundleLoading),jc=V(t=>t.gitBundleSlow),vn=V(t=>t.gitBundleError),qn=V(t=>t.gitBundleLastLoadedAt),Rc=V(t=>t.beginGitBundleLoading),Nc=V(t=>t.setGitBundleSlowFor),fi=V(t=>t.finishGitBundleLoading),Ia=V(t=>t.resetGitBundleLoading),hi=V(t=>t.setGitBundleError),Cc=V(t=>t.markGitBundleLoaded),le=Gn??v,Da=V(t=>!!(le&&t.hideGitIgnoredRoots[le])),Uh=V(t=>t.hideGitIgnoredRootsHydrated),Hh=V(t=>t.setHideGitIgnoredRoot),[mi,Ec]=a.useState(!1),[Mc,pi]=a.useState(null);a.useEffect(()=>{pi(null)},[le]);const $c=a.useMemo(()=>le?Ub(le,Se):"",[le,Se]),As=a.useMemo(()=>Ob(Me),[Me]),Pc=a.useMemo(()=>({excludePatterns:As,caseSensitive:_e,wholeWord:W,regex:ye}),[_e,As,ye,W]),Fa=V(t=>le?t.fileSortModes[le]??"name":"name"),Ac=V(t=>!!(le&&t.directoryCache.has(le))),Vn=a.useRef(null),St=a.useRef(0),[Lc]=a.useState(()=>++p0),Tr=a.useRef(null),Yr=a.useRef(null),_a=a.useRef(0),Vt=a.useRef(new Map),Yt=a.useRef(new Map),mr=a.useRef(new Set),yn=a.useRef(new Set),wn=a.useRef(0),Xr=a.useRef(null),Yn=a.useRef(0),Xn=a.useRef(null),Jn=a.useRef(0),Jr=a.useRef(null),gi=a.useRef(new Set),bi=a.useRef(null),xi=a.useRef(null),Ba=a.useRef(null),vi=a.useRef(null),yi=a.useRef(null),Ls=a.useRef(new Set);a.useEffect(()=>{if(Hn===null)return;const t=Math.max(0,Date.now()-Hn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,u=Math.max(50,i-t%i),w=window.setTimeout(()=>Ih(Date.now()),u);return()=>window.clearTimeout(w)},[si,Hn]);const Oa=a.useRef(null),Ir=a.useRef(null),wi=a.useRef(null),Tc=a.useRef(null),Ts=a.useRef(null),Pe=a.useCallback(t=>V.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=i=>{const u=v0(i.target);u&&ta("global_change_row_event",{...y0(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:V.getState().selectedFilePath,rightTab:V.getState().rightTab,activeGitRepoRoot:ce,changedFiles:V.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const Ic=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(mr.current.has(t)||yn.current.has(t))return dt("untracked_skip_cached",{cwd:t,rootPath:v,completed:mr.current.has(t),running:yn.current.has(t)}),null;const i=v,u=_a.current+1;_a.current=u,Vt.current.set(t,u);const w=`right-sidebar-git-untracked:${t}`,y=new AbortController;Yt.current.set(t,y),yn.current.add(t),dt("untracked_start",{requestId:u,cwd:t,rootPath:v});try{let k=await Kd(t,y.signal,w),N=0;for(;k.status==="running"&&N<120;){if(Vt.current.get(t)!==u||y.signal.aborted)return dt("untracked_stale_result",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,status:k.status}),null;if(!Pe(i))return dt("untracked_root_changed",{requestId:u,cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath}),null;await new Promise(oe=>window.setTimeout(oe,N<10?1e3:3e3)),N+=1,k=await Kd(t,y.signal,w)}if(Vt.current.get(t)!==u||!Pe(i))return dt("untracked_stale_result",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return Ta(kh(V.getState().changedFiles,k.files)),k.files.length>0&&Ne(oe=>{const Ae=new Map(oe.map(me=>[me.root,me])).get(t);if(!Ae)return oe;const Ze=n0(Ae.files,k.files),ee=oe.map(me=>me.root===t?{...me,files:Ze,context:me.context?{...me.context,changedFiles:Ze.map(Le=>({path:Le.path,absolutePath:Le.absolutePath,status:Le.status})),truncated:!1}:me.context,untrackedDeferred:!1}:me);rt(Sh(ee,v));const X=ee.find(me=>me.root===v);return X?.context&&he(me=>me?.root===X.root?{...me,...X.context}:me),ee}),mr.current.add(t),dt("untracked_apply",{requestId:u,cwd:t,files:k.files.length}),k;const ne=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return mr.current.add(t),dt("untracked_error",{requestId:u,cwd:t,message:ne,code:k.code,status:k.status}),null}catch(k){if(Vt.current.get(t)!==u||!Pe(i)||yr(k))return dt("untracked_aborted",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const N=k instanceof Error?k.message:"Failed to scan untracked files";return mr.current.add(t),dt("untracked_error",{requestId:u,cwd:t,message:N}),null}finally{Yt.current.get(t)===y&&Yt.current.delete(t),Vt.current.get(t)===u&&Vt.current.delete(t),yn.current.delete(t)}},[M,Pe,v,Ta]),or=a.useMemo(()=>{const t=new Set($e.map(u=>u.root)),i=Wr.filter(u=>t.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Wr,$e]),Dc=or.length===0,kn=a.useMemo(()=>or.map(t=>fe.find(i=>i.root===t)).filter(t=>!!t),[or,fe]),zh=a.useMemo(()=>$e.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[$e]),pr=a.useCallback(async()=>{if(!v){rn([]),Ur([]);return}const t=v,i=Yn.current+1;Yn.current=i,Xn.current?.abort();const u=new AbortController;Xn.current=u,Mr(kt.length===0),zr(null);try{const w=or.length>0?await Promise.all(or.map(y=>qd({workspaceRoot:v,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(k=>k.records),walkthroughs:y.flatMap(k=>k.walkthroughs??[])})):await qd({workspaceRoot:v},u.signal);if(Yn.current!==i||!Pe(t))return;rn(w.records),Ur(w.walkthroughs??[])}catch(w){if(Yn.current!==i||!Pe(t)||yr(w))return;zr(w instanceof Error?w.message:"Failed to load change audit explanations")}finally{Xn.current===u&&(Xn.current=null),Yn.current===i&&Pe(t)&&Mr(!1)}},[kt.length,or,Pe,v]),Ua=a.useCallback(async(t,i,u)=>{if(!t&&!v){Gr([]),ws([]);return}const w=v,y=Jn.current+1;Jn.current=y,Jr.current?.abort();const k=new AbortController;Jr.current=k;try{const N=t?[t]:Array.from(new Set([v,...fe.map(oe=>oe.root)].filter(oe=>!!oe))),ne=await Promise.all(N.map(oe=>cp({repoRoot:oe,baseRef:i,branchName:u},k.signal))).then(oe=>{const xe=new Map,Ae=new Map;for(const Ze of oe){for(const ee of Ze.records)xe.set(ee.id,ee);for(const ee of Ze.walkthroughs??[])Ae.set(ee.id,ee)}return{records:Array.from(xe.values()),walkthroughs:Array.from(Ae.values())}});if(Jn.current!==y||!Pe(w))return;Gr(ne.records),ws(ne.walkthroughs??[])}catch(N){if(Jn.current!==y||!Pe(w)||yr(N))return;console.warn("[RightSidebar] Failed to load branch explanations",N)}finally{Jr.current===k&&(Jr.current=null)}},[fe,Pe,v]),Qn=a.useCallback((t,i={})=>{if(!Pe(v)){dt("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:V.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}dt(t.files.length===0?"empty_bundle":"apply",{rootPath:v,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let u=Uf(t),w=t.repoFilters??[],y=t.files;const k=V.getState().changedFiles;if(!!(i.cacheOnly&&!t.cached&&t.files.length===0&&u.length===0)&&(k.size>0||fe.length>0||M)){dt("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:fe.length});return}const ne=u.some(X=>X.deferred);if(ne&&!i.replaceWorkspace){const X=new Set(u.filter(Le=>!Le.deferred||Le.root===v).map(Le=>Le.root));y=[...Array.from(k.values()).filter(Le=>!X.has(bt(Le,v)??"")),...t.files]}const oe=Ku(k.values(),v),xe=Ku(t.files,v),Ae=u.some(X=>X.root!==v);if(!!(i.background&&!ne&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||oe>0&&xe===0&&!Ae))){dt("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:oe,nextNestedCount:xe,nextRepositories:u.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(i.replaceRepoRoot){const X=jh(k.values(),fe,t,i.replaceRepoRoot,v);y=X.files,u=X.repositories,w=X.repoFilters}if(Ta(wh(y)),Ne(X=>{if(!ne||i.replaceWorkspace)return u;const me=new Map(X.map(Le=>[Le.root,Le]));return u.map(Le=>{const Ge=me.get(Le.root);return!Le.deferred||!Ge?Le:{...Le,available:Ge.available,files:Ge.files,context:Ge.context,deferred:Ge.deferred,untrackedDeferred:Ge.untrackedDeferred,error:Ge.error}})}),rt(w),yi.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:me}=V.getState(),Le=X?me[X]??null:null,Ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:Le,ze=px({...t,repositories:u,repoFilters:w},Ge);Te(ze)}typeof t.cacheUpdatedAt=="number"&&cc(t.cacheUpdatedAt),he(X=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==v)return X;if(!t.context)return null;const me=X?.root??v;return!X?.available||me!==(t.context.root??v)?t.context:{...X,...t.context}}),i.reloadDiff&&Go(X=>X+1);const ee=V.getState().selectedFilePath;if(ee&&!ee.startsWith("/")&&!y.some(X=>X.path===ee||X.absolutePath===ee)&&it(null),Nr(X=>{const me=new Set(y.map(Ge=>bt(Ge,v)).filter(Boolean)),Le=new Set;for(const Ge of X)me.has(Ge)&&Le.add(Ge);return il(nl,Le),Le}),i.loadDeferred!==!1){const X=u.filter(me=>me.untrackedDeferred&&me.root).map(me=>me.root);for(const me of X)Ic(me)}i.loadAudit!==!1&&pr()},[Pe,pr,Ic,v,it,Te,Ta]);a.useEffect(()=>{Ia(),bi.current=null,xi.current=v;const t=[],i=[];St.current+=1,wn.current+=1,_a.current+=1,Tr.current?.abort(),jt(Zs(Yr.current?.cwd??v??void 0)),Yr.current=null,Tr.current=null,Xr.current?.abort(),jt("right-sidebar-git-details"),Xr.current=null;for(const N of Yt.current.values())N.abort();for(const N of Yt.current.keys())jt(`right-sidebar-git-untracked:${N}`);Yt.current.clear(),Vt.current.clear(),Yn.current+=1,Xn.current?.abort(),Xn.current=null,Jn.current+=1,Jr.current?.abort(),Jr.current=null,qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,rn([]),Ur([]),Mr(!1),zr(null),Fn([]),nn(!1),Gr([]),ws([]),cr(!1),rr(null),Be(!1),Oe(null),mt(null),dr(null),on(null),Kr(!1),dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1),ka(null),fn(null),hn(null),tc(!1),At(sl,!1),Yo(!1);const u=v?Du()[v]:null,w=u?.previewEntries??[],y=u?.selectedPreviewKey??null,k=y?w.find(N=>N.key===y)??null:null;++K.current,Be(!1),Xo(u?.selectedRepoRoots??[]),ja(u?.repoTargetBranches??{}),Ra(u?.repoBaseBranches??{}),an(w),L(u?.previewScrollTops??{}),k&&u?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(rr(k.diff),fn(k.key),hn(u.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),cr(!0)),Jo(u?.repoIncludeUncommitted??Object.fromEntries(Object.keys(u?.repoTargetBranches??{}).map(N=>[N,u?.includeUncommitted??!0]))),bi.current=v,Ea(!1),mr.current.clear(),yn.current.clear(),Ms(null),$s(null),mn(null),qt(null),cc(null),Ne(t),rt(i),he(null),vi.current=null,yi.current=null,Ls.current.clear()},[Ia,v]);const Bt=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const u=v,w=St.current;if(await vg(()=>Promise.all([V.getState().hydrateNestedGitScanRoots(),V.getState().hydrateActiveGitRepos()]).then(()=>{})),St.current!==w||!Pe(u))return null;const y=t===v&&Js(v),k=i.includeNested??y,N=i.refresh??i.reloadDiff??!1,ne=i.cacheOnly??!1,oe=i.background??!1,xe=k&&(i.discoverOnly??!1);N&&mr.current.clear();const Ae=Yr.current;if(Ae&&Ae.cwd===t&&Ae.includeNested===k&&Ae.refresh===N&&Ae.cacheOnly===ne&&Ae.discoverOnly===xe)return dt("reuse_pending",{cwd:t,includeNested:k,refresh:N,cacheOnly:ne,discoverOnly:xe}),Ae.promise;const Ze=St.current+1;St.current=Ze;const ee=`right-sidebar:${Lc}:${Ze}`;Tr.current?.abort();const X=Zs(t);jt(X);const me=new AbortController;Tr.current=me;let Le=null;oe||Rc(ee),hi(null),dt("start",{requestId:Ze,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:N,cacheOnly:ne,background:oe,existingChanges:Fe.size,lastLoadedAt:qn}),!oe&&typeof window<"u"&&(Le=window.setTimeout(()=>{St.current===Ze&&Nc(ee,!0)},Xb));const Ge=(async()=>{const ze=await Yi(t,me.signal,{includeNested:k,refresh:N,cacheOnly:ne,discoverOnly:xe,action:N?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:N?null:void 0});if(o0(ze)){if(dt("cancelled_result_ignored",{requestId:Ze,activeRequestId:St.current,cwd:t,error:ze.error??ze.context?.error}),me.signal.aborted)return null;throw new Error(ze.error??ze.context?.error??"Failed to load Git changes")}return St.current!==Ze||!Pe(u)?(dt("stale_result",{requestId:Ze,activeRequestId:St.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,files:ze.files.length,repositories:ze.repositories?.length??0}),null):(Qn(ze,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:oe,cacheOnly:ne,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),ze)})();Yr.current={cwd:t,includeNested:k,refresh:N,cacheOnly:ne,discoverOnly:xe,promise:Ge};try{const ze=await Ge;return St.current===Ze&&ze&&Pe(u)?Cc({cached:ze.cached,stale:ze.stale,cacheAgeMs:ze.cacheAgeMs,nestedDeferred:!k||ze.nestedDeferred,untrackedDeferred:ze.untrackedDeferred}):St.current===Ze&&Pe(u)&&fi(ee),ze}catch(ze){return St.current!==Ze||!Pe(u)||me.signal.aborted?(dt("aborted",{requestId:Ze,activeRequestId:St.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,message:ze instanceof Error?ze.message:String(ze)}),null):(dt("error",{requestId:Ze,cwd:t,includeNested:k,refresh:N,background:oe,message:ze instanceof Error?ze.message:String(ze)}),oe||(he(null),hi(ze instanceof Error?ze.message:"Failed to load Git changes")),null)}finally{Le!==null&&window.clearTimeout(Le),Tr.current===me&&(Tr.current=null),Yr.current?.promise===Ge&&(Yr.current=null),!oe&&St.current===Ze&&Pe(u)&&fi(ee)}},[Qn,Rc,Fe.size,fi,Lc,qn,Pe,Cc,v,hi,Nc]),Zn=a.useCallback(async()=>{v&&await Bt(v,{reloadDiff:!0,refresh:!0})},[Bt,v]),ki=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,u=wn.current+1;wn.current=u,Xr.current?.abort(),jt("right-sidebar-git-details");const w=new AbortController;Xr.current=w,Ea(!0);try{const y=await Vd(t,w.signal,"load_git_details","right-sidebar-git-details");return wn.current!==u||!Pe(i)?null:(Ne(k=>k.map(N=>N.root===y.root?{...N,available:y.available,context:y,error:y.error}:N)),he(k=>k?.root&&y.root&&k.root!==y.root?k:!k?.available||!y.available?y:{...k,...y}),y)}catch(y){return yr(y)||!Pe(i)||wn.current===u&&qt(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Xr.current===w&&(Xr.current=null),wn.current===u&&Pe(i)&&Ea(!1)}},[Pe,v]);a.useEffect(()=>{if(!r){St.current+=1,Ia(),vi.current=null,wn.current+=1,_a.current+=1,Tr.current?.abort(),jt(Zs(Yr.current?.cwd??v??void 0)),Yr.current=null,Tr.current=null,Xr.current?.abort(),jt("right-sidebar-git-details"),Xr.current=null;for(const t of Yt.current.values())t.abort();for(const t of Yt.current.keys())jt(`right-sidebar-git-untracked:${t}`);Yt.current.clear(),Vt.current.clear(),Jn.current+=1,Jr.current?.abort(),Jr.current=null,qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,Ea(!1),Be(!1),Oe(null),mt(null),dr(null),on(null),Kr(!1),dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1),Y(""),P(!1),Wt(null),ri(!1),se&&sc(!1)}},[se,r,Ia,P]),a.useEffect(()=>{if(!Z)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[Z]),a.useEffect(()=>{se||Ar(!1)},[se]);const Fc=a.useCallback(t=>{ei(t);const i=wi.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(se)if(Ar(f),f&&ot){Lr(1);const t=Ir.current;t&&(t.update(),t.activeIndex!==1&&(Ts.current=1,t.slideTo(1,0)))}else{Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Wt(null)}},[se,f,v,ot]),a.useEffect(()=>{if(p!==void 0&&!f){Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ar(!1),Wt(null)}},[p,f]),a.useEffect(()=>{E!==void 0&&Ie(null)},[E]),a.useEffect(()=>{!se&&f&&h?.()},[se,h,f]),a.useEffect(()=>{li(t=>Al(t,s))},[s]);const Wh=a.useCallback(t=>{se||(t.preventDefault(),Oa.current={startX:t.clientX,startWidth:ii,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[ii,se]),Gh=a.useCallback(t=>{const i=Oa.current;if(!i||i.pointerId!==t.pointerId)return;const u=Al(i.startWidth+t.clientX-i.startX,s);li(u),aa(na,u,Yb)},[s]),_c=a.useCallback(t=>{const i=Oa.current;if(!(!i||i.pointerId!==t.pointerId)){Oa.current=null,Xs(na);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),es=!!(v&&qn!==null&&Yu(M)),Si=!!(v&&!vn&&Fe.size===0&&qn===null),Mt=(()=>{let t=ci;return t==="android"&&!Vr&&(t="files"),(t==="architecture"||t==="computer")&&!ar[t]&&(t="files"),es&&(t==="git"||t==="diff")&&(t="files"),t})(),ct=Mt==="git",Dr=Mt==="files",$t=Mt==="diff",ts=Mt==="android",rs=Mt==="computer",Sn=Mt==="architecture",[Kh,qh]=a.useState(!1);a.useEffect(()=>{r&&rs&&qh(!0)},[r,rs]);const[Vh,Yh]=a.useState(!1);a.useEffect(()=>{r&&Sn&&Yh(!0)},[r,Sn]);const ji=a.useRef(null),ns=a.useCallback((t,i)=>{const u=V.getState().rightTab;if(u===t)return;const w=performance.now(),y=w-i.timeStamp;ji.current={from:u,to:t,startedAt:w,inputDelayMs:y>=0&&y<6e4?Math.round(y):null},Ft(t)},[Ft]);a.useEffect(()=>{const t=ji.current;if(!t||t.to!==Mt)return;ji.current=null;const i=Math.round(performance.now()-t.startedAt);let u=window.requestAnimationFrame(()=>{u=window.requestAnimationFrame(()=>{ta("tab_switch_presented",{from:t.from,to:t.to,inputDelayMs:t.inputDelayMs,commitMs:i,frameMs:Math.round(performance.now()-t.startedAt)})})});return()=>window.cancelAnimationFrame(u)},[Mt]);const Xh=Ap(t=>t.overlay==="sidebar")&&ts;a.useEffect(()=>{if(!se){Na(!0);return}if(!r){const i=window.setTimeout(()=>{Na(!1)},Zb);return()=>window.clearTimeout(i)}Na(!1);const t=window.setTimeout(()=>{Na(!0)},Qb);return()=>window.clearTimeout(t)},[se,r]),a.useEffect(()=>{if(!se||!$t)return;const t=wi.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[$t,se]),a.useEffect(()=>{if(!es||!v||hr)return;const t=window.setTimeout(()=>{Bt(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[es,v,hr,Bt]);const Jh=a.useCallback(t=>{Bt(t,{discoverOnly:!0})},[Bt]);yg({active:r&&(ct||$t),rootPath:v,loading:hr,delay:ct&&!se?0:ol,lastStartedRoot:vi,load:Jh}),a.useEffect(()=>{!r||!ct||(!se||ti)&&ri(!0)},[ct,se,r,ti]),a.useEffect(()=>{if(!r||ct)return;const t=window.setTimeout(()=>{ri(!0)},ol);return()=>window.clearTimeout(t)},[ct,r]),a.useEffect(()=>{Dr&&Ah(!0)},[Dr]),a.useEffect(()=>{$t&&sc(!0)},[$t]),a.useEffect(()=>{!r||!ts||(n&&Ca&&Ca.sessionId!==n&&(Vi.getState().setDock(Xi,null),ra({androidPanel:{docked:null}}).catch(()=>{})),ac(!0))},[ts,r,n,Ca]),a.useEffect(()=>{if(r&&ts||!ni)return;const t=window.setTimeout(()=>ac(!1),Jb);return()=>window.clearTimeout(t)},[r,ts,ni]),a.useEffect(()=>{let t=!1;return Zu().then(i=>{t||(Es.current.has("android")||oc(i.androidPanel?.enabled===!0),ic(u=>({architecture:Es.current.has("architecture")?u.architecture:i.rightSidebarTabs?.architecture===!0,computer:Es.current.has("computer")?u.computer:i.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{t=!0}},[]);const Bc=a.useCallback(t=>{Es.current.add("android"),oc(t),t?Ft("android"):V.getState().rightTab==="android"&&Ft("files"),ra({androidPanel:{enabled:t}}).catch(()=>{})},[Ft]),Qh=a.useCallback((t,i)=>{Es.current.add(t),ic(u=>({...u,[t]:i})),i?Ft(t):V.getState().rightTab===t&&Ft("files"),ra({rightSidebarTabs:{[t]:i}}).catch(()=>{})},[Ft]),Oc=a.useCallback(t=>{le&&Qx(le,t.currentTarget.scrollTop)},[le]);a.useEffect(()=>()=>{Tr.current?.abort(),Xs(Ul),Xs(Hl),Xs(na),Xs(al)},[]),a.useEffect(()=>{if(!le||!Ac)return;const t=vh()[le]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Vn.current&&(Vn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Vn.current&&(Vn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[le,Ac]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return dp(t.signal).then(i=>mc(!!i.available)).catch(()=>mc(!1)),()=>t.abort()},[r]);const Is=a.useCallback(t=>{if(R(null),it(t),Wt(null),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,it]),Ri=a.useCallback((t,i)=>{if(R(null),it(t),Tt(i),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,it]),Ot=Qg(t=>Ps(t,!1)),Ha=Ot.busy,Ds=a.useCallback(async(t,i)=>{const u=i||Gn||v;!u||!t.length||await Ot.start(u,t)},[Gn,v,Ot.start]),Uc=a.useCallback(async t=>{try{await up(t)}catch(i){qt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>qt(null),4e3)}},[o]),za=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&ai(!0)},[]),Hc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ai(!1)},[]),zc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ai(!1);const i=t.dataTransfer.files;i.length>0&&Ds(Array.from(i))},[Ds]),Ni=a.useCallback(t=>{te(t),window.setTimeout(()=>te(i=>i===t?null:i),1400)},[]),gr=a.useCallback(t=>{nt(t),window.setTimeout(()=>nt(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{At(Eu,B)},[B]),a.useEffect(()=>{At(Mu,Ce)},[Ce]),a.useEffect(()=>{At($u,xt)},[xt]),a.useEffect(()=>{aa(al,Nt,Wb)},[Nt]),a.useEffect(()=>(xc().catch(()=>{}),Yd(t=>{t.type==="pinned-explorer-roots"&&vc(t.pinnedExplorerRoots)})),[xc,vc]);const Wc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Wa=a.useRef(null),jn=a.useRef(null),[Gc,Ci]=a.useState(!1);a.useEffect(()=>{if(!r)return;Ci(!1);let t=!1;fp().then(u=>{t||(Wa.current=u.text,Ct(w=>u.text&&u.text!==w?u.text:w),Ci(!0))}).catch(()=>{t||Ci(!0)});const i=Yd(u=>{u.type==="context-draft"&&u.origin!==Wc.current&&(Wa.current=u.text,Ct(u.text))});return()=>{t=!0,i(),jn.current!==null&&(window.clearTimeout(jn.current),jn.current=null)}},[r]),a.useEffect(()=>{if(!Gc||Wa.current===Nt)return;jn.current!==null&&window.clearTimeout(jn.current);const t=Nt;jn.current=window.setTimeout(()=>{jn.current=null,hp(t,Wc.current).then(()=>{Wa.current=t}).catch(()=>{})},500)},[Nt,Gc]);const ss=a.useCallback(async(t,i,u,w)=>{if(!t)return!1;if(lr(!1),w&&!Ji(w)())return lr(!0),!1;if(mp(u?t+u:t))return Ni(i),!0;if(B)Ct(y=>Yg(y,t)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(et(!1),gs(y=>y+1));else{const y=n??Qr.getState().activeSessionId;if(!await sf(u?t+u:t,y,()=>_s.current&&y===Qr.getState().activeSessionId,w))return lr(!0),!1}return Ni(i),!0},[B,Ni,n]),Ga=a.useCallback(t=>{const i=Pn(t,v);return Lp(i,v)},[v]),Ei=xf(gr),Xt=a.useCallback((t,i,u)=>{const w=Pn(t,v);return ss(su(w,v),i??`path:${w}`,void 0,u)},[v,ss]),as=a.useRef({sessionId:n,contextDraftEnabled:B,isOpen:r});as.current={sessionId:n,contextDraftEnabled:B,isOpen:r};const Zh=a.useCallback(async(t,i)=>{const u=n??Qr.getState().activeSessionId,w=()=>_s.current&&as.current.isOpen&&(as.current.sessionId??Qr.getState().activeSessionId)===u&&Qr.getState().activeSessionId===u&&as.current.contextDraftEnabled===B;await Ot.start("/tmp",[t],k=>Xt(k,`path:${k}`,i),w)&&w()&&se&&!B&&l()},[B,Xt,se,l,n,Ot.start]),Fs=a.useRef(!0),Ka=a.useRef(n);Ka.current=n,a.useEffect(()=>(Fs.current=!0,()=>{Fs.current=!1}),[]);const em=a.useCallback(t=>{Tp.getState().enqueue(t,n??null,v||"/",async(i,u)=>{if(as.current.contextDraftEnabled&&Fs.current&&Ka.current===n){if(!await Mi.current(su(i,null),`path:${i}`,u))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return au(i,n,u)})},[n,v,B,Xt,o]),tm=a.useCallback(async(t,i)=>{const u=Ji(i),y=(await bl("/tmp",[t])).files[0]?.path;if(!y)throw new Error("截图上传未返回文件路径");if(!u()||!Fs.current||Ka.current!==n||as.current.contextDraftEnabled!==B)throw new Error(o("rightSidebar.uploadReferenceRejected"));if(B&&Fs.current&&Ka.current===n){if(!await Xt(y,void 0,i))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await au(y,n,i)},[B,Xt,n,o]),Fr=a.useCallback((t,i,u)=>{if(!t)return Promise.resolve(!1);const w=t.includes(`
|
|
1661
|
+
`})(),Mr=`path:${Ve}`,$r=M?`path:${Ve}:${M.start}-${M.end}`:Mr,zr=A===Mr,Wr=A===$r,Fn=_===Mr,vs=_===$r,nn=Wr||vs,tr=M?M.start===M.end?`L${M.start}`:`L${M.start}-${M.end}`:null,Gr=L=>{const K=Me.current;if(!K)return;const be=K.getBoundingClientRect(),Ee=L.currentTarget.getBoundingClientRect(),st=L.clientX||Ee.left+Ee.width/2,Ye=(L.clientY||Ee.top+Ee.height/2)-be.top+K.scrollTop,Oe=p?116:132,Xe=K.scrollLeft+Math.max(8,K.clientWidth-Oe),mt=Math.min(Math.max(8,st-be.left+K.scrollLeft+10),Xe);ge({top:Ye,left:mt})},ws=(L,K)=>{Sl()||(Gr(L),N(be=>{const Ee=jl(be,K,K);return Ee||ge(null),Ee}))},ys=(L,K,be)=>{Gr(L),N(Ee=>{const st=jl(Ee,K,be);return st||ge(null),st})},Pr=(L,K,be,Ee)=>{Ee==="end"&&Gr(L),N({start:K,end:be})},cr=L=>{const{scrollTop:K,scrollLeft:be}=L.currentTarget;fe(K),fl(H,n,{top:K,left:be,markdownTop:K})},ve=L=>{if(L.directory){h?.(L.path);return}if(L.path===Ve||R.kind==="text"&&L.path===R.sourcePath){L.fragment&&In(L.fragment);return}$e(K=>[...K,Ve]),Te.current=L.path,ce(L.fragment),N(null),U(L.path)},rr=()=>{const L=Ne[Ne.length-1];L&&($e(K=>K.slice(0,-1)),Te.current=L,ce(null),N(null),U(L))},sn=L=>{const{scrollTop:K,scrollLeft:be}=L.currentTarget;fl(H,n,{top:K,left:be})},an=L=>{if(r){r(Hr,$r,void 0,L.currentTarget);return}M&&d(Hr,$r,L.currentTarget)},ks=()=>{if(!(R.kind==="loading"||R.kind==="error"))return te.start()};return e.jsxs("div",{ref:B,tabIndex:-1,onKeyDown:Wt,onFocusCapture:()=>{s&&je&&Rt.trim()&&sl(O,Ce,I.current)},onPointerDownCapture:L=>{L.target instanceof Element&&!L.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&L.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[kr.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(Gt||Kt)?"py-1.5":"py-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[p&&g&&e.jsx("button",{type:"button",onClick:g,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:e.jsx(uf,{size:16})}),Ne.length>0&&e.jsxs("button",{type:"button",onClick:rr,className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-primary/10 text-primary transition hover:bg-primary/15 active:scale-95 ${p?"w-9":"px-2.5"}`,"aria-label":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[e.jsx(ca,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ve,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Tt.name}),Tt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Tt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[jr&&e.jsx("button",{type:"button",onClick:je?Dn:tn,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${je?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(ms,{size:14})}),Er&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{x&&E?.(),_e(L=>{const K=L==="preview"?"source":"preview";return At(Pf,K),K}),N(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?ue==="preview"?e.jsx(Nl,{size:14}):e.jsx(Rl,{size:14}):o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),va&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{W(L=>{const K=L==="preview"?"source":"preview";return ib(H,n,K),K}),N(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?Ue==="preview"?e.jsx(Nl,{size:14}):e.jsx(Rl,{size:14}):o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Kt&&e.jsx("button",{type:"button",onClick:()=>{ye.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o(we?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(we?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(ff,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:L=>l(Ve,Mr,L.currentTarget),...kr(Rr,Mr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${zr||Fn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Rr}),children:o(Fn?"rightSidebar.copied":zr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Rr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.copyReference",{reference:Rr}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(dp,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ks()},disabled:te.status==="pending"||R.kind==="loading"||R.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:te.status==="error"?te.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(ft,{size:13,className:"animate-spin"}):e.jsx(lf,{size:14})}),te.status==="pending"&&e.jsx("button",{type:"button",onClick:te.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),te.status==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",te.error]}),te.status==="canceled"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),te.status==="saved"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),te.status==="started"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),je&&jr&&e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:xt,type:"search",value:Rt,onChange:L=>lr(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),Or(L.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:O.length>0?`${Ce+1}/${O.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Or(-1),disabled:O.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(zl,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Or(1),disabled:O.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Ip,{size:13})}),e.jsx("button",{type:"button",onClick:Dn,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Lt,{size:13})})]}),Cr&&!(p&&(Gt||Kt))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Cr.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Cr.size.toLocaleString()})}),"truncated"in Cr&&Cr.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Cr&&e.jsx("span",{children:Cr.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(Gt||Kt))&&!qo&&R.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:rn?o("rightSidebar.edaPickHint"):xa?o("rightSidebar.csvTablePreview"):It||bs?o("rightSidebar.kicadProjectPickHint"):kt?o("rightSidebar.videoPreviewHint"):wa?o("rightSidebar.imagePreviewHint"):Gt?M?o("rightSidebar.selectedLineHint",{lineLabel:tr??""}):o("rightSidebar.markdownPreviewHint"):Kt?o("rightSidebar.htmlPreviewHint"):M?o("rightSidebar.selectedLineHint",{lineLabel:tr??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||Kt)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(Yi,{label:R.mode==="eda"?o("rightSidebar.edaLoading"):R.mode==="image"?o("rightSidebar.loadingImage"):R.mode==="model3d"?o("rightSidebar.model3dLoading"):R.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):R.kind==="error"?e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[e.jsx("div",{className:"mx-3 mt-3 border border-destructive/20 bg-destructive/5 px-4 py-4 text-sm text-destructive",children:R.message}),e.jsx("button",{type:"button",onClick:er,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):R.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:o("rightSidebar.binaryPreviewHint")})}):R.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:R.meta.mimeType==="image/svg+xml"?e.jsx(Nf,{blobUrl:R.objectUrl,filePath:Ve,viewLabel:"SVG 文件",onInsertAnnotation:r??c}):e.jsx(Ah,{src:R.objectUrl,alt:Tt.name,vector:!1,onLoad:L=>{const K=L.currentTarget;z(be=>be.kind==="image"?{...be,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:be)},onError:()=>z({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):R.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(xb,{url:R.url,onLoadError:()=>z({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):R.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Rb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Ve.toLowerCase().endsWith(".kicad_pcb"),onViewChange:P,onInsertAnnotation:r??c,onRefresh:er,interactive3d:G?e.jsx(a.Suspense,{fallback:e.jsx(Yi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Iu,{blobUrl:G.objectUrl,ext:".glb",fileName:Tt.name,filePath:G.sourcePath,features:null,onInsertFeature:r??c,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:L=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(L)?L:"PCB板体/铜箔/丝印",active:R.view==="pcb-3d"})}):void 0})}):R.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx(Yi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Iu,{blobUrl:R.objectUrl,ext:R.ext,fileName:Tt.name,filePath:R.sourcePath,features:pe,onInsertFeature:r??c,onRefresh:er})})}):R.kind==="text"&&xa?e.jsx(Eb,{content:R.content,filePath:Ve,onInsertAnnotation:r??c},Ve):R.kind==="text"&&(It||bs)?e.jsx(Pb,{content:R.content,filePath:Ve,localState:bs,onInsertAnnotation:r??c},Ve):Gt?e.jsxs("div",{ref:Me,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:cr,style:{touchAction:"pan-x pan-y"},children:[e.jsx(kh,{content:R.content,filePath:R.sourcePath,rootPath:H,lineRange:M,onLineRangeClick:ys,onLineRangeDrag:Pr,scrollTop:he,outlineOpen:x,outlineCloseSignal:f,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:j,lightboxCloseSignal:T,onLightboxOpen:D,onLightboxClose:F,onLocalLinkOpen:ve}),M&&Q&&e.jsxs("button",{type:"button",onClick:an,...kr(Hr,$r),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:mu(p,nn),title:`Insert markdown reference: ${Ur}`,children:[e.jsx(Lo,{size:p?13:11}),vs?o("rightSidebar.copied"):Wr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:tr??""})]})]}):Kt?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Bb,{ref:ye,src:up(Ve),title:`${Tt.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:He},`${Ve}:${Tn}:${zt}`)}):R.kind==="text"?e.jsxs("div",{ref:Me,onScroll:sn,className:`${Kl} termdock-native-select termdock-code relative min-h-0 flex-1 overflow-auto rounded-none bg-surface p-2 font-mono text-[11px] leading-relaxed text-foreground`,children:[Nr.length>0?e.jsx("div",{className:"min-w-full",children:Nr.map((L,K)=>{const be=K+1,Ee=!!(M&&be>=M.start&&be<=M.end),st=Ie&&Ie.length===Nr.length?Ie[K]:null;return e.jsxs("div",{ref:Be=>{Be?ke.current.set(be,Be):ke.current.delete(be)},role:"button","data-file-preview-line":be,tabIndex:0,onClick:Be=>ws(Be,be),onKeyDown:Be=>{Be.key!=="Enter"&&Be.key!==" "||(Be.preventDefault(),ws(Be,be))},style:{gridTemplateColumns:`${ba}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Ee?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Rr}:${be}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Ee?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:be}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:st??(L||" ")})]},K)})}):"Empty file.",M&&Q&&e.jsxs("button",{type:"button",onClick:an,...kr(Hr,$r),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:mu(p,nn),title:`Insert code reference: ${Ur}`,children:[e.jsx(Lo,{size:p?13:11}),vs?o("rightSidebar.copied"):Wr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:tr??""})]})]}):null]})}function k0({rootPath:r,file:n,active:s,...l}){const[d,c]=a.useState(null),[m,g]=a.useState(n.line??1),h=a.useCallback(()=>g(null),[]);return e.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:e.jsx(zo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:d,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:h,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function S0({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:h=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:x,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:E,onOpenRightSidebarRepoPicker:j,onCloseRightSidebarRepoPicker:T,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:M,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A=!1,markdownImageLightboxCloseSignal:_,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:S}){const{t:o,locale:B}=ht(),[I,Y]=a.useState(""),H=V(t=>t.pendingTerminalPath),[U,R]=a.useState(null),z=a.useRef(0),Z=V(t=>t.rightSearchOpen),P=V(t=>t.setRightSearchOpen),G=V(t=>t.rightSidebarLayoutPreference),J=V(t=>t.setRightSidebarLayoutPreference),[ie,pe]=a.useState(()=>xx()),[Se,ke]=a.useState("."),[Me,Q]=a.useState(""),[ge,ue]=a.useState(!1),[_e,Ue]=a.useState(!1),[W,ye]=a.useState(!1),[we,He]=a.useState(!1),Ke=a.useDeferredValue(I),[$,he]=a.useState(null),[fe,Ne]=a.useState([]),[$e,rt]=a.useState([]),ce=V(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Te=V(t=>t.setActiveGitRepo),[qe,Ie]=a.useState(null),[De,te]=a.useState(null),[je,nt]=a.useState(null),[Rt,lr]=a.useState(!1),[O,ae]=a.useState(()=>gt($u,sa)??!1),[Ce,et]=a.useState(()=>gt(Pu,sa)??!1),[xt,kr]=a.useState(()=>gt(Au,sa)??!1),[Nt,Ct]=a.useState(()=>gt(il,hx)??""),[Tn,gs]=a.useState(0),[Sr,zt]=a.useState(!1),[en,er]=a.useState(!1),In=a.useRef(null),jr=a.useRef(null),[Dn,tn]=a.useState(!1),[Or,Wt]=a.useState(null),[Ve,Tt]=a.useState(null),[Rr,Nr]=a.useState(()=>Fu(al)),[ba,Cr]=a.useState(()=>Fu(Mu)),[Er,xa]=a.useState(()=>fx()),[It,bs]=a.useState(()=>mx()),[Gt,va]=a.useState(()=>gx()),Kt="words",[wa,qo]=a.useState(0),[kt,rn]=a.useState([]),[xs,Ur]=a.useState([]),[Hr,Mr]=a.useState(!1),[$r,zr]=a.useState(null),[Wr,Fn]=a.useState([]),[vs,nn]=a.useState(!1),[tr,Gr]=a.useState([]),[ws,ys]=a.useState([]),[Pr,cr]=a.useState(!1),[ve,rr]=a.useState(null),[sn,an]=a.useState([]),[ks,L]=a.useState({}),K=a.useRef(0),[be,Ee]=a.useState(0),[st,Be]=a.useState(!1),[Ye,Oe]=a.useState(null),[Xe,mt]=a.useState(null),[_n,dr]=a.useState(null),[Ss,on]=a.useState(null),[ln,Kr]=a.useState(!1),[cn,dn]=a.useState(""),js=a.useDeferredValue(cn),[re,Je]=a.useState({}),[Dt,ur]=a.useState([]),[ya,Rs]=a.useState(!1),[ka,Ns]=a.useState(!1),[Vo,Bn]=a.useState(null),[Yo,On]=a.useState(!1),fr=a.useRef(null),qr=a.useRef(0),rc=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Lh,Sa]=a.useState(null),[Cs,nc]=a.useState(()=>gt(ol,sa)??!1),[Xo,Jo]=a.useState(!1),[ja,Qo]=a.useState([]),[nr,Ra]=a.useState({}),[Et,Na]=a.useState({}),[un,Zo]=a.useState({}),[sc,ac]=a.useState(()=>new Set),[Qe,fn]=a.useState(null),[ei,hn]=a.useState(null),[Th,Ar]=a.useState(!1),[ti,Lr]=a.useState(0),[,ri]=a.useState(0),[ni,Ca]=a.useState(!1),[Ih,Dh]=a.useState(()=>V.getState().rightTab==="files"),[sr,si]=a.useState(!1),[Fh,oc]=a.useState(()=>V.getState().rightTab==="diff"),[ai,ic]=a.useState(()=>V.getState().rightTab==="android"),[Vr,lc]=a.useState(!1),[ar,cc]=a.useState({architecture:!1,computer:!1}),Es=a.useRef(new Set),Ea=Xi(t=>t.docks[Qi]),_h=!!Ea,[We,Ms]=a.useState(null),[Un,$s]=a.useState(null),[vt,mn]=a.useState(null),[dc,qt]=a.useState(null),[Hn,uc]=a.useState(null),[oi,Bh]=a.useState(()=>Date.now()),[Oh,Uh]=a.useState(!1),[pn,Ma]=a.useState(!1),[$a,fc]=a.useState(""),[zn,Pa]=a.useState(""),[gn,Aa]=a.useState(""),[bn,La]=a.useState(""),[hc,Wn]=a.useState(null),[mc,ii]=a.useState(!1),[pc,gc]=a.useState(!1),[Ta,Hh]=a.useState({key:null,nonce:0}),bc=a.useRef(null),xc=a.useRef(null),se=Sp(s,m,G),li=Uf(se,m,Gt),[ci,di]=a.useState(()=>Rx(s)),ui=V(t=>t.rightTab),Ft=V(t=>t.setRightTab),v=V(t=>t.rootPath),Gn=V(t=>t.explorerRoot),vc=V(t=>t.pinnedExplorerRootsCache),wc=V(t=>t.hydratePinnedExplorerRoots),yc=V(t=>t.syncPinnedExplorerRoots),_t=V(t=>t.setExplorerRoot),kc=V(t=>t.resetExplorerToProject),Kn=V(t=>t.pinExplorerRoot),xn=V(t=>t.unpinExplorerRoot),ot=V(t=>t.selectedFilePath),it=V(t=>t.selectFile),fi=V(t=>t.showHiddenFiles),zh=V(t=>t.toggleShowHiddenFiles),hi=V(t=>!!(v&&t.nestedGitScanRoots[v])),Fe=V(t=>t.changedFiles),Ia=V(t=>t.setChangedFiles),Ps=V(t=>t.invalidateDirectoryCache),Wh=V(t=>t.setDirectorySortMode),Sc=V(t=>t.applyFileWatchEvents),jc=V(t=>t.reconcileDirectoryCache),Rc=V(t=>t.bumpFileWatchEpoch),hr=V(t=>t.gitBundleLoading),Nc=V(t=>t.gitBundleSlow),vn=V(t=>t.gitBundleError),qn=V(t=>t.gitBundleLastLoadedAt),Cc=V(t=>t.beginGitBundleLoading),Ec=V(t=>t.setGitBundleSlowFor),mi=V(t=>t.finishGitBundleLoading),Da=V(t=>t.resetGitBundleLoading),pi=V(t=>t.setGitBundleError),Mc=V(t=>t.markGitBundleLoaded),le=Gn??v,Fa=V(t=>!!(le&&t.hideGitIgnoredRoots[le])),Gh=V(t=>t.hideGitIgnoredRootsHydrated),Kh=V(t=>t.setHideGitIgnoredRoot),[gi,$c]=a.useState(!1),[Pc,bi]=a.useState(null);a.useEffect(()=>{bi(null)},[le]);const Ac=a.useMemo(()=>le?Gb(le,Se):"",[le,Se]),As=a.useMemo(()=>Wb(Me),[Me]),Lc=a.useMemo(()=>({excludePatterns:As,caseSensitive:_e,wholeWord:W,regex:we}),[_e,As,we,W]),_a=V(t=>le?t.fileSortModes[le]??"name":"name"),Tc=V(t=>!!(le&&t.directoryCache.has(le))),Vn=a.useRef(null),St=a.useRef(0),[Ic]=a.useState(()=>++g0),Tr=a.useRef(null),Yr=a.useRef(null),Ba=a.useRef(0),Vt=a.useRef(new Map),Yt=a.useRef(new Map),mr=a.useRef(new Set),wn=a.useRef(new Set),yn=a.useRef(0),Xr=a.useRef(null),Yn=a.useRef(0),Xn=a.useRef(null),Jn=a.useRef(0),Jr=a.useRef(null),xi=a.useRef(new Set),vi=a.useRef(null),wi=a.useRef(null),Oa=a.useRef(null),yi=a.useRef(null),ki=a.useRef(null),Ls=a.useRef(new Set);a.useEffect(()=>{if(Hn===null)return;const t=Math.max(0,Date.now()-Hn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,u=Math.max(50,i-t%i),y=window.setTimeout(()=>Bh(Date.now()),u);return()=>window.clearTimeout(y)},[oi,Hn]);const Ua=a.useRef(null),Ir=a.useRef(null),Si=a.useRef(null),Dc=a.useRef(null),Ts=a.useRef(null),Pe=a.useCallback(t=>V.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=i=>{const u=w0(i.target);u&&ta("global_change_row_event",{...y0(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:V.getState().selectedFilePath,rightTab:V.getState().rightTab,activeGitRepoRoot:ce,changedFiles:V.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const Fc=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(mr.current.has(t)||wn.current.has(t))return ut("untracked_skip_cached",{cwd:t,rootPath:v,completed:mr.current.has(t),running:wn.current.has(t)}),null;const i=v,u=Ba.current+1;Ba.current=u,Vt.current.set(t,u);const y=`right-sidebar-git-untracked:${t}`,w=new AbortController;Yt.current.set(t,w),wn.current.add(t),ut("untracked_start",{requestId:u,cwd:t,rootPath:v});try{let k=await Vd(t,w.signal,y),C=0;for(;k.status==="running"&&C<120;){if(Vt.current.get(t)!==u||w.signal.aborted)return ut("untracked_stale_result",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,status:k.status}),null;if(!Pe(i))return ut("untracked_root_changed",{requestId:u,cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath}),null;await new Promise(oe=>window.setTimeout(oe,C<10?1e3:3e3)),C+=1,k=await Vd(t,w.signal,y)}if(Vt.current.get(t)!==u||!Pe(i))return ut("untracked_stale_result",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return Ia(Nh(V.getState().changedFiles,k.files)),k.files.length>0&&Ne(oe=>{const Ae=new Map(oe.map(me=>[me.root,me])).get(t);if(!Ae)return oe;const Ze=s0(Ae.files,k.files),ee=oe.map(me=>me.root===t?{...me,files:Ze,context:me.context?{...me.context,changedFiles:Ze.map(Le=>({path:Le.path,absolutePath:Le.absolutePath,status:Le.status})),truncated:!1}:me.context,untrackedDeferred:!1}:me);rt(Ch(ee,v));const X=ee.find(me=>me.root===v);return X?.context&&he(me=>me?.root===X.root?{...me,...X.context}:me),ee}),mr.current.add(t),ut("untracked_apply",{requestId:u,cwd:t,files:k.files.length}),k;const ne=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return mr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:ne,code:k.code,status:k.status}),null}catch(k){if(Vt.current.get(t)!==u||!Pe(i)||wr(k))return ut("untracked_aborted",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const C=k instanceof Error?k.message:"Failed to scan untracked files";return mr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:C}),null}finally{Yt.current.get(t)===w&&Yt.current.delete(t),Vt.current.get(t)===u&&Vt.current.delete(t),wn.current.delete(t)}},[$,Pe,v,Ia]),or=a.useMemo(()=>{const t=new Set($e.map(u=>u.root)),i=Wr.filter(u=>t.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Wr,$e]),_c=or.length===0,kn=a.useMemo(()=>or.map(t=>fe.find(i=>i.root===t)).filter(t=>!!t),[or,fe]),qh=a.useMemo(()=>$e.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[$e]),pr=a.useCallback(async()=>{if(!v){rn([]),Ur([]);return}const t=v,i=Yn.current+1;Yn.current=i,Xn.current?.abort();const u=new AbortController;Xn.current=u,Mr(kt.length===0),zr(null);try{const y=or.length>0?await Promise.all(or.map(w=>Yd({workspaceRoot:v,repoRoot:w},u.signal))).then(w=>({records:w.flatMap(k=>k.records),walkthroughs:w.flatMap(k=>k.walkthroughs??[])})):await Yd({workspaceRoot:v},u.signal);if(Yn.current!==i||!Pe(t))return;rn(y.records),Ur(y.walkthroughs??[])}catch(y){if(Yn.current!==i||!Pe(t)||wr(y))return;zr(y instanceof Error?y.message:"Failed to load change audit explanations")}finally{Xn.current===u&&(Xn.current=null),Yn.current===i&&Pe(t)&&Mr(!1)}},[kt.length,or,Pe,v]),Ha=a.useCallback(async(t,i,u)=>{if(!t&&!v){Gr([]),ys([]);return}const y=v,w=Jn.current+1;Jn.current=w,Jr.current?.abort();const k=new AbortController;Jr.current=k;try{const C=t?[t]:Array.from(new Set([v,...fe.map(oe=>oe.root)].filter(oe=>!!oe))),ne=await Promise.all(C.map(oe=>hp({repoRoot:oe,baseRef:i,branchName:u},k.signal))).then(oe=>{const xe=new Map,Ae=new Map;for(const Ze of oe){for(const ee of Ze.records)xe.set(ee.id,ee);for(const ee of Ze.walkthroughs??[])Ae.set(ee.id,ee)}return{records:Array.from(xe.values()),walkthroughs:Array.from(Ae.values())}});if(Jn.current!==w||!Pe(y))return;Gr(ne.records),ys(ne.walkthroughs??[])}catch(C){if(Jn.current!==w||!Pe(y)||wr(C))return;console.warn("[RightSidebar] Failed to load branch explanations",C)}finally{Jr.current===k&&(Jr.current=null)}},[fe,Pe,v]),Qn=a.useCallback((t,i={})=>{if(!Pe(v)){ut("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:V.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}ut(t.files.length===0?"empty_bundle":"apply",{rootPath:v,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let u=Hf(t),y=t.repoFilters??[],w=t.files;const k=V.getState().changedFiles;if(!!(i.cacheOnly&&!t.cached&&t.files.length===0&&u.length===0)&&(k.size>0||fe.length>0||$)){ut("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:fe.length});return}const ne=u.some(X=>X.deferred);if(ne&&!i.replaceWorkspace){const X=new Set(u.filter(Le=>!Le.deferred||Le.root===v).map(Le=>Le.root));w=[...Array.from(k.values()).filter(Le=>!X.has(bt(Le,v)??"")),...t.files]}const oe=Vu(k.values(),v),xe=Vu(t.files,v),Ae=u.some(X=>X.root!==v);if(!!(i.background&&!ne&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||oe>0&&xe===0&&!Ae))){ut("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:oe,nextNestedCount:xe,nextRepositories:u.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(i.replaceRepoRoot){const X=Eh(k.values(),fe,t,i.replaceRepoRoot,v);w=X.files,u=X.repositories,y=X.repoFilters}if(Ia(Rh(w)),Ne(X=>{if(!ne||i.replaceWorkspace)return u;const me=new Map(X.map(Le=>[Le.root,Le]));return u.map(Le=>{const Ge=me.get(Le.root);return!Le.deferred||!Ge?Le:{...Le,available:Ge.available,files:Ge.files,context:Ge.context,deferred:Ge.deferred,untrackedDeferred:Ge.untrackedDeferred,error:Ge.error}})}),rt(y),ki.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:me}=V.getState(),Le=X?me[X]??null:null,Ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:Le,ze=vx({...t,repositories:u,repoFilters:y},Ge);Te(ze)}typeof t.cacheUpdatedAt=="number"&&uc(t.cacheUpdatedAt),he(X=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==v)return X;if(!t.context)return null;const me=X?.root??v;return!X?.available||me!==(t.context.root??v)?t.context:{...X,...t.context}}),i.reloadDiff&&qo(X=>X+1);const ee=V.getState().selectedFilePath;if(ee&&!ee.startsWith("/")&&!w.some(X=>X.path===ee||X.absolutePath===ee)&&it(null),Nr(X=>{const me=new Set(w.map(Ge=>bt(Ge,v)).filter(Boolean)),Le=new Set;for(const Ge of X)me.has(Ge)&&Le.add(Ge);return cl(al,Le),Le}),i.loadDeferred!==!1){const X=u.filter(me=>me.untrackedDeferred&&me.root).map(me=>me.root);for(const me of X)Fc(me)}i.loadAudit!==!1&&pr()},[Pe,pr,Fc,v,it,Te,Ia]);a.useEffect(()=>{Da(),vi.current=null,wi.current=v;const t=[],i=[];St.current+=1,yn.current+=1,Ba.current+=1,Tr.current?.abort(),jt(Zs(Yr.current?.cwd??v??void 0)),Yr.current=null,Tr.current=null,Xr.current?.abort(),jt("right-sidebar-git-details"),Xr.current=null;for(const C of Yt.current.values())C.abort();for(const C of Yt.current.keys())jt(`right-sidebar-git-untracked:${C}`);Yt.current.clear(),Vt.current.clear(),Yn.current+=1,Xn.current?.abort(),Xn.current=null,Jn.current+=1,Jr.current?.abort(),Jr.current=null,qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,rn([]),Ur([]),Mr(!1),zr(null),Fn([]),nn(!1),Gr([]),ys([]),cr(!1),rr(null),Be(!1),Oe(null),mt(null),dr(null),on(null),Kr(!1),dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1),Sa(null),fn(null),hn(null),nc(!1),At(ol,!1),Jo(!1);const u=v?_u()[v]:null,y=u?.previewEntries??[],w=u?.selectedPreviewKey??null,k=w?y.find(C=>C.key===w)??null:null;++K.current,Be(!1),Qo(u?.selectedRepoRoots??[]),Ra(u?.repoTargetBranches??{}),Na(u?.repoBaseBranches??{}),an(y),L(u?.previewScrollTops??{}),k&&u?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(rr(k.diff),fn(k.key),hn(u.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),cr(!0)),Zo(u?.repoIncludeUncommitted??Object.fromEntries(Object.keys(u?.repoTargetBranches??{}).map(C=>[C,u?.includeUncommitted??!0]))),vi.current=v,Ma(!1),mr.current.clear(),wn.current.clear(),Ms(null),$s(null),mn(null),qt(null),uc(null),Ne(t),rt(i),he(null),yi.current=null,ki.current=null,Ls.current.clear()},[Da,v]);const Bt=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const u=v,y=St.current;if(await Sg(()=>Promise.all([V.getState().hydrateNestedGitScanRoots(),V.getState().hydrateActiveGitRepos()]).then(()=>{})),St.current!==y||!Pe(u))return null;const w=t===v&&Js(v),k=i.includeNested??w,C=i.refresh??i.reloadDiff??!1,ne=i.cacheOnly??!1,oe=i.background??!1,xe=k&&(i.discoverOnly??!1);C&&mr.current.clear();const Ae=Yr.current;if(Ae&&Ae.cwd===t&&Ae.includeNested===k&&Ae.refresh===C&&Ae.cacheOnly===ne&&Ae.discoverOnly===xe)return ut("reuse_pending",{cwd:t,includeNested:k,refresh:C,cacheOnly:ne,discoverOnly:xe}),Ae.promise;const Ze=St.current+1;St.current=Ze;const ee=`right-sidebar:${Ic}:${Ze}`;Tr.current?.abort();const X=Zs(t);jt(X);const me=new AbortController;Tr.current=me;let Le=null;oe||Cc(ee),pi(null),ut("start",{requestId:Ze,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:C,cacheOnly:ne,background:oe,existingChanges:Fe.size,lastLoadedAt:qn}),!oe&&typeof window<"u"&&(Le=window.setTimeout(()=>{St.current===Ze&&Ec(ee,!0)},ex));const Ge=(async()=>{const ze=await Ji(t,me.signal,{includeNested:k,refresh:C,cacheOnly:ne,discoverOnly:xe,action:C?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:C?null:void 0});if(i0(ze)){if(ut("cancelled_result_ignored",{requestId:Ze,activeRequestId:St.current,cwd:t,error:ze.error??ze.context?.error}),me.signal.aborted)return null;throw new Error(ze.error??ze.context?.error??"Failed to load Git changes")}return St.current!==Ze||!Pe(u)?(ut("stale_result",{requestId:Ze,activeRequestId:St.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,files:ze.files.length,repositories:ze.repositories?.length??0}),null):(Qn(ze,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:oe,cacheOnly:ne,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),ze)})();Yr.current={cwd:t,includeNested:k,refresh:C,cacheOnly:ne,discoverOnly:xe,promise:Ge};try{const ze=await Ge;return St.current===Ze&&ze&&Pe(u)?Mc({cached:ze.cached,stale:ze.stale,cacheAgeMs:ze.cacheAgeMs,nestedDeferred:!k||ze.nestedDeferred,untrackedDeferred:ze.untrackedDeferred}):St.current===Ze&&Pe(u)&&mi(ee),ze}catch(ze){return St.current!==Ze||!Pe(u)||me.signal.aborted?(ut("aborted",{requestId:Ze,activeRequestId:St.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,message:ze instanceof Error?ze.message:String(ze)}),null):(ut("error",{requestId:Ze,cwd:t,includeNested:k,refresh:C,background:oe,message:ze instanceof Error?ze.message:String(ze)}),oe||(he(null),pi(ze instanceof Error?ze.message:"Failed to load Git changes")),null)}finally{Le!==null&&window.clearTimeout(Le),Tr.current===me&&(Tr.current=null),Yr.current?.promise===Ge&&(Yr.current=null),!oe&&St.current===Ze&&Pe(u)&&mi(ee)}},[Qn,Cc,Fe.size,mi,Ic,qn,Pe,Mc,v,pi,Ec]),Zn=a.useCallback(async()=>{v&&await Bt(v,{reloadDiff:!0,refresh:!0})},[Bt,v]),ji=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,u=yn.current+1;yn.current=u,Xr.current?.abort(),jt("right-sidebar-git-details");const y=new AbortController;Xr.current=y,Ma(!0);try{const w=await Xd(t,y.signal,"load_git_details","right-sidebar-git-details");return yn.current!==u||!Pe(i)?null:(Ne(k=>k.map(C=>C.root===w.root?{...C,available:w.available,context:w,error:w.error}:C)),he(k=>k?.root&&w.root&&k.root!==w.root?k:!k?.available||!w.available?w:{...k,...w}),w)}catch(w){return wr(w)||!Pe(i)||yn.current===u&&qt(w instanceof Error?w.message:"Failed to load Git details"),null}finally{Xr.current===y&&(Xr.current=null),yn.current===u&&Pe(i)&&Ma(!1)}},[Pe,v]);a.useEffect(()=>{if(!r){St.current+=1,Da(),yi.current=null,yn.current+=1,Ba.current+=1,Tr.current?.abort(),jt(Zs(Yr.current?.cwd??v??void 0)),Yr.current=null,Tr.current=null,Xr.current?.abort(),jt("right-sidebar-git-details"),Xr.current=null;for(const t of Yt.current.values())t.abort();for(const t of Yt.current.keys())jt(`right-sidebar-git-untracked:${t}`);Yt.current.clear(),Vt.current.clear(),Jn.current+=1,Jr.current?.abort(),Jr.current=null,qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,Ma(!1),Be(!1),Oe(null),mt(null),dr(null),on(null),Kr(!1),dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1),Y(""),P(!1),Wt(null),si(!1),se&&oc(!1)}},[se,r,Da,P]),a.useEffect(()=>{if(!Z)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[Z]),a.useEffect(()=>{se||Ar(!1)},[se]);const Bc=a.useCallback(t=>{ri(t);const i=Si.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(se)if(Ar(h),h&&ot){Lr(1);const t=Ir.current;t&&(t.update(),t.activeIndex!==1&&(Ts.current=1,t.slideTo(1,0)))}else{Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Wt(null)}},[se,h,v,ot]),a.useEffect(()=>{if(p!==void 0&&!h){Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ar(!1),Wt(null)}},[p,h]),a.useEffect(()=>{E!==void 0&&Ie(null)},[E]),a.useEffect(()=>{!se&&h&&f?.()},[se,f,h]),a.useEffect(()=>{di(t=>Tl(t,s))},[s]);const Vh=a.useCallback(t=>{se||(t.preventDefault(),Ua.current={startX:t.clientX,startWidth:ci,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[ci,se]),Yh=a.useCallback(t=>{const i=Ua.current;if(!i||i.pointerId!==t.pointerId)return;const u=Tl(i.startWidth+t.clientX-i.startX,s);di(u),aa(na,u,Zb)},[s]),Oc=a.useCallback(t=>{const i=Ua.current;if(!(!i||i.pointerId!==t.pointerId)){Ua.current=null,Xs(na);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),es=!!(v&&qn!==null&&Ju($)),Ri=!!(v&&!vn&&Fe.size===0&&qn===null),Mt=(()=>{let t=ui;return t==="android"&&!Vr&&(t="files"),(t==="architecture"||t==="computer")&&!ar[t]&&(t="files"),es&&(t==="git"||t==="diff")&&(t="files"),t})(),dt=Mt==="git",Dr=Mt==="files",$t=Mt==="diff",ts=Mt==="android",rs=Mt==="computer",Sn=Mt==="architecture",[Xh,Jh]=a.useState(!1);a.useEffect(()=>{r&&rs&&Jh(!0)},[r,rs]);const[Qh,Zh]=a.useState(!1);a.useEffect(()=>{r&&Sn&&Zh(!0)},[r,Sn]);const Ni=a.useRef(null),ns=a.useCallback((t,i)=>{const u=V.getState().rightTab;if(u===t)return;const y=performance.now(),w=y-i.timeStamp;Ni.current={from:u,to:t,startedAt:y,inputDelayMs:w>=0&&w<6e4?Math.round(w):null},Ft(t)},[Ft]);a.useEffect(()=>{const t=Ni.current;if(!t||t.to!==Mt)return;Ni.current=null;const i=Math.round(performance.now()-t.startedAt);let u=window.requestAnimationFrame(()=>{u=window.requestAnimationFrame(()=>{ta("tab_switch_presented",{from:t.from,to:t.to,inputDelayMs:t.inputDelayMs,commitMs:i,frameMs:Math.round(performance.now()-t.startedAt)})})});return()=>window.cancelAnimationFrame(u)},[Mt]);const em=Dp(t=>t.overlay==="sidebar")&&ts;a.useEffect(()=>{if(!se){Ca(!0);return}if(!r){const i=window.setTimeout(()=>{Ca(!1)},nx);return()=>window.clearTimeout(i)}Ca(!1);const t=window.setTimeout(()=>{Ca(!0)},rx);return()=>window.clearTimeout(t)},[se,r]),a.useEffect(()=>{if(!se||!$t)return;const t=Si.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[$t,se]),a.useEffect(()=>{if(!es||!v||hr)return;const t=window.setTimeout(()=>{Bt(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[es,v,hr,Bt]);const tm=a.useCallback(t=>{Bt(t,{discoverOnly:!0})},[Bt]);jg({active:r&&(dt||$t),rootPath:v,loading:hr,delay:dt&&!se?0:ll,lastStartedRoot:yi,load:tm}),a.useEffect(()=>{!r||!dt||(!se||ni)&&si(!0)},[dt,se,r,ni]),a.useEffect(()=>{if(!r||dt)return;const t=window.setTimeout(()=>{si(!0)},ll);return()=>window.clearTimeout(t)},[dt,r]),a.useEffect(()=>{Dr&&Dh(!0)},[Dr]),a.useEffect(()=>{$t&&oc(!0)},[$t]),a.useEffect(()=>{!r||!ts||(n&&Ea&&Ea.sessionId!==n&&(Xi.getState().setDock(Qi,null),ra({androidPanel:{docked:null}}).catch(()=>{})),ic(!0))},[ts,r,n,Ea]),a.useEffect(()=>{if(r&&ts||!ai)return;const t=window.setTimeout(()=>ic(!1),tx);return()=>window.clearTimeout(t)},[r,ts,ai]),a.useEffect(()=>{let t=!1;return tf().then(i=>{t||(Es.current.has("android")||lc(i.androidPanel?.enabled===!0),cc(u=>({architecture:Es.current.has("architecture")?u.architecture:i.rightSidebarTabs?.architecture===!0,computer:Es.current.has("computer")?u.computer:i.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{t=!0}},[]);const Uc=a.useCallback(t=>{Es.current.add("android"),lc(t),t?Ft("android"):V.getState().rightTab==="android"&&Ft("files"),ra({androidPanel:{enabled:t}}).catch(()=>{})},[Ft]),rm=a.useCallback((t,i)=>{Es.current.add(t),cc(u=>({...u,[t]:i})),i?Ft(t):V.getState().rightTab===t&&Ft("files"),ra({rightSidebarTabs:{[t]:i}}).catch(()=>{})},[Ft]),Hc=a.useCallback(t=>{le&&Zx(le,t.currentTarget.scrollTop)},[le]);a.useEffect(()=>()=>{Tr.current?.abort(),Xs(Wl),Xs(Gl),Xs(na),Xs(il)},[]),a.useEffect(()=>{if(!le||!Tc)return;const t=Sh()[le]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Vn.current&&(Vn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Vn.current&&(Vn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[le,Tc]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return mp(t.signal).then(i=>gc(!!i.available)).catch(()=>gc(!1)),()=>t.abort()},[r]);const Is=a.useCallback(t=>{if(R(null),it(t),Wt(null),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,it]),Ci=a.useCallback((t,i)=>{if(R(null),it(t),Tt(i),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,it]),Ot=rb(t=>Ps(t,!1)),za=Ot.busy,Ds=a.useCallback(async(t,i)=>{const u=i||Gn||v;!u||!t.length||await Ot.start(u,t)},[Gn,v,Ot.start]),zc=a.useCallback(async t=>{try{await pp(t)}catch(i){qt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>qt(null),4e3)}},[o]),Wa=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&ii(!0)},[]),Wc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ii(!1)},[]),Gc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ii(!1);const i=t.dataTransfer.files;i.length>0&&Ds(Array.from(i))},[Ds]),Ei=a.useCallback(t=>{te(t),window.setTimeout(()=>te(i=>i===t?null:i),1400)},[]),gr=a.useCallback(t=>{nt(t),window.setTimeout(()=>nt(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{At($u,O)},[O]),a.useEffect(()=>{At(Pu,Ce)},[Ce]),a.useEffect(()=>{At(Au,xt)},[xt]),a.useEffect(()=>{aa(il,Nt,Vb)},[Nt]),a.useEffect(()=>(wc().catch(()=>{}),Jd(t=>{t.type==="pinned-explorer-roots"&&yc(t.pinnedExplorerRoots)})),[wc,yc]);const Kc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Ga=a.useRef(null),jn=a.useRef(null),[qc,Mi]=a.useState(!1);a.useEffect(()=>{if(!r)return;Mi(!1);let t=!1;gp().then(u=>{t||(Ga.current=u.text,Ct(y=>u.text&&u.text!==y?u.text:y),Mi(!0))}).catch(()=>{t||Mi(!0)});const i=Jd(u=>{u.type==="context-draft"&&u.origin!==Kc.current&&(Ga.current=u.text,Ct(u.text))});return()=>{t=!0,i(),jn.current!==null&&(window.clearTimeout(jn.current),jn.current=null)}},[r]),a.useEffect(()=>{if(!qc||Ga.current===Nt)return;jn.current!==null&&window.clearTimeout(jn.current);const t=Nt;jn.current=window.setTimeout(()=>{jn.current=null,bp(t,Kc.current).then(()=>{Ga.current=t}).catch(()=>{})},500)},[Nt,qc]);const ss=a.useCallback(async(t,i,u,y)=>{if(!t)return!1;if(lr(!1),y&&!Zi(y)())return lr(!0),!1;if(xp(u?t+u:t))return Ei(i),!0;if(O)Ct(w=>Zg(w,t)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(et(!1),gs(w=>w+1));else{const w=n??Qr.getState().activeSessionId;if(!await af(u?t+u:t,w,()=>_s.current&&w===Qr.getState().activeSessionId,y))return lr(!0),!1}return Ei(i),!0},[O,Ei,n]),Ka=a.useCallback(t=>{const i=Pn(t,v);return Fp(i,v)},[v]),$i=vf(gr),Xt=a.useCallback((t,i,u)=>{const y=Pn(t,v);return ss(ou(y,v),i??`path:${y}`,void 0,u)},[v,ss]),as=a.useRef({sessionId:n,contextDraftEnabled:O,isOpen:r});as.current={sessionId:n,contextDraftEnabled:O,isOpen:r};const nm=a.useCallback(async(t,i)=>{const u=n??Qr.getState().activeSessionId,y=()=>_s.current&&as.current.isOpen&&(as.current.sessionId??Qr.getState().activeSessionId)===u&&Qr.getState().activeSessionId===u&&as.current.contextDraftEnabled===O;await Ot.start("/tmp",[t],k=>Xt(k,`path:${k}`,i),y)&&y()&&se&&!O&&l()},[O,Xt,se,l,n,Ot.start]),Fs=a.useRef(!0),qa=a.useRef(n);qa.current=n,a.useEffect(()=>(Fs.current=!0,()=>{Fs.current=!1}),[]);const sm=a.useCallback(t=>{_p.getState().enqueue(t,n??null,v||"/",async(i,u)=>{if(as.current.contextDraftEnabled&&Fs.current&&qa.current===n){if(!await Pi.current(ou(i,null),`path:${i}`,u))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return iu(i,n,u)})},[n,v,O,Xt,o]),am=a.useCallback(async(t,i)=>{const u=Zi(i),w=(await vl("/tmp",[t])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");if(!u()||!Fs.current||qa.current!==n||as.current.contextDraftEnabled!==O)throw new Error(o("rightSidebar.uploadReferenceRejected"));if(O&&Fs.current&&qa.current===n){if(!await Xt(w,void 0,i))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await iu(w,n,i)},[O,Xt,n,o]),Fr=a.useCallback((t,i,u)=>{if(!t)return Promise.resolve(!1);const y=t.includes(`
|
|
1660
1662
|
`)?`
|
|
1661
1663
|
`:void 0;return ss(t.endsWith(`
|
|
1662
|
-
`)||t.endsWith(" ")?t:`${t} `,i,
|
|
1663
|
-
`,
|
|
1664
|
-
`)},[
|
|
1665
|
-
`):[];if(!r||t.length===0){Wn(null);return}const i=new AbortController;let u=!1,w=0,y=0;Wn(null);const k=async()=>{let N=0;for(;!u&&!i.signal.aborted;){let ne=null;try{Wn(null),await yp(t,xe=>{const{applicableEvents:Ae,unavailableReason:Ze}=zg(xe);Ae.length>0&&wc(Ae);const ee=new Set(Ae.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Da)for(const X of Ae){if(X.type==="created"||X.type==="updated"){const me=So(X.path);me&&ee.add(me)}X.path.endsWith("/.gitignore")&&le&&Ps(le,!0)}for(const X of ee){const me={path:X},Le=V.getState();if(!Le.directoryCache.has(me.path))continue;Nn.current.get(me.path)?.abort();const ze=new AbortController;Nn.current.set(me.path,ze);const Hd=`file-watch-rescan:${me.path}`;jt(Hd),Qu(me.path,ze.signal,Le.showHiddenFiles,"watch_rescan",Hd,Le.fileSortModes[me.path]??"name",le??void 0).then(qs=>{Nn.current.get(me.path)===ze&&kc(me.path,qs.entries)}).catch(qs=>{yr(qs)||Wn(qs instanceof Error?qs.message:"File refresh unavailable")}).finally(()=>{Nn.current.get(me.path)===ze&&Nn.current.delete(me.path)})}Ze&&Wn(Ze)},i.signal),ne=new Error("File watch stream ended")}catch(xe){ne=xe}if(u||i.signal.aborted||yr(ne))return;Wn(ne instanceof Error?ne.message:"File watching unavailable");const oe=Pu[Math.min(N,Pu.length-1)];N+=1,await new Promise(xe=>{y=window.setTimeout(xe,oe)})}};return w=window.setTimeout(()=>{u||k()},ol),()=>{u=!0,window.clearTimeout(w),window.clearTimeout(y),i.abort();for(const N of Nn.current.values())N.abort();Nn.current.clear()}},[wc,r,kc,Ai,le,Da,Ps]),a.useEffect(()=>{if(!v||bi.current!==v)return;if(xi.current===v){xi.current=null;return}const t=Du();aa(If,{...t,[v]:{selectedRepoRoots:Sa,repoTargetBranches:nr,repoBaseBranches:Et,previewEntries:sn,selectedPreviewKey:ve&&Pr?Qe:null,selectedPreviewFileKey:ve&&Pr?Qo:null,previewDetailOpen:!!(ve&&Pr),previewScrollTops:ks,previewMobileSlideIndex:1,repoIncludeUncommitted:un,updatedAt:Date.now()}},zb)},[Pr,un,ve,sn,ks,Et,nr,Sa,v,Qo,Qe]);const pt=a.useMemo(()=>Vu(Fe.values()),[Fe]),lt=a.useMemo(()=>{const t=new Map;for(const i of fe)t.set(i.root,i);return t},[fe]),Os=a.useMemo(()=>{const t=new Map;for(const i of fe)i.deferred||t.set(i.root,i.files.length);return t},[fe]),Xa=a.useCallback(t=>{if(t){if(!t.deferred){Ls.current.delete(t.root);return}Os.has(t.root)||Ls.current.has(t.root)||(Ls.current.add(t.root),Bt(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ls.current.delete(t.root)}))}},[Bt,Os]),ir=a.useMemo(()=>ce?$e.find(t=>t.root===ce)??null:null,[ce,$e]),Jt=a.useMemo(()=>ot?Array.from(Fe.values()).find(t=>t.path===ot||t.absolutePath===ot)??null:null,[Fe,ot]),Ht=a.useMemo(()=>{const t=new Map;for(const i of fe)i.available&&i.context?.available&&t.set(i.root,i);return t.size===0&&M?.available&&M.root&&t.set(M.root,{id:M.root,root:M.root,relativeRoot:".",name:at,depth:0,nested:!1,available:!0,files:Array.from(Fe.values()).filter(i=>bt(i,v)===M.root),context:M}),Array.from(t.values()).sort((i,u)=>i.root===v?-1:u.root===v?1:(i.relativeRoot||i.name).localeCompare(u.relativeRoot||u.name)).map(i=>{const u=i.relativeRoot==="."?at:i.relativeRoot||i.name||wt(i.root),w=qu(i.files),y=i.files.length;return{value:i.root,label:u,meta:[i.context?.branch,y>0?o("rightSidebar.repoChangedCount",{count:y}):null,w>0?o("rightSidebar.repoStagedCount",{count:w}):null].filter(Boolean).join(" · ")}})},[Fe,M,fe,at,v,o]),Re=a.useMemo(()=>ce&&Ht.some(t=>t.value===ce)?ce:Jt?.repoRoot&&Ht.some(t=>t.value===Jt.repoRoot)?Jt.repoRoot:Ht.length===1||Ht.length>1?Ht[0].value:null,[ce,Ht,Jt?.repoRoot]),ed=Re?lt.get(Re)??null:null,de=ed?.context?.available?ed.context:Re===M?.root?M:null,tt=Ht.length>0&&!Re,td=a.useMemo(()=>tt?[]:Re?Array.from(Fe.values()).filter(t=>bt(t,v)===Re):Array.from(Fe.values()),[Re,Fe,tt,v]),Cn=a.useMemo(()=>Vu(td),[td]),Li=!!(de?.available&&de.root&&Re&&de.root===Re),im=Re?Ht.find(t=>t.value===Re)?.label??wt(Re):o("rightSidebar.gitRepositoryPlaceholder"),rd=Li?de?.branch??"HEAD":tt?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",En=!!(de?.available&&de.root===Re&&de.status);a.useEffect(()=>{ec.current={count:Dt.length,loading:ya,loadingMore:wa,hasMore:qo}},[Dt.length,qo,ya,wa]),a.useEffect(()=>{qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1)},[Re]);const Us=a.useCallback(async(t={})=>{if(!v||!Re||tt)return;const i=t.reset??!1,u=ec.current,w=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const y=qr.current+1;qr.current=y,fr.current?.abort(),jt("right-sidebar-recent-commits");const k=new AbortController;fr.current=k,i?Rs(!0):Ns(!0),Bn(null);try{const N=await pp({cwd:v,repoRoot:Re,limit:ex,skip:w,query:js.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(qr.current!==y)return;if(!N.available){Bn(N.error??"Recent commits are unavailable"),i&&ur([]),On(!1);return}Je(ne=>i?N.commitSyncStatus??{}:{...ne,...N.commitSyncStatus}),ur(ne=>i?N.commits:[...ne,...N.commits]),On(N.hasMore)}catch(N){if(qr.current!==y||yr(N))return;Bn(N instanceof Error?N.message:"Failed to load recent commits"),i&&ur([]),On(!1)}finally{fr.current===k&&(fr.current=null),qr.current===y&&(Rs(!1),Ns(!1))}},[Re,js,tt,v]);a.useEffect(()=>{ln&&Us({reset:!0})},[js,Us,ln,de?.ahead,de?.behind,de?.upstream]);const lm=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Us({reset:!1})},[Us]);a.useEffect(()=>{!Re||!M?.available||!ct||!sr||En||pn||tt||ki(Re)},[Re,M?.available,En,pn,ct,sr,ki,tt]);const nd=r&&($t||ct);a.useEffect(()=>{!nd||!v||pr()},[nd,pr,v]),a.useEffect(()=>{!r||!ct||!sr||!Cs||!v||Ua(null)},[Cs,ct,sr,r,Ua,v]);const cm=a.useMemo(()=>{if(!ce)return 0;const t=$e.findIndex(i=>i.root===ce);return t>=0?t+1:0},[ce,$e]),sd=a.useCallback(t=>{if(!t)return null;const i=Array.from(Fe.values()).filter(u=>bt(u,v)===t).sort((u,w)=>u.path.localeCompare(w.path))[0];return i?vr(i):null},[Fe,v]),Mn=$e.length>1,Ja=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Fe.size,branch:null,deferred:!1},...$e.map(t=>({root:t.root,label:t.label,count:t.deferred?Os.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Os.has(t.root)}))],[Fe.size,$e,Os,o]),ad=Ja[cm]??Ja[0],Qa=!!ce,od=a.useMemo(()=>Hf($e,fe),[$e,fe]);a.useEffect(()=>{yi.current===v&&ce&&!od.has(ce)&&Te(null),Fn(t=>t.filter(i=>$e.some(u=>u.root===i)))},[ce,$e,od,v,Te]),a.useEffect(()=>{ce&&Xa(lt.get(ce))},[ce,Xa,lt]);const dm=a.useMemo(()=>{const t=new Set;de?.branch&&t.add(de.branch);for(const i of de?.branches??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,o]),id=a.useMemo(()=>{const t=new Set;de?.upstreamRemote&&t.add(de.upstreamRemote);for(const i of de?.remotes??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,o]),ld=id.length>1,um=a.useMemo(()=>{const t=[],i=new Set,u=(y,k)=>{!y||i.has(y)||(i.add(y),t.push({value:y,label:y,meta:k}))};u(de?.upstreamBranch,de?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const y of de?.branches??[])u(y,y===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const w=de?.upstreamRemote;for(const y of de?.remoteBranches??[]){const k=y.indexOf("/"),N=k>=0?y.slice(0,k):null,ne=k>=0?y.slice(k+1):y;(!w||N===w)&&u(ne,"remote")}return t},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,o]),Qt=a.useMemo(()=>Ht.map(t=>{const i=lt.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Ht,lt]);a.useEffect(()=>{Qt.length!==0&&(ja(t=>{let i=!1;const u={...t},w=new Set(Qt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Qt)!u[y.root]&&y.branch&&(u[y.root]=y.branch,i=!0);return i?u:t}),Ra(t=>{let i=!1;const u={...t},w=new Set(Qt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Qt){const k=lt.get(y.root)?.context;if(u[y.root]&&zf(u[y.root],k?.branch)&&(delete u[y.root],i=!0),u[y.root])continue;const N=Bu(k);N&&(u[y.root]=N,i=!0)}return i?u:t}))},[Qt,lt]);const Za=a.useMemo(()=>{const t=new Set(Qt.map(i=>i.root));return Sa.filter(i=>t.has(i))},[Sa,Qt]),eo=Za.length===0,br=a.useMemo(()=>eo?Qt:Qt.filter(t=>Za.includes(t.root)),[Qt,Za,eo]),Hs=a.useMemo(()=>br.filter(t=>!!Et[t.root]?.trim()),[Et,br]),os=a.useCallback((t,i)=>{const u=lt.get(t)?.context?.branch;return!!(u&&i&&i.replace(/^refs\/heads\//,"")===u)},[lt]),cd=a.useMemo(()=>br.filter(t=>!Et[t.root]?.trim()),[Et,br]),dd=a.useCallback(async t=>{if(!t||gi.current.has(t))return;const i=lt.get(t)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=v;gi.current.add(t),nc(w=>new Set(w).add(t));try{const w=await Vd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!w.available||!Pe(u))return;Ne(y=>y.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...w},error:void 0}:k)),ja(y=>y[t]||!w.branch?y:{...y,[t]:w.branch}),Ra(y=>{if(y[t])return y;const k=Bu(w);return k?{...y,[t]:k}:y})}catch(w){yr(w)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,w)}finally{gi.current.delete(t),nc(w=>{const y=new Set(w);return y.delete(t),y})}},[lt,Pe,v]);a.useEffect(()=>{if(Vo)for(const t of br)dd(t.root)},[Vo,br,dd]),a.useEffect(()=>{!Li||!de||($a(de.branch||(de.branches?.[0]??"")),Pa(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),Aa(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Li]);const ud=a.useMemo(()=>{if(tt)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!En||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=de.ahead??0,i=de.behind??0;return t>0&&i>0?{text:o("rightSidebar.pushDivergedCount",{ahead:t,behind:i}),className:"bg-destructive/10 text-destructive"}:t>0?{text:o("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:i>0?{text:o("rightSidebar.pushBehindCount",{count:i}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,En,pn,tt,o]),fm=a.useCallback(t=>{if(t&&!se){const i=t.currentTarget.getBoundingClientRect();Ie({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else Ie(null);S?.()},[se,S]),Ti=a.useCallback(()=>{Ie(null),T?.()},[T]);function fd(){if(!Mn)return null;const t=ad?.label??o("rightSidebar.allRepositories"),i=ad?.count??Fe.size,u=wt(t)||t;return e.jsxs("button",{type:"button",onClick:fm,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${b?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":b,title:t,children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${i>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:i}),e.jsx(da,{size:12,className:"shrink-0"})]})}function hm(){if(!b||!Mn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(qe?.x??t-368,t-352)),w=Math.max(12,Math.min(qe?.y??80,i-420)),y=se?void 0:{left:u,top:w},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${se?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Ti,children:e.jsxs("div",{className:se?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:y,onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:se?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:se?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!se&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Ja.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Fe.size})]})]}),e.jsx("button",{type:"button",onClick:Ti,className:se?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:se?16:14})})]}),e.jsx("div",{className:se?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:Ja.map(N=>{const ne=(N.root??null)===ce,oe=wt(N.label)||N.label;return e.jsxs("button",{type:"button",onClick:()=>{Ad(N.root),Ti()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${se?"px-3 py-2":"px-2 py-1.5"} ${ne?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:N.label,role:"option","aria-selected":ne,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${ne?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),e.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${ne?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(xr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${se?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:oe}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:N.root===null?o("rightSidebar.allRepositories"):N.label})]}),N.branch&&e.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:N.branch}),N.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${N.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:N.count})]},N.root??"all")})})]})});return Mf(k,se,document.body)}function mm(){return hm()}function hd(t){const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=Eo(u,i??v);return{key:vr(t),path:t.path,absolutePath:u,displayName:w.name,displayDir:w.dir,oldPath:t.oldPath,status:t.status,title:u}}function md(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function to(t,i){const u=Pn(t,v),w=`path:${u}`,y=De===w,k=je===w,N=y||k;return e.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),Xt(u,w,ne.currentTarget)},...Ei(Ga(u),w),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${N?"max-w-20 px-2":"max-w-20 px-2 md:max-w-0 md:px-0 md:opacity-0 md:group-hover:max-w-20 md:group-hover:px-2 md:group-hover:opacity-100"} ${N?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function pd(t){const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=Hm(t),y=ml(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(i0,{actions:w,running:We,completed:Un?.path===y?Un:null}),to(u,o("rightSidebar.insertThisFile"))]})}function gd(t,i){const u=i.root??v;if(!u)return null;const w=Pn(t,u);return to(w,o("fileTree.insertRefTitle"))}function zs(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Nd("unified"),"aria-pressed":Gt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Gt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Nd("split"),"aria-pressed":Gt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Gt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function bd(){return Ws.map(t=>{const i=qu(t.files.map(([,k])=>k)),u=$l({activeGitRepoRoot:ce,groupCount:Ws.length,label:t.label,rootName:at}),w=!!(u&&t.root&&Rr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:w,files:t.files.map(([,k])=>hd(k)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${w?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Am(t.root),"aria-expanded":!w,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:w?e.jsx(hs,{size:13}):e.jsx(da,{size:13})}),e.jsx(xr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),i>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:i})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),lo("stage-all",t.root,t.label)},disabled:!!We,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),lo("stash-all",t.root,t.label)},disabled:!!We,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const $n=a.useMemo(()=>new Map(Array.from(Fe.values(),t=>[vr(t),t])),[Fe]);function xd(t){const i=$n.get(t.key),u=i?bt(i,v):null,w=$g(kt,u,i?.path??t.path);return e.jsx(Rl,{changeStatus:t.status,auditStatus:w,renderChangeBadge:y=>e.jsx(oa,{status:y})})}const ro=a.useCallback(t=>{if(se)return null;const i=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const w=t.getBoundingClientRect().top+48;let y=null,k=Number.POSITIVE_INFINITY;for(const ne of i){const oe=ne.getBoundingClientRect();if(oe.bottom<w)continue;const xe=Math.abs(oe.top-w);xe<k&&(y=ne,k=xe)}const N=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return N?(Ba.current===N&&V.getState().selectedFilePath===N||(Ba.current=N,it(N)),N):null},[se,it]),pm=!!(!We&&Re&&!tt&&(de?.upstream||gn.trim()&&bn.trim())),gm=!!(!We&&Re&&!tt&&(de?.upstream||gn.trim()&&bn.trim())),bm=!!(!We&&Re&&!tt&&zn.trim()&&zn.trim()!==de?.branch),Zt=a.useMemo(()=>{const t=Ke.trim().toLowerCase(),i=Array.from(Fe.entries()).filter(([,u])=>!ce||bt(u,v)===ce).sort(([u],[w])=>u.localeCompare(w));return t?i.filter(([u,w])=>`${u} ${w.path} ${w.status} ${w.repoRelativeRoot??""} ${w.repoName??""}`.toLowerCase().includes(t)):i},[ce,Fe,Ke,v]);a.useEffect(()=>{ta("selected_file_state",{selectedFilePath:ot,selectedChangedFilePath:Jt?.path??null,selectedChangedFileAbsolutePath:Jt?.absolutePath??null,selectedChangedFileRepoRoot:Jt?.repoRoot??null,rootPath:v,activeGitRepoRoot:ce,rightTab:ci,effectiveRightTab:Mt,diffPaneActive:$t,changedFiles:Fe.size,filteredChangedFiles:Zt.length,gitBundleLoading:hr,gitBundleLastLoadedAt:qn})},[ce,Fe.size,$t,Mt,Zt.length,qn,hr,ci,v,Jt?.absolutePath,Jt?.path,Jt?.repoRoot,ot]);const Ws=a.useMemo(()=>{const t=new Map;for(const i of Zt){const[,u]=i,w=bt(u,v),y=a0(u)||at,k=w??y,N=w?lt.get(w):void 0,ne=t.get(k)??{root:w,label:y,branch:N?.context?.branch,files:[]};ne.files.push(i),t.set(k,ne)}return Array.from(t.values()).sort((i,u)=>i.label===at?-1:u.label===at?1:i.label.localeCompare(u.label))},[Zt,lt,at,v]),Gs=a.useMemo(()=>{const t=[],i=new Map;for(const u of Zt)i.set(vr(u[1]),u);for(const u of Ws){if(!!(u.root&&$l({activeGitRepoRoot:ce,groupCount:Ws.length,label:u.label,rootName:at})&&Rr.has(u.root)))continue;if(Er!=="tree"){t.push(...u.files);continue}const y=u.files.map(([,k])=>hd(k));for(const k of Gp(y)){const N=i.get(k.key);N&&t.push(N)}}return t},[ce,Rr,Er,Ws,Zt,at]),vd=a.useMemo(()=>Fe.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Gs.map(([,t])=>{const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:vr(t),path:t.path,absolutePath:u,status:t.status,repoRoot:i,displayName:Eo(u,i).name,displayDir:Eo(u,i).dir,auditRecords:kt}}),[kt,Fe.size,Gs,v,o]);a.useEffect(()=>{if(!$t||Gs.length===0||se)return;const t=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&ro(u))return;const w=document.querySelector("[data-diff-stream-item]"),y=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;if(y){Ba.current=y,it(y);return}const k=Gs[0]?.[1];if(!k)return;const N=vr(k);Ba.current=N,it(N)};for(const u of[80,240,600,1200])t.push(window.setTimeout(i,u));return()=>t.forEach(u=>window.clearTimeout(u))},[$t,se,Gs,it,ro]);const Ii=a.useMemo(()=>{const t=N=>`'${N.replace(/'/g,"'\\''")}'`,i=or.length>0?kn:fe.filter(N=>N.files.length>0),u=i.length>0?i:v?[{root:v,relativeRoot:".",name:at}]:[],w=u.length>0?u.map(N=>`- ${N.relativeRoot==="."?".":N.relativeRoot} (${N.root})`).join(`
|
|
1666
|
-
`):`- ${v?".":""}`,
|
|
1667
|
-
`):" td audit-export",k=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${v??""}`,"目标仓库:",
|
|
1668
|
-
`)},[or.length,kn,fe,at,v]),
|
|
1669
|
-
`);return
|
|
1670
|
-
`))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(
|
|
1671
|
-
`):`- ${v?".":""}`,
|
|
1664
|
+
`)||t.endsWith(" ")?t:`${t} `,i,y,u)},[ss]),Pi=a.useRef(Fr);Pi.current=Fr;const _s=a.useRef(!0);a.useEffect(()=>(_s.current=!0,()=>{_s.current=!1}),[]);const Ai=a.useRef(new Set),Va=a.useCallback((t,i,u,y)=>{if(Ai.current.has(i))return!1;const w=Zi(y);if(!w())return!1;const k=n??Qr.getState().activeSessionId;return Ai.current.add(i),Ag(t,i,u,{insert:(C,ne)=>Fr(C,ne,y),upload:async(C,ne)=>(await vl("/tmp",[C],ne)).files[0]?.path,isCurrent:()=>w()&&_s.current&&Pi.current===Fr&&k===Qr.getState().activeSessionId}).catch(()=>(lr(!0),!1)).finally(()=>Ai.current.delete(i))},[Fr,n]),_r=a.useCallback((t,i,u,y)=>i?ss(i.endsWith(" ")?i:`${i} `,u??`context:${t}`,`
|
|
1665
|
+
`,y):Promise.resolve(!1),[ss]),Vc=sb({text:Nt,sessionId:n??Qr.getState().activeSessionId,active:r&&O,onAccepted:()=>{tn(!1),Ct(""),xt&&et(!0)},onRejected:()=>{tn(!0),et(!1)}}),at=a.useMemo(()=>v?yt(v):o("rightSidebar.workspace"),[v,o]),om=a.useMemo(()=>yt(le)||at,[le,at]),Ya=a.useMemo(()=>jo(le),[le]),Xa=a.useMemo(()=>v?vc[v]??[]:[],[vc,v]),Rn=a.useMemo(()=>new Set(Xa.map(t=>t.path)),[Xa]),Bs=!!(le&&Rn.has(le)),Li=!!(v&&le&&le!==v),im=!!(v&&Gn&&Gn!==v),Ut=le?`path:${le}`:null,Yc="context:change-audit",lm=a.useCallback(()=>{Ya&&_t(Ya)},[Ya,_t]),Xc=a.useCallback(()=>{kc()},[kc]),cm=a.useCallback(()=>{le&&(Ps(le,!0),Rc())},[Rc,le,Ps]),dm=a.useCallback(()=>{!le||!Li||(Bs?xn(le):Kn(le,"directory"))},[Li,le,Bs,Kn,xn]),Jc=a.useCallback(t=>{_t(t),Y("")},[_t]),Qc=a.useCallback(t=>{le&&(ke(Kb(le,t)),P(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[le,P]),Zc=a.useCallback(t=>{!v||t===v||(Rn.has(t)?xn(t):Kn(t,"directory"))},[Kn,Rn,v,xn]),ed=a.useCallback(t=>{!v||!t||(Rn.has(t)?xn(t):Kn(t,"file"))},[Kn,Rn,v,xn]),td=V(t=>t.expandedPaths),Ti=a.useMemo(()=>{const t=new Set;if(Dr&&le){t.add(le);const i=`${le.replace(/\/+$/,"")}/`;for(const u of td)u.startsWith(i)&&t.add(u)}if(Dr&&v&&ot){const i=ot.startsWith("/")?ot:`${v}/${ot}`,u=jo(i);u&&t.add(u)}return Gg(t).join(`
|
|
1666
|
+
`)},[td,Dr,le,v,ot]),Nn=a.useRef(new Map);a.useEffect(()=>{const t=Ti?Ti.split(`
|
|
1667
|
+
`):[];if(!r||t.length===0){Wn(null);return}const i=new AbortController;let u=!1,y=0,w=0;Wn(null);const k=async()=>{let C=0;for(;!u&&!i.signal.aborted;){let ne=null;try{Wn(null),await jp(t,xe=>{const{applicableEvents:Ae,unavailableReason:Ze}=qg(xe);Ae.length>0&&Sc(Ae);const ee=new Set(Ae.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Fa)for(const X of Ae){if(X.type==="created"||X.type==="updated"){const me=jo(X.path);me&&ee.add(me)}X.path.endsWith("/.gitignore")&&le&&Ps(le,!0)}for(const X of ee){const me={path:X},Le=V.getState();if(!Le.directoryCache.has(me.path))continue;Nn.current.get(me.path)?.abort();const ze=new AbortController;Nn.current.set(me.path,ze);const Wd=`file-watch-rescan:${me.path}`;jt(Wd),ef(me.path,ze.signal,Le.showHiddenFiles,"watch_rescan",Wd,Le.fileSortModes[me.path]??"name",le??void 0).then(qs=>{Nn.current.get(me.path)===ze&&jc(me.path,qs.entries)}).catch(qs=>{wr(qs)||Wn(qs instanceof Error?qs.message:"File refresh unavailable")}).finally(()=>{Nn.current.get(me.path)===ze&&Nn.current.delete(me.path)})}Ze&&Wn(Ze)},i.signal),ne=new Error("File watch stream ended")}catch(xe){ne=xe}if(u||i.signal.aborted||wr(ne))return;Wn(ne instanceof Error?ne.message:"File watching unavailable");const oe=Lu[Math.min(C,Lu.length-1)];C+=1,await new Promise(xe=>{w=window.setTimeout(xe,oe)})}};return y=window.setTimeout(()=>{u||k()},ll),()=>{u=!0,window.clearTimeout(y),window.clearTimeout(w),i.abort();for(const C of Nn.current.values())C.abort();Nn.current.clear()}},[Sc,r,jc,Ti,le,Fa,Ps]),a.useEffect(()=>{if(!v||vi.current!==v)return;if(wi.current===v){wi.current=null;return}const t=_u();aa(Df,{...t,[v]:{selectedRepoRoots:ja,repoTargetBranches:nr,repoBaseBranches:Et,previewEntries:sn,selectedPreviewKey:ve&&Pr?Qe:null,selectedPreviewFileKey:ve&&Pr?ei:null,previewDetailOpen:!!(ve&&Pr),previewScrollTops:ks,previewMobileSlideIndex:1,repoIncludeUncommitted:un,updatedAt:Date.now()}},qb)},[Pr,un,ve,sn,ks,Et,nr,ja,v,ei,Qe]);const pt=a.useMemo(()=>Xu(Fe.values()),[Fe]),lt=a.useMemo(()=>{const t=new Map;for(const i of fe)t.set(i.root,i);return t},[fe]),Os=a.useMemo(()=>{const t=new Map;for(const i of fe)i.deferred||t.set(i.root,i.files.length);return t},[fe]),Ja=a.useCallback(t=>{if(t){if(!t.deferred){Ls.current.delete(t.root);return}Os.has(t.root)||Ls.current.has(t.root)||(Ls.current.add(t.root),Bt(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ls.current.delete(t.root)}))}},[Bt,Os]),ir=a.useMemo(()=>ce?$e.find(t=>t.root===ce)??null:null,[ce,$e]),Jt=a.useMemo(()=>ot?Array.from(Fe.values()).find(t=>t.path===ot||t.absolutePath===ot)??null:null,[Fe,ot]),Ht=a.useMemo(()=>{const t=new Map;for(const i of fe)i.available&&i.context?.available&&t.set(i.root,i);return t.size===0&&$?.available&&$.root&&t.set($.root,{id:$.root,root:$.root,relativeRoot:".",name:at,depth:0,nested:!1,available:!0,files:Array.from(Fe.values()).filter(i=>bt(i,v)===$.root),context:$}),Array.from(t.values()).sort((i,u)=>i.root===v?-1:u.root===v?1:(i.relativeRoot||i.name).localeCompare(u.relativeRoot||u.name)).map(i=>{const u=i.relativeRoot==="."?at:i.relativeRoot||i.name||yt(i.root),y=Yu(i.files),w=i.files.length;return{value:i.root,label:u,meta:[i.context?.branch,w>0?o("rightSidebar.repoChangedCount",{count:w}):null,y>0?o("rightSidebar.repoStagedCount",{count:y}):null].filter(Boolean).join(" · ")}})},[Fe,$,fe,at,v,o]),Re=a.useMemo(()=>ce&&Ht.some(t=>t.value===ce)?ce:Jt?.repoRoot&&Ht.some(t=>t.value===Jt.repoRoot)?Jt.repoRoot:Ht.length===1||Ht.length>1?Ht[0].value:null,[ce,Ht,Jt?.repoRoot]),rd=Re?lt.get(Re)??null:null,de=rd?.context?.available?rd.context:Re===$?.root?$:null,tt=Ht.length>0&&!Re,nd=a.useMemo(()=>tt?[]:Re?Array.from(Fe.values()).filter(t=>bt(t,v)===Re):Array.from(Fe.values()),[Re,Fe,tt,v]),Cn=a.useMemo(()=>Xu(nd),[nd]),Ii=!!(de?.available&&de.root&&Re&&de.root===Re),um=Re?Ht.find(t=>t.value===Re)?.label??yt(Re):o("rightSidebar.gitRepositoryPlaceholder"),sd=Ii?de?.branch??"HEAD":tt?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",En=!!(de?.available&&de.root===Re&&de.status);a.useEffect(()=>{rc.current={count:Dt.length,loading:ya,loadingMore:ka,hasMore:Yo}},[Dt.length,Yo,ya,ka]),a.useEffect(()=>{qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1)},[Re]);const Us=a.useCallback(async(t={})=>{if(!v||!Re||tt)return;const i=t.reset??!1,u=rc.current,y=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const w=qr.current+1;qr.current=w,fr.current?.abort(),jt("right-sidebar-recent-commits");const k=new AbortController;fr.current=k,i?Rs(!0):Ns(!0),Bn(null);try{const C=await vp({cwd:v,repoRoot:Re,limit:sx,skip:y,query:js.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(qr.current!==w)return;if(!C.available){Bn(C.error??"Recent commits are unavailable"),i&&ur([]),On(!1);return}Je(ne=>i?C.commitSyncStatus??{}:{...ne,...C.commitSyncStatus}),ur(ne=>i?C.commits:[...ne,...C.commits]),On(C.hasMore)}catch(C){if(qr.current!==w||wr(C))return;Bn(C instanceof Error?C.message:"Failed to load recent commits"),i&&ur([]),On(!1)}finally{fr.current===k&&(fr.current=null),qr.current===w&&(Rs(!1),Ns(!1))}},[Re,js,tt,v]);a.useEffect(()=>{ln&&Us({reset:!0})},[js,Us,ln,de?.ahead,de?.behind,de?.upstream]);const fm=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Us({reset:!1})},[Us]);a.useEffect(()=>{!Re||!$?.available||!dt||!sr||En||pn||tt||ji(Re)},[Re,$?.available,En,pn,dt,sr,ji,tt]);const ad=r&&($t||dt);a.useEffect(()=>{!ad||!v||pr()},[ad,pr,v]),a.useEffect(()=>{!r||!dt||!sr||!Cs||!v||Ha(null)},[Cs,dt,sr,r,Ha,v]);const hm=a.useMemo(()=>{if(!ce)return 0;const t=$e.findIndex(i=>i.root===ce);return t>=0?t+1:0},[ce,$e]),od=a.useCallback(t=>{if(!t)return null;const i=Array.from(Fe.values()).filter(u=>bt(u,v)===t).sort((u,y)=>u.path.localeCompare(y.path))[0];return i?vr(i):null},[Fe,v]),Mn=$e.length>1,Qa=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Fe.size,branch:null,deferred:!1},...$e.map(t=>({root:t.root,label:t.label,count:t.deferred?Os.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Os.has(t.root)}))],[Fe.size,$e,Os,o]),id=Qa[hm]??Qa[0],Za=!!ce,ld=a.useMemo(()=>zf($e,fe),[$e,fe]);a.useEffect(()=>{ki.current===v&&ce&&!ld.has(ce)&&Te(null),Fn(t=>t.filter(i=>$e.some(u=>u.root===i)))},[ce,$e,ld,v,Te]),a.useEffect(()=>{ce&&Ja(lt.get(ce))},[ce,Ja,lt]);const mm=a.useMemo(()=>{const t=new Set;de?.branch&&t.add(de.branch);for(const i of de?.branches??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,o]),cd=a.useMemo(()=>{const t=new Set;de?.upstreamRemote&&t.add(de.upstreamRemote);for(const i of de?.remotes??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,o]),dd=cd.length>1,pm=a.useMemo(()=>{const t=[],i=new Set,u=(w,k)=>{!w||i.has(w)||(i.add(w),t.push({value:w,label:w,meta:k}))};u(de?.upstreamBranch,de?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const w of de?.branches??[])u(w,w===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const y=de?.upstreamRemote;for(const w of de?.remoteBranches??[]){const k=w.indexOf("/"),C=k>=0?w.slice(0,k):null,ne=k>=0?w.slice(k+1):w;(!y||C===y)&&u(ne,"remote")}return t},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,o]),Qt=a.useMemo(()=>Ht.map(t=>{const i=lt.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Ht,lt]);a.useEffect(()=>{Qt.length!==0&&(Ra(t=>{let i=!1;const u={...t},y=new Set(Qt.map(w=>w.root));for(const w of Object.keys(u))y.has(w)||(delete u[w],i=!0);for(const w of Qt)!u[w.root]&&w.branch&&(u[w.root]=w.branch,i=!0);return i?u:t}),Na(t=>{let i=!1;const u={...t},y=new Set(Qt.map(w=>w.root));for(const w of Object.keys(u))y.has(w)||(delete u[w],i=!0);for(const w of Qt){const k=lt.get(w.root)?.context;if(u[w.root]&&Wf(u[w.root],k?.branch)&&(delete u[w.root],i=!0),u[w.root])continue;const C=Uu(k);C&&(u[w.root]=C,i=!0)}return i?u:t}))},[Qt,lt]);const eo=a.useMemo(()=>{const t=new Set(Qt.map(i=>i.root));return ja.filter(i=>t.has(i))},[ja,Qt]),to=eo.length===0,br=a.useMemo(()=>to?Qt:Qt.filter(t=>eo.includes(t.root)),[Qt,eo,to]),Hs=a.useMemo(()=>br.filter(t=>!!Et[t.root]?.trim()),[Et,br]),os=a.useCallback((t,i)=>{const u=lt.get(t)?.context?.branch;return!!(u&&i&&i.replace(/^refs\/heads\//,"")===u)},[lt]),ud=a.useMemo(()=>br.filter(t=>!Et[t.root]?.trim()),[Et,br]),fd=a.useCallback(async t=>{if(!t||xi.current.has(t))return;const i=lt.get(t)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=v;xi.current.add(t),ac(y=>new Set(y).add(t));try{const y=await Xd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!y.available||!Pe(u))return;Ne(w=>w.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...y},error:void 0}:k)),Ra(w=>w[t]||!y.branch?w:{...w,[t]:y.branch}),Na(w=>{if(w[t])return w;const k=Uu(y);return k?{...w,[t]:k}:w})}catch(y){wr(y)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,y)}finally{xi.current.delete(t),ac(y=>{const w=new Set(y);return w.delete(t),w})}},[lt,Pe,v]);a.useEffect(()=>{if(Xo)for(const t of br)fd(t.root)},[Xo,br,fd]),a.useEffect(()=>{!Ii||!de||(Pa(de.branch||(de.branches?.[0]??"")),Aa(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),La(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Ii]);const hd=a.useMemo(()=>{if(tt)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!En||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=de.ahead??0,i=de.behind??0;return t>0&&i>0?{text:o("rightSidebar.pushDivergedCount",{ahead:t,behind:i}),className:"bg-destructive/10 text-destructive"}:t>0?{text:o("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:i>0?{text:o("rightSidebar.pushBehindCount",{count:i}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,En,pn,tt,o]),gm=a.useCallback(t=>{if(t&&!se){const i=t.currentTarget.getBoundingClientRect();Ie({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else Ie(null);j?.()},[se,j]),Di=a.useCallback(()=>{Ie(null),T?.()},[T]);function md(){if(!Mn)return null;const t=id?.label??o("rightSidebar.allRepositories"),i=id?.count??Fe.size,u=yt(t)||t;return e.jsxs("button",{type:"button",onClick:gm,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${b?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":b,title:t,children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${i>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:i}),e.jsx(da,{size:12,className:"shrink-0"})]})}function bm(){if(!b||!Mn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(qe?.x??t-368,t-352)),y=Math.max(12,Math.min(qe?.y??80,i-420)),w=se?void 0:{left:u,top:y},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${se?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Di,children:e.jsxs("div",{className:se?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:w,onClick:C=>C.stopPropagation(),children:[e.jsxs("div",{className:se?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:se?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!se&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Qa.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Fe.size})]})]}),e.jsx("button",{type:"button",onClick:Di,className:se?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:se?16:14})})]}),e.jsx("div",{className:se?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:Qa.map(C=>{const ne=(C.root??null)===ce,oe=yt(C.label)||C.label;return e.jsxs("button",{type:"button",onClick:()=>{Td(C.root),Di()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${se?"px-3 py-2":"px-2 py-1.5"} ${ne?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:C.label,role:"option","aria-selected":ne,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${ne?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),e.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${ne?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(xr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${se?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:oe}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:C.root===null?o("rightSidebar.allRepositories"):C.label})]}),C.branch&&e.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:C.branch}),C.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${C.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:C.count})]},C.root??"all")})})]})});return $f(k,se,document.body)}function xm(){return bm()}function pd(t){const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),y=Mo(u,i??v);return{key:vr(t),path:t.path,absolutePath:u,displayName:y.name,displayDir:y.dir,oldPath:t.oldPath,status:t.status,title:u}}function gd(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function ro(t,i){const u=Pn(t,v),y=`path:${u}`,w=De===y,k=je===y,C=w||k;return e.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),Xt(u,y,ne.currentTarget)},...$i(Ka(u),y),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${C?"max-w-20 px-2":"max-w-20 px-2 md:max-w-0 md:px-0 md:opacity-0 md:group-hover:max-w-20 md:group-hover:px-2 md:group-hover:opacity-100"} ${C?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":w?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function bd(t){const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),y=Km(t),w=gl(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(l0,{actions:y,running:We,completed:Un?.path===w?Un:null}),ro(u,o("rightSidebar.insertThisFile"))]})}function xd(t,i){const u=i.root??v;if(!u)return null;const y=Pn(t,u);return ro(y,o("fileTree.insertRefTitle"))}function zs(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Ed("unified"),"aria-pressed":Gt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Gt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Ed("split"),"aria-pressed":Gt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Gt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function vd(){return Ws.map(t=>{const i=Yu(t.files.map(([,k])=>k)),u=Al({activeGitRepoRoot:ce,groupCount:Ws.length,label:t.label,rootName:at}),y=!!(u&&t.root&&Rr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:y,files:t.files.map(([,k])=>pd(k)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${y?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Dm(t.root),"aria-expanded":!y,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:y?e.jsx(hs,{size:13}):e.jsx(da,{size:13})}),e.jsx(xr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),i>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:i})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),co("stage-all",t.root,t.label)},disabled:!!We,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),co("stash-all",t.root,t.label)},disabled:!!We,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const $n=a.useMemo(()=>new Map(Array.from(Fe.values(),t=>[vr(t),t])),[Fe]);function wd(t){const i=$n.get(t.key),u=i?bt(i,v):null,y=Tg(kt,u,i?.path??t.path);return e.jsx(Cl,{changeStatus:t.status,auditStatus:y,renderChangeBadge:w=>e.jsx(oa,{status:w})})}const no=a.useCallback(t=>{if(se)return null;const i=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const y=t.getBoundingClientRect().top+48;let w=null,k=Number.POSITIVE_INFINITY;for(const ne of i){const oe=ne.getBoundingClientRect();if(oe.bottom<y)continue;const xe=Math.abs(oe.top-y);xe<k&&(w=ne,k=xe)}const C=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;return C?(Oa.current===C&&V.getState().selectedFilePath===C||(Oa.current=C,it(C)),C):null},[se,it]),vm=!!(!We&&Re&&!tt&&(de?.upstream||gn.trim()&&bn.trim())),wm=!!(!We&&Re&&!tt&&(de?.upstream||gn.trim()&&bn.trim())),ym=!!(!We&&Re&&!tt&&zn.trim()&&zn.trim()!==de?.branch),Zt=a.useMemo(()=>{const t=Ke.trim().toLowerCase(),i=Array.from(Fe.entries()).filter(([,u])=>!ce||bt(u,v)===ce).sort(([u],[y])=>u.localeCompare(y));return t?i.filter(([u,y])=>`${u} ${y.path} ${y.status} ${y.repoRelativeRoot??""} ${y.repoName??""}`.toLowerCase().includes(t)):i},[ce,Fe,Ke,v]);a.useEffect(()=>{ta("selected_file_state",{selectedFilePath:ot,selectedChangedFilePath:Jt?.path??null,selectedChangedFileAbsolutePath:Jt?.absolutePath??null,selectedChangedFileRepoRoot:Jt?.repoRoot??null,rootPath:v,activeGitRepoRoot:ce,rightTab:ui,effectiveRightTab:Mt,diffPaneActive:$t,changedFiles:Fe.size,filteredChangedFiles:Zt.length,gitBundleLoading:hr,gitBundleLastLoadedAt:qn})},[ce,Fe.size,$t,Mt,Zt.length,qn,hr,ui,v,Jt?.absolutePath,Jt?.path,Jt?.repoRoot,ot]);const Ws=a.useMemo(()=>{const t=new Map;for(const i of Zt){const[,u]=i,y=bt(u,v),w=o0(u)||at,k=y??w,C=y?lt.get(y):void 0,ne=t.get(k)??{root:y,label:w,branch:C?.context?.branch,files:[]};ne.files.push(i),t.set(k,ne)}return Array.from(t.values()).sort((i,u)=>i.label===at?-1:u.label===at?1:i.label.localeCompare(u.label))},[Zt,lt,at,v]),Gs=a.useMemo(()=>{const t=[],i=new Map;for(const u of Zt)i.set(vr(u[1]),u);for(const u of Ws){if(!!(u.root&&Al({activeGitRepoRoot:ce,groupCount:Ws.length,label:u.label,rootName:at})&&Rr.has(u.root)))continue;if(Er!=="tree"){t.push(...u.files);continue}const w=u.files.map(([,k])=>pd(k));for(const k of Yp(w)){const C=i.get(k.key);C&&t.push(C)}}return t},[ce,Rr,Er,Ws,Zt,at]),yd=a.useMemo(()=>Fe.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Gs.map(([,t])=>{const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:vr(t),path:t.path,absolutePath:u,status:t.status,repoRoot:i,displayName:Mo(u,i).name,displayDir:Mo(u,i).dir,auditRecords:kt}}),[kt,Fe.size,Gs,v,o]);a.useEffect(()=>{if(!$t||Gs.length===0||se)return;const t=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&no(u))return;const y=document.querySelector("[data-diff-stream-item]"),w=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;if(w){Oa.current=w,it(w);return}const k=Gs[0]?.[1];if(!k)return;const C=vr(k);Oa.current=C,it(C)};for(const u of[80,240,600,1200])t.push(window.setTimeout(i,u));return()=>t.forEach(u=>window.clearTimeout(u))},[$t,se,Gs,it,no]);const Fi=a.useMemo(()=>{const t=C=>`'${C.replace(/'/g,"'\\''")}'`,i=or.length>0?kn:fe.filter(C=>C.files.length>0),u=i.length>0?i:v?[{root:v,relativeRoot:".",name:at}]:[],y=u.length>0?u.map(C=>`- ${C.relativeRoot==="."?".":C.relativeRoot} (${C.root})`).join(`
|
|
1668
|
+
`):`- ${v?".":""}`,w=u.length>0?u.map(C=>` td audit-export ${t(C.root)}`).join(`
|
|
1669
|
+
`):" td audit-export",k=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${v??""}`,"目标仓库:",y,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",w,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",k,'10. 少量 hunk 或临时补单条时使用:printf "%s\\n" "这里写该 hunk 的改动意义" | td audit-explain <hunkId> <对应仓库绝对路径>',"11. 注入成功后清理本次 payload:rm -f ~/.termdock/change-audit/payload*.json","","payload.walkthrough 示例字段:","{",' "title": "一句话标题",',' "summary": "整批改动的目的和结果",',' "highlights": [{ "what": "改了什么", "effect": "用户或系统得到什么", "tag": "体验" }],',' "nodes": [{ "id": "n1", "title": "节点标题", "kind": "ui", "business": "零上下文业务解释", "anchor": { "repoRoot": "<repoRoot>", "filePath": "<filePath>", "hunkIndex": 0, "hunkFingerprint": "<fingerprint>", "sectionIndex": 0, "sectionFingerprint": "<sectionFingerprint>" } }],',' "edges": [{ "from": "n1", "to": "n2", "label": "调用/传递/消费", "desc": "这条关系的业务含义" }],',' "risks": [{ "title": "真实风险或口径疑问", "anchor": { "filePath": "<filePath>" } }],',' "checks": ["可执行验证动作"]',"}","","写作标准:","- summary:一句话概括该 hunk 在整批改动中的职责。","- explanation:自包含说明业务链路、该 hunk 的作用、解决的问题、与其它 hunk 的关系。","- walkthrough.highlights 必须大白话,不要堆文件名/函数名;只看 highlights 应该知道这次改动干嘛。","- walkthrough.nodes 优先对应方法、关键业务步骤或关键 section;每个有 anchor 的节点必须能跳回真实 diff。","- 面向不了解本轮对话的 AI 编写,补足必要上下文。","- 输出高信息量结论;避免铺垫、套话、流程复述、泛泛风险、逐行翻译 diff。","","完成条件:汇报每个目标仓库已注入的 hunk 数和总数。"].join(`
|
|
1670
|
+
`)},[or.length,kn,fe,at,v]),km=a.useCallback(async(t="generate",i)=>{if(Mn&&Wr.length===0&&!ce){nn(!0);return}const u=t==="generate"?Fi:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Fi].join(`
|
|
1671
|
+
`);return ut("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:or,mode:t,hasAuditListCommand:u.includes("td audit-list"),promptLength:u.length}),await _r(o("rightSidebar.insertChangeAuditPrompt"),u,`${Yc}:${t}`,i)?(pr(),c||l(),!0):!1},[ce,Fi,Wr.length,or,_r,pr,l,c,v,Mn,o]),so=a.useCallback(async t=>{try{await Qd({ids:[t]}),rn(i=>i.filter(u=>u.id!==t))}catch{pr()}},[pr]),Sm=a.useCallback(async()=>{if(kt.length===0)return;const t=kt.map(i=>i.id);try{await Qd({ids:t}),rn(i=>i.filter(u=>!t.includes(u.id))),zr(null)}catch(i){const u=i instanceof Error?i.message:"Failed to clear change audit explanations";zr(o("rightSidebar.changeAuditClearFailed",{message:u})),pr()}},[kt,pr,o]),jm=a.useCallback(async t=>{if(t.records.length===0)return;const i=t.records.map(u=>u.id);try{await wp({ids:i}),Gr(u=>u.filter(y=>!i.includes(y.id))),Qe===t.key&&(fn(null),cr(!1))}catch(u){qt(o("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),Ha(null)}},[Ha,Qe,o]),Rm=a.useCallback(t=>{Fn(i=>t===null?(nn(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),Nm=a.useCallback(t=>{Qo(i=>t===null?(Jo(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),_i=a.useMemo(()=>{if(!sr)return[];const t=i=>{const u=i.diff??"";let y=0,w=0;for(const k of u.split(`
|
|
1672
|
+
`))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(y+=1),k.startsWith("-")&&(w+=1));return{filePath:i.filePath,oldPath:i.oldPath,newPath:i.newPath,hunkHeader:i.hunkHeader,hunkIndex:i.hunkIndex??0,fingerprint:i.fingerprint,additions:y,deletions:w,diff:u}};return ve?(ve.hunks??[]).map(i=>{const u=ve.comparisonRepos&&ve.comparisonRepos.length>1?[...ve.comparisonRepos].sort((w,k)=>k.label.length-w.label.length).find(w=>i.filePath.startsWith(`${w.label}/`)):void 0,y=tr.find(w=>w.repoRoot===ve.repoRoot&&w.baseRef===ve.baseRef&&(w.branchName??null)===(ve.currentBranch??null)&&w.filePath===i.filePath&&w.hunkHeader===i.hunkHeader&&(w.hunkIndex??0)===i.hunkIndex&&w.fingerprint===i.fingerprint)??null;return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex}`,repoRoot:u?.repoRoot??ve.repoRoot,repositoryPath:u?i.filePath.slice(u.label.length+1):i.filePath,hunk:i.previewRevert&&!os(i.previewRevert.cwd,i.previewRevert.comparisonBranch)?{...i,previewRevert:void 0}:i,current:y,stale:null}}):Qe?tr.filter(i=>Bu(i)===Qe).map(i=>{const u=t(i);return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex??0}`,hunk:u,current:i,stale:null}}):[]},[ve,tr,os,sr,Qe]),Bi=tr.length>0,is=a.useMemo(()=>{if(!sr)return[];const t=new Map;for(const i of tr){const u=i.repoRoot,y=lt.get(u),w=y?.relativeRoot==="."?at:y?.relativeRoot||y?.name||yt(u),k=Bu(i),C=t.get(k)??{key:k,repoRoot:u,repoLabel:w,baseRef:i.baseRef,branchName:i.branchName??null,headRef:i.headRef??null,diffFingerprint:i.diffFingerprint??null,records:[],latestInjectedAt:0};C.records.push(i),C.latestInjectedAt=Math.max(C.latestInjectedAt,i.injectedAt??0),t.set(k,C)}return Array.from(t.values()).sort((i,u)=>u.latestInjectedAt-i.latestInjectedAt)},[tr,lt,sr,at]),Oi=a.useMemo(()=>Qe?is.find(t=>t.key===Qe)??null:null,[is,Qe]),Ks=ve?{repoRoot:ve.repoRoot??"",repoLabel:ve.repoRoot?lt.get(ve.repoRoot)?.relativeRoot==="."?at:lt.get(ve.repoRoot)?.relativeRoot||lt.get(ve.repoRoot)?.name||yt(ve.repoRoot):at,baseRef:ve.baseRef??ve.baseBranch??"",branchName:ve.currentBranch??null,headRef:ve.headRef??null,diffFingerprint:ve.diffFingerprint??null}:Oi,Cm=a.useMemo(()=>(Xe?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,repoRoot:Xe?.repoRoot,hunk:t,current:null,stale:null})),[Xe?.hunks,Xe?.repoRoot]),Em=a.useMemo(()=>{if(ve)return[];const t=Oi;return t?ws.filter(i=>i.repoRoot===t.repoRoot&&i.baseRef===t.baseRef&&(i.branchName??null)===t.branchName&&(!t.diffFingerprint||i.diffFingerprint===t.diffFingerprint)):[]},[ve,ws,Oi]),Mm=a.useCallback(t=>{const i=_i.find(u=>u.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${u.hunk.filePath}`===t.filePath:!1));i&&(hn(i.key),window.setTimeout(()=>An(t),90),window.setTimeout(()=>An(t),320),window.setTimeout(()=>An(t),760))},[_i]),Ui=a.useMemo(()=>{const t=w=>`'${w.replace(/'/g,"'\\''")}'`,i=Hs,u=i.length>0?i.map(w=>`- ${w.label} (${w.root}),目标分支:${nr[w.root]||w.branch||"(current branch)"},基线分支:${Et[w.root]||"(not set)"},包含本地未提交更改:${os(w.root,nr[w.root]||w.branch)&&(un[w.root]??!0)?"是":"否"}`).join(`
|
|
1673
|
+
`):`- ${v?".":""}`,y=i.length>0?i.map(w=>{const k=nr[w.root]||w.branch||"",C=Et[w.root]||"",ne=w.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(w.root)} switch ${t(k)}`:` # ${w.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(C)} ${t(w.root)} > ~/.termdock/branch-audit/branch-audit-export-${ne}.json`].join(`
|
|
1672
1674
|
`)}).join(`
|
|
1673
|
-
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",u,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",
|
|
1674
|
-
`)},[un,os,Hs,Et,nr,v])
|
|
1675
|
-
`);return await _r(o("rightSidebar.branchAuditShort"),u,`context:branch-audit-scope:${t}`,i)?(c||l(),!0):!1},[
|
|
1676
|
-
`),files:
|
|
1677
|
-
`),truncated:N.some(ee=>ee.truncated)};if(oe.comparisonRepos=u.map((ee,X)=>({...ee,head:ee.head??N[X].currentBranch??null,includeUncommitted:N[X].includeUncommitted===!0,canIncludeUncommitted:N[X].canIncludeUncommitted})),oe.canIncludeUncommitted=N.every(ee=>ee.canIncludeUncommitted===!0),oe.includeUncommitted=N.some(ee=>ee.includeUncommitted===!0),Jo(ee=>({...ee,...Object.fromEntries(oe.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(oe.hunks??[]).length===0){Oe(o("rightSidebar.branchAuditDiffEmpty"));return}const xe=Date.now(),Ae=(i?Qe:null)??["preview",oe.repoRoot??v,oe.baseRef??oe.baseBranch??"",oe.currentBranch??"",oe.headRef??"",oe.diffFingerprint??xe].join("\0"),Ze=u.length===1?u[0].label:`${u.length} repos`;rr(oe),an(ee=>[{key:Ae,diff:oe,repoLabel:Ze,createdAt:xe},...ee.filter(X=>X.key!==Ae)].slice(0,8)),i||L(ee=>ee[Ae]===void 0?ee:{...ee,[Ae]:0}),fn(Ae),hn(ee=>{const X=oe.hunks?.[0],me=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&ee&&(oe.hunks??[]).some(Le=>Le.filePath===ee.split("\0")[0])?ee:me}),cr(!0)}catch(N){if(!k()||yr(N))return;Oe(N instanceof Error?N.message:"Failed to load branch diff")}finally{k()&&Be(!1)}},[un,ve,Qe,Hs,Et,nr,Pe,v,o]),Cm=a.useCallback(t=>{++K.current,Be(!1),rr(t.diff),Oe(null),fn(t.key),hn(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),cr(!0)},[]),Em=a.useCallback(t=>{an(i=>i.filter(u=>u.key!==t)),L(i=>{if(!(t in i))return i;const u={...i};return delete u[t],u}),Qe===t&&(fn(null),rr(null),cr(!1))},[Qe]),Mm=a.useCallback(t=>{++K.current,Be(!1);const i=is.find(u=>u.key===t);i&&(rr(null),Oe(null),fn(t),hn(i.records[0]?.filePath??null),cr(!0))},[is]),$m=a.useCallback(async t=>{if(!v||!Re)return;const[i]=t.split(/\s+/);if(i){dr(i),on(null),mt(null);try{const u=await bp({cwd:v,repoRoot:Re,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){on(u.error??"Commit diff is unavailable");return}mt(u);const w=u.hunks?.[0];ka(w?`${w.filePath}\0${w.hunkHeader}\0${w.hunkIndex}`:null)}catch(u){on(u instanceof Error?u.message:"Failed to load commit diff")}finally{dr(null)}}},[Re,v]),Pm=a.useCallback(t=>{if(!ve||!Qe)return;const i=Math.max(0,Math.round(t));L(u=>Math.abs((u[Qe]??0)-i)<24?u:{...u,[Qe]:i})},[ve,Qe]);a.useEffect(()=>{!ve||!Qe||an(t=>t.map(i=>i.key===Qe&&i.diff!==ve?{...i,diff:ve}:i))},[ve,Qe]);const yd=!!ve;a.useEffect(()=>{if(!se||!Pr||!yd)return;const t=Tc.current;if(!t||t.destroyed)return;t.update(),t.slideTo(1,0);const i=window.requestAnimationFrame(()=>{t.destroyed||(t.update(),t.slideTo(1,0))});return()=>window.cancelAnimationFrame(i)},[Pr,yd,se]);const wd=a.useCallback(t=>{t&&_h(i=>Kp(i,t))},[]),kd=La.key===ot?La.key:null,so=a.useCallback(t=>{const i=V.getState(),u=x0();ta("select_diff_file",{interactionId:u,path:t,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),it(t),Ft("diff"),se&&t&&Fc(1),wd(t),queueMicrotask(()=>{const w=V.getState();ta("select_diff_file_after",{interactionId:u,requestedPath:t,selectedFilePath:w.selectedFilePath,rootPath:w.rootPath,rightTab:w.rightTab,changedFiles:w.changedFiles.size,activeGitRepoRoot:ce})})},[ce,se,wd,it,Ft,Fc]),Sd=a.useCallback(t=>{const i=Array.from(Fe.values()).find(u=>{const w=bt(u,v),y=vr(u);return u.path===t.filePath||y===t.filePath||u.absolutePath===t.filePath||(w?`${w}/${u.path}`===t.filePath:!1)||t.repoRoot&&w===t.repoRoot&&u.path===t.filePath});if(i){so(vr(i)),window.setTimeout(()=>An(t),90),window.setTimeout(()=>An(t),320),window.setTimeout(()=>An(t),760);return}An(t)},[Fe,v,so]),jd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:u}={})=>xs.length>0?e.jsx(ff,{walkthroughs:xs,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:w=>{se&&window.requestAnimationFrame(()=>t?.()),Sd(w)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(ua,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[ce,xs,Sd,se,o]),Am=a.useCallback(t=>{t&&Nr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),il(nl,u),u})},[]),Rd=a.useCallback(t=>{Cr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),il(Cu,u),u})},[]),ao=a.useCallback(t=>{ba(t),At(Pf,t)},[]);a.useEffect(()=>{Qa||Er!=="ai"||ao("tree")},[Er,ao,Qa]);const oo=a.useCallback(()=>{bs(t=>{const i=!t;return At(Af,i),i})},[]),Nd=a.useCallback(t=>{xa(t),At(Lf,t)},[]),{whitespace:Cd,context:Ed}=Vp(),Md=a.useMemo(()=>({algorithm:"histogram",whitespace:Cd,context:Ed}),[Cd,Ed]),$d=a.useCallback(t=>{pe(t),At(Tf,t)},[]),io=a.useCallback(async(t,i,u,w)=>{let y=t;for(;y.ok&&y.status==="running";)await new Promise(N=>window.setTimeout(N,1500)),y=await Qd({jobId:y.jobId,cwd:i.cwd,action:i.action});if(!y.ok)throw new Error("Git action status is unavailable");if(y.status==="error")throw new Error(y.error||y.message||"Git action failed");const k={action:i.action,path:w,label:u};return $s(k),window.setTimeout(()=>$s(N=>N?.action===k.action&&N.path===k.path?null:N),1400),y},[]),yt=a.useCallback(async(t,i,u)=>{const w=v;v&&mr.current.delete(v),qt(null),$s(null),Ms({action:t.action,path:u});try{const y=await xp({...t,includeNested:Js(v)}),k=await io(y,t,i,u);if(!Pe(w))return!1;const N=v?await Yi(v,void 0,{includeNested:Js(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Zs(v)}).catch(()=>k.bundle):k.bundle;return Pe(w)?(N&&Qn(N,{reloadDiff:!0,cacheOnly:!0}),mn(null),!0):!1}catch(y){return $s(null),qt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Pe(w)&&Ms(null)}},[Qn,Pe,v,o,io]),Pd=a.useCallback(async t=>{const i=v;await Zd({...t,includeNested:Js(v)}),Pe(i)&&Bt(v??void 0,{refresh:!0,background:!0})},[Pe,Bt,v]),Lm=a.useCallback(async t=>{const i=ve,u=K.current,w=i?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!i||!w||!t.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));Ee(k=>k+1),Oe(null);try{await Zd(t)}catch(k){throw Ee(N=>N-1),k}if(u!==K.current||!Pe(v)){Ee(k=>k-1);return}const y=k=>{rr(N=>{if(!N||u!==K.current)return N;const ne=N.hunks??[],oe=k===void 0?ne.filter(Ae=>!(Ae.previewRevert?.cwd===t.cwd&&Ae.previewRevert.patch===t.patch)):[...ne.filter(Ae=>Ae.filePath!==w.filePath),...k];return{...N,hunks:oe}})};y(),Jd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(u!==K.current||!Pe(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const N=t.path.slice(t.cwd.length+1),ne=w.filePath.slice(0,w.filePath.length-N.length);y((k.hunks??[]).map(oe=>({...oe,filePath:`${ne}${oe.filePath}`,oldPath:oe.oldPath?`${ne}${oe.oldPath}`:oe.oldPath,newPath:oe.newPath?`${ne}${oe.newPath}`:oe.newPath})))}).catch(k=>{u===K.current&&Pe(v)&&!yr(k)&&Oe(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>Ee(k=>k-1))},[ve,Pe,v,o]),lo=a.useCallback((t,i,u)=>{if(i){if(t==="stage-all"){yt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}mn({kind:"stash-all",repoRoot:i,repoLabel:u})}},[yt,o]),Ad=a.useCallback(t=>{Te(t),$a(""),Pa(""),Aa(""),it(sd(t)),ct||Ft("diff"),t&&Xa(lt.get(t))},[Xa,sd,ct,lt,it,Te,Ft]),Ld=a.useCallback(t=>{const i=new Set([...Yt.current.keys(),...yn.current,...mr.current]);for(const u of i)u!==t&&(Vt.current.delete(u),Yt.current.get(u)?.abort(),Yt.current.delete(u),jt(`right-sidebar-git-untracked:${u}`),yn.current.delete(u),mr.current.delete(u))},[]),Tm=a.useCallback(async t=>{const i=v;if(!i||(await V.getState().setNestedGitScanRoot(i,t),!Pe(i)))return;if(t){await Bt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Ld(i),$a(""),Pa(""),Aa(""),Xo(w=>w.filter(y=>y===i));const u=Jt;u&&bt(u,i)!==i&&it(null),await Bt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Ld,Pe,Bt,v,it,Jt]),Im=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=zn.trim();!t||t===de?.branch||await yt({action:"switch-branch",cwd:Re,branch:t},o("rightSidebar.switchBranch"))},[de?.branch,Re,tt,yt,zn,o]),Td=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Ma.trim();if(!t)return;await yt({action:"commit",cwd:Re,message:t},o("rightSidebar.commitChanges"))&&dc("")},[Re,Ma,tt,yt,o]),Dm=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=gn.trim(),i=bn.trim();await yt({action:"push",cwd:Re,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Re,bn,gn,tt,yt,o]),Fm=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=gn.trim(),i=bn.trim();await yt({action:"pull",cwd:Re,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Re,bn,gn,tt,yt,o]);a.useEffect(()=>{if(!ct||!Re||We)return;let t=!1;const i={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const w=await Qd({cwd:Re,action:u}).catch(()=>null);if(!w?.ok||w.status!=="running")continue;const y={action:u,cwd:Re},k=i[u]??u;Ms({action:u});try{const N=await io(w,y,k);if(t||!Pe(v))return;const ne=v?await Yi(v,void 0,{includeNested:Js(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Zs(v)}).catch(()=>N.bundle):N.bundle;ne&&Qn(ne,{reloadDiff:!0,cacheOnly:!0})}catch(N){t||qt(o("rightSidebar.gitActionFailed",{message:N instanceof Error?N.message:"Unknown error"}))}finally{t||Ms(null)}return}})(),()=>{t=!0}},[Re,Qn,ct,Pe,v,We,o,io]);const Ui=Un?.action==="commit",Hi=Un?.action==="switch-branch",zi=Un?.action==="pull",Wi=Un?.action==="push",co=ct||Dh,Gi=eo?o("rightSidebar.changeAuditScopeAll"):br.length===1?br[0].label:`${br.length} repos`,_m=br.length>0,Id=Hs.length>0,Bm=v?e.jsx(Wu,{open:Vo,onOpenChange:Yo,showScopePicker:!0,selectedAll:eo,repos:Qt,selectedRoots:Za,onToggleRepo:km,onGenerate:t=>Nm(Fi?"regenerate":"generate",t),disabled:!_m,generateDisabled:!Id,inserted:De?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Fi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Gi,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Fi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Oi()},secondaryDisabled:!Id||st,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:st,loading:rc.size>0,statusTitle:rc.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:cd.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:o("rightSidebar.missingBaseReposSkipped",{repositories:cd.map(t=>t.label).join(_==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=lt.get(t.root),u=os(t.root,nr[t.root]||i?.context?.branch),w=[],y=new Set,k=(xe,Ae)=>{!xe||y.has(xe)||(y.add(xe),w.push({value:xe,label:xe,meta:Ae}))};k(nr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const xe of i?.context?.branches??[])k(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const xe of i?.context?.remoteBranches??[])k(xe,o("rightSidebar.remoteBranch"));const N=[],ne=new Set,oe=(xe,Ae)=>{!xe||ne.has(xe)||(ne.add(xe),N.push({value:xe,label:xe,meta:Ae}))};oe(Et[t.root],Et[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),oe(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const xe of i?.context?.remoteBranches??[])oe(xe,"remote");for(const xe of i?.context?.branches??[])oe(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:nr[t.root]||i?.context?.branch||"",options:w,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:xe=>{ja(Ae=>({...Ae,[t.root]:xe}))}}),e.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:N,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:xe=>{Ra(Ae=>({...Ae,[t.root]:xe}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(u?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:u&&(un[t.root]??!0),disabled:!u,onChange:xe=>Jo(Ae=>({...Ae,[t.root]:xe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Dd=ea(kt.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),_),Om=()=>v?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>tc(t=>{const i=!t;return At(sl,i),i}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(ua,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Gi})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Cs?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]}),Cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",Gi]}),Bm]}),Ye&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ye}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[sn.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Cm(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),ea(t.createdAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:ea(t.createdAt,_)})]}),e.jsx("button",{type:"button",onClick:()=>Em(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:e.jsx(jo,{size:12})})]},t.key)),is.length>0?is.slice(0,Math.max(0,8-sn.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Mm(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),ea(t.latestInjectedAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:ea(t.latestInjectedAt,_)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{ym(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:e.jsx(jo,{size:12})})]},t.key)):sn.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Um=()=>sr&&v&&En?e.jsxs("div",{className:co?"overflow-visible":"overflow-hidden",children:[Om(),e.jsxs("button",{type:"button",onClick:()=>{ct||Fh(t=>{const i=!t;return i&&Re&&!En&&!pn&&ki(Re),i})},"aria-expanded":co,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${ct?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(xr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&e.jsx(ut,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!ct&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${co?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),co&&e.jsxs("div",{className:"space-y-0",children:[Ht.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:im})]})}),e.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:Re??"",options:Ht,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!We,onChange:t=>{Ad(t||null)}}),tt&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:o("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:zn!==rd?rd:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Im()},disabled:!bm,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Hi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[e.jsx("span",{className:We?.action==="switch-branch"||Hi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),We?.action==="switch-branch"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),Hi&&We?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:zn,options:dm,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!We,onChange:$a})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:tt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Td()},disabled:!!We||tt||Cn.staged===0||!Ma.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${Ui?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:tt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:We?.action==="commit"||Ui?"opacity-0":"",children:o("rightSidebar.commitChanges")}),We?.action==="commit"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),Ui&&We?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ma,onChange:t=>dc(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Td())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!We,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Kr(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":ln,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[ya&&e.jsx(ut,{size:12,className:"animate-spin text-muted-foreground"}),e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${ln?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),ln&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:12,className:"shrink-0"}),e.jsx("input",{value:cn,onChange:t=>dn(t.target.value),placeholder:o("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),cn&&e.jsx("button",{type:"button",onClick:()=>dn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:lm,children:[Dt.length>0?Dt.map(t=>{const[i,...u]=t.split(/\s+/),w=u.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{$m(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:w,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:w,children:w}),re[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${re[i]==="ahead"?"bg-accent/10 text-accent":re[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(re[i]==="ahead"?"rightSidebar.commitAhead":re[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),_n===i&&e.jsx(ut,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):ya?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):Ko?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),wa&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(ut,{size:12,className:"animate-spin"})}),qo&&!wa&&Dt.length>0&&e.jsx("button",{type:"button",onClick:()=>{Us({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:o("rightSidebar.recentCommitsLoadMore")})]})]}),Ss&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ss}),Ko&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ko})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Fm()},disabled:!pm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${zi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[e.jsx("span",{className:We?.action==="pull"||zi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),We?.action==="pull"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),zi&&We?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Dm()},disabled:!gm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Wi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[e.jsx("span",{className:We?.action==="push"||Wi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),We?.action==="push"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),Wi&&We?.action!=="push"&&e.jsx("span",{className:"absolute",children:"✓"})]})]})]}),e.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${ud.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:ud.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:de?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${ld?"grid-cols-2":"grid-cols-1"}`,children:[ld&&e.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:gn,options:id,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!We,onChange:Pa}),e.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:bn,options:um,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!We,onChange:Aa})]})]})]})]}):null,Hm=a.useCallback(t=>{const i=bt(t,v);if(!i)return[];const u=ml(t),w=[];return t.canStage&&w.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{yt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),u)}}),t.canUnstage&&w.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{yt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),u)}}),t.canStash&&w.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{yt({action:"stash-file",cwd:i,paths:[t.path]},o("rightSidebar.stashFile"),u)}}),t.canRestoreWorktree&&w.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>mn({kind:"restore",file:t,phrase:""})}),w},[v,yt,o]),zm=a.useCallback(()=>{if(f){h?.();return}Lr(0),Ir.current?.slideTo(0),Ar(!1),Wt(null)},[h,f]),Fd=a.useCallback(t=>{if(Y(""),_t(t),it(null),Wt(null),R(null),se){f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1);return}},[se,h,f,it,_t]);a.useEffect(()=>{if(!H||V.getState().pendingTerminalPath!==H)return;V.setState({pendingTerminalPath:null}),(()=>{const i=H,u=i.path;if(!u.startsWith("/"))return;Y(""),Wt(null),Tt(null);const w=!!(v&&(u===v||u.startsWith(`${v}/`)));if(i.kind==="file"){const y=So(u);Is(u),typeof i.line=="number"&&Number.isSafeInteger(i.line)&&i.line>0&&Tt(i.line),_t(w?null:y),R({path:u,nonce:++z.current});return}it(null),w?(_t(null),R({path:u,nonce:++z.current})):(R(null),_t(u)),se&&(f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1))})()},[H,Is,se,h,f,v,it,_t]),a.useEffect(()=>{r||(zt(!1),er(!1))},[r]),a.useEffect(()=>{if(!Sr&&!en)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(In.current?.contains(i.target)||jr.current?.contains(i.target))||(zt(!1),er(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[en,Sr]);const _d=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:sm,disabled:!Va,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:e.jsx(Ol,{size:14})}),e.jsx("button",{type:"button",onClick:Vc,disabled:!v||Gn===v,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:e.jsx(ou,{size:14})}),e.jsx("button",{type:"button",onClick:am,disabled:!le,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:uc?o("rightSidebar.fileWatchUnavailable",{message:uc}):o("rightSidebar.refreshFiles"),children:e.jsx(Ro,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:le??void 0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[e.jsx("span",{className:"truncate",children:rm}),Fa==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(iu,{size:11})})]})}),e.jsx("button",{type:"button",onClick:t=>le&&Xt(le,Ut??void 0,t.currentTarget),disabled:!le,...le&&Ut?Ei(Ga(le),Ut):{},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-35 active:scale-95 ${Ut&&(De===Ut||je===Ut)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ut&&je===Ut?"rightSidebar.copied":Ut&&De===Ut?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ut&&(De===Ut||je===Ut)?e.jsx(Po,{size:13}):e.jsx(Ao,{size:13})}),e.jsx(Rg,{rootPath:le,disabled:!le||!Uh||mi,pressed:Da,saving:mi,onToggle:()=>{if(!le||mi)return;const t=le;Ec(!0),pi(null),Hh(t,!Da).catch(()=>{const i=V.getState();(i.explorerRoot??i.rootPath)===t&&pi(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>Ec(!1))}}),e.jsxs("div",{ref:jr,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),er(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${en?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":en,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx($o,{size:14})}),en&&e.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{er(!1),om()},disabled:!Pi,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Bs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Bs?e.jsx(Qi,{size:14}):e.jsx(ho,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(Bs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{er(!1),Bh()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${di?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[di?e.jsx(Qp,{size:14}):e.jsx(Sl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(di?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!le,onClick:()=>{le&&(er(!1),Oh(le,Fa==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[Fa==="modified"?e.jsx(Ip,{size:14}):e.jsx(iu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(Fa==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),Mc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:Mc}),v&&(Ya.length>0||nm)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Vc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${le===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(ou,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:at})]}),Ya.map(t=>{const i=t.path,u=t.kind==="file",w=u?ot===i:le===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${w?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?Is(i):_t(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(jl,{size:10,className:"shrink-0"}):e.jsx(ho,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:wt(i)})]}),e.jsx("button",{type:"button",onClick:()=>xn(i),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.unpinFolder",{name:wt(i)}),title:o("rightSidebar.unpinFolder",{name:wt(i)}),children:e.jsx(Lt,{size:9})})]},i)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),Ki=a.useMemo(()=>{if(Hn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((si-Hn)/1e3)),u=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[w,y]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return u.format(w,y)},[si,Hn]),uo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Bd=v&&!es?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{Tm(!ui)},"aria-checked":ui,title:o("rightSidebar.multiRepoScanTitle"),className:uo,children:[e.jsx(xr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),ui&&e.jsx(Po,{size:14,className:"shrink-0 text-primary"})]}):null,Od=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Ki?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Ki}),children:Ki}):null,e.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:e.jsx(Ro,{size:13,className:hr?"animate-spin":""})})]}):null,Wm=Dc?o("rightSidebar.changeAuditScopeAll"):kn.length===1?kn[0].relativeRoot==="."?at:kn[0].relativeRoot||kn[0].name:`${kn.length} repos`,Gm=t=>v?e.jsxs("div",{role:"none",children:[e.jsx(Wu,{menuItem:!0,open:vs,onOpenChange:i=>{nn(i),i&&t()},showScopePicker:Mn,selectedAll:Dc,repos:zh,selectedRoots:or,onToggleRepo:wm,onGenerate:async i=>{const u=await xm("generate",i);return u!==!1&&t(),u},disabled:!v,inserted:De===qc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Wm,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Hr,error:!!$r,statusTitle:$r??(Hr?o("rightSidebar.changeAuditLoading"):kt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:kt.length})}${Dd?` · ${o("rightSidebar.changeAuditLoadedAt",{time:Dd})}`:""}`:void 0)}),kt.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),vm()},disabled:Hr||kt.length===0,className:uo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(jo,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ls=ir??(M?.available&&v&&Fe.size>0&&fe.length<=1?{root:v,label:at}:null),Ud=t=>e.jsxs(e.Fragment,{children:[ls&&e.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),lo("stage-all",ls.root,ls.label)},disabled:!!We,className:uo,children:[e.jsx(wp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),lo("stash-all",ls.root,ls.label)},disabled:!!We,className:uo,children:[e.jsx(Wp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ls&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Gm(t),Bd&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Bd]}),fo=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[M?.available&&M.branch&&e.jsxs("span",{className:"inline-flex min-w-0 max-w-[8rem] items-center gap-0.5 truncate rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",title:M.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:M.branch})]}),pt.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[pt.modified,"M"]}),pt.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",pt.added]}),pt.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",pt.deleted]}),pt.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.renamed,"R"]}),pt.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.copied,"C"]}),pt.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.untracked,"U"]}),pt.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[pt.conflicted,"!"]}),pt.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.other,"?"]}),pt.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:pt.staged})})]});return e.jsxs(Dp,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m,children:[Ei.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Xh?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:v??void 0,children:at}),(!se||ti)&&M?.available&&M.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:M.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:M.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!Z;P(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):Y("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Z?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:e.jsx(ms,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":B,onClick:()=>{ae(t=>!t),et(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${B?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[e.jsx(Fp,{size:14}),!B&&Nt.trim()&&e.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),e.jsx("input",{ref:pc,type:"file",multiple:!0,className:"hidden",onChange:t=>{const i=t.target.files;!i||i.length===0||(Ds(Array.from(i)),t.target.value="")}}),e.jsx("input",{ref:gc,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&Zh(i,t.currentTarget.closest("[data-sidebar]")??void 0)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${m?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:m?e.jsx(Qi,{size:14}):e.jsx(ho,{size:14})}),e.jsxs("div",{ref:In,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{er(!1),zt(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Sr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Sr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx($o,{size:15})}),Sr&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[["architecture","computer"].map(t=>e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":ar[t],onClick:()=>Qh(t,!ar[t]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t==="architecture"?e.jsx(lu,{size:14,className:"text-muted-foreground"}):e.jsx(eu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o(t==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${ar[t]?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${ar[t]?"left-3.5":"left-0.5"}`})})]},t)),e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Vr,onClick:()=>Bc(!Vr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(tu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Vr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Vr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),pc.current?.click()},disabled:Ha,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[Ha?e.jsx(ut,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(_p,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),gc.current?.click()},disabled:Ha,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[Ha?e.jsx(ut,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(sg,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${m?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[m?e.jsx(Qi,{size:14}):e.jsx(ho,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),m&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":o("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([t,i])=>{const u=G===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(t),zt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:i},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:14})})]}),Z&&e.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-3 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:t=>Y(t.target.value),placeholder:o(ie==="content"?"rightSidebar.searchPlaceholderContent":"rightSidebar.filterChanges"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",enterKeyHint:"search",spellCheck:!1}),e.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${se?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>$d("name"),"aria-pressed":ie==="name",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${ie==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>$d("content"),"aria-pressed":ie==="content",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${ie==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>Y(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(Bp,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:Se,onChange:t=>ke(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Se!=="."&&e.jsx("button",{type:"button",onClick:()=>ke("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:e.jsx(Lt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>ue(t=>!t),"aria-expanded":ge,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${ge||As.length>0||_e||W||ye?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[e.jsx(Op,{size:13}),As.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[8px] font-bold leading-4 text-primary-foreground",children:As.length})]})]}),ge&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:Me,onChange:t=>Q(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Me&&e.jsx("button",{type:"button",onClick:()=>Q(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:e.jsx(Lt,{size:11})})]}),ie==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[_e,()=>Ue(t=>!t),Xp,o("rightSidebar.matchCase")],[W,()=>we(t=>!t),dg,o("rightSidebar.matchWholeWord")],[ye,()=>He(t=>!t),og,o("rightSidebar.useRegex")]].map(([t,i,u,w])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),w]},w))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(es?1:3)+Number(ar.architecture)+Number(ar.computer)+Number(Vr)}, minmax(0, 1fr))`},children:[!es&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>ns("git",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>ns("diff",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(vf,{size:12}),o("rightSidebar.tabChanges"),Fe.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Fe.size}):null]})]}),e.jsxs("button",{type:"button",onClick:t=>ns("files",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xl,{size:12}),o("rightSidebar.tabFiles")]}),ar.architecture&&e.jsxs("button",{type:"button",onClick:t=>ns("architecture",t),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Sn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(lu,{size:12}),o("architecture.tab")]}),ar.computer&&e.jsxs("button",{type:"button",onClick:t=>ns("computer",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${rs?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(eu,{size:12}),o("rightSidebar.tabComputer")]}),Vr&&e.jsxs("button",{type:"button",onClick:t=>ns("android",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(tu,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),lc&&e.jsx("div",{className:"pointer-events-none absolute right-3 top-10 z-20 max-w-[72%] rounded-lg bg-destructive/95 px-3 py-2 text-[11px] font-medium text-destructive-foreground shadow-md animate-fade-in",children:lc})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(ds,{active:ct,mounted:sr,fallback:e.jsx(ul,{slow:!1}),children:()=>Xe?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(xu,{items:Sm,diffViewType:oi,inlineMode:Kt,viewControls:m?zs():void 0,renderPathReference:(t,i)=>to(Pn(t,Xe.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Mh,onSelect:ka,emptyText:o("rightSidebar.noChanges"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Xe.headRef??""}${Xe.commits?.[0]?` · ${Xe.commits[0]}`:""}`,onClose:()=>{mt(null),ka(null)},closeLabel:o("common.back"),wrap:It,onToggleWrap:oo,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no})}):Pr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(xu,{items:Di,diffViewType:oi,inlineMode:Kt,viewControls:m?zs():void 0,renderPathReference:(t,i)=>{const u=ve?.comparisonRepos,w=u&&u.length>1?[...u].sort((k,N)=>N.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,y=w?t===w.label?w.repoRoot:Pn(t.slice(w.label.length+1),w.repoRoot):Pn(t,Ks?.repoRoot||v);return to(y,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Qo,onSelect:hn,emptyText:o(ve?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(ve?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Ks?`${Ks.repoLabel} · ${Ks.branchName??"HEAD"} → ${Ks.baseRef}`:void 0,onClose:()=>{++K.current,Be(!1),cr(!1),rr(null)},closeLabel:o("common.back"),wrap:It,onToggleWrap:oo,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no,localOptions:ve?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??ve.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??os(t.repoRoot,t.head)),onChange:i=>{Oi({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:ve?.includeUncommitted?Lm:void 0,error:Ye,actionsBusy:be>0,onRefresh:()=>{Oi({refresh:!0})},refreshing:st,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:jm,onWalkthroughNavigate:Rm,initialDetailScrollTop:ve&&Qe?ks[Qe]:void 0,onDetailScrollPositionChange:Pm,externalSwiperRef:se?Tc:void 0,onMobileSlideChange:se?ei:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:sr&&v&&En?e.jsx("div",{className:"px-3",children:Um()}):hr?e.jsx(ul,{slow:jc}):vn?e.jsx(ko,{message:vn,onRetry:()=>{Zn()}}):Yu(M)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):M?.available===!1?e.jsx(ko,{message:M.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Zn()}}):v?e.jsx(ul,{slow:jc}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(ds,{active:Dr,mounted:Ph||Dr,children:()=>se?e.jsxs(cf,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Ir.current=t,t.slideTo(Zo,0)},onSlideChange:t=>{if(Lr(t.activeIndex),Ts.current===t.activeIndex){Ts.current=null;return}t.activeIndex===0&&(Ar(!1),Wt(null),h?.())},children:[e.jsx(vl,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Vn,onScroll:Oc,onDragOver:za,onDragEnter:za,onDragLeave:Hc,onDrop:zc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[fc&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!I.trim()&&_d,e.jsx(cu,{rootPath:le??"",onFileSelect:Is,onPathReference:Xt,getReferenceText:Ga,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onDirectoryRoot:Yc,onSearchFromDirectory:Xc,onDirectoryPinToggle:Jc,onFilePinToggle:Qc,pinnedPaths:Rn,selectedFilePath:ot,query:Ke,searchRootPath:$c,searchOptions:Pc,searchMode:ie,onContentMatchSelect:Ri,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:U,canOpenInFileBrowser:hc,onOpenInFileBrowser:Uc})]})}),e.jsx(vl,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Uo,{filePath:$h||Zo===1?ot:null,active:r&&Dr&&Zo===1,onInsertReference:Xt,onInsertText:Fr,onInsertFeature:qa,onReviewReference:qa,onReferenceCopied:gr,onClose:zm,onDirectoryLinkOpen:Fd,isMobile:!0,lineRange:Or,onLineRangeChange:Wt,insertedReferenceKey:De,copiedReferenceKey:je,scrollToLine:Ve,onScrollToLineHandled:()=>Tt(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:C,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:O,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Vn,onScroll:Oc,onDragOver:za,onDragEnter:za,onDragLeave:Hc,onDrop:zc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:ii},children:[fc&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!I.trim()&&_d,e.jsx(cu,{rootPath:le??"",onFileSelect:Is,onPathReference:Xt,getReferenceText:Ga,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onDirectoryRoot:Yc,onSearchFromDirectory:Xc,onDirectoryPinToggle:Jc,onFilePinToggle:Qc,pinnedPaths:Rn,selectedFilePath:ot,query:Ke,searchRootPath:$c,searchOptions:Pc,searchMode:ie,onContentMatchSelect:Ri,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:U,canOpenInFileBrowser:hc,onOpenInFileBrowser:Uc})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:Wh,onPointerMove:Gh,onPointerUp:_c,onPointerCancel:_c,onDoubleClick:()=>{li(Ml),At(na,Ml)},children:e.jsx("span",{className:"absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-border/20 transition group-hover:bg-primary/45"})}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Uo,{filePath:ot,active:r&&Dr,onInsertReference:Xt,onInsertText:Fr,onInsertFeature:qa,onReviewReference:qa,onReferenceCopied:gr,onDirectoryLinkOpen:Fd,isMobile:!1,lineRange:Or,onLineRangeChange:Wt,insertedReferenceKey:De,copiedReferenceKey:je,scrollToLine:Ve,onScrollToLineHandled:()=>Tt(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:C,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:O,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})]})}),e.jsx(ds,{active:$t,mounted:Lh||$t,children:()=>Si?e.jsx(Up,{}):se?e.jsx(yl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:wi,onMobileSlideChange:ei,groups:Zt.length>0?bd():[],mode:Er,onModeChange:ao,selectedKey:ot,scrollToKey:kd,scrollToKeyNonce:La.nonce,compact:!1,collapsedDirectoryKeys:ga,onToggleDirectory:Rd,onSelectFile:t=>{const i=$n.get(t.key);i&&so(vr(i))},renderLeading:xd,renderTrailing:t=>{const i=$n.get(t.key);return i?pd(i):null},renderDirectoryTrailing:gd,renderSubtitle:t=>{const i=$n.get(t.key);return i?md(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[fo&&e.jsx("div",{className:"mb-2",children:fo}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Zt.length,"/",Fe.size]})]}),e.jsxs(pu,{actions:Ud,children:[fd(),t,m&&zs(),Od]},v),ir&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&Mn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Qa?(t=>jd(t)):void 0,emptyContent:Si?null:vn&&Fe.size===0?e.jsx(ko,{message:vn,onRetry:()=>{Zn()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Zt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:t})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[e.jsx(ca,{size:14}),o("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[m&&zs(),e.jsxs("button",{type:"button",onClick:oo,"aria-pressed":It,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${It?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(It?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:e.jsx(Ro,{size:14,className:hr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:vd,activePane:$t,wrap:It,diffViewType:oi,inlineMode:Kt,diffOptions:Md,reloadKey:va,renderStreamBadge:t=>e.jsx(oa,{status:t}),onHunkGitAction:Pd,onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no,onDetailScroll:ro}):e.jsx(yl,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:o("rightSidebar.backToChangeList"),groups:Zt.length>0?bd():[],mode:Er,onModeChange:ao,selectedKey:ot,scrollToKey:kd,scrollToKeyNonce:La.nonce,compact:!0,collapsedDirectoryKeys:ga,onToggleDirectory:Rd,onSelectFile:t=>{const i=$n.get(t.key);i&&so(vr(i))},renderLeading:xd,renderTrailing:t=>{const i=$n.get(t.key);return i?pd(i):null},renderDirectoryTrailing:gd,renderSubtitle:t=>{const i=$n.get(t.key);return i?md(i):null},aiContent:Qa?(t=>jd(t)):void 0,emptyContent:Si?null:vn&&Fe.size===0?e.jsx(ko,{message:vn,onRetry:()=>{Zn()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Zt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[fo&&e.jsx("div",{className:"mb-2",children:fo}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Zt.length,"/",Fe.size]})})]}),e.jsxs(pu,{actions:Ud,children:[fd(),t,zs(),e.jsxs("button",{type:"button",onClick:oo,"aria-pressed":It,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${It?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(It?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Od]},v),ir&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&Mn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:vd,activePane:$t,wrap:It,diffViewType:Gt,inlineMode:Kt,diffOptions:Md,reloadKey:va,renderStreamBadge:t=>e.jsx(oa,{status:t}),onHunkGitAction:Pd,onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no,onDetailScroll:ro})}),e.jsx(ds,{active:Sn,mounted:ar.architecture&&(Vh||r&&Sn),children:e.jsx(a.Suspense,{fallback:e.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:e.jsx(nx,{rootPath:v,active:r&&Sn,onInsertPrompt:(t,i)=>Fr(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(w0,{rootPath:v,file:t,active:r&&Sn,isMobile:se,onInsertReference:Xt,onInsertText:Fr,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(Ft("files"),_t(null),Ri(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(ds,{active:r&&rs,mounted:ar.computer&&(Kh||r&&rs),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(sx,{active:r&&rs})})}),e.jsx(ds,{active:ts,mounted:ni&&Vr,children:Th?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:o("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{Vi.getState().setDock(Xi,null),ra({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Hp,{sessionId:n??null,onCloseTab:()=>Bc(!1),onInsertPrompt:async(t,i)=>{if(!await _r("android-deps",t,void 0,i))throw new Error(o("rightSidebar.uploadReferenceRejected"))},onInsertFile:tm,onRecordingComplete:em})})]}),r&&Rt&&e.jsx("div",{role:"alert",className:"shrink-0 border-t border-border/15 px-3 py-2 text-xs text-destructive",children:o("rightSidebar.referenceInsertFailed")}),r&&Ot.task&&e.jsx(Zg,{task:Ot.task,onCancel:Ot.cancel,onRetry:()=>{Ot.retry()},onDismiss:Ot.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Ot.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Ot.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:Ot.task.files.length})}}),r&&B&&e.jsx(Vg,{value:Nt,collapsed:Ce,autoCollapseAfterSend:xt,focusRequest:Tn,insertError:Dn?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{tn(!1),Ct(t)},onCollapsedChange:et,onAutoCollapseAfterSendChange:kr,onDisable:()=>ae(!1),onClear:()=>Ct(""),onInsert:t=>Kc(!1,t),onInsertAndSend:t=>Kc(!0,t),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>o("rightSidebar.contextDraftCharacterCount",{count:t})}}),mm(),vt&&typeof document<"u"&&wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>mn(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:vt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:vt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:af(vt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),vt.kind==="restore"&&e.jsx("input",{value:vt.phrase,onChange:t=>mn({...vt,phrase:t.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>mn(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),e.jsx("button",{type:"button",disabled:!!We||vt.kind==="restore"&&vt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(vt.kind==="restore"){const t=bt(vt.file,v);if(!t)return;yt({action:"restore-worktree-file",cwd:t,paths:[vt.file.path],confirm:{acknowledged:!0,phrase:vt.phrase}},o("rightSidebar.restoreFile"),ml(vt.file))}else{const t=vt.repoRoot??v;if(!t)return;yt({action:"stash-all",cwd:t},o("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${vt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(We?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const T0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Uo,MarkdownImageLightbox:bh,MarkdownPreview:xh,RightSidebar:k0,__testParseMarkdownListBlock:Bx,buildMarkdownPreviewBlocks:Yx,buildMarkdownPreviewRenderResult:Xl,collectKnownGitRepoRoots:Hf,computeMarkdownImageDisplayBox:eh,getMarkdownHeadingOutline:gh,getMarkdownHeadingPathAtLine:ph,getNextMarkdownPreviewLineRange:t0,isSvgImageSrc:pa,mountRightSidebarRepoPickerOverlay:Mf,replaceGitRepositorySnapshot:jh,resolveMarkdownLocalLinkTarget:Wl,resolveRightSidebarDiffViewType:Of,shouldCloseMarkdownImageLightboxDrag:fh,showsGitRepoGroupHeader:$l},Symbol.toStringTag,{value:"Module"}));export{Sl as E,T0 as R,lg as S,Qp as a,Yx as b,Ng as c,Sg as i,kg as l,L0 as m};
|
|
1675
|
+
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",u,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",y,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:v??null,repoRoot:"<target repo root>",baseRef:"<target repo base branch>",branchName:"<from export currentBranch>",headRef:"<from export headRef>",diffFingerprint:"<from export diffFingerprint>",generatedBy:"termdock-branch-audit",walkthrough:{title:"<one-line branch change title>",summary:"<branch change goal and effect>",highlights:[{what:"<what changed>",effect:"<user/system effect>",tag:"<category>"}],nodes:[{id:"n1",title:"<node title>",kind:"process",business:"<zero-context business explanation>",anchor:{repoRoot:"<target repo root>",filePath:"<from hunk.filePath>",hunkIndex:0,hunkFingerprint:"<from hunk.fingerprint>"}}],edges:[{from:"n1",to:"n2",label:"<relationship>",desc:"<business meaning>"}],risks:[{title:"<real risk or validation gap>"}],checks:["<executable validation step>"]},records:[{filePath:"<from hunk.filePath>",oldPath:"<from hunk.oldPath or null>",newPath:"<from hunk.newPath or null>",hunkHeader:"<from hunk.hunkHeader>",hunkIndex:0,fingerprint:"<from hunk.fingerprint>",diff:"<copy from hunk.diff exactly>",explanation:"<replace with hunk explanation>",summary:""}]},null,2),"```"].join(`
|
|
1676
|
+
`)},[un,os,Hs,Et,nr,v]),$m=a.useCallback(async(t="generate",i)=>{const u=t==="generate"?Ui:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ui].join(`
|
|
1677
|
+
`);return await _r(o("rightSidebar.branchAuditShort"),u,`context:branch-audit-scope:${t}`,i)?(c||l(),!0):!1},[Ui,_r,l,c,o]),Hi=a.useCallback(async(t={})=>{const i=t.refresh===!0,u=i&&ve?.comparisonRepos?ve.comparisonRepos:Hs.map(C=>{const ne=(nr[C.root]||C.branch||"").trim();return{repoRoot:C.root,label:C.label,base:Et[C.root]?.trim()??"",head:ne||null,includeUncommitted:un[C.root]??!0}});if(!v||u.length===0)return;const y=++K.current,w=v,k=()=>Pe(w)&&y===K.current;Be(!0),Oe(null),i||(rr(null),mt(null));try{const C=await Promise.all(u.map(async ee=>{if(!ee.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:ee.label}));return Zd({cwd:v,repoRoot:ee.repoRoot,base:ee.base,head:ee.head,includeUncommitted:t.repoRoot===ee.repoRoot?t.includeUncommitted??!1:ee.includeUncommitted??ve?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${ee.repoRoot}`})}));if(!k())return;const ne=C.find(ee=>!ee.available);if(ne){Oe(ne.error??"Branch diff is unavailable");return}const oe=C.length===1?C[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:C.map(ee=>ee.baseRef??ee.baseBranch).filter(Boolean).join(", "),currentBranch:C.map(ee=>ee.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:C.map(ee=>ee.headRef).filter(Boolean).join(", "),diffFingerprint:C.map(ee=>ee.diffFingerprint).filter(Boolean).join("+"),stat:C.map(ee=>ee.stat).filter(Boolean).join(`
|
|
1678
|
+
`),files:C.flatMap((ee,X)=>{const me=u[X];return(ee.files??[]).map(Le=>`${me?.label??ee.repoRoot??"repo"}/${Le}`)}),hunks:C.flatMap((ee,X)=>{const Le=u[X]?.label??ee.repoRoot??"repo";return(ee.hunks??[]).map(Ge=>({...Ge,filePath:`${Le}/${Ge.filePath}`,oldPath:Ge.oldPath?`${Le}/${Ge.oldPath}`:Ge.oldPath,newPath:Ge.newPath?`${Le}/${Ge.newPath}`:Ge.newPath}))}),commits:C.flatMap(ee=>ee.commits??[]),commitCount:C.reduce((ee,X)=>ee+(X.commitCount??X.commits?.length??0),0),diff:C.map(ee=>ee.diff).filter(Boolean).join(`
|
|
1679
|
+
`),truncated:C.some(ee=>ee.truncated)};if(oe.comparisonRepos=u.map((ee,X)=>({...ee,head:ee.head??C[X].currentBranch??null,includeUncommitted:C[X].includeUncommitted===!0,canIncludeUncommitted:C[X].canIncludeUncommitted})),oe.canIncludeUncommitted=C.every(ee=>ee.canIncludeUncommitted===!0),oe.includeUncommitted=C.some(ee=>ee.includeUncommitted===!0),Zo(ee=>({...ee,...Object.fromEntries(oe.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(oe.hunks??[]).length===0){Oe(o("rightSidebar.branchAuditDiffEmpty"));return}const xe=Date.now(),Ae=(i?Qe:null)??["preview",oe.repoRoot??v,oe.baseRef??oe.baseBranch??"",oe.currentBranch??"",oe.headRef??"",oe.diffFingerprint??xe].join("\0"),Ze=u.length===1?u[0].label:`${u.length} repos`;rr(oe),an(ee=>[{key:Ae,diff:oe,repoLabel:Ze,createdAt:xe},...ee.filter(X=>X.key!==Ae)].slice(0,8)),i||L(ee=>ee[Ae]===void 0?ee:{...ee,[Ae]:0}),fn(Ae),hn(ee=>{const X=oe.hunks?.[0],me=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&ee&&(oe.hunks??[]).some(Le=>Le.filePath===ee.split("\0")[0])?ee:me}),cr(!0)}catch(C){if(!k()||wr(C))return;Oe(C instanceof Error?C.message:"Failed to load branch diff")}finally{k()&&Be(!1)}},[un,ve,Qe,Hs,Et,nr,Pe,v,o]),Pm=a.useCallback(t=>{++K.current,Be(!1),rr(t.diff),Oe(null),fn(t.key),hn(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),cr(!0)},[]),Am=a.useCallback(t=>{an(i=>i.filter(u=>u.key!==t)),L(i=>{if(!(t in i))return i;const u={...i};return delete u[t],u}),Qe===t&&(fn(null),rr(null),cr(!1))},[Qe]),Lm=a.useCallback(t=>{++K.current,Be(!1);const i=is.find(u=>u.key===t);i&&(rr(null),Oe(null),fn(t),hn(i.records[0]?.filePath??null),cr(!0))},[is]),Tm=a.useCallback(async t=>{if(!v||!Re)return;const[i]=t.split(/\s+/);if(i){dr(i),on(null),mt(null);try{const u=await yp({cwd:v,repoRoot:Re,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){on(u.error??"Commit diff is unavailable");return}mt(u);const y=u.hunks?.[0];Sa(y?`${y.filePath}\0${y.hunkHeader}\0${y.hunkIndex}`:null)}catch(u){on(u instanceof Error?u.message:"Failed to load commit diff")}finally{dr(null)}}},[Re,v]),Im=a.useCallback(t=>{if(!ve||!Qe)return;const i=Math.max(0,Math.round(t));L(u=>Math.abs((u[Qe]??0)-i)<24?u:{...u,[Qe]:i})},[ve,Qe]);a.useEffect(()=>{!ve||!Qe||an(t=>t.map(i=>i.key===Qe&&i.diff!==ve?{...i,diff:ve}:i))},[ve,Qe]);const kd=!!ve;a.useEffect(()=>{if(!se||!Pr||!kd)return;const t=Dc.current;if(!t||t.destroyed)return;t.update(),t.slideTo(1,0);const i=window.requestAnimationFrame(()=>{t.destroyed||(t.update(),t.slideTo(1,0))});return()=>window.cancelAnimationFrame(i)},[Pr,kd,se]);const Sd=a.useCallback(t=>{t&&Hh(i=>Xp(i,t))},[]),jd=Ta.key===ot?Ta.key:null,ao=a.useCallback(t=>{const i=V.getState(),u=v0();ta("select_diff_file",{interactionId:u,path:t,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),it(t),Ft("diff"),se&&t&&Bc(1),Sd(t),queueMicrotask(()=>{const y=V.getState();ta("select_diff_file_after",{interactionId:u,requestedPath:t,selectedFilePath:y.selectedFilePath,rootPath:y.rootPath,rightTab:y.rightTab,changedFiles:y.changedFiles.size,activeGitRepoRoot:ce})})},[ce,se,Sd,it,Ft,Bc]),Rd=a.useCallback(t=>{const i=Array.from(Fe.values()).find(u=>{const y=bt(u,v),w=vr(u);return u.path===t.filePath||w===t.filePath||u.absolutePath===t.filePath||(y?`${y}/${u.path}`===t.filePath:!1)||t.repoRoot&&y===t.repoRoot&&u.path===t.filePath});if(i){ao(vr(i)),window.setTimeout(()=>An(t),90),window.setTimeout(()=>An(t),320),window.setTimeout(()=>An(t),760);return}An(t)},[Fe,v,ao]),Nd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:u}={})=>xs.length>0?e.jsx(hf,{walkthroughs:xs,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:y=>{se&&window.requestAnimationFrame(()=>t?.()),Rd(y)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(ua,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[ce,xs,Rd,se,o]),Dm=a.useCallback(t=>{t&&Nr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),cl(al,u),u})},[]),Cd=a.useCallback(t=>{Cr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),cl(Mu,u),u})},[]),oo=a.useCallback(t=>{xa(t),At(Af,t)},[]);a.useEffect(()=>{Za||Er!=="ai"||oo("tree")},[Er,oo,Za]);const io=a.useCallback(()=>{bs(t=>{const i=!t;return At(Lf,i),i})},[]),Ed=a.useCallback(t=>{va(t),At(Tf,t)},[]),{whitespace:Md,context:$d}=Qp(),Pd=a.useMemo(()=>({algorithm:"histogram",whitespace:Md,context:$d}),[Md,$d]),Ad=a.useCallback(t=>{pe(t),At(If,t)},[]),lo=a.useCallback(async(t,i,u,y)=>{let w=t;for(;w.ok&&w.status==="running";)await new Promise(C=>window.setTimeout(C,1500)),w=await eu({jobId:w.jobId,cwd:i.cwd,action:i.action});if(!w.ok)throw new Error("Git action status is unavailable");if(w.status==="error")throw new Error(w.error||w.message||"Git action failed");const k={action:i.action,path:y,label:u};return $s(k),window.setTimeout(()=>$s(C=>C?.action===k.action&&C.path===k.path?null:C),1400),w},[]),wt=a.useCallback(async(t,i,u)=>{const y=v;v&&mr.current.delete(v),qt(null),$s(null),Ms({action:t.action,path:u});try{const w=await kp({...t,includeNested:Js(v)}),k=await lo(w,t,i,u);if(!Pe(y))return!1;const C=v?await Ji(v,void 0,{includeNested:Js(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Zs(v)}).catch(()=>k.bundle):k.bundle;return Pe(y)?(C&&Qn(C,{reloadDiff:!0,cacheOnly:!0}),mn(null),!0):!1}catch(w){return $s(null),qt(o("rightSidebar.gitActionFailed",{message:w instanceof Error?w.message:"Unknown error"})),!1}finally{Pe(y)&&Ms(null)}},[Qn,Pe,v,o,lo]),Ld=a.useCallback(async t=>{const i=v;await tu({...t,includeNested:Js(v)}),Pe(i)&&Bt(v??void 0,{refresh:!0,background:!0})},[Pe,Bt,v]),Fm=a.useCallback(async t=>{const i=ve,u=K.current,y=i?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!i||!y||!t.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));Ee(k=>k+1),Oe(null);try{await tu(t)}catch(k){throw Ee(C=>C-1),k}if(u!==K.current||!Pe(v)){Ee(k=>k-1);return}const w=k=>{rr(C=>{if(!C||u!==K.current)return C;const ne=C.hunks??[],oe=k===void 0?ne.filter(Ae=>!(Ae.previewRevert?.cwd===t.cwd&&Ae.previewRevert.patch===t.patch)):[...ne.filter(Ae=>Ae.filePath!==y.filePath),...k];return{...C,hunks:oe}})};w(),Zd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(u!==K.current||!Pe(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const C=t.path.slice(t.cwd.length+1),ne=y.filePath.slice(0,y.filePath.length-C.length);w((k.hunks??[]).map(oe=>({...oe,filePath:`${ne}${oe.filePath}`,oldPath:oe.oldPath?`${ne}${oe.oldPath}`:oe.oldPath,newPath:oe.newPath?`${ne}${oe.newPath}`:oe.newPath})))}).catch(k=>{u===K.current&&Pe(v)&&!wr(k)&&Oe(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>Ee(k=>k-1))},[ve,Pe,v,o]),co=a.useCallback((t,i,u)=>{if(i){if(t==="stage-all"){wt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}mn({kind:"stash-all",repoRoot:i,repoLabel:u})}},[wt,o]),Td=a.useCallback(t=>{Te(t),Pa(""),Aa(""),La(""),it(od(t)),dt||Ft("diff"),t&&Ja(lt.get(t))},[Ja,od,dt,lt,it,Te,Ft]),Id=a.useCallback(t=>{const i=new Set([...Yt.current.keys(),...wn.current,...mr.current]);for(const u of i)u!==t&&(Vt.current.delete(u),Yt.current.get(u)?.abort(),Yt.current.delete(u),jt(`right-sidebar-git-untracked:${u}`),wn.current.delete(u),mr.current.delete(u))},[]),_m=a.useCallback(async t=>{const i=v;if(!i||(await V.getState().setNestedGitScanRoot(i,t),!Pe(i)))return;if(t){await Bt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Id(i),Pa(""),Aa(""),La(""),Qo(y=>y.filter(w=>w===i));const u=Jt;u&&bt(u,i)!==i&&it(null),await Bt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Id,Pe,Bt,v,it,Jt]),Bm=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=zn.trim();!t||t===de?.branch||await wt({action:"switch-branch",cwd:Re,branch:t},o("rightSidebar.switchBranch"))},[de?.branch,Re,tt,wt,zn,o]),Dd=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=$a.trim();if(!t)return;await wt({action:"commit",cwd:Re,message:t},o("rightSidebar.commitChanges"))&&fc("")},[Re,$a,tt,wt,o]),Om=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=gn.trim(),i=bn.trim();await wt({action:"push",cwd:Re,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Re,bn,gn,tt,wt,o]),Um=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=gn.trim(),i=bn.trim();await wt({action:"pull",cwd:Re,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Re,bn,gn,tt,wt,o]);a.useEffect(()=>{if(!dt||!Re||We)return;let t=!1;const i={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const y=await eu({cwd:Re,action:u}).catch(()=>null);if(!y?.ok||y.status!=="running")continue;const w={action:u,cwd:Re},k=i[u]??u;Ms({action:u});try{const C=await lo(y,w,k);if(t||!Pe(v))return;const ne=v?await Ji(v,void 0,{includeNested:Js(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Zs(v)}).catch(()=>C.bundle):C.bundle;ne&&Qn(ne,{reloadDiff:!0,cacheOnly:!0})}catch(C){t||qt(o("rightSidebar.gitActionFailed",{message:C instanceof Error?C.message:"Unknown error"}))}finally{t||Ms(null)}return}})(),()=>{t=!0}},[Re,Qn,dt,Pe,v,We,o,lo]);const zi=Un?.action==="commit",Wi=Un?.action==="switch-branch",Gi=Un?.action==="pull",Ki=Un?.action==="push",uo=dt||Oh,qi=to?o("rightSidebar.changeAuditScopeAll"):br.length===1?br[0].label:`${br.length} repos`,Hm=br.length>0,Fd=Hs.length>0,zm=v?e.jsx(Ku,{open:Xo,onOpenChange:Jo,showScopePicker:!0,selectedAll:to,repos:Qt,selectedRoots:eo,onToggleRepo:Nm,onGenerate:t=>$m(Bi?"regenerate":"generate",t),disabled:!Hm,generateDisabled:!Fd,inserted:De?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Bi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:qi,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Bi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Hi()},secondaryDisabled:!Fd||st,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:st,loading:sc.size>0,statusTitle:sc.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:ud.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:o("rightSidebar.missingBaseReposSkipped",{repositories:ud.map(t=>t.label).join(B==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=lt.get(t.root),u=os(t.root,nr[t.root]||i?.context?.branch),y=[],w=new Set,k=(xe,Ae)=>{!xe||w.has(xe)||(w.add(xe),y.push({value:xe,label:xe,meta:Ae}))};k(nr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const xe of i?.context?.branches??[])k(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const xe of i?.context?.remoteBranches??[])k(xe,o("rightSidebar.remoteBranch"));const C=[],ne=new Set,oe=(xe,Ae)=>{!xe||ne.has(xe)||(ne.add(xe),C.push({value:xe,label:xe,meta:Ae}))};oe(Et[t.root],Et[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),oe(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const xe of i?.context?.remoteBranches??[])oe(xe,"remote");for(const xe of i?.context?.branches??[])oe(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:nr[t.root]||i?.context?.branch||"",options:y,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:xe=>{Ra(Ae=>({...Ae,[t.root]:xe}))}}),e.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:C,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:xe=>{Na(Ae=>({...Ae,[t.root]:xe}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(u?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:u&&(un[t.root]??!0),disabled:!u,onChange:xe=>Zo(Ae=>({...Ae,[t.root]:xe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,_d=ea(kt.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),B),Wm=()=>v?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>nc(t=>{const i=!t;return At(ol,i),i}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(ua,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:qi})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Cs?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]}),Cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",qi]}),zm]}),Ye&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ye}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[sn.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Pm(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),ea(t.createdAt,B)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:ea(t.createdAt,B)})]}),e.jsx("button",{type:"button",onClick:()=>Am(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:e.jsx(Ro,{size:12})})]},t.key)),is.length>0?is.slice(0,Math.max(0,8-sn.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Lm(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),ea(t.latestInjectedAt,B)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:ea(t.latestInjectedAt,B)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{jm(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:e.jsx(Ro,{size:12})})]},t.key)):sn.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Gm=()=>sr&&v&&En?e.jsxs("div",{className:uo?"overflow-visible":"overflow-hidden",children:[Wm(),e.jsxs("button",{type:"button",onClick:()=>{dt||Uh(t=>{const i=!t;return i&&Re&&!En&&!pn&&ji(Re),i})},"aria-expanded":uo,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${dt?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(xr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&e.jsx(ft,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!dt&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${uo?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),uo&&e.jsxs("div",{className:"space-y-0",children:[Ht.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:um})]})}),e.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:Re??"",options:Ht,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!We,onChange:t=>{Td(t||null)}}),tt&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:o("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:zn!==sd?sd:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Bm()},disabled:!ym,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Wi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[e.jsx("span",{className:We?.action==="switch-branch"||Wi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),We?.action==="switch-branch"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Wi&&We?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:zn,options:mm,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!We,onChange:Pa})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:tt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Dd()},disabled:!!We||tt||Cn.staged===0||!$a.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${zi?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:tt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:We?.action==="commit"||zi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),We?.action==="commit"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),zi&&We?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:$a,onChange:t=>fc(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Dd())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!We,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Kr(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":ln,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[ya&&e.jsx(ft,{size:12,className:"animate-spin text-muted-foreground"}),e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${ln?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),ln&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:12,className:"shrink-0"}),e.jsx("input",{value:cn,onChange:t=>dn(t.target.value),placeholder:o("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),cn&&e.jsx("button",{type:"button",onClick:()=>dn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:fm,children:[Dt.length>0?Dt.map(t=>{const[i,...u]=t.split(/\s+/),y=u.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Tm(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:y,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:y,children:y}),re[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${re[i]==="ahead"?"bg-accent/10 text-accent":re[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(re[i]==="ahead"?"rightSidebar.commitAhead":re[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),_n===i&&e.jsx(ft,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):ya?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):Vo?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),ka&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(ft,{size:12,className:"animate-spin"})}),Yo&&!ka&&Dt.length>0&&e.jsx("button",{type:"button",onClick:()=>{Us({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:o("rightSidebar.recentCommitsLoadMore")})]})]}),Ss&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ss}),Vo&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Vo})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Um()},disabled:!vm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Gi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[e.jsx("span",{className:We?.action==="pull"||Gi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),We?.action==="pull"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Gi&&We?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Om()},disabled:!wm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Ki?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[e.jsx("span",{className:We?.action==="push"||Ki?"opacity-0":"",children:o("rightSidebar.pushChanges")}),We?.action==="push"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Ki&&We?.action!=="push"&&e.jsx("span",{className:"absolute",children:"✓"})]})]})]}),e.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${hd.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:hd.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:de?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${dd?"grid-cols-2":"grid-cols-1"}`,children:[dd&&e.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:gn,options:cd,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!We,onChange:Aa}),e.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:bn,options:pm,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!We,onChange:La})]})]})]})]}):null,Km=a.useCallback(t=>{const i=bt(t,v);if(!i)return[];const u=gl(t),y=[];return t.canStage&&y.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{wt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),u)}}),t.canUnstage&&y.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{wt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),u)}}),t.canStash&&y.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{wt({action:"stash-file",cwd:i,paths:[t.path]},o("rightSidebar.stashFile"),u)}}),t.canRestoreWorktree&&y.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>mn({kind:"restore",file:t,phrase:""})}),y},[v,wt,o]),qm=a.useCallback(()=>{if(h){f?.();return}Lr(0),Ir.current?.slideTo(0),Ar(!1),Wt(null)},[f,h]),Bd=a.useCallback(t=>{if(Y(""),_t(t),it(null),Wt(null),R(null),se){h&&f?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1);return}},[se,f,h,it,_t]);a.useEffect(()=>{if(!H||V.getState().pendingTerminalPath!==H)return;V.setState({pendingTerminalPath:null}),(()=>{const i=H,u=i.path;if(!u.startsWith("/"))return;Y(""),Wt(null),Tt(null);const y=!!(v&&(u===v||u.startsWith(`${v}/`)));if(i.kind==="file"){const w=jo(u);Is(u),typeof i.line=="number"&&Number.isSafeInteger(i.line)&&i.line>0&&Tt(i.line),_t(y?null:w),R({path:u,nonce:++z.current});return}it(null),y?(_t(null),R({path:u,nonce:++z.current})):(R(null),_t(u)),se&&(h&&f?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1))})()},[H,Is,se,f,h,v,it,_t]),a.useEffect(()=>{r||(zt(!1),er(!1))},[r]),a.useEffect(()=>{if(!Sr&&!en)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(In.current?.contains(i.target)||jr.current?.contains(i.target))||(zt(!1),er(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[en,Sr]);const Od=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:lm,disabled:!Ya,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:e.jsx(zl,{size:14})}),e.jsx("button",{type:"button",onClick:Xc,disabled:!v||Gn===v,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:e.jsx(lu,{size:14})}),e.jsx("button",{type:"button",onClick:cm,disabled:!le,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:hc?o("rightSidebar.fileWatchUnavailable",{message:hc}):o("rightSidebar.refreshFiles"),children:e.jsx(No,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:le??void 0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[e.jsx("span",{className:"truncate",children:om}),_a==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(cu,{size:11})})]})}),e.jsx("button",{type:"button",onClick:t=>le&&Xt(le,Ut??void 0,t.currentTarget),disabled:!le,...le&&Ut?$i(Ka(le),Ut):{},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-35 active:scale-95 ${Ut&&(De===Ut||je===Ut)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ut&&je===Ut?"rightSidebar.copied":Ut&&De===Ut?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ut&&(De===Ut||je===Ut)?e.jsx(Ao,{size:13}):e.jsx(Lo,{size:13})}),e.jsx(Mg,{rootPath:le,disabled:!le||!Gh||gi,pressed:Fa,saving:gi,onToggle:()=>{if(!le||gi)return;const t=le;$c(!0),bi(null),Kh(t,!Fa).catch(()=>{const i=V.getState();(i.explorerRoot??i.rootPath)===t&&bi(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>$c(!1))}}),e.jsxs("div",{ref:jr,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),er(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${en?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":en,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(Po,{size:14})}),en&&e.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{er(!1),dm()},disabled:!Li,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Bs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Bs?e.jsx(el,{size:14}):e.jsx(mo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(Bs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{er(!1),zh()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${fi?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[fi?e.jsx(rg,{size:14}):e.jsx(Rl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(fi?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!le,onClick:()=>{le&&(er(!1),Wh(le,_a==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[_a==="modified"?e.jsx(Bp,{size:14}):e.jsx(cu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(_a==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),Pc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:Pc}),v&&(Xa.length>0||im)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Xc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${le===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(lu,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:at})]}),Xa.map(t=>{const i=t.path,u=t.kind==="file",y=u?ot===i:le===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${y?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?Is(i):_t(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(Nl,{size:10,className:"shrink-0"}):e.jsx(mo,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:yt(i)})]}),e.jsx("button",{type:"button",onClick:()=>xn(i),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.unpinFolder",{name:yt(i)}),title:o("rightSidebar.unpinFolder",{name:yt(i)}),children:e.jsx(Lt,{size:9})})]},i)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),Vi=a.useMemo(()=>{if(Hn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((oi-Hn)/1e3)),u=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[y,w]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return u.format(y,w)},[oi,Hn]),fo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Ud=v&&!es?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{_m(!hi)},"aria-checked":hi,title:o("rightSidebar.multiRepoScanTitle"),className:fo,children:[e.jsx(xr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),hi&&e.jsx(Ao,{size:14,className:"shrink-0 text-primary"})]}):null,Hd=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Vi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Vi}),children:Vi}):null,e.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:e.jsx(No,{size:13,className:hr?"animate-spin":""})})]}):null,Vm=_c?o("rightSidebar.changeAuditScopeAll"):kn.length===1?kn[0].relativeRoot==="."?at:kn[0].relativeRoot||kn[0].name:`${kn.length} repos`,Ym=t=>v?e.jsxs("div",{role:"none",children:[e.jsx(Ku,{menuItem:!0,open:vs,onOpenChange:i=>{nn(i),i&&t()},showScopePicker:Mn,selectedAll:_c,repos:qh,selectedRoots:or,onToggleRepo:Rm,onGenerate:async i=>{const u=await km("generate",i);return u!==!1&&t(),u},disabled:!v,inserted:De===Yc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Vm,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Hr,error:!!$r,statusTitle:$r??(Hr?o("rightSidebar.changeAuditLoading"):kt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:kt.length})}${_d?` · ${o("rightSidebar.changeAuditLoadedAt",{time:_d})}`:""}`:void 0)}),kt.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),Sm()},disabled:Hr||kt.length===0,className:fo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(Ro,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ls=ir??($?.available&&v&&Fe.size>0&&fe.length<=1?{root:v,label:at}:null),zd=t=>e.jsxs(e.Fragment,{children:[ls&&e.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),co("stage-all",ls.root,ls.label)},disabled:!!We,className:fo,children:[e.jsx(Rp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),co("stash-all",ls.root,ls.label)},disabled:!!We,className:fo,children:[e.jsx(Vp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ls&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Ym(t),Ud&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Ud]}),ho=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[$?.available&&$.branch&&e.jsxs("span",{className:"inline-flex min-w-0 max-w-[8rem] items-center gap-0.5 truncate rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",title:$.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:$.branch})]}),pt.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[pt.modified,"M"]}),pt.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",pt.added]}),pt.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",pt.deleted]}),pt.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.renamed,"R"]}),pt.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.copied,"C"]}),pt.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.untracked,"U"]}),pt.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[pt.conflicted,"!"]}),pt.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.other,"?"]}),pt.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:pt.staged})})]});return e.jsxs(Op,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m,children:[$i.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${em?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:v??void 0,children:at}),(!se||ni)&&$?.available&&$.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:$.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:$.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!Z;P(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):Y("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Z?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:e.jsx(ms,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":O,onClick:()=>{ae(t=>!t),et(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${O?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[e.jsx(Up,{size:14}),!O&&Nt.trim()&&e.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),e.jsx("input",{ref:bc,type:"file",multiple:!0,className:"hidden",onChange:t=>{const i=t.target.files;!i||i.length===0||(Ds(Array.from(i)),t.target.value="")}}),e.jsx("input",{ref:xc,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&nm(i,t.currentTarget.closest("[data-sidebar]")??void 0)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${m?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:m?e.jsx(el,{size:14}):e.jsx(mo,{size:14})}),e.jsxs("div",{ref:In,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{er(!1),zt(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Sr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Sr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(Po,{size:15})}),Sr&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[["architecture","computer"].map(t=>e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":ar[t],onClick:()=>rm(t,!ar[t]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t==="architecture"?e.jsx(du,{size:14,className:"text-muted-foreground"}):e.jsx(ru,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o(t==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${ar[t]?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${ar[t]?"left-3.5":"left-0.5"}`})})]},t)),e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Vr,onClick:()=>Uc(!Vr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(nu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Vr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Vr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),bc.current?.click()},disabled:za,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[za?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Hp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),xc.current?.click()},disabled:za,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[za?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(lg,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${m?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[m?e.jsx(el,{size:14}):e.jsx(mo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),m&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":o("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([t,i])=>{const u=G===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(t),zt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:i},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:14})})]}),Z&&e.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-3 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:t=>Y(t.target.value),placeholder:o(ie==="content"?"rightSidebar.searchPlaceholderContent":"rightSidebar.filterChanges"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",enterKeyHint:"search",spellCheck:!1}),e.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${se?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Ad("name"),"aria-pressed":ie==="name",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${ie==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Ad("content"),"aria-pressed":ie==="content",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${ie==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>Y(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(zp,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:Se,onChange:t=>ke(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Se!=="."&&e.jsx("button",{type:"button",onClick:()=>ke("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:e.jsx(Lt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>ue(t=>!t),"aria-expanded":ge,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${ge||As.length>0||_e||W||we?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[e.jsx(Wp,{size:13}),As.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[8px] font-bold leading-4 text-primary-foreground",children:As.length})]})]}),ge&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:Me,onChange:t=>Q(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Me&&e.jsx("button",{type:"button",onClick:()=>Q(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:e.jsx(Lt,{size:11})})]}),ie==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[_e,()=>Ue(t=>!t),eg,o("rightSidebar.matchCase")],[W,()=>ye(t=>!t),mg,o("rightSidebar.matchWholeWord")],[we,()=>He(t=>!t),dg,o("rightSidebar.useRegex")]].map(([t,i,u,y])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),y]},y))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(es?1:3)+Number(ar.architecture)+Number(ar.computer)+Number(Vr)}, minmax(0, 1fr))`},children:[!es&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>ns("git",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>ns("diff",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(wf,{size:12}),o("rightSidebar.tabChanges"),Fe.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Fe.size}):null]})]}),e.jsxs("button",{type:"button",onClick:t=>ns("files",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(wl,{size:12}),o("rightSidebar.tabFiles")]}),ar.architecture&&e.jsxs("button",{type:"button",onClick:t=>ns("architecture",t),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Sn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(du,{size:12}),o("architecture.tab")]}),ar.computer&&e.jsxs("button",{type:"button",onClick:t=>ns("computer",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${rs?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(ru,{size:12}),o("rightSidebar.tabComputer")]}),Vr&&e.jsxs("button",{type:"button",onClick:t=>ns("android",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(nu,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),dc&&e.jsx("div",{className:"pointer-events-none absolute right-3 top-10 z-20 max-w-[72%] rounded-lg bg-destructive/95 px-3 py-2 text-[11px] font-medium text-destructive-foreground shadow-md animate-fade-in",children:dc})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(ds,{active:dt,mounted:sr,fallback:e.jsx(hl,{slow:!1}),children:()=>Xe?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(wu,{items:Cm,diffViewType:li,inlineMode:Kt,viewControls:m?zs():void 0,renderPathReference:(t,i)=>ro(Pn(t,Xe.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Lh,onSelect:Sa,emptyText:o("rightSidebar.noChanges"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Xe.headRef??""}${Xe.commits?.[0]?` · ${Xe.commits[0]}`:""}`,onClose:()=>{mt(null),Sa(null)},closeLabel:o("common.back"),wrap:It,onToggleWrap:io,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:so})}):Pr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(wu,{items:_i,diffViewType:li,inlineMode:Kt,viewControls:m?zs():void 0,renderPathReference:(t,i)=>{const u=ve?.comparisonRepos,y=u&&u.length>1?[...u].sort((k,C)=>C.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,w=y?t===y.label?y.repoRoot:Pn(t.slice(y.label.length+1),y.repoRoot):Pn(t,Ks?.repoRoot||v);return ro(w,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:ei,onSelect:hn,emptyText:o(ve?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(ve?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Ks?`${Ks.repoLabel} · ${Ks.branchName??"HEAD"} → ${Ks.baseRef}`:void 0,onClose:()=>{++K.current,Be(!1),cr(!1),rr(null)},closeLabel:o("common.back"),wrap:It,onToggleWrap:io,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:so,localOptions:ve?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??ve.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??os(t.repoRoot,t.head)),onChange:i=>{Hi({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:ve?.includeUncommitted?Fm:void 0,error:Ye,actionsBusy:be>0,onRefresh:()=>{Hi({refresh:!0})},refreshing:st,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Em,onWalkthroughNavigate:Mm,initialDetailScrollTop:ve&&Qe?ks[Qe]:void 0,onDetailScrollPositionChange:Im,externalSwiperRef:se?Dc:void 0,onMobileSlideChange:se?ri:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:sr&&v&&En?e.jsx("div",{className:"px-3",children:Gm()}):hr?e.jsx(hl,{slow:Nc}):vn?e.jsx(So,{message:vn,onRetry:()=>{Zn()}}):Ju($)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):$?.available===!1?e.jsx(So,{message:$.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Zn()}}):v?e.jsx(hl,{slow:Nc}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(ds,{active:Dr,mounted:Ih||Dr,children:()=>se?e.jsxs(df,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Ir.current=t,t.slideTo(ti,0)},onSlideChange:t=>{if(Lr(t.activeIndex),Ts.current===t.activeIndex){Ts.current=null;return}t.activeIndex===0&&(Ar(!1),Wt(null),f?.())},children:[e.jsx(yl,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Vn,onScroll:Hc,onDragOver:Wa,onDragEnter:Wa,onDragLeave:Wc,onDrop:Gc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[mc&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!I.trim()&&Od,e.jsx(uu,{rootPath:le??"",onFileSelect:Is,onPathReference:Xt,getReferenceText:Ka,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onDirectoryRoot:Jc,onSearchFromDirectory:Qc,onDirectoryPinToggle:Zc,onFilePinToggle:ed,pinnedPaths:Rn,selectedFilePath:ot,query:Ke,searchRootPath:Ac,searchOptions:Lc,searchMode:ie,onContentMatchSelect:Ci,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:U,canOpenInFileBrowser:pc,onOpenInFileBrowser:zc})]})}),e.jsx(yl,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(zo,{filePath:Th||ti===1?ot:null,active:r&&Dr&&ti===1,onInsertReference:Xt,onInsertText:Fr,onInsertFeature:Va,onReviewReference:Va,onReferenceCopied:gr,onClose:qm,onDirectoryLinkOpen:Bd,isMobile:!0,lineRange:Or,onLineRangeChange:Wt,insertedReferenceKey:De,copiedReferenceKey:je,scrollToLine:Ve,onScrollToLineHandled:()=>Tt(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:M,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:_,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:S})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Vn,onScroll:Hc,onDragOver:Wa,onDragEnter:Wa,onDragLeave:Wc,onDrop:Gc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:ci},children:[mc&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!I.trim()&&Od,e.jsx(uu,{rootPath:le??"",onFileSelect:Is,onPathReference:Xt,getReferenceText:Ka,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onDirectoryRoot:Jc,onSearchFromDirectory:Qc,onDirectoryPinToggle:Zc,onFilePinToggle:ed,pinnedPaths:Rn,selectedFilePath:ot,query:Ke,searchRootPath:Ac,searchOptions:Lc,searchMode:ie,onContentMatchSelect:Ci,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:U,canOpenInFileBrowser:pc,onOpenInFileBrowser:zc})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:Vh,onPointerMove:Yh,onPointerUp:Oc,onPointerCancel:Oc,onDoubleClick:()=>{di(Pl),At(na,Pl)},children:e.jsx("span",{className:"absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-border/20 transition group-hover:bg-primary/45"})}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:e.jsx(zo,{filePath:ot,active:r&&Dr,onInsertReference:Xt,onInsertText:Fr,onInsertFeature:Va,onReviewReference:Va,onReferenceCopied:gr,onDirectoryLinkOpen:Bd,isMobile:!1,lineRange:Or,onLineRangeChange:Wt,insertedReferenceKey:De,copiedReferenceKey:je,scrollToLine:Ve,onScrollToLineHandled:()=>Tt(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:M,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:_,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:S})})]})}),e.jsx(ds,{active:$t,mounted:Fh||$t,children:()=>Ri?e.jsx(Gp,{}):se?e.jsx(kl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:Si,onMobileSlideChange:ri,groups:Zt.length>0?vd():[],mode:Er,onModeChange:oo,selectedKey:ot,scrollToKey:jd,scrollToKeyNonce:Ta.nonce,compact:!1,collapsedDirectoryKeys:ba,onToggleDirectory:Cd,onSelectFile:t=>{const i=$n.get(t.key);i&&ao(vr(i))},renderLeading:wd,renderTrailing:t=>{const i=$n.get(t.key);return i?bd(i):null},renderDirectoryTrailing:xd,renderSubtitle:t=>{const i=$n.get(t.key);return i?gd(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[ho&&e.jsx("div",{className:"mb-2",children:ho}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Zt.length,"/",Fe.size]})]}),e.jsxs(bu,{actions:zd,children:[md(),t,m&&zs(),Hd]},v),ir&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&Mn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Za?(t=>Nd(t)):void 0,emptyContent:Ri?null:vn&&Fe.size===0?e.jsx(So,{message:vn,onRetry:()=>{Zn()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Zt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:t})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[e.jsx(ca,{size:14}),o("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[m&&zs(),e.jsxs("button",{type:"button",onClick:io,"aria-pressed":It,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${It?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(It?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:e.jsx(No,{size:14,className:hr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:yd,activePane:$t,wrap:It,diffViewType:li,inlineMode:Kt,diffOptions:Pd,reloadKey:wa,renderStreamBadge:t=>e.jsx(oa,{status:t}),onHunkGitAction:Ld,onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:so,onDetailScroll:no}):e.jsx(kl,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:o("rightSidebar.backToChangeList"),groups:Zt.length>0?vd():[],mode:Er,onModeChange:oo,selectedKey:ot,scrollToKey:jd,scrollToKeyNonce:Ta.nonce,compact:!0,collapsedDirectoryKeys:ba,onToggleDirectory:Cd,onSelectFile:t=>{const i=$n.get(t.key);i&&ao(vr(i))},renderLeading:wd,renderTrailing:t=>{const i=$n.get(t.key);return i?bd(i):null},renderDirectoryTrailing:xd,renderSubtitle:t=>{const i=$n.get(t.key);return i?gd(i):null},aiContent:Za?(t=>Nd(t)):void 0,emptyContent:Ri?null:vn&&Fe.size===0?e.jsx(So,{message:vn,onRetry:()=>{Zn()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Zt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[ho&&e.jsx("div",{className:"mb-2",children:ho}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Zt.length,"/",Fe.size]})})]}),e.jsxs(bu,{actions:zd,children:[md(),t,zs(),e.jsxs("button",{type:"button",onClick:io,"aria-pressed":It,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${It?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(It?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Hd]},v),ir&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&Mn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:yd,activePane:$t,wrap:It,diffViewType:Gt,inlineMode:Kt,diffOptions:Pd,reloadKey:wa,renderStreamBadge:t=>e.jsx(oa,{status:t}),onHunkGitAction:Ld,onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:so,onDetailScroll:no})}),e.jsx(ds,{active:Sn,mounted:ar.architecture&&(Qh||r&&Sn),children:e.jsx(a.Suspense,{fallback:e.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:e.jsx(ix,{rootPath:v,active:r&&Sn,onInsertPrompt:(t,i)=>Fr(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(k0,{rootPath:v,file:t,active:r&&Sn,isMobile:se,onInsertReference:Xt,onInsertText:Fr,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(Ft("files"),_t(null),Ci(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(ds,{active:r&&rs,mounted:ar.computer&&(Xh||r&&rs),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(lx,{active:r&&rs})})}),e.jsx(ds,{active:ts,mounted:ai&&Vr,children:_h?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:o("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{Xi.getState().setDock(Qi,null),ra({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Kp,{sessionId:n??null,onCloseTab:()=>Uc(!1),onInsertPrompt:async(t,i)=>{if(!await _r("android-deps",t,void 0,i))throw new Error(o("rightSidebar.uploadReferenceRejected"))},onInsertFile:am,onRecordingComplete:sm})})]}),r&&Rt&&e.jsx("div",{role:"alert",className:"shrink-0 border-t border-border/15 px-3 py-2 text-xs text-destructive",children:o("rightSidebar.referenceInsertFailed")}),r&&Ot.task&&e.jsx(nb,{task:Ot.task,onCancel:Ot.cancel,onRetry:()=>{Ot.retry()},onDismiss:Ot.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Ot.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Ot.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:Ot.task.files.length})}}),r&&O&&e.jsx(Qg,{value:Nt,collapsed:Ce,autoCollapseAfterSend:xt,focusRequest:Tn,insertError:Dn?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{tn(!1),Ct(t)},onCollapsedChange:et,onAutoCollapseAfterSendChange:kr,onDisable:()=>ae(!1),onClear:()=>Ct(""),onInsert:t=>Vc(!1,t),onInsertAndSend:t=>Vc(!0,t),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>o("rightSidebar.contextDraftCharacterCount",{count:t})}}),xm(),vt&&typeof document<"u"&&yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>mn(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:vt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:vt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:of(vt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),vt.kind==="restore"&&e.jsx("input",{value:vt.phrase,onChange:t=>mn({...vt,phrase:t.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>mn(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),e.jsx("button",{type:"button",disabled:!!We||vt.kind==="restore"&&vt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(vt.kind==="restore"){const t=bt(vt.file,v);if(!t)return;wt({action:"restore-worktree-file",cwd:t,paths:[vt.file.path],confirm:{acknowledged:!0,phrase:vt.phrase}},o("rightSidebar.restoreFile"),gl(vt.file))}else{const t=vt.repoRoot??v;if(!t)return;wt({action:"stash-all",cwd:t},o("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${vt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(We?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const I0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:zo,MarkdownImageLightbox:yh,MarkdownPreview:kh,RightSidebar:S0,__testParseMarkdownListBlock:Ox,buildMarkdownPreviewBlocks:Xx,buildMarkdownPreviewRenderResult:Ql,collectKnownGitRepoRoots:zf,computeMarkdownImageDisplayBox:sh,getMarkdownHeadingOutline:wh,getMarkdownHeadingPathAtLine:vh,getNextMarkdownPreviewLineRange:r0,isSvgImageSrc:ga,mountRightSidebarRepoPickerOverlay:$f,replaceGitRepositorySnapshot:Eh,resolveMarkdownLocalLinkTarget:Go,resolveRightSidebarDiffViewType:Uf,shouldCloseMarkdownImageLightboxDrag:gh,showsGitRepoGroupHeader:Al},Symbol.toStringTag,{value:"Module"}));export{Rl as E,I0 as R,fg as S,rg as a,Xx as b,$g as c,Cg as i,Ng as l,T0 as m};
|