termdock 1.4.178 → 1.4.179
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-DXq9kwY5.js +150 -0
- package/dist/client/assets/App-DXq9kwY5.js.br +0 -0
- package/dist/client/assets/App-DXq9kwY5.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-BNWqAnqc.js → ChangeWalkthroughPanel-DWUBYx6Q.js} +2 -2
- package/dist/client/assets/ChangeWalkthroughPanel-DWUBYx6Q.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DWUBYx6Q.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-IlTGwr-I.js → DagPlayground-DyczrcHM.js} +1 -1
- package/dist/client/assets/DagPlayground-DyczrcHM.js.br +0 -0
- package/dist/client/assets/DagPlayground-DyczrcHM.js.gz +0 -0
- package/dist/client/assets/{DiffLab-CwhNpJvo.js → DiffLab-D5wb-H7y.js} +1 -1
- package/dist/client/assets/DiffLab-D5wb-H7y.js.br +0 -0
- package/dist/client/assets/DiffLab-D5wb-H7y.js.gz +0 -0
- package/dist/client/assets/{DiffReview-DyhINv0F.js → DiffReview-CVIz-B5T.js} +1 -1
- package/dist/client/assets/DiffReview-CVIz-B5T.js.br +0 -0
- package/dist/client/assets/DiffReview-CVIz-B5T.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-D9Kt5VwB.js → DiffReviewLab-99hTNRaj.js} +1 -1
- package/dist/client/assets/DiffReviewLab-99hTNRaj.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-99hTNRaj.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-3zz2PI-8.js → DiffViewer-BPor2_7o.js} +1 -1
- package/dist/client/assets/DiffViewer-BPor2_7o.js.br +0 -0
- package/dist/client/assets/DiffViewer-BPor2_7o.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-CN8xsiGC.js → ModelPreview-DpImj4vY.js} +1 -1
- package/dist/client/assets/ModelPreview-DpImj4vY.js.br +0 -0
- package/dist/client/assets/ModelPreview-DpImj4vY.js.gz +0 -0
- package/dist/client/assets/RightSidebar-BW8SSsoA.js +79 -0
- package/dist/client/assets/RightSidebar-BW8SSsoA.js.br +0 -0
- package/dist/client/assets/RightSidebar-BW8SSsoA.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-DkdoJ2ZH.js → abnfDiagram-VCTEODGH-CNWmFVMh.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-CNWmFVMh.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CNWmFVMh.js.gz +0 -0
- package/dist/client/assets/app-Pl7tV8Be.js +34 -0
- package/dist/client/assets/app-Pl7tV8Be.js.br +0 -0
- package/dist/client/assets/app-Pl7tV8Be.js.gz +0 -0
- package/dist/client/assets/{arc-ctzz5PcK.js → arc-Z8mcHjh7.js} +1 -1
- package/dist/client/assets/arc-Z8mcHjh7.js.br +0 -0
- package/dist/client/assets/arc-Z8mcHjh7.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-DNLcYfGQ.js → architectureDiagram-5GKGNRK7-DuxbAeFP.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DuxbAeFP.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DuxbAeFP.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-Coye1ou5.js → blockDiagram-I7D4REHJ-SxAFw0An.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-SxAFw0An.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-SxAFw0An.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-DTa8jyPp.js → c4Diagram-7LVT6UL2-CcRdiWo7.js} +1 -1
- package/dist/client/assets/{c4Diagram-7LVT6UL2-DTa8jyPp.js.br → c4Diagram-7LVT6UL2-CcRdiWo7.js.br} +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-CcRdiWo7.js.gz +0 -0
- package/dist/client/assets/channel-nXn0ntBk.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-BpDyjNfs.js → chunk-2Q5K7J3B-DJ_qzvZZ.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DgwdqXKl.js → chunk-5VM5RSS4-l3H0C2ci.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-DWf2gZ96.js → chunk-F27PBJKO-B7xASv8n.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-B7xASv8n.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-B7xASv8n.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-l42o_E2c.js → chunk-IMKFNOWR-Wg5gR7sZ.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-Wg5gR7sZ.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Wg5gR7sZ.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-8CkEf05l.js → chunk-JWPE2WC7-BlXUS79m.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-BKKOfbdg.js → chunk-POPQ4Y6H-CU38G8hb.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-RORrf2aM.js → chunk-SVP7TREG-D-yZlXqX.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-D-yZlXqX.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-D-yZlXqX.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-hPqafEtC.js → chunk-TICWLB2K-DrOYmcBB.js} +1 -1
- package/dist/client/assets/{chunk-TICWLB2K-hPqafEtC.js.br → chunk-TICWLB2K-DrOYmcBB.js.br} +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DrOYmcBB.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-CrvjJwms.js → chunk-XXDRQBXY-BbsHtVFa.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-DxqN38m7.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DxqN38m7.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CwRSiQLa.js → cose-bilkent-JH36ORCC-_wKUNL8T.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-_wKUNL8T.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-_wKUNL8T.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-CXnppZ8I.js → cynefin-OW5HDTMX-CPr--Wnc.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-CPr--Wnc.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CPr--Wnc.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-BSDrHSIA.js → cynefinDiagram-5FMLGOSQ-5ygpPOWT.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-5ygpPOWT.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-5ygpPOWT.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-d-5j4vkq.js → dagre-GXQ25YYZ-Cvx65nHO.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-Cvx65nHO.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-Cvx65nHO.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-DizMBpGW.js → diagram-S7CK7UJ4-Dw5cp_BA.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-Dw5cp_BA.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Dw5cp_BA.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-CNQK26rH.js → diagram-UQ7AKVKN-D8BZ5Tp3.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-D8BZ5Tp3.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-D8BZ5Tp3.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-Dua-2_46.js → diagram-VSXAHHWV-BxJD7ZWH.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-BxJD7ZWH.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-BxJD7ZWH.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-CIq-4729.js → diagram-VX7I27RA-CvzlU0bI.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-CvzlU0bI.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CvzlU0bI.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-BukQ0u-x.js → diagram-Z3DM3KII-Be4HdFlL.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-Be4HdFlL.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-Be4HdFlL.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-D2zRkRBI.js → ebnfDiagram-PWID7BFC-C_wrrPjF.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C_wrrPjF.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C_wrrPjF.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-DbX6A3ls.js → erDiagram-RLTQ6QDP-IHyLgV6M.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-IHyLgV6M.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-IHyLgV6M.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-YECDWA2G.js → flowDiagram-HODETNUW-CpfW88Uc.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-CpfW88Uc.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-CpfW88Uc.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-D3EJdUov.js → ganttDiagram-EL5Y4UJY-CsbQ6KLb.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CsbQ6KLb.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CsbQ6KLb.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-D3IZpZS7.js → gestureArbiter-CJQ8K48V.js} +1 -1
- package/dist/client/assets/gestureArbiter-CJQ8K48V.js.br +0 -0
- package/dist/client/assets/gestureArbiter-CJQ8K48V.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-tr_HKoQK.js → gitGraphDiagram-WWUBYQGX-DJZqSGtH.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DJZqSGtH.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DJZqSGtH.js.gz +0 -0
- package/dist/client/assets/{index-C4Ny0NDQ.css → index-PWu1VEN_.css} +1 -1
- package/dist/client/assets/index-PWu1VEN_.css.br +0 -0
- package/dist/client/assets/index-PWu1VEN_.css.gz +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-xBV63YYg.js → infoDiagram-27XIBGKW-D6sSgR2Y.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BrYSZu1R.js → ishikawaDiagram-5VMMS53U-BJJSUXep.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BJJSUXep.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BJJSUXep.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-C9Ft--aA.js → journeyDiagram-3NMN7TZE-ou1XS2DP.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-ou1XS2DP.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-ou1XS2DP.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-FCxqSu11.js → kanban-definition-UXKFOSKX-BFQGYQzd.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-BFQGYQzd.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BFQGYQzd.js.gz +0 -0
- package/dist/client/assets/{layout-BqjIyPqO.js → layout-zUU3xcam.js} +1 -1
- package/dist/client/assets/layout-zUU3xcam.js.br +0 -0
- package/dist/client/assets/layout-zUU3xcam.js.gz +0 -0
- package/dist/client/assets/{linear-CEAGQX5N.js → linear-CYwYQI2I.js} +1 -1
- package/dist/client/assets/linear-CYwYQI2I.js.br +0 -0
- package/dist/client/assets/linear-CYwYQI2I.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-DvAY78t_.js → mermaid.core-91Llsw5j.js} +5 -5
- package/dist/client/assets/mermaid.core-91Llsw5j.js.br +0 -0
- package/dist/client/assets/mermaid.core-91Llsw5j.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-D7_qIQ9H.js → mindmap-definition-YA3MSWOX-RWG074lb.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-RWG074lb.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-RWG074lb.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-Dksfdvk3.js → passwordBootstrap-DRknuNUN.js} +1 -1
- package/dist/client/assets/passwordBootstrap-DRknuNUN.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-DRknuNUN.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-DeTIBKGC.js → pegDiagram-XKGWAZYB-Dyh2rzGS.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-Dyh2rzGS.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-Dyh2rzGS.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-z5IcoVwx.js → pieDiagram-E7YTZNPT-CL3UcUfh.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-CL3UcUfh.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CL3UcUfh.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-B-zCZvES.js → quadrantDiagram-AXDQQJYC-DOkejMel.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DOkejMel.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DOkejMel.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-DbpeB7P2.js → railroadDiagram-O6MQD6OU-BC780Uh3.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-BC780Uh3.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-BC780Uh3.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-p56g9xFb.js → referenceLongPress-Dlc0425_.js} +1 -1
- package/dist/client/assets/referenceLongPress-Dlc0425_.js.br +0 -0
- package/dist/client/assets/referenceLongPress-Dlc0425_.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-UhJYMJ_U.js → requirementDiagram-BXWQKSXE-CwCGr0qR.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CwCGr0qR.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CwCGr0qR.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-xKsuFR17.js → sankeyDiagram-P5KCCOFB-CYDYBwJQ.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CYDYBwJQ.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CYDYBwJQ.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DrjBl65C.js → sequenceDiagram-WJ2MYXX4-DhHsZi3K.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DhHsZi3K.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DhHsZi3K.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-BIlGJ9tm.js → sizeCapture-INFHLROL-4oUXWvYA.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-4oUXWvYA.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-4oUXWvYA.js.gz +0 -0
- package/dist/client/assets/{sparkles-B-uEi0Pa.js → sparkles-gqiuBkfP.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-C3k9XvA6.js → stateDiagram-D77RDMKH-7hUELZGo.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-7hUELZGo.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-7hUELZGo.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-MO84Jqt6.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-BN-x1rXp.js → swimlanes-42K2YHIH-E1qoordP.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-E1qoordP.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-E1qoordP.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DnSXMnZQ.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-Dcedjtic.js → timeline-definition-24CTP7MA-CTYyCnUW.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-CTYyCnUW.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CTYyCnUW.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-BSNAwyll.js → triangle-alert-DrBuMUPw.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-DAIk-5Rt.js → vennDiagram-4TSXK5OY-DVWbhWsS.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-DVWbhWsS.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DVWbhWsS.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-3iXOTpAg.js → wardleyDiagram-VM6X3IG4-BFAwOxhc.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFAwOxhc.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFAwOxhc.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-OD1a_9Qg.js → xychartDiagram-S5SC5T6Z-DYXOiBiX.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-DYXOiBiX.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-DYXOiBiX.js.gz +0 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw-notifications.js +5 -45
- package/dist/client/sw-notifications.js.br +0 -0
- package/dist/client/sw-notifications.js.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/agent/collaborationCli.js +10 -3
- package/dist/server/agent/collaborationDeliveryWorker.js +154 -0
- package/dist/server/agent/collaborationRoutes.js +15 -4
- package/dist/server/agent/collaborationRouting.js +94 -0
- package/dist/server/agent/collaborationStore.js +6 -1
- package/dist/server/agent/collaborationTmuxDelivery.js +10 -0
- package/dist/server/agent/sessionBindingRecovery.js +59 -0
- package/dist/server/entry.js +30 -13
- package/dist/server/federation/desktopTargets.js +64 -0
- package/dist/server/federation/directRoutes.js +27 -19
- package/dist/server/federation/routeAccess.js +14 -7
- package/dist/server/federation/trustedCa.js +55 -0
- package/dist/server/routes/terminal.js +242 -67
- package/package.json +1 -1
- package/runtime-manifest.json +3 -3
- package/dist/client/assets/App-CAEtVL8Z.js +0 -150
- package/dist/client/assets/App-CAEtVL8Z.js.br +0 -0
- package/dist/client/assets/App-CAEtVL8Z.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-BNWqAnqc.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-BNWqAnqc.js.gz +0 -0
- package/dist/client/assets/DagPlayground-IlTGwr-I.js.br +0 -0
- package/dist/client/assets/DagPlayground-IlTGwr-I.js.gz +0 -0
- package/dist/client/assets/DiffLab-CwhNpJvo.js.br +0 -0
- package/dist/client/assets/DiffLab-CwhNpJvo.js.gz +0 -0
- package/dist/client/assets/DiffReview-DyhINv0F.js.br +0 -0
- package/dist/client/assets/DiffReview-DyhINv0F.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-D9Kt5VwB.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-D9Kt5VwB.js.gz +0 -0
- package/dist/client/assets/DiffViewer-3zz2PI-8.js.br +0 -0
- package/dist/client/assets/DiffViewer-3zz2PI-8.js.gz +0 -0
- package/dist/client/assets/ModelPreview-CN8xsiGC.js.br +0 -0
- package/dist/client/assets/ModelPreview-CN8xsiGC.js.gz +0 -0
- package/dist/client/assets/RightSidebar-DQk1cwKH.js +0 -79
- package/dist/client/assets/RightSidebar-DQk1cwKH.js.br +0 -0
- package/dist/client/assets/RightSidebar-DQk1cwKH.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DkdoJ2ZH.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DkdoJ2ZH.js.gz +0 -0
- package/dist/client/assets/app-B42CoF1r.js +0 -34
- package/dist/client/assets/app-B42CoF1r.js.br +0 -0
- package/dist/client/assets/app-B42CoF1r.js.gz +0 -0
- package/dist/client/assets/arc-ctzz5PcK.js.br +0 -0
- package/dist/client/assets/arc-ctzz5PcK.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DNLcYfGQ.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DNLcYfGQ.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-Coye1ou5.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-Coye1ou5.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DTa8jyPp.js.gz +0 -0
- package/dist/client/assets/channel-CzvSDv06.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-DWf2gZ96.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-DWf2gZ96.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-l42o_E2c.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-l42o_E2c.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-RORrf2aM.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-RORrf2aM.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-hPqafEtC.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-CDknJfE0.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CDknJfE0.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-CwRSiQLa.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-CwRSiQLa.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CXnppZ8I.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CXnppZ8I.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BSDrHSIA.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BSDrHSIA.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-d-5j4vkq.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-d-5j4vkq.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-DizMBpGW.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-DizMBpGW.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-CNQK26rH.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-CNQK26rH.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Dua-2_46.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Dua-2_46.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CIq-4729.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CIq-4729.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BukQ0u-x.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BukQ0u-x.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-D2zRkRBI.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-D2zRkRBI.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DbX6A3ls.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DbX6A3ls.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-YECDWA2G.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-YECDWA2G.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-D3EJdUov.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-D3EJdUov.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-D3IZpZS7.js.br +0 -0
- package/dist/client/assets/gestureArbiter-D3IZpZS7.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tr_HKoQK.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tr_HKoQK.js.gz +0 -0
- package/dist/client/assets/index-C4Ny0NDQ.css.br +0 -0
- package/dist/client/assets/index-C4Ny0NDQ.css.gz +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BrYSZu1R.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BrYSZu1R.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-C9Ft--aA.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-C9Ft--aA.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-FCxqSu11.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-FCxqSu11.js.gz +0 -0
- package/dist/client/assets/layout-BqjIyPqO.js.br +0 -0
- package/dist/client/assets/layout-BqjIyPqO.js.gz +0 -0
- package/dist/client/assets/linear-CEAGQX5N.js.br +0 -0
- package/dist/client/assets/linear-CEAGQX5N.js.gz +0 -0
- package/dist/client/assets/mermaid.core-DvAY78t_.js.br +0 -0
- package/dist/client/assets/mermaid.core-DvAY78t_.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D7_qIQ9H.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D7_qIQ9H.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-Dksfdvk3.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-Dksfdvk3.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DeTIBKGC.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DeTIBKGC.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-z5IcoVwx.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-z5IcoVwx.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-B-zCZvES.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-B-zCZvES.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DbpeB7P2.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DbpeB7P2.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-p56g9xFb.js.br +0 -0
- package/dist/client/assets/referenceLongPress-p56g9xFb.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-UhJYMJ_U.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-UhJYMJ_U.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-xKsuFR17.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-xKsuFR17.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DrjBl65C.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DrjBl65C.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-BIlGJ9tm.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-BIlGJ9tm.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-C3k9XvA6.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-C3k9XvA6.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-B7GnCu2o.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-BN-x1rXp.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-BN-x1rXp.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BH_gm34Y.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-Dcedjtic.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-Dcedjtic.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DAIk-5Rt.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DAIk-5Rt.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-3iXOTpAg.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-3iXOTpAg.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-OD1a_9Qg.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-OD1a_9Qg.js.gz +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-CN8xsiGC.js","assets/app-B42CoF1r.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-C4Ny0NDQ.css","assets/App-CAEtVL8Z.js","assets/gestureArbiter-D3IZpZS7.js","assets/gestureArbiter-C2J0D0kV.css","assets/referenceLongPress-p56g9xFb.js","assets/triangle-alert-BSNAwyll.js","assets/DiffReview-DyhINv0F.js","assets/sparkles-B-uEi0Pa.js","assets/DiffViewer-3zz2PI-8.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-BNWqAnqc.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-DvAY78t_.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{I as pt,aD as e,bF as gt,a as ks,aj as Gf,C as co,c as Ss,X as Dt,bD as Uf,au as Kf,r as us,$ as qf,ay as Vf,aA as xd,aB as Yf,aC as Xf,az as fs,a9 as Zf,E as Qf,M as Jf,ax as eh,aS as th,aU as rh,aV as nh,aq as sh,aT as Rc,q as jt,e as ah,L as tt,n as ih,b as oh,ap as Nc,a6 as Cc,a4 as lh,ad as wa,ae as Ac,af as ch,bE as zi,aN as dh,a8 as uh,bB as fh,ah as hh,y as $c,x as mh,a5 as ph,a7 as gh,ab as Ec,bd as xh,l as bh,d as ya,f as uo,o as vh,U as wh,_ as js,bH as yh,aK as kh,W as Sh}from"./app-B42CoF1r.js";import{b as i,r as Wr}from"./dnd-BCFAPC0L.js";import{w as jh,f as Rh,n as Pa,d as Nh,P as Ch,i as Ah,R as fo,o as bd,p as $h,S as Wn,D as Eh,c as vd,a as Mh,v as wd,t as Mc,s as ka,q as Th,r as Ph,u as Lh,T as Tc,C as Pc,h as Hi,g as Sa,b as Fh,k as Dh,e as _h,l as Ih,F as Lc}from"./App-CAEtVL8Z.js";import{a as Bh,S as zh,b as yd,c as ho,F as Hh}from"./gestureArbiter-D3IZpZS7.js";import{a as Oh,w as mt,r as Ze,e as ae,u as kd,g as vs,f as hs,d as Wh}from"./referenceLongPress-p56g9xFb.js";import{D as mo,C as ws,L as Sd,f as Gh,n as Uh}from"./DiffReview-DyhINv0F.js";import{T as Kh,L as _a}from"./triangle-alert-BSNAwyll.js";import{S as Rs}from"./sparkles-B-uEi0Pa.js";import{C as jd,a as Rd,M as Nd,G as Rr}from"./ChangeWalkthroughPanel-BNWqAnqc.js";import{r as Cd,s as Ad,l as $d,u as qh,G as Ed,h as Md}from"./DiffViewer-3zz2PI-8.js";const Vh=[["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"}]],Yh=pt("case-sensitive",Vh);const Xh=[["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"}]],Zh=pt("eye-off",Xh);const Qh=[["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"}]],po=pt("eye",Qh);const Jh=[["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"}]],go=pt("file-text",Jh);const em=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Fc=pt("house",em);const tm=[["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"}]],rm=pt("image-plus",tm);const nm=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],sm=pt("maximize",nm);const am=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],im=pt("minimize",am);const om=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],lm=pt("pencil-line",om);const cm=[["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"}]],dm=pt("regex",cm);const um=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],fm=pt("rotate-cw",um);const hm=[["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"}]],mm=pt("scan",hm);const pm=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Dc=pt("send",pm);const gm=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],xm=pt("upload",gm);const bm=[["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"}]],vm=pt("whole-word",bm);function wm(t,n,s){try{const l=t instanceof HTMLImageElement?t.naturalWidth:t.width,d=t instanceof HTMLImageElement?t.naturalHeight:t.height;if(!l||!d)return Promise.resolve(null);const c=t 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 h=m.getContext("2d");if(!h)return Promise.resolve(null);const p=getComputedStyle(document.documentElement);if(h.fillStyle=p.getPropertyValue("--surface").trim()||"white",h.fillRect(0,0,m.width,m.height),h.drawImage(t,0,0,m.width,m.height),s){const g=Math.max(10,Math.min(16,m.width/35));h.font=`${g}px sans-serif`;const f=[];let y="";for(const w of s.split(" "))y&&h.measureText(`${y} ${w}`).width>m.width-20?(f.push(y),y=w):y=y?`${y} ${w}`:w;y&&f.push(y),h.fillStyle=p.getPropertyValue("--surface").trim()||"white",h.fillRect(0,0,m.width,f.length*(g+4)+12),h.fillStyle=p.getPropertyValue("--foreground").trim()||"black",f.forEach((w,$)=>h.fillText(w,10,8+g+$*(g+4)))}if(n){const g=n.xPercent*m.width/100,f=n.yPercent*m.height/100,y=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),w=y*1.6;h.strokeStyle=p.getPropertyValue("--primary").trim()||"black",h.lineWidth=Math.max(1,y/3),h.beginPath(),h.arc(g,f,y,0,Math.PI*2),h.stroke(),h.beginPath(),h.moveTo(g-w,f),h.lineTo(g+w,f),h.moveTo(g,f-w),h.lineTo(g,f+w),h.stroke()}return new Promise(g=>m.toBlob(g,"image/png"))}catch{return Promise.resolve(null)}}function ym(t,n,s,l){return[t.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
-
`)}function dx(t,n,s){const l=n*Math.PI/360,d=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(t,1e-6)/Math.sin(d)*1.15}async function km(t,n,s,l){if(!s?.snapshot){l.isCurrent()&&l.insert(t,n);return}const d=new Date().toISOString(),c=new AbortController;let m,h;try{h=await Promise.race([(async()=>{const p=await s.snapshot;if(!(!p||c.signal.aborted||!l.isCurrent()))return l.upload(new File([p],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(p=>{m=setTimeout(()=>{c.abort(),p(void 0)},3e3)})])}catch{}finally{clearTimeout(m),c.abort()}l.isCurrent()&&l.insert(h?ym(t,"",d,h):t,n)}function Sm(t){let n=1,s="terminal";for(;;){let l=!1;for(const d of t.values())if(d.name===s){l=!0;break}if(!l)break;s=`terminal-${n}`,n++}return s}const _c=Oh((t,n)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:s=>{const l=jh(),d=Date.now(),c=n().sessions,m=Sm(c),h={id:l,cwd:s,sessionId:null,name:m,customName:!1,createdAt:d,lastActivity:d};return t(p=>{const g=new Map(p.sessions);return g.set(l,h),{sessions:g,activeSessionId:p.activeSessionId??l,nextSessionNumber:p.nextSessionNumber+1}}),l},closeSession:s=>{t(l=>{const d=new Map(l.sessions),c=l.activeSessionId===s;d.delete(s);let m=l.activeSessionId;if(c){const h=Array.from(d.keys());m=h.length>0?h[0]:null}return{sessions:d,activeSessionId:m}})},switchSession:s=>{t(l=>l.sessions.has(s)?{activeSessionId:s}:l)},updateSession:(s,l)=>{t(d=>{const c=d.sessions.get(s);if(!c)return d;const m=new Map(d.sessions);return m.set(s,{...c,...l,lastActivity:Date.now()}),{sessions:m}})},setTerminalSession:(s,l)=>{n().updateSession(s,{sessionId:l.sessionId})},getActiveSession:()=>{const s=n();if(s.activeSessionId)return s.sessions.get(s.activeSessionId)},getSessionCount:()=>n().sessions.size,clearAllSessions:()=>{t({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}}));function jm(t,n){return t===n||n.endsWith(`/${t}`)||t.endsWith(`/${n}`)}function Ic(t,n){return`${t??""}\0${n}`}function Rm(t,n,s){if(!t||t.length===0||!s)return{explained:0,stale:0};const l=Ic(n,s);let d=0,c=0;for(const m of t){const h=[m.filePath,m.newPath,m.oldPath].filter(g=>typeof g=="string"&&g.length>0);(h.some(g=>Ic(m.repoRoot,g)===l)||h.some(g=>jm(g,s)))&&(d+=1)}return{explained:d,stale:c}}function Nm({status:t}){if(!t)return null;const n=t.stale>0&&t.explained===0;if(!(t.explained>0||t.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(Kh,{size:10}):e.jsx(Rs,{size:10})})}function xo({changeStatus:t,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(t),e.jsx(Nm,{status:n})]})}const Td="termdock:right-sidebar:diff-change-list-mode:v1";function Cm(t){return t==="list"||t==="tree"}function Am(){return Ze(Td,Cm)??"tree"}function $m(t){for(const l of t){const d=l.hunk;if(d.oldPath&&d.newPath&&d.oldPath!==d.newPath)return"renamed";if(!d.oldPath&&d.newPath)return"added";if(d.oldPath&&!d.newPath)return"deleted"}const n=t.some(l=>l.hunk.additions>0),s=t.some(l=>l.hunk.deletions>0);return n&&!s?"added":!n&&s?"deleted":"modified"}function Em(t){const n=new Map;for(const l of t){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=$m(l.items);return s}function Mm(t){const n=t.filePath.split("/").pop()??t.filePath;return{key:t.key,path:t.filePath,displayName:n,displayDir:t.filePath.includes("/")?t.filePath.slice(0,-n.length-1):"",status:t.changeType,title:t.filePath}}function Tm(t,n){const s=t.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 h=m.split(`
|
|
4
|
-
`),p=h.findIndex(y=>y.startsWith("@@ "));if(p<0){l.push(...h);continue}c===0&&l.push(...h.slice(0,p));const g=n[c];let f=p;for(;f>=0&&f<h.length;){const y=h.findIndex((j,T)=>T>f&&j.startsWith("@@ ")),w=y>=0?y:h.length,$=h.slice(f,w),E=$[0]??"",_=g?E===g:!0,L=E||g||$.join(`
|
|
5
|
-
`);_&&!d.has(L)&&(l.push(...$),d.add(L)),f=y}}return l.join(`
|
|
6
|
-
`)}function Pm({groups:t,onInsertDiffReference:n}){return t.map(s=>{const l=Tm(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):"";return{key:s.key,path:s.filePath,absolutePath:d[0]?.repoRoot?`${d[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:d[0]?.repoRoot??null,displayName:c,displayDir:m,diffOverride:l,auditRecords:d,onInsertDiffReference:n}})}function Lm(t,n,s){const l=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=t.getBoundingClientRect().top+48;let m=null,h=Number.POSITIVE_INFINITY;for(const g of l){const f=g.getBoundingClientRect();if(f.bottom<c)continue;const y=Math.abs(f.top-c);y<h&&(m=g,h=y)}const p=m?.dataset.diffSelectionPath??m?.dataset.diffStreamItem??null;return!p||p===n||s(p),p}function Bc({items:t,selectedKey:n,onSelect:s,emptyText:l,mobile:d=!1,backLabel:c="Back",headerTitle:m,headerMeta:h,onClose:p,closeLabel:g="Back",wrap:f=!0,onToggleWrap:y,wrapTitle:w,wrapOnLabel:$="Wrap on",wrapOffLabel:E="Wrap off",desktopLayout:_="split",onInsertDiffReference:L,onReferenceCopied:j,insertedReferenceKey:T,copiedReferenceKey:C,onClearAuditRecord:F,walkthroughs:U=[],onWalkthroughNavigate:D,initialDetailScrollTop:a,onDetailScrollPositionChange:k,scrollToKey:B,scrollToKeyNonce:S,externalSwiperRef:Y,onMobileSlideChange:le}){const{t:ie}=gt(),ue=i.useMemo(()=>Em(t),[t]),K=i.useMemo(()=>new Map(ue.map(fe=>[fe.key,fe])),[ue]),[X,A]=i.useState(()=>Am()),[I,V]=i.useState(()=>new Set),[re,ee]=i.useState({key:null,nonce:0}),ge=ue.find(fe=>fe.explained>0||fe.stale>0)?.key??ue[0]?.key??null,O=n&&ue.some(fe=>fe.key===n)?n:ge,xe=i.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ue.map(Mm)}],[ue]),W=i.useMemo(()=>Pm({groups:ue,onInsertDiffReference:L}),[ue,L]),pe=i.useRef(ge),je=i.useRef(s);pe.current=ge,je.current=s,i.useEffect(()=>{!n&&pe.current&&je.current(pe.current)},[n]);const Ae=y?e.jsxs("button",{type:"button",onClick:y,"aria-pressed":f,title:w,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"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:f?$:E})]}):null,_e=fe=>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}),h&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:h})]}),p&&e.jsxs("button",{type:"button",onClick:p,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(ks,{size:14}),g]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[fe,Ae]})]});if(t.length===0){const fe=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!m&&!p?fe:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[_e(null),fe]})}const Rt=y?({slideToList:fe})=>e.jsxs("div",{className:"flex 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:fe,children:[e.jsx(ks,{size:14}),c]}),e.jsxs("button",{type:"button",onClick:y,"aria-pressed":f,title:w,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"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:f?$:E})]})]}):void 0;return e.jsx(mo,{mobile:d,desktopLayout:_,backLabel:c,groups:xe,selectedKey:O,mode:X,onModeChange:fe=>{A(fe),fe!=="ai"&&mt(Td,fe)},compact:d,collapsedDirectoryKeys:I,onToggleDirectory:fe=>{V(ne=>{const N=new Set(ne);return N.has(fe)?N.delete(fe):N.add(fe),N})},onSelectFile:fe=>{s(fe.key),ee(ne=>({key:fe.key,nonce:ne.nonce+1}))},renderLeading:fe=>{const ne=K.get(fe.key);return e.jsx(xo,{changeStatus:fe.status,auditStatus:ne,renderChangeBadge:N=>e.jsx(ws,{status:N})})},renderTrailing:fe=>{const ne=K.get(fe.key);return ne?e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",ne.additions," -",ne.deletions]}):null},renderListHeader:_e,aiContent:({slideToDetail:fe,fullscreen:ne,toggleFullscreen:N})=>U.length>0&&D?e.jsx(jd,{walkthroughs:U,repoRoot:U[0]?.repoRoot,fullscreen:ne,onToggleFullscreen:N,onNavigate:Z=>{d&&window.requestAnimationFrame(fe),D(Z)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:ie("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Rt,externalSwiperRef:Y,onMobileSlideChange:le,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:a,scrollToKey:B??re.key,scrollToKeyNonce:B==null?re.nonce:S,onDetailScroll:fe=>{Lm(fe,O,s),k?.(fe.scrollTop)},files:W,activePane:!0,wrap:f,showScrollHint:!f,renderStreamBadge:(fe,ne)=>{const N=K.get(ne.key);return e.jsx(xo,{changeStatus:fe,auditStatus:N,renderChangeBadge:Z=>e.jsx(ws,{status:Z})})},onInsertDiffReference:L,onReferenceCopied:j,insertedReferenceKey:T,copiedReferenceKey:C,onClearAuditRecord:F,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function Fm(t){return t.replace(/\/+$/,"")||"/"}function Dm(t){return[...new Set(Array.from(t,Fm))].sort((n,s)=>n.localeCompare(s))}function _m(t){return t==="event-storm"||t==="reconnected"||t==="directory-rescan"||t==="polling-fallback"}function Im(t){let n=null;return{applicableEvents:t.filter(l=>{const d=l.type==="rescan-required"&&!_m(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const Bm=1400,zm=1200,Pd=44,Hm=.7;function Oi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function bo(t){return`termdock:right-sidebar:context-draft-height:${t}:v1`}function Om(t){try{const n=window.localStorage.getItem(bo(t)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Pd?s:null}catch{return null}}function zc(t,n){try{n===null?window.localStorage.removeItem(bo(t)):window.localStorage.setItem(bo(t),String(n))}catch{}}function ja(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Wm({value:t,collapsed:n,labels:s,focusRequest:l,insertError:d,autoCollapseAfterSend:c,onChange:m,onCollapsedChange:h,onAutoCollapseAfterSendChange:p,onDisable:g,onClear:f,onInsert:y,onInsertAndSend:w}){const[$,E]=i.useState(null),[_,L]=i.useState(!1),[j,T]=i.useState(()=>Om(Oi())),C=i.useRef(j),F=i.useRef(null),U=i.useRef(null),D=i.useRef(t),a=i.useRef(null),k=i.useRef(null),B=!!t.trim(),S=t.trim().split(`
|
|
7
|
-
`)[0]??"",Y=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";i.useEffect(()=>()=>{F.current!==null&&window.clearTimeout(F.current),U.current!==null&&window.clearTimeout(U.current)},[]),i.useEffect(()=>{let W=!1;const pe=Oi();return Gf().then(je=>{if(W)return;const Ae=je.contextDraftHeight?.[pe]??null;zc(pe,Ae),C.current=Ae,T(Ae)}).catch(()=>{}),()=>{W=!0}},[]),i.useEffect(()=>{if(l!==void 0&&l>0){const W=a.current;if(!W)return;ja()||W.focus(),W.setSelectionRange(W.value.length,W.value.length),W.scrollTop=W.scrollHeight}},[l]),i.useEffect(()=>{const W=D.current;D.current=t,!(!n||t.length<=W.length)&&(L(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,L(!1)},zm))},[t,n]),i.useEffect(()=>{if(n)return;const W=a.current;W&&(W.style.height=j!==null?`${j}px`:"")},[t,n,j]),i.useEffect(()=>{if(n)return;const W=a.current;!W||document.activeElement===W||(W.scrollTop=W.scrollHeight)},[t,n]),i.useEffect(()=>{if(n||ja())return;const W=a.current;!W||document.activeElement===W||(W.focus(),W.setSelectionRange(W.value.length,W.value.length))},[n]);const le=i.useRef(null);i.useLayoutEffect(()=>{if(!ja())return;const W=window.visualViewport;if(!W)return;const pe=()=>{const je=le.current;if(!je)return;if(W.height>=window.innerHeight*.75){je.style.transform="";return}const Ae=je.getBoundingClientRect(),_e=Math.round(W.height-Ae.bottom);je.style.transform=_e!==0?`translateY(${_e}px)`:""};return pe(),W.addEventListener("resize",pe),W.addEventListener("scroll",pe),()=>{W.removeEventListener("resize",pe),W.removeEventListener("scroll",pe),le.current&&(le.current.style.transform="")}},[n]);const ie=W=>{E(W),F.current!==null&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>{F.current=null,E(null)},Bm)},ue=W=>{h(!1),ja()&&window.requestAnimationFrame(()=>{const pe=a.current;if(!pe)return;pe.focus();const je=pe.value.length;pe.setSelectionRange(je,je),window.requestAnimationFrame(()=>{pe.setSelectionRange(je,je)})})},K=()=>{y(),ie("inserted")},X=()=>{B&&(w(),ie("sent"))},A=W=>{if(W.key==="Escape"){W.preventDefault(),h(!0);return}W.key!=="Enter"||!W.metaKey&&!W.ctrlKey||(W.preventDefault(),X())},I=W=>{W.preventDefault()},V=W=>{W.preventDefault();const pe=a.current;pe&&(k.current={startY:W.clientY,startHeight:pe.getBoundingClientRect().height},W.currentTarget.setPointerCapture?.(W.pointerId))},re=W=>{const pe=k.current;if(!pe)return;const je=window.visualViewport?.height??window.innerHeight,Ae=Math.round(Math.min(Math.max(pe.startHeight+(pe.startY-W.clientY),Pd),je*Hm));C.current=Ae,T(Ae)},ee=W=>{const pe=Oi();zc(pe,W),Uf({contextDraftHeight:{[pe]:W}}).catch(()=>{})},ge=()=>{k.current&&(k.current=null,C.current!==null&&ee(C.current))},O=()=>{C.current=null,T(null),ee(null)},xe=t.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(t.length)});return n?e.jsx("section",{ref:le,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:()=>ue(),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(Rh,{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":_?"text-primary":B?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(_?s.appended:B?S:s.title)})]}),xe,e.jsx("button",{type:"button",onClick:X,disabled:!B,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${B?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:$==="sent"?e.jsx(co,{size:12}):e.jsx(Dc,{size:12})})]})}):e.jsxs("section",{ref:le,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:V,onPointerMove:re,onPointerUp:ge,onPointerCancel:ge,onDoubleClick:O,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:I,onClick:()=>h(!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(Ss,{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}),xe]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:I,onClick:()=>p(!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:I,onClick:g,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(Dt,{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:a,value:t,onChange:W=>m(W.target.value),onKeyDown:A,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:I,onClick:f,disabled:!B,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(Pa,{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:I,onClick:K,disabled:!B,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(Nh,{size:11}),e.jsx("span",{children:$==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:I,onClick:X,disabled:!B,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} · ${Y}`,children:[$==="sent"?e.jsx(co,{size:11}):e.jsx(Dc,{size:11}),e.jsx("span",{children:$==="sent"?s.sent:s.send})]})]})]})})]})}function Gm(t,n){const s=n.trim();if(!s)return t;if(!t.trim())return s;const l=t.endsWith(`
|
|
8
|
-
|
|
9
|
-
`)?"":t.endsWith(`
|
|
10
|
-
`)?`
|
|
11
|
-
`:`
|
|
12
|
-
|
|
13
|
-
`;return`${t}${l}${s}`}function Um(t,n){const s=t.trim();return s?n?`${s}\r`:/\s$/.test(t)?t:`${s} `:""}const vo="termdock:right-sidebar:html-view-mode-by-file:v1";function Km(t){return t==="preview"||t==="source"}function Ld(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(Km)}function Fd(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function Hc(t,n){const s=Fd(t,n);return s?Ze(vo,Ld)?.[s]??"source":"source"}function qm(t,n,s){const l=Fd(t,n);if(!l)return;const d=Ze(vo,Ld)??{};mt(vo,{...d,[l]:s})}function Wi(t){const n=Number.isFinite(t)&&t>0?Math.floor(t):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 Vm(t,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(t-n.left)/n.width))*s}const Ym=350,Xm=12,Zm=90;function Qm({url:t,onLoadError:n}){const{t:s}=gt(),l=i.useRef(null),d=i.useRef(null),c=i.useRef(null),m=i.useRef(null),h=i.useRef(!1),p=i.useRef(null),g=i.useRef(null),f=i.useRef(0),y=i.useRef(!1),w=i.useRef(!1),$=i.useRef(!1),E=i.useRef(null),_=i.useRef(null),L=i.useRef(!1),j=i.useRef(1),T=i.useRef(!1),[C,F]=i.useState(0),[U,D]=i.useState(0),[a,k]=i.useState(!1),[B,S]=i.useState(!1),[Y,le]=i.useState(null),[ie,ue]=i.useState(!1),[K,X]=i.useState(0),[A,I]=i.useState(!1),[V,re]=i.useState({width:0,height:0}),ee=i.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),ge=i.useCallback(()=>{if(ee(),_.current=null,!L.current)return!1;const z=c.current;return z&&(z.playbackRate=j.current),L.current=!1,ue(!1),!0},[ee]);i.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),g.current!==null&&clearTimeout(g.current),ee();const z=c.current;z&&L.current&&(z.playbackRate=j.current)},[ee]),i.useEffect(()=>{const z=d.current;if(!z||typeof ResizeObserver>"u")return;const ce=new ResizeObserver(([te])=>{te&&re({width:te.contentRect.width,height:te.contentRect.height})});return ce.observe(z),()=>ce.disconnect()},[]),i.useEffect(()=>{const z=()=>I(document.fullscreenElement===l.current);return document.addEventListener("fullscreenchange",z),()=>document.removeEventListener("fullscreenchange",z)},[]);const O=i.useCallback((z,ce=!1)=>{const te=c.current;if(!te)return!1;const Te=Number.isFinite(te.duration)?te.duration:z,Ce=Math.min(Math.max(z,0),Te);if(D(Ce),Math.abs(te.currentTime-Ce)<1/120)return!1;const _t=te.fastSeek;return ce&&typeof _t=="function"?_t.call(te,Ce):te.currentTime=Ce,!0},[]),xe=i.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const z=c.current;if(!z||!y.current||w.current||z.seeking)return;const ce=$.current;$.current=!1,w.current=O(f.current,!ce)}))},[O]),W=i.useCallback(z=>{const ce=m.current,te=c.current;if(!ce||!te)return;const Te=ce.getBoundingClientRect(),Ce=Vm(z,Te,te.duration);f.current=Ce,le(Ce),$.current=!1,xe(),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,$.current=!0,xe()},Zm)},[xe]),pe=i.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),g.current!==null&&(clearTimeout(g.current),g.current=null),$.current=!1,w.current=!1,O(f.current)},[O]),je=i.useCallback(z=>{const ce=c.current;if(!(!ce||!Number.isFinite(ce.duration)||ce.duration<=0)){h.current=!ce.paused,ce.pause(),y.current=!0,S(!0);try{z.currentTarget.setPointerCapture(z.pointerId)}catch{}W(z.clientX)}},[W]),Ae=i.useCallback(()=>{y.current=!1,pe(),S(!1),le(null);const z=c.current;z&&h.current&&!z.ended&&z.play().catch(()=>{}),h.current=!1},[pe]),_e=i.useCallback(()=>{const z=c.current;if(z){if(T.current){T.current=!1;return}z.paused?z.play().catch(()=>{}):z.pause()}},[]),Rt=i.useCallback(z=>{const ce=c.current;!ce||ce.paused||z.button!==0||(ee(),_.current={id:z.pointerId,x:z.clientX,y:z.clientY},E.current=setTimeout(()=>{E.current=null,j.current=ce.playbackRate,ce.playbackRate=2,L.current=!0,ue(!0)},Ym))},[ee]),fe=i.useCallback(z=>{const ce=_.current;!ce||ce.id!==z.pointerId||L.current||Math.hypot(z.clientX-ce.x,z.clientY-ce.y)>Xm&&(ee(),_.current=null)},[ee]),ne=i.useCallback(()=>{ge()&&(T.current=!0)},[ge]);i.useEffect(()=>(window.addEventListener("pointerup",ne),window.addEventListener("pointercancel",ne),window.addEventListener("blur",ne),()=>{window.removeEventListener("pointerup",ne),window.removeEventListener("pointercancel",ne),window.removeEventListener("blur",ne)}),[ne]);const N=i.useCallback(async()=>{const z=l.current,ce=c.current;if(!(!z||!ce))try{document.fullscreenElement===z?await document.exitFullscreen():z.requestFullscreen?await z.requestFullscreen():ce.webkitEnterFullscreen?.()}catch{ce.webkitEnterFullscreen?.()}},[]),Z=i.useCallback(()=>X(z=>(z+90)%360),[]),Se=i.useCallback(z=>{const ce=c.current;if(!ce||!Number.isFinite(ce.duration))return;const te=z.shiftKey?10:5;let Te=null;z.key==="ArrowLeft"?Te=ce.currentTime-te:z.key==="ArrowRight"?Te=ce.currentTime+te:z.key==="Home"?Te=0:z.key==="End"&&(Te=ce.duration),Te!==null&&(z.preventDefault(),O(Te))},[O]),be=B&&Y!==null?Y:U,De=C>0?Math.min(1,Math.max(0,be/C)):0,Ge=(K===90||K===270)&&V.width>0&&V.height>0?{width:`${V.height}px`,height:`${V.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:l,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":K,children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:c,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...Ge,transform:`translate(-50%, -50%) rotate(${K}deg)`},src:t,preload:"auto",playsInline:!0,onClick:_e,onPointerDown:Rt,onPointerMove:fe,onPointerUp:ne,onPointerCancel:ne,onContextMenu:z=>{L.current&&z.preventDefault()},onPlay:()=>k(!0),onPause:()=>k(!1),onTimeUpdate:z=>D(z.currentTarget.currentTime),onSeeked:z=>{const ce=z.currentTarget;if(D(ce.currentTime),w.current=!1,!y.current)return;const te=ce.requestVideoFrameCallback;typeof te=="function"?te.call(ce,()=>{y.current&&xe()}):requestAnimationFrame(()=>{y.current&&xe()})},onLoadedMetadata:z=>F(Number.isFinite(z.currentTarget.duration)?z.currentTarget.duration:0),onDurationChange:z=>F(Number.isFinite(z.currentTarget.duration)?z.currentTarget.duration:0),onError:n,children:s("rightSidebar.videoUnsupported")}),ie&&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:s("rightSidebar.videoLongPressSpeed")}),B&&Y!==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:`${De*100}%`},"data-testid":"file-preview-video-scrub-time",children:Wi(Y)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Bh}`,[zh]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:_e,"aria-label":s(a?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:s(a?"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:a?e.jsx(Ch,{size:14}):e.jsx(Ah,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(C),"aria-valuenow":Math.floor(be),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:je,onPointerMove:z=>{B&&W(z.clientX)},onPointerUp:Ae,onPointerCancel:Ae,onKeyDown:Se,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:`${De*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:`${De*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Wi(be)," / ",Wi(C)]}),e.jsx("button",{type:"button",onClick:Z,"aria-label":s("rightSidebar.videoRotate"),title:s("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(fm,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{N()},"aria-label":s(A?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:s(A?"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:A?e.jsx(im,{size:14}):e.jsx(sm,{size:14})})]})})]})}function Jm(t){const n=Math.max(0,Math.min(100,t.xPercent)),s=Math.max(0,Math.min(100,t.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 Ua({anchor:t,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()},title:d,style:Jm(t),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(_a,{size:11}),n]})}function ep(t,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,h=s.left+(s.width-c)/2,p=s.top+(s.height-m)/2,g=t-h,f=n-p;if(g<0||f<0||g>c||f>m)return null;const y=g/c*100,w=f/m*100;return{x:l.x+l.width*y/100,y:l.y+l.height*w/100,xPercent:y,yPercent:w}}function tp(t,n,s){const l=[`SVG标注: ${t}`,`视图: ${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 rp(t){const n=new DOMParser().parseFromString(t,"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 np(t,n,s){let l=null;for(const d of Array.from(t.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const m=Number(d.getAttribute("x")),h=Number(d.getAttribute("y"));if(!Number.isFinite(m)||!Number.isFinite(h))continue;const p=Math.hypot(m-n,h-s);(!l||p<l.distance)&&(l={text:c,distance:p})}return l?.text.slice(0,120)}function Dd({blobUrl:t,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=i.useRef(null),c=i.useRef(null),[m,h]=i.useState(null),[p,g]=i.useState(null),[f,y]=i.useState(1),[w,$]=i.useState(!1),[E,_]=i.useState(null),L=i.useRef(new Map),j=i.useRef(null),T=i.useRef(!1),C=i.useRef(null),F=i.useRef(f);F.current=f,i.useEffect(()=>{const A=new AbortController;return h(null),g(null),_(null),y(1),fetch(t,{signal:A.signal}).then(I=>I.text()).then(I=>h(rp(I))).catch(I=>{A.signal.aborted||g(I instanceof Error?I.message:"SVG preview failed")}),()=>A.abort()},[t]),i.useEffect(()=>{if(!w)return;const A=I=>{I.key==="Escape"&&$(!1)};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[w]),i.useLayoutEffect(()=>{const A=c.current,I=A?.querySelector("[data-svg-document] > svg");if(!A||!I)return;let V;try{V=I.getBBox()}catch{return}if(!V.width||!V.height)return;const re=Math.max(2,Math.min(V.width,V.height)*.025);I.setAttribute("viewBox",`${V.x-re} ${V.y-re} ${V.width+2*re} ${V.height+2*re}`),I.style.width=`${f*100}%`,I.style.height=`${f*100}%`,I.style.minWidth=`${f*100}%`,I.style.minHeight=`${f*100}%`,I.style.display="block"},[m,f]);const U=i.useMemo(()=>E?tp(n,s,E):null,[n,E,s]),D=A=>{if(T.current){T.current=!1;return}const I=c.current,V=I?.querySelector("[data-svg-document] > svg"),re=d.current;if(!I||!V||!re)return;const ee=V.viewBox.baseVal,ge=ep(A.clientX,A.clientY,V.getBoundingClientRect(),ee);if(!ge)return;const O=re.getBoundingClientRect();_({...ge,nearestText:np(V,ge.x,ge.y),stageX:A.clientX-O.left,stageY:A.clientY-O.top,stageXPercent:(A.clientX-O.left)/O.width*100,stageYPercent:(A.clientY-O.top)/O.height*100})},a=A=>Math.max(1,Math.min(12,A)),k=(A,I)=>{const V=a(I),re=A.querySelector("[data-svg-document] > svg");if(!re)return V;const ee=`${V*100}%`;return re.style.width=ee,re.style.height=ee,re.style.minWidth=ee,re.style.minHeight=ee,F.current=V,V},B=(A,I,V,re)=>{const ee=F.current,ge=A.getBoundingClientRect(),O=V-ge.left,xe=re-ge.top,W=(A.scrollLeft+O)/ee,pe=(A.scrollTop+xe)/ee,je=k(A,I);return A.scrollLeft=W*je-O,A.scrollTop=pe*je-xe,je},S=()=>{const A=Array.from(L.current.values());return A.length>=2?Math.hypot(A[0].x-A[1].x,A[0].y-A[1].y):0},Y=A=>{if(A.pointerType==="mouse"&&A.button!==0)return;const I=c.current;I&&(L.current.set(A.pointerId,{x:A.clientX,y:A.clientY}),I.setPointerCapture?.(A.pointerId),L.current.size>=2?(j.current={kind:"pinch",startX:A.clientX,startY:A.clientY,startScrollLeft:I.scrollLeft,startScrollTop:I.scrollTop,startDistance:S(),startZoom:F.current,moved:!1},T.current=!0):F.current>1&&(j.current={kind:"pan",startX:A.clientX,startY:A.clientY,startScrollLeft:I.scrollLeft,startScrollTop:I.scrollTop,startZoom:F.current,moved:!1}))},le=A=>{if(!L.current.has(A.pointerId))return;L.current.set(A.pointerId,{x:A.clientX,y:A.clientY});const I=c.current,V=j.current;if(!(!I||!V)){if(L.current.size>=2&&V.kind==="pinch"){const re=S();if(!V.startDistance||!re)return;const ee=a(V.startZoom*re/V.startDistance);if(Math.abs(ee-F.current)<.01)return;const ge=Array.from(L.current.values()),O=(ge[0].x+ge[1].x)/2,xe=(ge[0].y+ge[1].y)/2;V.moved=!0,T.current=!0,B(I,ee,O,xe),A.preventDefault();return}if(V.kind==="pan"&&L.current.size===1){const re=A.clientX-V.startX,ee=A.clientY-V.startY;if(!V.moved&&Math.hypot(re,ee)<6)return;V.moved=!0,T.current=!0,I.scrollLeft=V.startScrollLeft-re,I.scrollTop=V.startScrollTop-ee,A.preventDefault()}}},ie=A=>{const I=c.current,V=j.current,re=L.current.size===1&&!V?.moved;L.current.delete(A.pointerId);try{I?.releasePointerCapture?.(A.pointerId)}catch{}if(L.current.size===1&&V?.kind==="pinch"){const O=Array.from(L.current.values())[0];j.current=I?{kind:"pan",startX:O.x,startY:O.y,startScrollLeft:I.scrollLeft,startScrollTop:I.scrollTop,startZoom:F.current,moved:!1}:null;return}if(L.current.size>0||(j.current=null,V?.kind==="pinch"&&y(F.current),!re||T.current))return;const ee=Date.now(),ge=C.current;ge&&ee-ge.time<350&&Math.hypot(A.clientX-ge.x,A.clientY-ge.y)<24?(C.current=null,T.current=!0,y(O=>O>1?1:2.5)):C.current={time:ee,x:A.clientX,y:A.clientY}},ue=A=>{if(!A.ctrlKey&&!A.metaKey)return;const I=c.current;if(!I)return;A.preventDefault();const V=B(I,F.current*Math.exp(-A.deltaY*.01),A.clientX,A.clientY);y(V)},K=()=>{y(1),F.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},X=e.jsxs("div",{className:w?"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:D,onDoubleClick:A=>{A.preventDefault(),y(I=>I>1?1:2.5)},onPointerDown:Y,onPointerMove:le,onPointerUp:ie,onPointerCancel:ie,onWheel:ue,onScroll:()=>_(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:p?e.jsx("div",{className:"p-4 text-sm text-destructive",children:p}):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…"})}),E&&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:E.stageX,top:E.stageY}}),E&&U&&e.jsx(Ua,{anchor:{xPercent:E.stageXPercent,yPercent:E.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${E.x.toFixed(2)}:${E.y.toFixed(2)}`),_(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:A=>{A.stopPropagation(),K()},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(mm,{size:14})}),e.jsx("button",{type:"button","aria-label":w?"退出全屏 SVG":"全屏 SVG",title:w?"退出全屏 SVG":"全屏 SVG",onClick:A=>{A.stopPropagation(),$(I=>!I)},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:w?e.jsx(Rd,{size:14}):e.jsx(Nd,{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:E?`SVG (${E.x.toFixed(2)}, ${E.y.toFixed(2)}) · ${E.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return w?Wr.createPortal(X,document.body):X}function La(t){switch(t){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function sp(t,n,s,l){const d=[`电子标注: ${t}`,`视图: ${La(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 ap({blobUrl:t,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:m,interactive3d:h}){const{t:p}=gt(),g=i.useRef(null),f=i.useRef(null),y=i.useRef(null),[w,$]=i.useState(null),[E,_]=i.useState(!1);i.useEffect(()=>(y.current?.abort(),$(null),_(!1),()=>y.current?.abort()),[t,s]);const L=i.useMemo(()=>w?sp(n,s,w,w.inspection):null,[n,w,s]),j=C=>{const F=g.current,U=f.current;if(!F||!U||!U.naturalWidth||!U.naturalHeight)return;const D=F.getBoundingClientRect(),a=U.getBoundingClientRect(),k=Math.min(a.width/U.naturalWidth,a.height/U.naturalHeight),B=U.naturalWidth*k,S=U.naturalHeight*k,Y=a.left+(a.width-B)/2,le=a.top+(a.height-S)/2,ie=C.clientX-Y,ue=C.clientY-le;if(ie<0||ue<0||ie>B||ue>S)return;const K={xPercent:Math.max(0,Math.min(100,ie/B*100)),yPercent:Math.max(0,Math.min(100,ue/S*100)),stageXPercent:(C.clientX-D.left)/D.width*100,stageYPercent:(C.clientY-D.top)/D.height*100,inspecting:l&&s!=="pcb-3d"};if($(K),y.current?.abort(),!K.inspecting)return;const X=new AbortController;y.current=X,Kf(n,s,K.xPercent,K.yPercent,X.signal).then(A=>$(I=>I===K?{...I,inspection:A,inspecting:!1}:I)).catch(()=>{X.signal.aborted||$(A=>A===K?{...A,inspection:{available:!1},inspecting:!1}:A)})},T=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:T.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:La(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:p("rightSidebar.edaRefresh"),"aria-label":p("rightSidebar.edaRefresh"),children:e.jsx(fo,{size:13})})]}),l&&h?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:h}):null,l?s==="pcb-3d"?h?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:g,role:"button",tabIndex:0,onClick:j,onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),$({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:p("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:t,alt:`${n} ${La(s)}`,onLoad:()=>_(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${E?"opacity-100":"opacity-0"}`}),w&&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:`${w.stageXPercent}%`,top:`${w.stageYPercent}%`}}),w&&L&&e.jsx(Ua,{anchor:{xPercent:w.stageXPercent,yPercent:w.stageYPercent},disabled:w.inspecting,title:p("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(L,`eda:${s}:${w.xPercent.toFixed(1)}:${w.yPercent.toFixed(1)}`,{snapshot:f.current?wm(f.current,w):Promise.resolve(null)}),$(null)},children:p("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:w?w.inspecting?p("rightSidebar.edaInspecting"):w.inspection?.available?p("rightSidebar.edaPickedBoardPosition",{x:w.inspection.xMm?.toFixed(2)??"—",y:w.inspection.yMm?.toFixed(2)??"—",object:w.inspection.nearest?.label??p("rightSidebar.edaNoNearbyObject")}):p("rightSidebar.edaPickedPosition",{x:w.xPercent.toFixed(1),y:w.yPercent.toFixed(1)}):p("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Dd,{blobUrl:t,filePath:n,viewLabel:La(s),onInsertAnnotation:c})})]})}function ip(t){const n=[];let s=[],l="",d=!1;for(let c=0;c<t.length;c+=1){const m=t[c];d?m==='"'&&t[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 op(t,n,s,l,d){const c=n[d]||`第${d+1}列`,m=s[d]??"",h=n.map((p,g)=>`${p||`第${g+1}列`}=${s[g]??""}`).join(";");return`"表格标注: ${t} / 数据行: ${l+1} / 列: ${c} / 值: ${m} / 记录: ${h}"`}function lp({content:t,filePath:n,onInsertAnnotation:s}){const{t:l}=gt(),d=i.useMemo(()=>ip(t),[t]),c=d[0]??[],m=d.slice(1),h=i.useRef(null),[p,g]=i.useState(null),f=p?m[p.row]:null,y=p&&f?op(n,c,f,p.row+1,p.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:h,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((w,$)=>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:w||l("rightSidebar.csvUnnamedColumn",{index:$+1})},`${w}:${$}`))]})}),e.jsx("tbody",{children:m.map((w,$)=>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:$+1}),c.map((E,_)=>{const L=p?.row===$&&p.column===_;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${L?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:j=>{const T=h.current?.getBoundingClientRect(),C=j.currentTarget.getBoundingClientRect();if(!T?.width||!T.height)return;const F=j.clientX||C.left+C.width/2,U=j.clientY||C.top+C.height/2;g({row:$,column:_,xPercent:(F-T.left)/T.width*100,yPercent:(U-T.top)/T.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:w[_]||" "})},`cell:${$}:${_}`)})]},`row:${$}`))})]})}),p&&y&&e.jsx(Ua,{anchor:{xPercent:p.xPercent,yPercent:p.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(y,`csv:${n}:${p.row+1}:${p.column+1}`),g(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:p&&f?l("rightSidebar.csvSelectedCell",{row:p.row+1,column:c[p.column]||p.column+1}):l("rightSidebar.csvPickHint",{rows:m.length,columns:c.length})})})]})}function zn(t,n){let s=t;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function cp(t,n){const s=JSON.parse(t),l=zn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(zn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(zn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:zn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=zn(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(h=>h&&typeof h=="object"&&h.name==="Default"):void 0,m=zn(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 dp(t,n){return`"KiCad项目标注: ${t} / 项: ${n.label} / 值: ${n.value}"`}function up({content:t,filePath:n,localState:s,onInsertAnnotation:l}){const{t:d}=gt(),c=i.useRef(null),[m,h]=i.useState(null),p=i.useMemo(()=>{try{return{items:cp(t,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[t,s]),g=m===null?null:p.items[m.index];return p.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:t}):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:p.items.map((f,y)=>e.jsxs("button",{type:"button",onClick:w=>{const $=c.current?.getBoundingClientRect(),E=w.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const _=w.clientX||E.left+E.width/2,L=w.clientY||E.top+E.height/2;h({index:y,xPercent:(_-$.left)/$.width*100,yPercent:(L-$.top)/$.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===y?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:f.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:f.value})]},f.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:t})]})]}),g&&m&&e.jsx(Ua,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(dp(n,g),`kicad-project:${n}:${g.label}`),h(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:g?`${g.label}: ${g.value}`:d("rightSidebar.kicadProjectPickHint")})})]})}const Ra="/api/terminal/fs/preview/",fp=8*1024*1024,hp=32*1024*1024,mp=128,pp="data:,";function St(t){throw new Error(t)}function Gi(t){return JSON.stringify(t).replace(/</g,"\\u003c")}async function Oc(t,n,s){let l="",d=0;for(const c of t.matchAll(n))l+=t.slice(d,c.index)+await s(c),d=c.index+c[0].length;return l+t.slice(d)}async function gp(t,n){const s=n.origin??location.origin,l=new URL(t,s);(l.origin!==s||!us(l.pathname)?.startsWith(Ra))&&St("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,m=[],h=K=>{!m.includes(K)&&m.length<20&&m.push(K)},p=new Set,g=[],f=new Set,y=new Map,w=new Map;let $=0,E=!1;const _=new Set,L=()=>{E=!0;for(const K of[..._])K();p.clear(),g.length=0};async function j(K){K.ok||St(`预览资源读取失败(${K.status})`);const X=K.body?.getReader(),A=[];let I=0;try{if(X)for(;;){const ee=await X.read();if(ee.done)break;I+=ee.value.byteLength,$+=ee.value.byteLength,(I>fp||$>hp)&&St("预览资源超出大小限制"),A.push(ee.value)}}catch(ee){throw await X?.cancel().catch(()=>{}),ee}finally{X?.releaseLock()}const V=new Uint8Array(I);let re=0;for(const ee of A)V.set(ee,re),re+=ee.length;return{bytes:V,type:K.headers.get("content-type")??"application/octet-stream",status:K.status}}let T=l,C;for(let K=0;K<4;K++){const X=await n.fetch(T.pathname+T.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(X.status)){C=X;break}const A=X.headers.get("location");await X.body?.cancel(),A||St("预览重定向缺少目标");const I=new URL(A,T);(I.origin!==s||!us(I.pathname)?.startsWith(Ra))&&St("预览重定向越出文件范围"),T=I}C||St("预览重定向次数过多");const F=us(T.pathname),U=F.slice(Ra.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||St("服务未提供有效的预览资源授权");const D=us(l.pathname).slice(Ra.length).split("/");/^[a-f0-9]{32}$/.test(D[0])&&D.shift(),D.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&St("预览重定向改变了文件范围");const a=F.endsWith("/")?F:F.slice(0,F.lastIndexOf("/")+1),k=new URL(T.pathname.endsWith("/")?T.pathname:T.pathname.slice(0,T.pathname.lastIndexOf("/")+1),s);function B(K,X){const A=new URL(K,X);return A.origin!==s?null:(us(A.pathname)?.startsWith(a)||St("已阻止预览访问目录之外的资源"),A)}function S(K){const X=new URL(K,c);(X.origin!==new URL(c).origin||!X.pathname.startsWith(new URL(c).pathname))&&St("已阻止预览访问服务接口或目录之外的资源");const A=X.pathname.slice(new URL(c).pathname.length)+X.search;return B(A,k)??St("预览资源无效")}function Y(K){const X=K.pathname+K.search,A=y.get(X);if(A)return A;if(E||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(y.size>=mp)return Promise.reject(new Error("预览资源数量超出限制"));const I=n.fetch(X,{signal:n.signal,redirect:"manual"}).then(j);return y.set(X,I),I}function le(K,X){E&&St("预览已关闭");const A=`termdock-resource-${d}-${g.length}`;return g.push({token:A,data:K,type:X}),p.add(A),A}async function ie(K,X,A,I=new Set){if(!K||K.startsWith("#")||/^data:(?:image|font)\//i.test(K)&&A==="resource")return K;try{const V=B(K,X);if(!V){const xe=new URL(K,X);return(xe.protocol!=="https:"||xe.username||xe.password||xe.origin===new URL(c).origin)&&St("已阻止不安全的外部资源"),f.add(xe.origin),xe.href}const re=`${A}:${V.href}`;(I.has(re)||I.size>=8)&&St("预览资源存在循环或过深引用");const ee=w.get(re);if(ee)return ee;const ge=new Set(I);ge.add(re);const O=(async()=>{const xe=await Y(V);return A==="css"?le(await ue(new TextDecoder().decode(xe.bytes),V,ge),"text/css"):A==="script"?le(xe.bytes,"text/javascript"):le(xe.bytes,xe.type)})();return w.set(re,O),await O}catch(V){return h(V instanceof Error?V.message:"部分预览资源未能加载"),pp}}async function ue(K,X,A){return K=await Oc(K,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async I=>`@import url("${await ie(I[1],X,"css",A)}")${I[2]};`),Oc(K,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async I=>{const V=(I[1]??I[2]??I[3]).trim();return p.has(V)?I[0]:`url("${await ie(V,X,"resource",A)}")`})}try{const K=await j(C),X=new DOMParser().parseFromString(new TextDecoder().decode(K.bytes),"text/html");X.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(O=>O.remove());for(const O of X.querySelectorAll("*")){if(O.removeAttribute("ping"),O.removeAttribute("srcdoc"),O.hasAttribute("style")&&O.setAttribute("style",await ue(O.getAttribute("style"),T,new Set)),O.tagName==="STYLE"&&(O.textContent=await ue(O.textContent??"",T,new Set)),O.tagName==="FORM"&&(O.removeAttribute("action"),O.removeAttribute("method")),O.tagName==="A"||O.tagName==="AREA"){const xe=O.getAttribute("href");xe&&!xe.startsWith("#")&&(O.removeAttribute("href"),O.setAttribute("title","预览中的页面跳转已禁用"))}for(const xe of["action","formaction","data","manifest"])O.removeAttribute(xe);if(O.tagName==="SCRIPT"&&O.getAttribute("type")==="module"){O.remove(),h("模块脚本的动态依赖暂不支持安全预览");continue}if(O.tagName==="LINK"){const xe=(O.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(xe)){O.remove();continue}const W=O.getAttribute("href");W&&O.setAttribute("href",await ie(W,T,xe==="stylesheet"?"css":"resource"))}if(O.hasAttribute("src")&&O.setAttribute("src",await ie(O.getAttribute("src"),T,O.tagName==="SCRIPT"?"script":"resource")),O.hasAttribute("poster")&&O.setAttribute("poster",await ie(O.getAttribute("poster"),T,"resource")),O.hasAttribute("srcset")){const xe=O.getAttribute("srcset");/data:/i.test(xe)?(O.removeAttribute("srcset"),h("混合内嵌图片候选暂不支持安全预览")):O.setAttribute("srcset",(await Promise.all(xe.split(",").map(async W=>{const[pe,...je]=W.trim().split(/\s+/);return`${await ie(pe,T,"resource")} ${je.join(" ")}`}))).join(", "))}O.setAttribute("referrerpolicy","no-referrer"),O.removeAttribute("integrity"),O.removeAttribute("crossorigin")}const A=[...f].join(" "),I=X.createElement("meta");I.httpEquiv="Content-Security-Policy",I.content=`default-src 'none'; script-src 'unsafe-inline' blob: ${A}; style-src 'unsafe-inline' blob: ${A}; img-src blob: data: ${A}; font-src blob: data: ${A}; media-src blob: data: ${A}; connect-src ${A||"'none'"}; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const V=X.createElement("base");V.href=c;const re=X.createElement("meta");re.name="referrer",re.content="no-referrer";const ee=X.createElement("script");ee.textContent=xp(d,c,[...f]),X.head.prepend(I,re,V,ee);const ge=`<!doctype html>
|
|
15
|
-
`+X.documentElement.outerHTML;return{html:ge,shellUrl:`/preview-shell.html#${d}`,errors:m,attach(O,xe){const W=new Set,pe=Ae=>{if(Ae.source!==O.contentWindow||Ae.data?.capability!==d)return;if(Ae.data.type==="preview-ready"){O.contentWindow?.postMessage({type:"preview-init",capability:d,html:ge,resources:g},"*");return}if(Ae.data.type==="preview-error"){xe("部分动态内容被安全预览限制");return}if(Ae.data.type!=="preview-fetch"||Ae.ports.length!==1)return;const _e=Ae.ports[0];if(W.size>=8||!["GET","HEAD"].includes(Ae.data.method)){_e.postMessage({error:"预览仅允许读取已授权目录资源"}),_e.close();return}W.add(_e),(async()=>{const Rt=S(String(Ae.data.url)),fe=await Y(Rt);if(!W.has(_e)||E)return;const ne=Ae.data.method==="HEAD"?new Uint8Array:fe.bytes.slice();_e.postMessage({status:fe.status,headers:{"content-type":fe.type},data:ne.buffer},[ne.buffer])})().catch(()=>{_e.postMessage({error:"预览资源不在授权范围或无法加载"}),xe("部分动态资源不可用或超出预览目录")}).finally(()=>{W.delete(_e),_e.close()})};window.addEventListener("message",pe);const je=()=>{window.removeEventListener("message",pe);for(const Ae of W)Ae.close();W.clear(),_.delete(je)};return _.add(je),je},dispose:L}}catch(K){throw L(),K}}function xp(t,n,s){return`(() => {
|
|
16
|
-
const capability=${Gi(t)}, base=${Gi(n)}, external=new Set(${Gi(s)});
|
|
17
|
-
const report=()=>parent.postMessage({type:'preview-error',capability},'*');
|
|
18
|
-
const nativeFetch=window.fetch.bind(window);
|
|
19
|
-
Object.defineProperty(window,'fetch',{configurable:false,writable:false,value:async(input,init={})=>{
|
|
20
|
-
const url=new URL(typeof input==='string'?input:input.url||String(input),base);
|
|
21
|
-
const method=String(init.method||(input&&input.method)||'GET').toUpperCase();
|
|
22
|
-
if(!['GET','HEAD'].includes(method)){report();throw new Error('Preview is read-only');}
|
|
23
|
-
if(external.has(url.origin))return nativeFetch(url.href,{...init,method,credentials:'omit',referrerPolicy:'no-referrer'});
|
|
24
|
-
if(url.origin!==new URL(base).origin||!url.pathname.startsWith(new URL(base).pathname)){report();throw new Error('Outside preview scope');}
|
|
25
|
-
return new Promise((resolve,reject)=>{
|
|
26
|
-
const channel=new MessageChannel();const timer=setTimeout(()=>{channel.port1.close();report();reject(new Error('Preview resource timeout'));},15000);
|
|
27
|
-
channel.port1.onmessage=e=>{clearTimeout(timer);channel.port1.close();if(e.data.error){report();reject(new Error(e.data.error));}else resolve(new Response(method==='HEAD'?null:e.data.data,{status:e.data.status,headers:e.data.headers}));};
|
|
28
|
-
parent.postMessage({type:'preview-fetch',capability,url:url.href,method},'*',[channel.port2]);
|
|
29
|
-
});
|
|
30
|
-
}});
|
|
31
|
-
for(const name of ['XMLHttpRequest','WebSocket','EventSource','Worker','SharedWorker'])Object.defineProperty(window,name,{configurable:false,writable:false,value:function(){report();throw new Error(name+' is unavailable in secure preview');}});
|
|
32
|
-
Object.defineProperty(window,'open',{configurable:false,writable:false,value:()=>{report();return null;}});
|
|
33
|
-
document.addEventListener('submit',e=>{e.preventDefault();report();},true);
|
|
34
|
-
document.addEventListener('click',e=>{const a=e.target.closest&&e.target.closest('a,area');if(a&&a.getAttribute('href')&&!a.getAttribute('href').startsWith('#')){e.preventDefault();report();}},true);
|
|
35
|
-
window.addEventListener('securitypolicyviolation',report);
|
|
36
|
-
window.addEventListener('error',report,true);
|
|
37
|
-
window.addEventListener('unhandledrejection',report);
|
|
38
|
-
})();`}const bp=i.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const m=i.useRef(null),h=i.useRef(null),[p,g]=i.useState(),[f,y]=i.useState("");i.useEffect(()=>{const C=new AbortController;let F;return g(void 0),y(""),(async()=>{const U=await qf();if(F=await gp(n,{fetch:(D,a)=>U.fetch(D,a),signal:C.signal}),C.signal.aborted){F.dispose();return}g(F),F.errors.length&&y(F.errors.join(";"))})().catch(U=>{C.signal.aborted||y(U instanceof Error?U.message:"安全预览加载失败")}),()=>{C.abort(),F?.dispose()}},[n]),i.useEffect(()=>{if(!(!p||!h.current))return p.attach(h.current,y)},[p]);const[w,$]=i.useState(!1),[E,_]=i.useState(!1),L=w||E;i.useEffect(()=>{d?.(L)},[L,d]),i.useEffect(()=>{const C=()=>{$(document.fullscreenElement===m.current)};return document.addEventListener("fullscreenchange",C),()=>document.removeEventListener("fullscreenchange",C)},[]),i.useEffect(()=>{if(!E)return;const C=F=>{F.key==="Escape"&&_(!1)};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[E]);const j=i.useCallback(async()=>{const C=m.current;if(C){if(E){_(!1);return}if(document.fullscreenElement===C){await document.exitFullscreen();return}if(C.requestFullscreen&&document.fullscreenEnabled!==!1)try{await C.requestFullscreen();return}catch{}_(!0)}},[E]);i.useImperativeHandle(c,()=>({toggleFullscreen:j}),[j]);const T=e.jsxs("div",{ref:m,"data-html-preview-frame":!0,className:L?"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:[L&&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:()=>{j()},"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(Rd,{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 E?Wr.createPortal(T,document.body):T}),_d="termdock-file-search-match",wo="termdock-file-search-current";function vp(t){const n=t.metaKey||t.ctrlKey,s=t.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||t.key==="F3"?t.shiftKey?"previous":"next":t.key==="Escape"?"close":null}function wp(t){return t.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function yp(t,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const m=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=m.nextNode();f;f=m.nextNode()){if(!(f instanceof Text)||!f.data)continue;const y=wp(f);if(!y)continue;c&&c!==y&&(d+=`
|
|
39
|
-
`);const w=d.length;d+=f.data,l.push({node:f,start:w,end:d.length,group:y}),c=y}const h=d.toLocaleLowerCase(),p=[];let g=0;for(;g<=h.length-s.length;){const f=h.indexOf(s,g);if(f<0)break;const y=f+s.length,w=l.find(E=>E.start<=f&&E.end>f),$=l.find(E=>E.start<y&&E.end>=y);if(w&&$&&w.group===$.group){const E=document.createRange();E.setStart(w.node,f-w.start),E.setEnd($.node,y-$.start),p.push(E)}g=f+Math.max(s.length,1)}return p}function Id(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Na(){const t=Id();t?.delete(_d),t?.delete(wo)}function Wc(t,n){const s=Id();if(!s||typeof Highlight>"u")return;s.set(_d,new Highlight(...t));const l=t[n];l?s.set(wo,new Highlight(l)):s.delete(wo)}function Gc(t){t?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function kp(t){return Array.from(new Set(t.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Sp(t,n){const s=n.trim();return!s||s==="."?t:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${t.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function jp(t,n){if(n===t)return".";const s=`${t.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Bd(t,n,s){return n?t:Wr.createPortal(t,s)}const Po="termdock:right-sidebar:file-tree-scroll:v1",Lo="termdock:right-sidebar:file-preview-reading-state:v1",xs="termdock:right-sidebar:file-tree-width:v1",zd="termdock:right-sidebar:markdown-view-mode:v1",Hd="termdock:right-sidebar:diff-change-list-mode:v1",Od="termdock:right-sidebar:diff-wrap:v1",Wd="termdock:diff-viewer:view-type:v1",Gd="termdock:right-sidebar:file-search-mode:v1",Ui="termdock:right-sidebar:collapsed-git-repo-groups:v1",Uc="termdock:right-sidebar:collapsed-diff-directories:v1",Ki="termdock:right-sidebar:branch-audit-module-open:v1",Ud="termdock:right-sidebar:branch-audit-module:v1",Rp=150,Kd="termdock:right-sidebar:active-git-repo:v1",Kc="termdock:right-sidebar:context-draft-enabled:v1",qc="termdock:right-sidebar:context-draft-collapsed:v1",Vc="termdock:right-sidebar:context-draft-auto-collapse:v1",qi="termdock:right-sidebar:context-draft-text:v1",Np=300,Cp=20,Ap=120,$p=250,Ep=250,Mp=120,Tp=700,Vi=600,Yc=[2e3,5e3,15e3,3e4],Pp=320,Lp=500,Fp=20,Dp=12e3,yo=300,Xc=240,_p=560,qd="border-r px-2 py-1.5 sm:px-3 sm:py-2",Ia="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Vd=`${qd} border-b border-border/15 font-semibold last:border-r-0`,Yd=`${qd} border-border/10 align-top text-muted-foreground last:border-r-0`,Fo="termdock-file-preview-horizontal-scroll",Zc=i.lazy(()=>js(()=>import("./ModelPreview-CN8xsiGC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Xd=`${Fo} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Zd(t,n,s){return t&&!n?"unified":s}const Ip=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Bp(t){return t==="preview"||t==="source"}function zp(t){return t==="list"||t==="tree"||t==="ai"}function Qc(){return Ze(zd,Bp)??"preview"}function Hp(){return Ze(Hd,zp)??"tree"}function bs(t){return typeof t=="boolean"}function Op(t){return typeof t=="string"}function Wp(){return Ze(Od,bs)??!0}function Gp(t){return t==="unified"||t==="split"}function Up(){return Ze(Wd,Gp)??"unified"}function Kp(t){return t==="name"||t==="content"||t==="regex"}function qp(){return Ze(Gd,Kp)??"name"}function Qd(t){return t.repositories??(t.context?.root?[{id:t.context.root,root:t.context.root,relativeRoot:".",name:ct(t.context.root)||t.context.root,depth:0,nested:!1,available:t.available,files:t.files,context:t.context,error:t.error}]:[])}function Vp(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(n=>n===null||typeof n=="string")}function Jd(){return Ze(Kd,Vp)??{}}function Jc(t){if(!t)return;const n=Jd();return Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}function Yi(t,n){t&&mt(Kd,{...Jd(),[t]:n})}function Yp(t,n){if(!n)return null;const s=new Set((t.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(t.repositories??[]).some(l=>l.root===n)?n:null}function ko(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function ed(t){const n=Ze(t,ko);return n?new Set(n):new Set}function Xi(t,n){mt(t,[...n])}function Xp(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;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 Zp(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;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||ko(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Xp))&&(n.commits===void 0||ko(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 Qp(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.key=="string"&&Zp(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function Jp(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).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(Qp))&&(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.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function td(){return Ze(Ud,Jp)??{}}function rd(t){return[t.repoRoot,t.baseRef,t.branchName??"",t.headRef??"",t.diffFingerprint??""].join("\0")}function nd(t){const n=t?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function eu(t,n){const s=t?.trim(),l=n?.trim();return!s||!l?!1:s===l||nd(s)===nd(l)}function sd(t){const n=t?.branch??null;return[t?.upstream,...t?.remoteBranches??[],...t?.branches??[]].find(l=>l&&!eu(l,n))??""}function So(t,n){const s=Math.max(Xc,n-320),l=Math.min(_p,s);return Math.min(l,Math.max(Xc,t))}function eg(t){return typeof t=="number"&&Number.isFinite(t)}function tg(t){return So(Ze(xs,eg)??yo,t)}function tu(t){const n=t.split(/[\\/]/).pop()??t,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function ms(t){return Ip.has(tu(t))}function ru(t){const n=t.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function jo(t){const n=t.trim();return/^#{1,6}\s+/.test(n)||ru(t)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function rg(t){const n=t.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const nu=i.createContext(null);function Fa(t){return t.trim().replace(/\s+/g," ").toLowerCase()}function su(t){return t.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function au(t){return t.replace(/\s+#+\s*$/,"").trim()}function Ro(t,n){const l=su(t).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 ad(t){return su(t)||t.trim()}function Ba(t){const n=t.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Co(n[2]);return s?{id:Fa(n[1]),definition:{href:s.href,title:s.title}}:null}function ng(t){const n=new Map;for(const s of t){const l=Ba(s);l&&n.set(l.id,l.definition)}return n}function iu(t){return t.trim().toLowerCase()}function ou(t){const n=t.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:iu(n[1]),text:n[2]}:null}function sg(t){const n=new Map;let s=null;for(const l of t){const d=ou(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 lu(t){const n=new Set;let s=!1;return t.forEach((l,d)=>{if(ou(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function ag(t){const n=[...t];let s=0;const l=t[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<t.length&&t[s].trim()!==l;)n[s]="",s+=1;s<t.length&&(n[s]="",s+=1)}for(;s<t.length;){const d=t[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<t.length&&!t[s].includes("-->");)n[s]="",s+=1;s<t.length&&(n[s]="")}s+=1;continue}s+=1}return n}function cu(t){const n=t.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function ys(t){const n=t.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 du(t,n,s){const l=t.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):"",h=c.split("?",1)[0];if(!h)return null;let p,g=null;try{p=decodeURIComponent(h),g=m?decodeURIComponent(m):null}catch{return null}const f=s?ys(s):null;let y;if(p.startsWith("/")){const w=f&&(p===f||p.startsWith(`${f}/`));y=ys(f&&!w?`${f}/${p.slice(1)}`:p)}else{if(!n)return null;y=ys(`${cu(n)}/${p}`)}return f&&y!==f&&!y.startsWith(`${f}/`)?null:{path:y,fragment:g,directory:/\/$/.test(h)}}function ig(t,n,s){const l=t.trim();if(!l||/^(?:javascript|data):/i.test(l))return null;if(/^https?:\/\//i.test(l))return l;if(!xd(l.split(/[?#]/,1)[0]))return null;let d;if(l.startsWith("/")){const c=s&&(l===s||l.startsWith(`${s}/`));d=ys(s&&!c?`${s}/${l.slice(1)}`:l)}else{if(!n)return null;d=ys(`${cu(n)}/${l}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(d)}`}const No=128,og=360,Zi=480;function Ka(t){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(t))}catch{return!1}}function uu(t,n,s,l){if(!n||!s)return null;let d,c;return Ka(t)?(c=Math.min(Math.max(s,No),og),d=n*c/s):(d=n,c=s),l>0&&d>l&&(c=c*l/d,d=l),c>Zi&&(d=d*Zi/c,c=Zi),{width:Math.max(1,Math.round(d)),height:Math.max(1,Math.round(c))}}function lg(t){if(!t.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(t.slice(t.indexOf("?"))).get("path")}catch{return null}}function fu(t){const n=lg(t),s=ae(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${t}&v=${s}`:t}function cg({src:t,alt:n,title:s}){const l=Ka(t),d=fu(t),c=i.useRef(null),[m,h]=i.useState(!1),[p,g]=i.useState(0),[f,y]=i.useState({status:"loading"}),[w,$]=i.useState(null);i.useLayoutEffect(()=>{const L=c.current,j=L?.parentElement?.parentElement??L?.parentElement;if(!j)return;const T=()=>g(j.clientWidth);if(T(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(T);return C.observe(j),()=>C.disconnect()},[]),i.useEffect(()=>{if(m)return;const L=c.current;if(!L||typeof IntersectionObserver>"u"){h(!0);return}const j=new IntersectionObserver(T=>{T.some(C=>C.isIntersecting)&&(h(!0),j.disconnect())},{rootMargin:"400px"});return j.observe(L),()=>j.disconnect()},[m]),i.useEffect(()=>{if(!m)return;const L=new AbortController;let j=null;y({status:"loading"});const T=window.setTimeout(()=>{L.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Sh(d,{signal:L.signal}).then(async C=>{if(!C.ok)throw new Error(`HTTP ${C.status}`);const F=Number(C.headers.get("X-Image-Width"))||0,U=Number(C.headers.get("X-Image-Height"))||0;return{blob:await C.blob(),width:F,height:U}}).then(({blob:C,width:F,height:U})=>{L.signal.aborted||(j=URL.createObjectURL(C),F>0&&U>0&&$({width:F,height:U}),y({status:"ready",objectUrl:j}))}).catch(()=>{const C=L.signal.reason;L.signal.aborted&&!(C instanceof DOMException&&C.name==="TimeoutError")||y({status:"fallback"})}).finally(()=>{window.clearTimeout(T)}),()=>{window.clearTimeout(T),L.abort(),j&&URL.revokeObjectURL(j)}},[m,d]);const E=uu(t,w?.width??0,w?.height??0,p),_=E??{width:No*2,height:No};return e.jsx("div",{ref:c,className:"block max-w-full",style:E?{width:E.width,height:E.height}:void 0,children:f.status==="ready"?e.jsx("img",{src:f.objectUrl,alt:n,title:s,decoding:"async",className:`${l?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:E?{width:E.width,height:E.height}:void 0,onLoad:L=>{if(w)return;const j=L.currentTarget;j.naturalWidth>0&&j.naturalHeight>0&&$({width:j.naturalWidth,height:j.naturalHeight})}}):f.status==="fallback"?e.jsx("img",{src:d,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:E?{width:E.width,height:E.height}:void 0,onLoad:L=>{if(w)return;const j=L.currentTarget;j.naturalWidth>0&&j.naturalHeight>0&&$({width:j.naturalWidth,height:j.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:_.width,height:_.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Qi(t,n,s,l,d){const c=ig(s,d.markdownFilePath,d.rootPath);if(!c)return``;const m=d.images.length;d.images.push({kind:"image",src:c,alt:n,title:l});const h=e.jsx(cg,{src:c,alt:n,title:l});return d.onImageOpen?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?.(m)},children:h},t):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:h},t)}function Ji(t){let n=t,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function id(t){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(t)}function Co(t){const n=t.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 hu="",dg=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function ug(t){return t.replace(dg,(n,s)=>`${hu}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function od(t){return t.replace(new RegExp(`${hu}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function fg(t){const n=t.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const mu={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 Ca=null;function pu(){return Ca||(Ca=js(()=>import("./purify.es-4eNOHKSq.js"),[]).then(t=>t.default??t).catch(t=>{throw Ca=null,t})),Ca}function gu({html:t}){const{t:n}=gt(),[s,l]=i.useState(null);return i.useEffect(()=>{let d=!1;return l(null),pu().then(c=>{d||l(c.sanitize(t,mu))}).catch(()=>{d||l("")}),()=>{d=!0}},[t]),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 hg({html:t}){const[n,s]=i.useState(null);return i.useEffect(()=>{let l=!1;return s(null),pu().then(d=>{l||s(d.sanitize(t,mu))}).catch(()=>{l||s("")}),()=>{l=!0}},[t]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):t}function xu(t){const n=t.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(t)}}let Aa=null;function mg(){return Aa||(Aa=Promise.all([js(()=>import("./katex-DnlPpQZa.js"),[]),js(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([t])=>t.default??t).catch(t=>{throw Aa=null,t})),Aa}function Ns({tex:t,display:n=!1}){const[s,l]=i.useState(null),[d,c]=i.useState(!1);if(i.useEffect(()=>{let h=!1;return l(null),c(!1),mg().then(p=>{h||l(p.renderToString(t,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{h||c(!0)}),()=>{h=!0}},[n,t]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${t}$$`:`$${t}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":t});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 pg(t,n,s){if(/^<br\s*\/?>$/i.test(t))return e.jsx("br",{},n);const l=t.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(t)?e.jsx(hg,{html:t},n):null;const d=l[1].toLowerCase(),c=Qe(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 Qe(t,n,s=!0,l){const d=ug(t),c=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\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+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,m=[];let h=0,p;for(;(p=c.exec(d))!==null;){p.index>h&&m.push(od(d.slice(h,p.index)));const g=p[0],f=`${n}-${p.index}`,y=g.startsWith("<")?pg(g,f,l):null;if(y)m.push(y);else if(g.startsWith("\\(")&&g.endsWith("\\)"))m.push(e.jsx(Ns,{tex:g.slice(2,-2)},f));else if(g.startsWith("$")&&g.endsWith("$"))m.push(e.jsx(Ns,{tex:g.slice(1,-1)},f));else if(g.startsWith("`")){const w=g.match(/^`+/)?.[0].length??1;m.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:fg(g.slice(w,-w))},f))}else if(g.startsWith("~~"))m.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:Qe(g.slice(2,-2),`${f}-del`,s,l)},f));else if(g.startsWith("**")||g.startsWith("__"))m.push(e.jsx("strong",{className:"font-semibold text-foreground",children:Qe(g.slice(2,-2),`${f}-strong`,s,l)},f));else if(g.startsWith("*")||g.startsWith("_"))m.push(e.jsx("em",{className:"italic",children:Qe(g.slice(1,-1),`${f}-em`,s,l)},f));else if(g.startsWith("![")){const w=g.match(/^!\[([^\]]*)\]\((.*)\)$/),$=g.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),E=g.match(/^!\[([^\]]+)\]$/);if(w){const _=Co(w[2]);m.push(_?Qi(f,w[1],_.href,_.title,l):g)}else if($){const _=$[2]||$[1],L=l.referenceDefinitions.get(Fa(_));m.push(L?Qi(f,$[1],L.href,L.title,l):g)}else if(E){const _=l.referenceDefinitions.get(Fa(E[1]));m.push(_?Qi(f,E[1],_.href,_.title,l):g)}else m.push(g)}else if(g.startsWith("[^")){const w=iu(g.slice(2,-1)),$=l.footnoteDefinitions.get(w);m.push($?e.jsx("sup",{id:`fnref-${$.id}`,title:$.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${$.id}`,className:"text-primary no-underline",children:$.index})},f):g)}else if(g.startsWith("<http")){const w=g.slice(1,-1);m.push(e.jsx("a",{href:w,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f))}else if(g.startsWith("<")&&g.endsWith(">")&&id(g.slice(1,-1))){const w=g.slice(1,-1);m.push(e.jsx("a",{href:`mailto:${w}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f))}else if(id(Ji(g).linkText)){const{linkText:w,suffix:$}=Ji(g);m.push(e.jsx("a",{href:`mailto:${w}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f)),$&&m.push($)}else if(g.startsWith("http")||g.startsWith("www.")){const{linkText:w,suffix:$}=Ji(g),E=w.startsWith("www.")?`https://${w}`:w;m.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:w},f)),$&&m.push($)}else{const w=g.match(/^\[([^\]]+)\]\((.*)\)$/),$=g.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),E=g.match(/^\[([^\]]+)\]$/),_=$?$[2]||$[1]:E?.[1]??null,L=_?l.referenceDefinitions.get(Fa(_)):null,j=w?Co(w[2]):null,T=j?.href??L?.href??null,C=T?rg(T):null,F=w?.[1]??$?.[1]??E?.[1]??"";m.push(C?e.jsx("a",{href:C,title:j?.title??L?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:Qe(F,`${f}-link`,s,l)},f):g)}h=c.lastIndex}return h<d.length&&m.push(od(d.slice(h))),m.length>0?m:[t]}function bu(t){return/(?: {2,}|\\)$/.test(t)}function vu(t){return t.replace(/(?: {2,}|\\)$/,"")}function za(t){return/^(?: {4}|\t)/.test(t)}function wu(t){return t.startsWith(" ")?t.slice(1):t.replace(/^ {4}/,"")}function yu(t,n,s){const l=[];return t.forEach((d,c)=>{const m=bu(d);l.push(...Qe(vu(d),`${n}-${c}`,!0,s)),c<t.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Ao(t,n,s){const l=[],d=[];return t.forEach((c,m)=>{d.push(bu(c)),l.push(Qe(vu(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function $o(t,n,s,l,d){const c=[];return t.forEach((m,h)=>{const p=s[h]??0,g=!!(d&&p>=d.start&&p<=d.end);c.push(e.jsx("span",{"data-md-ref-start":p,"data-md-ref-end":p,"data-selected":g?"true":void 0,children:m},`${l}-ref-${h}`)),h<t.length-1&&c.push(n[h]?e.jsx("br",{},`${l}-${h}-br`):" ")}),c}function Cs(t){const n=t.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,m=0;for(let h=0;h<n.length;h+=1){const p=n[h];if(d){l+=p,d=!1;continue}if(p==="\\"){d=!0;continue}if(p==="`"){const g=h;for(;h+1<n.length&&n[h+1]==="`";)h+=1;const f=h-g+1;l+="`".repeat(f),c===0?c=f:c===f&&(c=0);continue}if(c===0&&p==="["?m+=1:c===0&&p==="]"&&m>0&&(m-=1),p==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=p}return d&&(l+="\\"),s.push(l.trim()),s}function ku(t){return Cs(t).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Ha(t){return t==="center"?"text-center":t==="right"?"text-right":"text-left"}function Oa(t){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(t.trim())}function Su(t,n){return t>96||t>44&&n>.35}function qa(t){return(t.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function As(t){const n=t.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 Do(t,n,s,l,d,c=new Set){const m=[],h=[];let p=n;for(;p<t.length;){const g=t[p];if(d&&(Ba(g)||c.has(p))){p+=1;continue}const f=As(g),y=qa(g);if(!f){if(y>s&&h.length>0){([...h].reverse().find(_=>_.indent<y)?.item??h[h.length-1].item).paragraphs.push(g.trim());for(const _ of h)_.item.lineEnd=p+1;p+=1;continue}break}if(y<s||y===s&&f.ordered!==l)break;const w={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:p+1,lineEnd:p+1};for(;h.length>0&&h[h.length-1].indent>=y;)h.pop();const $=h[h.length-1]?.item??null;$?$.children.push(w):m.push(w),h.push({indent:y,item:w});for(const E of h)E.item.lineEnd=p+1;p+=1}return{items:m,nextIndex:p}}function gg(t){const n=t.find(l=>As(l));if(!n)return[];const s=As(n);return s?Do(t,0,qa(n),s.ordered,!0,lu(t)).items:[]}function _o(t,n,s,l=0){return t.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,Qe(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((h,p)=>e.jsx("p",{children:Qe(h,`li-${n}-${c}-p-${p}`,!0,s)},`paragraph-${p}`))})]}),groups:xg(d.children,`${n}-${c}`,s,l)}})}function xg(t,n,s,l=0){const d=[];for(const c of t){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:_o(c.items,`${n}-g${m}`,s,l)}))}function Io(t,n){return t.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&&bg(s.groups,n)]},s.key)})}function bg(t,n){return t.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:Io(s.items,n)},`nested-${l}`)})}function vg(t){const n=Array.from(t.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:t.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[Qe(s.text,`footnote-${s.id}`,!0,t)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":t.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function wg(t,n,s,l){const d=[];let c=0;const m=h=>l?.[h]??h+1;for(;c<t.length;){const h=t[c],p=h.trim();if(!p){c+=1;continue}if(/^<details>\s*$/i.test(p)){const j=c;let T="Details";const C=[];for(c+=1;c<t.length&&!/^<\/details>\s*$/i.test(t[c].trim());){const F=t[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);F?T=F[1].trim()||T:C.push(t[c].trimStart()),c+=1}c<t.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:Qe(T,`${n}-details-${j}-summary`,!0,s)}),C.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:yu(C,`${n}-details-${j}`,s)})]},`${n}-details-${j}`)});continue}const g=xu(h);if(g){const j=[h],T=c;for(c+=1;c<t.length&&!g.selfContained&&!new RegExp(`</${g.tag}>`,"i").test(t[c]);)j.push(t[c]),c+=1;c<t.length&&!g.selfContained&&(j.push(t[c]),c+=1),d.push({kind:"static",node:e.jsx(gu,{html:j.join(`
|
|
40
|
-
`)},`${n}-html-${T}`)});continue}const f=p.match(/^(```|~~~)\s*(.*)$/);if(f){const j=[],T=f[1],C=f[2]?.trim(),F=c;for(c+=1;c<t.length&&!t[c].trim().startsWith(T);)j.push(t[c]),c+=1;c<t.length&&(c+=1),C.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(Ru,{code:j.join(`
|
|
41
|
-
`),blockKey:`${n}-code-${F}`},`${n}-code-${F}`)}):["math","latex","tex"].includes(C.toLowerCase())?d.push({kind:"static",node:e.jsx(Ns,{tex:j.join(`
|
|
42
|
-
`),display:!0},`${n}-code-${F}`)}):d.push({kind:"code",key:`${n}-code-${F}`,code:j.join(`
|
|
43
|
-
`),lang:C,blockKey:`${n}-code-${F}`,codeStartLine:m(F)+1});continue}if(za(h)){const j=[],T=c;for(;c<t.length&&(za(t[c])||!t[c].trim());)j.push(t[c].trim()?wu(t[c]):""),c+=1;d.push({kind:"code",key:`${n}-indented-code-${T}`,code:j.join(`
|
|
44
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${T}`,codeStartLine:m(T)});continue}const y=p.match(/^(#{1,6})\s+(.+)$/);if(y){const T=`h${Math.min(6,y[1].length+1)}`,C=au(y[2]),F=Ro(C,s);d.push({kind:"static",node:e.jsx(T,{id:F,className:"scroll-mt-16 font-semibold text-foreground",children:Qe(C,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<t.length&&h.includes("|")&&Oa(t[c+1])){const j=Cs(h),T=ku(t[c+1]),C=[],F=c;for(c+=2;c<t.length&&t[c].includes("|")&&t[c].trim();)C.push(Cs(t[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:Xd,"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:j.map((U,D)=>e.jsx("th",{className:`${Vd} ${Ha(T[D]??null)}`,children:e.jsx("div",{className:Ia,children:Qe(U,`${n}-th-${F}-${D}`,!0,s)})},`h-${D}`))})}),e.jsx("tbody",{children:C.map((U,D)=>e.jsx("tr",{className:"border-t border-border/10",children:j.map((a,k)=>e.jsx("td",{className:`${Yd} ${Ha(T[k]??null)}`,children:e.jsx("div",{className:Ia,children:Qe(U[k]??"",`${n}-td-${F}-${D}-${k}`,!0,s)})},`c-${k}`))},`r-${D}`))})]})},`${n}-table-${F}`)});continue}const w=As(h);if(w){const j=w.ordered,T=qa(h),C=w.start,F=c,U=Do(t,c,T,j,!1);c=U.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${F}`,ordered:j,start:j?C:void 0,renders:_o(U.items,`${n}-list-${F}`,s,m(0)-1)});continue}const $=[h.trimStart()],E=[m(c)],_=c;for(c+=1;c<t.length&&t[c].trim()&&!jo(t[c])&&!(c+1<t.length&&t[c].includes("|")&&Oa(t[c+1]));)$.push(t[c].trimStart()),E.push(m(c)),c+=1;const L=Ao($,`${n}-p-${_}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${_}`,perLine:L.perLine,hardBreaks:L.hardBreaks,lineNums:E})}return d}function yg(t,n){return t.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:$o(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:Io(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Wa,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let $a=null,ld=!1;const Ea=16,ju=192;function kg(){return $a||($a=js(()=>import("./mermaid.core-DvAY78t_.js").then(t=>t.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(t=>t.default??t).catch(t=>{throw $a=null,t})),$a}function Sg(t){ld||(t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),ld=!0)}function jg(t){const n=t.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return t;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 t;const m=Math.max(ju,Math.ceil(d)),h=Math.ceil(m/d*c);return t.replace(/<svg\b([^>]*)>/i,(p,g)=>`<svg${g.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${m}" height="${h}">`)}function Rg(t){const n=t?.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-Ea,d=s.y-Ea,c=s.width+Ea*2,m=s.height+Ea*2,h=Math.max(ju,Math.ceil(c)),p=Math.ceil(h/c*m);n.setAttribute("viewBox",`${l} ${d} ${c} ${m}`),n.setAttribute("width",String(h)),n.setAttribute("height",String(p)),n.removeAttribute("style")}function Ng(t){const n=t.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return Cd(`code.${s}`)??s}function Ru({code:t,blockKey:n}){const{t:s}=gt(),[l,d]=i.useState(null),[c,m]=i.useState(!1),h=i.useRef(null),p=i.useContext(nu);i.useEffect(()=>{let f=!1;return d(null),m(!1),kg().then(async y=>{Sg(y);const w=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:$}=await y.render(w,t);f||d(jg($))}).catch(()=>{f||m(!0)}),()=>{f=!0}},[n,t]),i.useLayoutEffect(()=>{l&&Rg(h.current)},[l]);const g=i.useCallback(()=>{const f=h.current?.querySelector("svg")?.outerHTML??l;f&&p?.(f)},[p,l]);return c?e.jsx(Wa,{code:t,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:f=>{f.stopPropagation(),g()},children:e.jsx("span",{ref:h,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 Wa({code:t,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Ng(n),[m,h]=i.useState(null);i.useEffect(()=>{if(!c||!Ad(t)){h(null);return}let g=!1;return $d().then(f=>{if(g||!f.registered(c)){g||h(null);return}try{h(Md(f,t,c))}catch{g||h(null)}}).catch(()=>{g||h(null)}),()=>{g=!0}},[s,t,c]);const p=m??(t||" ").split(`
|
|
45
|
-
`).map(g=>[g||" "]);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:`${Fo} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:p.map((g,f)=>{const y=l!=null?l+f:null,w=!!(d&&y!=null&&y>=d.start&&y<=d.end);return e.jsxs("span",{"data-md-ref-start":y??void 0,"data-md-ref-end":y??void 0,"data-selected":w?"true":void 0,children:[g,f<p.length-1?`
|
|
46
|
-
`:null]},`${s}-line-${f}`)})})})]})}function Bo(t,n,s,l,d){t=ag(t);const c=ng(t),m=lu(t),h=[],p={markdownFilePath:n,rootPath:s,referenceDefinitions:c,footnoteDefinitions:sg(t),headingSlugCounts:new Map,images:h,onImageOpen:l,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(w=>`Back to footnote ${w}`)},g=[];let f=0;for(;f<t.length;){const w=t[f],$=w.trim();if(Ba(w)||m.has(f)){f+=1;continue}if(!$){f+=1;continue}if(/^<details>\s*$/i.test($)){const D=f;let a="Details";const k=[];for(f+=1;f<t.length&&!/^<\/details>\s*$/i.test(t[f].trim());){const B=t[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);B?a=B[1].trim()||a:k.push(t[f].trimStart()),f+=1}f<t.length&&(f+=1),g.push({key:`details-${D}`,startLine:D+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:Qe(a,`details-${D}-summary`,!0,p)}),k.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:yu(k,`details-${D}`,p)})]})});continue}const E=xu(w);if(E){const D=[w],a=f;for(f+=1;f<t.length&&!E.selfContained&&!new RegExp(`</${E.tag}>`,"i").test(t[f]);)D.push(t[f]),f+=1;f<t.length&&!E.selfContained&&(D.push(t[f]),f+=1),g.push({key:`html-${a}`,startLine:a+1,endLine:f,content:e.jsx(gu,{html:D.join(`
|
|
47
|
-
`)})});continue}const _=$.match(/^(```|~~~)\s*(.*)$/);if(_){const D=[],a=_[1],k=_[2]?.trim(),B=f;for(f+=1;f<t.length&&!t[f].trim().startsWith(a);)D.push(t[f]),f+=1;f<t.length&&(f+=1),g.push({key:`code-${B}`,startLine:B+1,endLine:f,fineGrained:k.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(k.toLowerCase()),content:k.toLowerCase()==="mermaid"?e.jsx(Ru,{code:D.join(`
|
|
48
|
-
`),blockKey:`code-${B}`}):["math","latex","tex"].includes(k.toLowerCase())?e.jsx(Ns,{tex:D.join(`
|
|
49
|
-
`),display:!0}):S=>e.jsx(Wa,{code:D.join(`
|
|
50
|
-
`),lang:k,blockKey:`code-${B}`,codeStartLine:B+2,lineRange:S})});continue}if(za(w)){const D=[],a=f;for(f+=0;f<t.length&&(za(t[f])||!t[f].trim());)D.push(t[f].trim()?wu(t[f]):""),f+=1;g.push({key:`indented-code-${a}`,startLine:a+1,endLine:f,fineGrained:!0,content:k=>e.jsx(Wa,{code:D.join(`
|
|
51
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${a}`,codeStartLine:a+1,lineRange:k})});continue}if($.startsWith("$$")){const D=[],a=f,k=$.replace(/^\$\$\s*/,"");if(k.endsWith("$$")&&k.length>2)D.push(k.replace(/\s*\$\$$/,"")),f+=1;else{for(k&&D.push(k),f+=1;f<t.length&&!t[f].trim().endsWith("$$");)D.push(t[f]),f+=1;if(f<t.length){const B=t[f].trim().replace(/\s*\$\$$/,"");B&&D.push(B),f+=1}}g.push({key:`math-${a}`,startLine:a+1,endLine:f,content:e.jsx(Ns,{tex:D.join(`
|
|
52
|
-
`),display:!0})});continue}if(f+1<t.length&&$&&!jo(w)&&/^(=+|-+)\s*$/.test(t[f+1].trim())){const D=t[f+1].trim().startsWith("=")?1:2,a=`h${D}`,k=Ro($,p),B={level:D,text:ad($),id:k};g.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:B,content:e.jsx(a,{id:k,className:`scroll-mt-16 font-semibold text-foreground ${D===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:Qe($,`setext-heading-${f}`,!0,p)})}),f+=2;continue}const L=$.match(/^(#{1,6})\s+(.+)$/);if(L){const D=L[1].length,a=au(L[2]),k={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"},B=`h${D}`,S=Ro(a,p),Y={level:D,text:ad(a),id:S};g.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:Y,content:e.jsx(B,{id:S,className:`scroll-mt-16 font-semibold text-foreground ${k[D]}`,children:Qe(a,`heading-${f}`,!0,p)})}),f+=1;continue}if(ru(w)){g.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if($.startsWith(">")){const D=[],a=[],k=f;for(;f<t.length&&/^>\s?/.test(t[f].trim());)D.push(t[f].trim().replace(/^>\s?/,"")),a.push(f+1),f+=1;const B=D[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(B){const Y=B[1].toUpperCase(),le=B[2]?.trim(),ie=[...le?[le]:[],...D.slice(1)],ue=[...le?[a[0]]:[],...a.slice(1)],K=Ao(ie,`callout-${k}`,p);g.push({key:`callout-${k}`,startLine:k+1,endLine:f,fineGrained:!0,content:X=>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:Y}),ie.length>0&&e.jsx("div",{children:$o(K.perLine,K.hardBreaks,ue,`callout-${k}`,X)})]})});continue}const S=wg(D,`quote-${k}`,p,a);g.push({key:`quote-${k}`,startLine:k+1,endLine:f,fineGrained:!0,content:Y=>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:yg(S,Y)})});continue}if(f+1<t.length&&w.includes("|")&&Oa(t[f+1])){const D=Cs(w),a=ku(t[f+1]),k=[],B=f;for(f+=2;f<t.length&&t[f].includes("|")&&t[f].trim();)k.push(Cs(t[f])),f+=1;const S=D.map((le,ie)=>Qe(le,`th-${B}-${ie}`,!0,p)),Y=k.map((le,ie)=>D.map((ue,K)=>Qe(le[K]??"",`td-${B}-${ie}-${K}`,!0,p)));g.push({key:`table-${B}`,startLine:B+1,endLine:f,interactive:!1,kind:"table",content:le=>{const ie=ue=>!!(le&&ue>=le.start&&ue<=le.end);return e.jsx("div",{className:Xd,"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":B+1,"data-md-ref-start":B+1,"data-md-ref-end":B+1,"data-selected":ie(B+1)?"true":void 0,children:S.map((ue,K)=>e.jsx("th",{className:`${Vd} ${Ha(a[K]??null)}`,children:e.jsx("div",{className:Ia,children:ue})},`h-${K}`))})}),e.jsx("tbody",{children:Y.map((ue,K)=>{const X=B+K+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":X,"data-md-ref-start":X,"data-md-ref-end":X,"data-selected":ie(X)?"true":void 0,children:D.map((A,I)=>e.jsx("td",{className:`${Yd} ${Ha(a[I]??null)}`,children:e.jsx("div",{className:Ia,children:ue[I]})},`c-${I}`))},`r-${K}`)})})]})})}});continue}const j=As(w);if(j){const D=j.ordered,a=qa(w),k=j.start,B=f,S=Do(t,f,a,D,!0,m);f=S.nextIndex;const Y=D?"ol":"ul",le=_o(S.items,`list-${B}`,p);g.push({key:`list-${B}`,startLine:B+1,endLine:f,fineGrained:!0,content:ie=>e.jsx(Y,{start:D?k:void 0,className:`${D?"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:Io(le,ie)})});continue}const T=[w.trimStart()],C=[f+1],F=f;for(f+=1;f<t.length&&t[f].trim()&&!jo(t[f])&&!(f+1<t.length&&t[f].includes("|")&&Oa(t[f+1]));){if(Ba(t[f])||m.has(f)){f+=1;continue}T.push(t[f].trimStart()),C.push(f+1),f+=1}const U=Ao(T,`p-${F}`,p);g.push({key:`p-${F}`,startLine:F+1,endLine:f,fineGrained:!0,content:D=>e.jsx("p",{className:"text-muted-foreground",children:$o(U.perLine,U.hardBreaks,C,`p-${F}`,D)})})}const y=vg(p);return y&&g.push({key:"footnotes",startLine:t.length,endLine:t.length,content:y}),{blocks:g,images:h}}function Cg(t,n,s){return Bo(t,n,s).blocks}function Nu(t,n){const s=[];for(const l of t){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 Cu(t){return t.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Ag({src:t,alt:n,onZoomChange:s,onDoubleTap:l}){const d=fu(t);return e.jsx(zu,{src:d,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function Au({images:t,index:n,onChange:s,onClose:l}){const{t:d}=gt(),c=t[n],m=t.length>1,h=i.useRef(null),p=i.useRef(null),g=i.useRef(null),f=i.useRef(0),[y,w]=i.useState(!1),[$,E]=i.useState(0),[_,L]=i.useState(!1),j=i.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),T=i.useCallback(()=>{y||Date.now()<f.current||(j(),g.current=window.setTimeout(()=>{g.current=null,l()},450))},[j,y,l]),C=i.useCallback(a=>{if(t.length===0)return;const k=(a+t.length)%t.length;h.current?.slideTo(k),s(k)},[t.length,s]),F=i.useCallback(()=>C(n-1),[C,n]),U=i.useCallback(()=>C(n+1),[C,n]);if(i.useEffect(()=>{j(),E(0),L(!1),w(!1)},[j,n]),i.useEffect(()=>{const a=h.current;a&&(a.allowTouchMove=m&&!y)},[m,y]),i.useEffect(()=>{const a=h.current;!a||a.activeIndex===n||a.slideTo(n,0)},[n]),i.useEffect(()=>j,[j]),i.useEffect(()=>{const a=k=>{if(k.key==="Escape"){k.preventDefault(),l();return}m&&(k.key==="ArrowLeft"?(k.preventDefault(),F()):k.key==="ArrowRight"&&(k.preventDefault(),U()))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[m,U,F,l]),wd({onDrag:({movement:[a,k],pinching:B})=>{B||y||Math.abs(k)<Math.abs(a)*1.15&&$===0||(L(!0),Math.abs(k)>8&&(f.current=Date.now()+300),E(Math.max(0,k)))},onDragEnd:({movement:[,a],velocity:[,k]})=>{if(!y){if(L(!1),Math.abs(a)>8&&(f.current=Date.now()+300),Su(a,k)){l();return}E(0)}}},{target:p,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const D=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:D}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",t.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: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","aria-label":d("rightSidebar.previousImage"),title:d("common.previous"),children:e.jsx(ks,{size:17})}),e.jsx("button",{type:"button",onClick:U,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(oh,{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(Dt,{size:18})})]})]}),e.jsx("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onPointerDown:a=>a.stopPropagation(),onPointerMove:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onTouchMove:a=>a.stopPropagation(),onClick:T,children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${$}px, 0) scale(${Math.max(.86,1-$/900)})`,opacity:Math.max(.35,1-$/360),transition:_?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(yd,{onSwiper:a=>{h.current=a,a.allowTouchMove=m&&!y},onSlideChange:a=>{a.activeIndex!==n&&s(a.activeIndex)},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:t.map((a,k)=>e.jsx(ho,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:a.kind==="image"?e.jsx(Ag,{src:a.src,alt:a.alt||a.title||d("rightSidebar.markdownImage"),onZoomChange:w,onDoubleTap:j}):e.jsx(Gg,{svg:a.svg,title:a.title||a.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:w,onDoubleTap:j})})},`${a.kind}-${k}-${a.alt}`))})})})]})]}),document.body)}function $u({content:t,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:d,onLineRangeDrag:c,scrollTop:m,outlineOpen:h,outlineCloseSignal:p,onOutlineOpen:g,onOutlineClose:f,lightboxOpen:y,lightboxCloseSignal:w,onLightboxOpen:$,onLightboxClose:E,onLocalLinkOpen:_}){const{t:L}=gt(),[j,T]=i.useState(null),[C,F]=i.useState(null),[U,D]=i.useState(1),[a,k]=i.useState(null),B=i.useRef(null),S=i.useRef(null),{blocks:Y,images:le}=i.useMemo(()=>Bo(t.split(`
|
|
53
|
-
`),n,s,N=>{F(null),T(N),$?.()},{footnotes:L("rightSidebar.footnotes"),backToFootnote:N=>L("rightSidebar.backToFootnote",{index:N})}),[t,n,s,$,L]),ie=i.useMemo(()=>C?[...le,C]:le,[le,C]),ue=i.useCallback(N=>{F({kind:"mermaid",svg:N,alt:"Mermaid diagram",title:"Mermaid diagram"}),T(le.length),$?.()},[le.length,$]);i.useEffect(()=>{T(null),F(null)},[t,n]),i.useEffect(()=>{T(null),F(null)},[w]),i.useEffect(()=>{y||(T(null),F(null))},[y]),i.useEffect(()=>{D(1)},[t,n]),i.useLayoutEffect(()=>{const N=B.current;if(!N||Y.length===0)return;const Z=Array.from(N.querySelectorAll("[data-markdown-preview-block-start]"));let Se=1;const be=28;for(const De of Z)if(De.offsetTop-m<=be)Se=Number(De.dataset.markdownPreviewBlockStart)||Se;else break;D(De=>De===Se?De:Se)},[Y,m]);const K=i.useMemo(()=>Nu(Y,U),[U,Y]),X=i.useMemo(()=>Cu(Y),[Y]),A=`${n??""}
|
|
54
|
-
${t}`,I=i.useRef(A),V=i.useRef(null),re=i.useRef(null),ee=i.useRef(!1);i.useEffect(()=>{I.current!==A&&(I.current=A,f?.())},[f,A]),i.useEffect(()=>{p!==void 0&&k(null)},[p]),i.useLayoutEffect(()=>{if(!h){k(null);return}const N=()=>{const Z=S.current;if(!Z)return;const Se=Z.getBoundingClientRect(),be=window.innerWidth;k({top:Se.bottom+6,right:Math.max(8,be-Se.right)})};return N(),window.addEventListener("resize",N),window.addEventListener("scroll",N,!0),()=>{window.removeEventListener("resize",N),window.removeEventListener("scroll",N,!0)}},[h,m,K]);const ge=i.useCallback(N=>{const Z=B.current,Se=Z?.closest("[data-markdown-preview-scroller]"),be=Z?.querySelector(`[data-markdown-preview-block-start="${N.startLine}"]`);if(!Se||!be)return;const De=Se.getBoundingClientRect(),he=be.getBoundingClientRect(),z=Z?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,ce=he.top-De.top+Se.scrollTop;Se.scrollTo({top:Math.max(0,ce-z-8),behavior:"smooth"}),D(N.startLine),f?.()},[f]),O=i.useCallback(N=>{N.pointerType==="mouse"&&N.button!==0||io(N.target)||(V.current={pointerId:N.pointerId,startX:N.clientX,startY:N.clientY})},[]),xe=i.useCallback((N,Z,Se)=>{const be=V.current;if(V.current=null,!be||be.pointerId!==N.pointerId)return;const De=Math.abs(N.clientX-be.startX),he=Math.abs(N.clientY-be.startY);if(De>8||he>8)return;const Ge=N.target;if(io(Ge)||Mo())return;const z=gd(Ge,Z,Se);d(N,z.start,z.end)},[d]),W=i.useCallback(N=>{V.current?.pointerId===N.pointerId&&(V.current=null)},[]),pe=i.useCallback((N,Z)=>{const Se=B.current;if(!Se||typeof document.elementFromPoint!="function")return null;const be=document.elementFromPoint(N,Z);if(!(be instanceof HTMLElement)||!Se.contains(be))return null;const De=be.closest("[data-md-ref-start]");if(De){const Te=Number(De.dataset.mdRefStart);if(Number.isFinite(Te)&&Te>0)return Te}const he=be.closest("[data-markdown-preview-block-start]");if(!he)return null;const Ge=Number(he.dataset.markdownPreviewBlockStart),z=Y.find(Te=>Te.startLine===Ge);if(!z)return Number.isFinite(Ge)&&Ge>0?Ge:null;if(z.endLine<=z.startLine)return z.startLine;const ce=he.getBoundingClientRect(),te=ce.height>0?Math.min(1,Math.max(0,(Z-ce.top)/ce.height)):0;return Math.round(z.startLine+te*(z.endLine-z.startLine))},[Y]),je=i.useCallback(N=>{if(!c||N.pointerType==="mouse"&&N.button!==0)return;const Z=pe(N.clientX+24,N.clientY);if(Z!=null){re.current={pointerId:N.pointerId,anchorLine:Z,moved:!1};try{N.currentTarget.setPointerCapture(N.pointerId)}catch{}}},[c,pe]),Ae=i.useCallback(N=>{const Z=re.current;if(!Z||Z.pointerId!==N.pointerId||!c)return;const Se=pe(N.clientX+16,N.clientY);Se!=null&&(!Z.moved&&Se===Z.anchorLine||(Z.moved=!0,ee.current=!0,c(N,Math.min(Z.anchorLine,Se),Math.max(Z.anchorLine,Se),"move")))},[c,pe]),_e=i.useCallback(N=>{const Z=re.current;if(re.current=null,!Z||Z.pointerId!==N.pointerId||!c||!Z.moved)return;const Se=pe(N.clientX+16,N.clientY)??Z.anchorLine;c(N,Math.min(Z.anchorLine,Se),Math.max(Z.anchorLine,Se),"end")},[c,pe]),Rt=i.useCallback(N=>{re.current?.pointerId===N.pointerId&&(re.current=null)},[]),fe={onPointerDown:je,onPointerMove:Ae,onPointerUp:_e,onPointerCancel:Rt},ne=()=>ee.current?(ee.current=!1,!0):!1;return Y.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:L("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:B,className:"relative min-w-0 max-w-full",onClickCapture:N=>{const Z=N.target instanceof Element?N.target.closest("a[href]"):null;if(!Z||!_)return;const Se=Z.getAttribute("href");if(!Se)return;const be=du(Se,n,s);be&&(N.preventDefault(),_(be))},children:[K.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:K.map(N=>N.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:K[K.length-1].text}),X.length>1&&e.jsxs("button",{ref:S,type:"button",onClick:()=>{h?f?.():g?.()},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":L("rightSidebar.markdownOutline"),title:L("rightSidebar.markdownOutline"),children:[e.jsx(Sd,{size:12}),e.jsx("span",{children:L("rightSidebar.markdownOutlineShort")})]})]})}),h&&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: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:a?{top:`${a.top}px`,right:`${a.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:X.map(N=>{const Z=K[K.length-1]?.startLine===N.startLine;return e.jsxs("button",{type:"button",onClick:()=>ge(N),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] ${Z?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(N.level-1,4)*12+8}px`},title:N.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Z?"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",N.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:N.text})]},`desktop-${N.id}-${N.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:L("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":L("rightSidebar.closeMarkdownOutline"),title:L("common.close"),children:e.jsx(Dt,{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:X.map(N=>{const Z=K[K.length-1]?.startLine===N.startLine;return e.jsxs("button",{type:"button",onClick:()=>ge(N),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] ${Z?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(N.level-1,4)*12+8}px`},title:N.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Z?"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",N.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:N.text})]},`${N.id}-${N.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(nu.Provider,{value:ue,children:Y.map(N=>{const Z=!!(l&&N.startLine<=l.end&&N.endLine>=l.start),Se=!!(l&&l.start<=N.startLine&&l.end>=N.endLine),be=N.kind==="table"?!1:N.fineGrained?Se:Z,De=N.kind==="table"&&l?.start===N.startLine&&l.end===N.endLine;let he=null;if(N.kind!=="table"&&N.fineGrained&&Z&&!Se&&l){const te=N.endLine-N.startLine+1,Te=Math.max(l.start,N.startLine),Ce=Math.min(l.end,N.endLine),_t=(Te-N.startLine)/te,rt=(Ce-Te+1)/te;he=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) * ${_t})`,height:`calc((100% - 0.5rem) * ${rt})`}})}const Ge=typeof N.content=="function"?N.content(l):N.content,z=N.startLine===N.endLine?String(N.startLine):`${N.startLine}-${N.endLine}`,ce=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:no(be),"aria-hidden":"true",...fe,children:[e.jsx("span",{className:so(be)}),he]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:Ge})]});return N.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":N.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 ${be?"bg-primary/10":""}`,title:`Line ${z}`,"aria-label":`Line ${z}`,children:[N.kind==="table"?e.jsx("button",{type:"button",className:no(De,"self"),onClick:te=>{te.preventDefault(),!ne()&&d(te,N.startLine,N.endLine)},title:`Reference table lines ${z}`,"aria-label":`Reference table lines ${z}`,...fe,children:e.jsx("span",{className:so(De,"self")})}):e.jsxs("span",{className:no(be,"none"),"aria-hidden":"true",...fe,children:[e.jsx("span",{className:so(be,"none")}),he]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:O,onPointerUp:te=>xe(te,N.startLine,N.endLine),onPointerCancel:W,onKeyDown:te=>{te.key!=="Enter"&&te.key!==" "||(te.preventDefault(),d(te,N.startLine,N.endLine))},title:`Reference line ${z}`,"aria-label":`Reference line ${z}`,children:Ge})]},N.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":N.startLine,onClick:te=>{const Te=te.target;if(io(Te)||Mo()||ne())return;const Ce=gd(Te,N.startLine,N.endLine);d(te,Ce.start,Ce.end)},onKeyDown:te=>{te.key!=="Enter"&&te.key!==" "||(te.preventDefault(),d(te,N.startLine,N.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 ${be?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${z}`,"aria-label":`Reference line ${z}`,children:ce},N.key)})})})]}),y&&j!==null&&ie[j]&&e.jsx(Au,{images:ie,index:j,onChange:T,onClose:()=>{T(null),F(null),E?.()}})]})}function Hn({label:t,value:n,options:s,placeholder:l,searchPlaceholder:d,emptyText:c,disabled:m,onChange:h}){const{t:p}=gt(),[g,f]=i.useState(!1),[y,w]=i.useState(""),[$,E]=i.useState(null),_=i.useRef(null),L=i.useRef(null),j=y.trim().toLowerCase(),T=i.useMemo(()=>j?s.filter(a=>`${a.label} ${a.meta??""}`.toLowerCase().includes(j)):s,[j,s]),C=s.find(a=>a.value===n),F=()=>{const a=y.trim();a&&(h(a),f(!1),w(""))},U=i.useCallback(()=>{const a=_.current?.getBoundingClientRect();if(!a)return!1;const k=12,B=Math.max(220,Math.min(a.width,window.innerWidth-k*2)),S=Math.min(Math.max(k,a.left),window.innerWidth-B-k),Y=window.innerHeight-a.bottom-k,le=a.top-k,ie=Y>=180||Y>=le,ue=Math.max(96,(ie?Y:le)-4),K=Math.min(320,ue);return E({left:S,top:ie?a.bottom+4:Math.max(k,a.top-K-4),width:B,maxHeight:K}),!0},[]),D=()=>{U(),f(!0)};return i.useEffect(()=>{if(!g)return;let a=0;const k=()=>{a||(a=window.requestAnimationFrame(()=>{a=0,U()}))},B=S=>{const Y=S.target;Y instanceof Node&&(_.current?.contains(Y)||L.current?.contains(Y)||(f(!1),w("")))};return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),document.addEventListener("pointerdown",B,!0),()=>{a&&window.cancelAnimationFrame(a),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),document.removeEventListener("pointerdown",B,!0)}},[g,U]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:_,type:"button",disabled:m,onClick:()=>{if(!m){if(w(""),g){f(!1);return}D()}},className:"group flex w-full items-center justify-between gap-2 rounded-md border border-border/15 bg-surface-2 px-2.5 py-1.5 text-left transition hover:bg-surface-elevated disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[9px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("span",{className:`block truncate text-[12px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:C?.label??(n||l)})]}),e.jsx(Ss,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${g?"rotate-180":""}`})]}),g&&!m&&typeof document<"u"&&Wr.createPortal(e.jsxs("div",{ref:L,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:a=>a.stopPropagation(),style:{left:$?.left??12,top:$?.top??12,width:$?.width??260,maxHeight:$?.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(Wn,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:y,onChange:a=>w(a.target.value),onKeyDown:a=>{if(a.key==="Escape"){a.preventDefault(),f(!1),w("");return}a.key==="Enter"&&(a.preventDefault(),F())},onBlur:()=>{y.trim()&&T.length===0&&F()},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,($?.maxHeight??320)-46)},children:[y.trim()&&!s.some(a=>a.value===y.trim())&&e.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:F,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:y.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:p("common.use")})]}),T.length>0?T.map(a=>e.jsxs("button",{type:"button",onClick:()=>{h(a.value),f(!1),w("")},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 ${a.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:a.label}),a.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:a.meta})]},a.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function cd({open:t,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:d,selectedRoots:c,onToggleRepo:m,onGenerate:h,onSecondaryAction:p,disabled:g,generateDisabled:f,secondaryDisabled:y,inserted:w,buttonLabel:$,insertedLabel:E,title:_,ariaLabel:L,scopeTitle:j,scopeLabel:T,allLabel:C,generateLabel:F,secondaryLabel:U,secondaryTitle:D,secondaryLoading:a,loading:k,error:B,statusTitle:S,extraContent:Y,renderRepoExtra:le}){return e.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{s?n(!t):f||h()},disabled:g,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 ${B?"text-destructive hover:bg-destructive/5":w?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":L,title:S??(s?`${j}: ${T}`:_),children:[k?e.jsx(tt,{size:13,className:"animate-spin"}):e.jsx(Rs,{size:13}),e.jsx("span",{children:w?E:$}),s&&e.jsx(Ss,{size:11,className:`shrink-0 transition ${t?"rotate-180":""}`}),B&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&t&&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:ie=>ie.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:j}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:T})]}),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(Dt,{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(ie=>{const ue=c.includes(ie.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${ue?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>m(ie.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${ue?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:ie.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:ie.label}),ie.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:ie.branch})]}),ue&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),le&&(l||ue)&&e.jsx("div",{className:"px-2 pb-2",children:le(ie)})]},ie.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${p&&U?"sm:grid-cols-2":""}`,children:[p&&U&&e.jsxs("button",{type:"button",onClick:()=>{y||(n(!1),p())},disabled:y,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:D,children:[a?e.jsx(tt,{size:12,className:"animate-spin"}):e.jsx(Ed,{size:12}),U]}),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-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:_,children:[e.jsx(Rs,{size:12}),F]})]})]})}),document.body)]})}function $g(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(const n of Object.values(t)){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 Eu(){return Ze(Po,$g)??{}}function Eg(t,n){const s=Eu(),l=Object.entries({...s,[t]:{top:n,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Cp);vs(Po,Object.fromEntries(l),$p)}function Mg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;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 Tg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(const n of Object.values(t)){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&&!Mg(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function zo(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function Mu(){return Ze(Lo,Tg)??{}}function dd(t,n){const s=zo(t,n);return s?Mu()[s]??null:null}function eo(t,n,s){const l=zo(t,n);if(!l)return;const d=Mu(),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(([,h],[,p])=>p.updatedAt-h.updatedAt).slice(0,Ap);vs(Lo,Object.fromEntries(m),Ep)}function to({active:t,mounted:n=!0,fallback:s=null,children:l}){return e.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${t?"block":"hidden"}`,"aria-hidden":!t,children:n?typeof l=="function"?l():l:s})}function ps({slow:t}){const{t:n}=gt();return e.jsxs("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:[e.jsx(tt,{size:20,className:"mx-auto mb-2 animate-spin text-muted-foreground/80"}),e.jsx("div",{children:n("rightSidebar.loadingGitChanges")}),t&&e.jsx("div",{className:"mt-1 text-xs text-muted-foreground/75",children:n("rightSidebar.loadingGitChangesSlow")})]})}function Ma({message:t,onRetry:n}){const{t:s}=gt();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:t}),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 Da(t,n){const s=n&&t.startsWith(`${n}/`)?t.slice(n.length+1):t,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function ct(t){if(!t)return"";const n=t.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function ro(t){if(!t)return null;const n=t.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function Eo(t,n,s){const l=Math.min(n,s),d=Math.max(n,s);return t?.start===l&&t.end===d?null:t&&t.start===t.end?{start:Math.min(t.start,l),end:Math.max(t.end,d)}:{start:l,end:d}}function Pg(t,n,s){return Eo(t,n,s)}function no(t,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${t?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function so(t,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${t?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function ud(t,n){return`pointer-events-auto absolute z-30 inline-flex items-center gap-1 rounded-full font-semibold shadow-lg ring-1 transition active:scale-95 ${t?"h-9 px-4 text-[12px]":"h-7 px-3 text-[11px]"} ${n?"bg-surface-elevated text-foreground ring-border-strong/40 hover:bg-surface-2":"bg-primary text-primary-foreground ring-primary/30 hover:bg-primary/90"}`}function Tu(t){const n=new Map;for(const s of t)n.set(Ho(s),s);return n}function Pu(t,n){const s=new Map(t);for(const l of n)s.set(Ho(l),l);return s}function fd(t,n){let s=0;for(const l of t){const d=ht(l,n);d&&n&&d!==n&&(s+=1)}return s}function Lg(t){return t.reduce((n,s)=>n+(s.staged?1:0),0)}function Fg(t,n){return Array.from(Pu(Tu(t),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Dg(t,n){const s=t.relativeRoot==="."?ct(n??t.root)||t.name||t.root:t.relativeRoot||t.name||ct(t.root)||t.root;return{root:t.root,label:s,branch:t.context?.branch??null,count:t.files.length,staged:Lg(t.files)}}function Lu(t,n){const s=ct(n??"")||n||"";return t.map(l=>Dg(l,n)).sort((l,d)=>s&&l.label===s?-1:s&&d.label===s?1:l.label.localeCompare(d.label))}function Fu(t,n,s,l,d){const c=Qd(s),m=c.find(_=>_.root===l)??c[0]??null,h=n.find(_=>_.root===l)??null,p=h?.relativeRoot??m?.relativeRoot??".",g=h?.name??m?.name??(ct(l)||l),f=(m?.files??s.files).map(_=>({..._,repoRoot:l,repoRelativeRoot:p,repoName:g})),y=m?.context??s.context,w={...h??m??{id:l,root:l,relativeRoot:p,name:g,depth:0,nested:!!(d&&l!==d),available:s.available,files:[],context:null},...m??{},id:h?.id??m?.id??l,root:l,displayRoot:h?.displayRoot??m?.displayRoot,relativeRoot:p,name:g,depth:h?.depth??m?.depth??0,nested:h?.nested??m?.nested??!!(d&&l!==d),available:m?.available??s.available,files:f,context:y?{...y,root:l,changedFiles:f.map(_=>({path:_.path,absolutePath:_.absolutePath,status:_.status}))}:null,untrackedDeferred:m?.untrackedDeferred??s.untrackedDeferred,error:m?.error??s.error},$=h?n.map(_=>_.root===l?w:_):[...n,w];return{files:Array.from(t).filter(_=>ht(_,d)!==l).concat(f),repositories:$,repoFilters:Lu($,d)}}function ht(t,n){return t.repoRoot??n}function Ho(t){return`${t.repoRoot??""}\0${t.path}`}function lt(t){return t.absolutePath||t.path}function ao(t){return Ho(t)}function _g(t){return t.repoRelativeRoot&&t.repoRelativeRoot!=="."?t.repoRelativeRoot:t.repoName??""}function hd(t){return t.reduce((n,s)=>n+(s.staged?1:0),0)}function md(t){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of t)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 On(t){let n=0;const s=t??"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 gs(t,n){return typeof t!="number"||!Number.isFinite(t)||t<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function ir(t){return t instanceof DOMException&&t.name==="AbortError"}function Ig(t){const n=t.error??t.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function pd(t){return t?.available===!1&&t.code==="NOT_GIT_REPOSITORY"}function Mo(){if(typeof window>"u")return!1;const t=window.getSelection();return!!(t&&!t.isCollapsed&&t.toString().trim())}function io(t){return t instanceof HTMLElement&&!!t.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function gd(t,n,s){const l=t instanceof HTMLElement?t.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 Bg({actions:t,running:n,completed:s}){const{t:l}=gt(),[d,c]=i.useState(!1),m=i.useRef(null),h=t.find(g=>n?.action===g.key),p=t.find(g=>s?.action===g.key);return t.length===0?null:(i.useEffect(()=>{if(!d)return;const g=y=>{const w=y.target;w instanceof Node&&m.current?.contains(w)||c(!1)},f=y=>{y.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",f)}},[d]),e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),c(f=>!f)},disabled:t.every(g=>g.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-50 ${d?"bg-surface-elevated text-foreground":p?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:h?.label??p?.label??l("rightSidebar.gitQuickActions"),children:h?e.jsx(tt,{size:13,className:"animate-spin"}):p?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(uo,{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:t.map(g=>{const f=n?.action===g.key,y=s?.action===g.key;return e.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),g.onClick(),c(!1)},disabled:g.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 ${y?"bg-accent/10 text-accent":g.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:f?e.jsx(tt,{size:13,className:"animate-spin"}):y?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label})]},g.key)})})]}))}function zg(t){const n=window.getComputedStyle(t).overflowY;return(n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight+1}function Du(t){let n=t;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&zg(n))return n;n=n.parentElement}return t.closest(".termdock-diff-stream-scroller")}function Gn(t){return t.getClientRects().length>0&&window.getComputedStyle(t).visibility!=="hidden"}const oo=new WeakMap;function Ga(t){const n=oo.get(t);n!==void 0&&window.clearTimeout(n),t.classList.remove("diff-walkthrough-target"),t.offsetWidth,t.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{t.classList.remove("diff-walkthrough-target"),oo.delete(t)},1700);oo.set(t,s)}function Hg(t){const n=CSS.escape(t),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 h of l){if(!Gn(h))continue;const p=h.querySelector(s);if(p&&Gn(p)){d=p;break}}if(d??=Array.from(document.querySelectorAll(s)).find(Gn)??null,!d)return;const c=Du(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),Ga(d);return}const m=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,m),behavior:"instant"}),Ga(d)}function mn(t){const n=CSS.escape(t.filePath),s=typeof t.sectionIndex=="number"?String(t.sectionIndex):null,l=typeof t.hunkIndex=="number"?String(t.hunkIndex):null,d=t.sectionFingerprint?CSS.escape(t.sectionFingerprint):null,c=t.hunkFingerprint?CSS.escape(t.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(E=>!!E),h=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let p=null;for(const E of h)if(Gn(E)){for(const _ of m){const L=E.querySelector(_);if(L&&Gn(L)){p=L;break}}if(p)break}if(p??=m.flatMap(E=>Array.from(document.querySelectorAll(E))).find(Gn)??null,!p){Hg(t.filePath);return}const g=Du(p);if(!g){p.scrollIntoView({block:"center",behavior:"smooth"}),Ga(p);return}const f=p.getBoundingClientRect(),y=g.getBoundingClientRect(),$=f.top-y.top+g.scrollTop-Math.max(24,(g.clientHeight-f.height)/2);g.scrollTo({top:Math.max(0,$),behavior:"instant"}),Ga(p)}const _u=1,Iu=8;function Og(t){return Math.min(Iu,Math.max(_u,t))}function Bu({resetKey:t,onZoomChange:n,onDoubleTap:s,children:l}){const d=i.useRef(null),[c,m]=i.useState({scale:1,x:0,y:0}),[h,p]=i.useState(!1),g=i.useRef(null),f=i.useRef(new Set),y=i.useRef(!1),w=i.useRef(null),$=i.useRef(0),E=i.useRef(c);E.current=c,i.useEffect(()=>{m({scale:1,x:0,y:0})},[t]);const _=i.useCallback((C,F,U)=>{const D=d.current;if(!D)return{x:F,y:U};const a=D.firstElementChild instanceof HTMLElement?D.firstElementChild:null,k=a?.clientWidth||D.clientWidth,B=a?.clientHeight||D.clientHeight,S=Math.max(0,(k*C-D.clientWidth)/2),Y=Math.max(0,(B*C-D.clientHeight)/2);return{x:Math.min(S,Math.max(-S,F)),y:Math.min(Y,Math.max(-Y,U))}},[]),L=i.useCallback((C,F,U)=>{m(D=>{const a=Og(C),k=d.current;if(!k||a===1)return{scale:a,x:0,y:0};const B=k.getBoundingClientRect(),S=(F??B.left+B.width/2)-B.left-B.width/2,Y=(U??B.top+B.height/2)-B.top-B.height/2,le=a/D.scale,ie=S-(S-D.x)*le,ue=Y-(Y-D.y)*le;return{scale:a,..._(a,ie,ue)}})},[_]),j=i.useCallback((C,F)=>{p(!0),E.current.scale>1?m({scale:1,x:0,y:0}):L(2.5,C,F),window.setTimeout(()=>p(!1),220)},[L]);i.useEffect(()=>{const C=d.current;if(!C)return;const F=a=>{if(a.pointerType==="mouse"&&a.button!==0)return;const k=f.current.size===0;if(f.current.add(a.pointerId),k){const B=Date.now(),S=w.current;if(S&&B-S.time<350&&Math.hypot(a.clientX-S.x,a.clientY-S.y)<24){w.current=null,$.current=B,s?.(),j(a.clientX,a.clientY);return}}if(f.current.size>1){y.current=!0,g.current=null;return}if(!(E.current.scale<=1)){a.preventDefault(),g.current={pointerId:a.pointerId,startX:a.clientX,startY:a.clientY,originX:E.current.x,originY:E.current.y,moved:!1};try{C.setPointerCapture?.(a.pointerId)}catch{}p(!1)}},U=a=>{const k=g.current;if(!k||k.pointerId!==a.pointerId)return;const B=a.clientX-k.startX,S=a.clientY-k.startY;if(!k.moved){if(Math.hypot(B,S)<6)return;k.moved=!0}a.stopPropagation(),a.preventDefault(),m(Y=>({...Y,..._(Y.scale,k.originX+B,k.originY+S)}))},D=a=>{const k=g.current,B=k?.pointerId===a.pointerId&&k.moved;if(k?.pointerId===a.pointerId){k.moved&&a.stopPropagation(),g.current=null;try{C.releasePointerCapture?.(a.pointerId)}catch{}}f.current.delete(a.pointerId)&&f.current.size===0&&(!y.current&&!B&&(w.current={time:Date.now(),x:a.clientX,y:a.clientY}),y.current=!1)};return C.addEventListener("pointerdown",F,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",D,{capture:!0}),window.addEventListener("pointercancel",D,{capture:!0}),()=>{C.removeEventListener("pointerdown",F,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",D,{capture:!0}),window.removeEventListener("pointercancel",D,{capture:!0})}},[_,s,j]),wd({onPinch:({offset:[C],origin:[F,U]})=>{p(!1),L(C,F,U)},onWheel:({event:C,delta:[F,U],ctrlKey:D})=>{if(D){C.preventDefault(),C.stopPropagation(),p(!1),L(E.current.scale*(1-U*.01),C.clientX,C.clientY);return}E.current.scale<=1||(C.preventDefault(),C.stopPropagation(),p(!1),m(a=>({...a,..._(a.scale,a.x-F,a.y-U)})))}},{target:d,eventOptions:{passive:!1},pinch:{scaleBounds:{min:_u,max:Iu},from:()=>[E.current.scale,0],rubberband:!0}});const T=c.scale>1;return i.useEffect(()=>{n?.(T)},[n,T]),e.jsx("div",{ref:d,"data-sidebar-gesture-ignore":T?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:T?"grab":"zoom-in"},onDoubleClick:C=>{C.stopPropagation(),!(Date.now()-$.current<500)&&(s?.(),j(C.clientX,C.clientY))},children:l({scale:c.scale,zoomed:T,animateTransform:h,transformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`,transformOrigin:"center center",transition:h?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0)`,transformOrigin:"center center",transition:h?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function zu({src:t,alt:n,vector:s,onLoad:l,onError:d,onZoomChange:c,onDoubleTap:m}){const[h,p]=i.useState(null),g=s??Ka(t);return i.useEffect(()=>{p(null)},[t]),e.jsx(Bu,{resetKey:t,onZoomChange:c,onDoubleTap:m,children:({transformStyle:f,vectorTransformStyle:y,scale:w,animateTransform:$})=>{const E=e.jsx("img",{src:t,alt:n,draggable:!1,className:"max-h-full max-w-full touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:g&&h?{position:"absolute",left:"50%",top:"50%",width:h.width*w,height:h.height*w,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:$?"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"}:h?{...f,width:h.width,height:h.height}:g?y:f,onLoad:_=>{const L=_.currentTarget,j=L.parentElement;if(j&&L.naturalWidth>0&&L.naturalHeight>0){const T=Math.max(1,j.clientWidth-2),C=Math.max(1,j.clientHeight-2),F=Math.min(T/L.naturalWidth,C/L.naturalHeight),U=g?F:Math.min(F,1);p({width:Math.max(1,Math.round(L.naturalWidth*U)),height:Math.max(1,Math.round(L.naturalHeight*U))})}l(_)},onError:d});return!g||!h?E:e.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...y,width:h.width,height:h.height},children:E})}})}function Wg({svg:t,title:n,scale:s,vectorTransformStyle:l}){const d=i.useRef(null);return i.useLayoutEffect(()=>{const c=d.current,m=c?.querySelector("svg");if(!c||!m)return;const h=()=>{const f=m.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let y=f[2],w=f[3];if((!Number.isFinite(y)||!Number.isFinite(w)||y<=0||w<=0)&&(y=Number(m.getAttribute("width")),w=Number(m.getAttribute("height"))),!Number.isFinite(y)||!Number.isFinite(w)||y<=0||w<=0)return;const $=Math.max(1,c.clientWidth-24),E=Math.max(1,c.clientHeight-24),_=Math.min($/y,E/w,1);m.style.width=`${Math.max(1,Math.floor(y*_*s))}px`,m.style.height=`${Math.max(1,Math.floor(w*_*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")};h();const p=typeof ResizeObserver>"u"?null:new ResizeObserver(h);return p?.observe(c),()=>p?.disconnect()},[s,t,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:t}})}function Gg({svg:t,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Bu,{resetKey:t,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:d,scale:c})=>e.jsx(Wg,{svg:t,title:n,scale:c,vectorTransformStyle:d})})}let Ug=0,Kg=0,qg=0,Vg=0,Yg=0;function lo(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:t==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${t}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Ye(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:t==="error"||t==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${t}`,data:{seq:++Kg,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Ta(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${t}`,data:{seq:++Vg,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Xg(){return`diff-ui-${Date.now().toString(36)}-${(++Yg).toString(36)}`}function Zg(t){return t instanceof Element?t.closest("[data-diff-selection-path]"):null}function Qg(t){const n=t.target instanceof HTMLElement?t.target:null;return{eventType:t.type,button:t.button,pointerType:t instanceof globalThis.PointerEvent?t.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function To({onReviewReference:t,filePath:n,onInsertReference:s,onInsertText:l,onInsertFeature:d,onReferenceCopied:c,onClose:m,onDirectoryLinkOpen:h,isMobile:p,markdownOutlineOpen:g,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:y,onCloseMarkdownOutline:w,markdownImageLightboxOpen:$,markdownImageLightboxCloseSignal:E,onOpenMarkdownImageLightbox:_,onCloseMarkdownImageLightbox:L,lineRange:j,onLineRangeChange:T,insertedReferenceKey:C,copiedReferenceKey:F,scrollToLine:U,onScrollToLineHandled:D}){const{t:a}=gt(),k=ae(M=>M.rootPath),B=ae(M=>M.selectFile),[S,Y]=i.useState({kind:"idle"}),[le,ie]=i.useState("schematic"),[ue,K]=i.useState(null),X=i.useRef(null),[A,I]=i.useState(null),V=i.useRef(new Map),re=i.useRef(null),[ee,ge]=i.useState(null),[O,xe]=i.useState(()=>Qc()),[W,pe]=i.useState(()=>Hc(k,n)),je=i.useRef(null),[Ae,_e]=i.useState(!1),[Rt,fe]=i.useState(null),[ne,N]=i.useState(0),[Z,Se]=i.useState([]),[be,De]=i.useState(null),he=i.useRef(null),Ge=i.useRef(n),[z,ce]=i.useState(null),[te,Te]=i.useState({status:"idle"}),[Ce,_t]=i.useState(!1),[rt,pn]=i.useState(""),[dt,or]=i.useState([]),[Ut,gn]=i.useState(0),xt=i.useRef(null),It=kd(c),Gr=zo(k,n);i.useEffect(()=>{if(Ge.current===n)return;Ge.current=n;const M=n&&k&&!n.startsWith("/")?`${k}/${n}`:n;if(he.current===M){he.current=null;return}he.current=null,Se([]),De(null),_t(!1),pn("")},[n,k]);const lr=n?k&&!n.startsWith("/")?`${k}/${n}`:n:null,Kt=ae(M=>lr?(M.fileChangeVersions.get(lr)??0)+M.fileWatchEpoch:M.fileWatchEpoch),Et=i.useRef(null),cr=i.useRef(null),[Bt,$s]=i.useState(0),xn=i.useCallback(()=>$s(M=>M+1),[]);i.useEffect(()=>{const M=X.current;return X.current=null,K(null),M&&URL.revokeObjectURL(M.objectUrl),()=>{const G=X.current;X.current=null,G&&URL.revokeObjectURL(G.objectUrl)}},[lr,Kt,Bt]),i.useEffect(()=>{if(!n){Et.current=null,Y({kind:"idle"});return}const M=k&&!n.startsWith("/")?`${k}/${n}`:n,G=new AbortController,oe=++Ug,ve=`right-sidebar-file-preview:${oe}`,Ie=performance.now();let Ee=!1;const He=(Q,Fe={})=>{Ee||(Ee=!0,lo("end",{loadingId:oe,reason:Q,durationMs:Math.round(performance.now()-Ie),filePath:n,fullPath:M,rootPath:k,...Fe}))};let Le=null;const Je=Vf(M),nt=Je?M.toLowerCase().endsWith(".kicad_pcb")?le==="schematic"?"pcb-front":le:"schematic":le,Xt=!Je&&xd(M),pr=!Je&&!Xt&&Yf(M),kn=!Je&&!Xt&&!pr&&Xf(M),Zr=ms(M),Xn=fs(M),Zt=Je?"eda":Xt?"image":pr?"model3d":kn?"video":"text",Qt=Et.current!==M;if(Et.current=M,Qt){lo("start",{loadingId:oe,filePath:n,fullPath:M,rootPath:k,mode:Zt,externalVersion:Kt}),Te({status:"idle"}),Y({kind:"loading",mode:Zt}),cr.current=null;const Q=dd(k,n);T(Q?.lineRange??null),xe(Zr?Qc():"source"),pe(Xn?Hc(k,n):"source"),Je&&ie(Zf(M))}Qt||Y(Q=>Q.kind==="error"?{kind:"loading",mode:Zt}:Q);const Sn=window.setTimeout(()=>{Ee||G.signal.aborted||lo("still_active",{loadingId:oe,filePath:n,fullPath:M,rootPath:k,mode:Zt,durationMs:Math.round(performance.now()-Ie),isPathChange:Qt})},3e3),Qr=window.setTimeout(()=>{if(Ee||G.signal.aborted)return;const Q=Je?a("rightSidebar.edaTimeout"):pr?a("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";G.abort(new DOMException(Q,"TimeoutError")),Y({kind:"error",message:Q}),He("stuck_timeout",{error:Q})},Je?Qf+5e3:pr?Jf+5e3:eh(M)?35e3:Dp);if(Je){const Q=nt==="pcb-3d"?X.current:null;Q?(Y(Q),He("eda_3d_client_cache_hit",{bytes:Q.meta.size,view:Q.view,mimeType:Q.meta.mimeType})):th(M,nt,G.signal,"view_file",ve).then(Fe=>{if(G.signal.aborted)return;Le=URL.createObjectURL(Fe.blob);const Jt={kind:"eda",sourcePath:Fe.path||M,objectUrl:Le,view:Fe.view,meta:{size:Fe.size,mimeType:Fe.mimeType,modified:Fe.modified}};if(Fe.view==="pcb-3d"){const er=X.current;er&&er.objectUrl!==Le&&URL.revokeObjectURL(er.objectUrl),X.current=Jt,K(Jt),Le=null}Y(Jt),He("eda_loaded",{bytes:Fe.size,view:Fe.view,mimeType:Fe.mimeType})}).catch(Fe=>{G.signal.aborted||(Y({kind:"error",message:Fe instanceof Error&&/timed out/i.test(Fe.message)?a("rightSidebar.edaTimeout"):Fe instanceof Error?Fe.message:a("rightSidebar.edaLoadFailed")}),He("error",{error:Fe instanceof Error?Fe.message:String(Fe)}))})}else if(Xt)rh(M,G.signal,"view_file",ve).then(Q=>{Le=URL.createObjectURL(Q.blob),Y({kind:"image",objectUrl:Le,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),He("image_loaded",{bytes:Q.size,mimeType:Q.mimeType})}).catch(Q=>{G.signal.aborted||(Y({kind:"error",message:Q instanceof Error?Q.message:a("rightSidebar.imageLoadFailed")}),He("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(pr)nh(M,G.signal,"view_file",ve).then(Q=>{G.signal.aborted||(Le=URL.createObjectURL(Q.blob),Y({kind:"model3d",sourcePath:Q.path||M,objectUrl:Le,ext:Q.ext,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),He("model3d_loaded",{bytes:Q.size,ext:Q.ext}))}).catch(Q=>{G.signal.aborted||(Y({kind:"error",message:Q instanceof Error&&(Q.name==="TimeoutError"||/timed out/i.test(Q.message))?a("rightSidebar.model3dTimeout"):Q instanceof Error?Q.message:a("rightSidebar.model3dLoadFailed")}),He("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(kn){const Q=sh(M)??"",Fe=vh(M);Y(Jt=>Jt.kind==="video"&&Jt.url===Fe?Jt:{kind:"video",url:Fe,meta:{size:null,mimeType:Q,modified:null}}),He("video_ready",{mimeType:Q})}else Rc(M,G.signal,"view_file",ve).then(Q=>{if(!G.signal.aborted){if(Q.binary){Y({kind:"binary"});return}Y({kind:"text",content:Q.content,sourcePath:Q.path||M,meta:{size:Q.size,truncated:Q.truncated}}),He("text_loaded",{bytes:Q.size,truncated:!!Q.truncated})}}).catch(Q=>{G.signal.aborted||(Y({kind:"error",message:Q instanceof Error?Q.message:"Failed to read file"}),He("error",{error:Q instanceof Error?Q.message:String(Q)}))});return()=>{G.abort(),jt(ve),window.clearTimeout(Sn),window.clearTimeout(Qr),Le&&URL.revokeObjectURL(Le),He("cleanup")}},[n,k,Kt,Bt,T,a,le]),i.useEffect(()=>{if(S.kind!=="model3d"||!n){I(null);return}let M=!1;const G=n.lastIndexOf("/"),oe=G>=0?n.slice(G+1):n,ve=G>=0?n.slice(0,G):"",Ie=ve.lastIndexOf("/"),Ee=Ie>=0?ve.slice(0,Ie):"",He=oe.replace(/\.(stl|glb|gltf)$/i,""),Le=`${Ee?`${Ee}/`:""}features/${He}.json`;return Rc(Le).then(Je=>{if(!M)try{const nt=JSON.parse(Je.content);I(nt.version===1&&Array.isArray(nt.features)&&nt.features.length>0?nt.features:null)}catch{I(null)}}).catch(()=>{M||I(null)}),()=>{M=!0}},[S,n]),i.useEffect(()=>{if(S.kind!=="text"){ce(null);return}const M=k&&n&&!n.startsWith("/")?`${k}/${n}`:n,G=Cd(M),oe=S.content,ve=ms(M??"")&&O==="preview",Ie=fs(M??"")&&W==="preview";if(!G||ve||Ie||!Ad(oe)){ce(null);return}let Ee=!1;const He=Le=>{if(Ee||!Le.registered(G)){Ee||ce(null);return}try{ce(Md(Le,oe,G))}catch{ce(null)}};return Rt?He(Rt):(ce(null),$d().then(Le=>{Ee||(fe(Le),He(Le))}).catch(()=>{})),()=>{Ee=!0}},[S,Rt,n,k,O,W]),i.useLayoutEffect(()=>{if(!Gr||S.kind!=="text")return;const M=`${Gr}:${O}:${W}`;if(cr.current===M)return;const G=dd(k,n);if(cr.current=M,!G)return;const oe=requestAnimationFrame(()=>{const ve=re.current;if(!ve)return;const Ie=O==="preview"?G.markdownTop??G.top:G.top;ve.scrollTo({top:Math.max(0,Ie??0),left:Math.max(0,G.left??0)}),N(O==="preview"?Math.max(0,Ie??0):0)});return()=>cancelAnimationFrame(oe)},[n,O,W,S.kind,Gr,k]),i.useEffect(()=>{Gr&&eo(k,n,{lineRange:j})},[n,j,Gr,k]),i.useEffect(()=>{if(U==null||S.kind!=="text")return;ge(null),T({start:U,end:U});const M=U,G=requestAnimationFrame(()=>{const oe=V.current.get(M);oe&&oe.scrollIntoView({block:"center"}),D?.()});return()=>cancelAnimationFrame(G)},[U,S,T,D]);const Un=i.useCallback(M=>{const G=re.current;if(!G)return!1;const oe=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(M):M.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),ve=G.querySelector(`#${oe}`);return ve?(ve.scrollIntoView({block:"start"}),!0):!1},[]);i.useEffect(()=>{const M=k&&n&&!n.startsWith("/")?`${k}/${n}`:n,G=S.kind==="text"&&ms(M??"")&&O==="preview";if(!be||!G)return;const oe=requestAnimationFrame(()=>{Un(be)&&De(null)});return()=>cancelAnimationFrame(oe)},[n,Un,O,be,S,k]),i.useLayoutEffect(()=>{const M=re.current;if(!M||!j){ge(null);return}if(ee)return;const G=S.kind==="image"||S.kind==="loading"&&S.mode==="image",oe=k&&n&&!n.startsWith("/")?`${k}/${n}`:n,ve=S.kind==="text"&&ms(oe??"")&&O==="preview",Ie=S.kind==="text"&&fs(oe??"")&&W==="preview";if(S.kind!=="text"||G||ve||Ie){ge(null);return}const Ee=()=>{const Le=V.current.get(j.end);if(!Le||!M){ge(null);return}const Je=Le.offsetTop+Le.offsetHeight/2,nt=M.scrollLeft+Math.max(8,M.clientWidth-120);ge({top:Je,left:nt})};Ee();const He=new ResizeObserver(()=>Ee());return He.observe(M),()=>He.disconnect()},[j,ee,S,O,W,n,k,z]);const zt=S.kind==="text"&&!(fs(lr??"")&&W==="preview")&&!lr?.toLowerCase().endsWith(".csv")&&!lr?.toLowerCase().endsWith(".kicad_pro")&&!lr?.toLowerCase().endsWith(".kicad_prl"),Ur=i.useCallback(()=>{_t(!1),pn(""),or([]),gn(0),Na()},[]),bt=i.useCallback(()=>{zt&&(_t(!0),requestAnimationFrame(()=>{xt.current?.focus(),xt.current?.select()}))},[zt]),Nr=i.useCallback(M=>{gn(G=>dt.length===0?0:(G+M+dt.length)%dt.length)},[dt.length]);if(i.useEffect(()=>{const M=G=>{const oe=vp(G);if(oe==="open"&&zt){G.preventDefault(),bt();return}Ce&&(oe==="close"?(G.preventDefault(),Ur()):(oe==="next"||oe==="previous")&&(G.preventDefault(),Nr(oe==="previous"?-1:1)))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[Ur,Ce,Nr,bt,zt]),i.useLayoutEffect(()=>{if(Na(),!Ce||!rt.trim()||!re.current){or([]),gn(0);return}const M=yp(re.current,rt);return or(M),gn(0),Wc(M,0),Gc(M[0]),Na},[Ce,rt,z,O,S]),i.useEffect(()=>{Ce&&(Wc(dt,Ut),Gc(dt[Ut]))},[Ut,dt,Ce]),i.useEffect(()=>Na,[]),!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:a("rightSidebar.selectFilePrompt")});const Pe=k&&!n.startsWith("/")?`${k}/${n}`:n,Ht=Da(Pe,k),Cr=bd(Pe,k),dr=S.kind==="text"&&S.content?S.content.split(`
|
|
55
|
-
`):[],Va=Math.max(2,String(dr.length).length)+1,vt=S.kind==="text"||S.kind==="image"||S.kind==="model3d"||S.kind==="video"||S.kind==="eda"?S.meta:null,Es=ms(Pe),Mt=Pe.toLowerCase().endsWith(".csv"),Ms=Pe.toLowerCase().endsWith(".kicad_pro"),qt=Pe.toLowerCase().endsWith(".kicad_prl"),Kr=S.kind==="text"&&Es&&O==="preview",Kn=fs(Pe),ur=S.kind==="text"&&Kn&&W==="preview",Ya=S.kind==="image"||S.kind==="loading"&&S.mode==="image",wt=S.kind==="model3d"||S.kind==="loading"&&S.mode==="model3d",qr=S.kind==="video"||S.kind==="loading"&&S.mode==="video",qn=S.kind==="eda"||S.kind==="loading"&&S.mode==="eda",Vn=S.kind==="text"?S.sourcePath:Pe,Ar=$h(Vn,k,j),$r=(()=>{if(!j||S.kind!=="text"||dr.length===0)return Ar;const M=[];for(let ve=j.start;ve<=j.end;ve+=1)M.push(`${ve} ${dr[ve-1]??""}`);const G=tu(Pe).replace(/^\./,""),oe="```";return`${Ar}
|
|
56
|
-
${oe}${G}
|
|
57
|
-
${M.join(`
|
|
58
|
-
`)}
|
|
59
|
-
${oe}
|
|
60
|
-
`})(),Er=`path:${Pe}`,Tt=j?`path:${Pe}:${j.start}-${j.end}`:Er,Vr=C===Er,Yr=C===Tt,Ts=F===Er,Mr=F===Tt,fr=Yr||Mr,hr=j?j.start===j.end?`L${j.start}`:`L${j.start}-${j.end}`:null,bn=M=>{const G=re.current;if(!G)return;const oe=G.getBoundingClientRect(),ve=M.currentTarget.getBoundingClientRect(),Ie=M.clientX||ve.left+ve.width/2,He=(M.clientY||ve.top+ve.height/2)-oe.top+G.scrollTop,Le=p?116:132,Je=G.scrollLeft+Math.max(8,G.clientWidth-Le),nt=Math.min(Math.max(8,Ie-oe.left+G.scrollLeft+10),Je);ge({top:He,left:nt})},vn=(M,G)=>{Mo()||(bn(M),T(oe=>{const ve=Eo(oe,G,G);return ve||ge(null),ve}))},mr=(M,G,oe)=>{bn(M),T(ve=>{const Ie=Eo(ve,G,oe);return Ie||ge(null),Ie})},Vt=(M,G,oe,ve)=>{ve==="end"&&bn(M),T({start:G,end:oe})},$e=M=>{const{scrollTop:G,scrollLeft:oe}=M.currentTarget;N(G),eo(k,n,{top:G,left:oe,markdownTop:G})},Yt=M=>{if(M.directory){h?.(M.path);return}if(M.path===Pe||S.kind==="text"&&M.path===S.sourcePath){M.fragment&&Un(M.fragment);return}Se(G=>[...G,Pe]),he.current=M.path,De(M.fragment),T(null),B(M.path)},Xr=()=>{const M=Z[Z.length-1];M&&(Se(G=>G.slice(0,-1)),he.current=M,De(null),T(null),B(M))},Yn=M=>{const{scrollTop:G,scrollLeft:oe}=M.currentTarget;eo(k,n,{top:G,left:oe})},wn=()=>{if(t){t($r,Tt);return}j&&l($r,Tt)},yn=async()=>{if(!(!Pe||te.status==="pending")&&!(S.kind==="loading"||S.kind==="error")){Te({status:"pending"});try{await wh(Pe),Te({status:"idle"})}catch(M){Te({status:"error",message:M instanceof Error?M.message:a("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[It.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(Kr||ur)?"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&&m&&e.jsx("button",{type:"button",onClick:m,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":a("rightSidebar.backToFileList"),title:a("rightSidebar.backToFileList"),children:e.jsx(Sd,{size:16})}),Z.length>0&&e.jsxs("button",{type:"button",onClick:Xr,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":a("rightSidebar.backToPreviousPreview"),title:a("rightSidebar.backToPreviousPreview"),children:[e.jsx(ks,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:a("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Pe,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Ht.name}),Ht.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Ht.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[zt&&e.jsx("button",{type:"button",onClick:Ce?Ur:bt,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 ${Ce?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":a("rightSidebar.findInFile"),title:`${a("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Wn,{size:14})}),Es&&S.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{g&&w?.(),xe(M=>{const G=M==="preview"?"source":"preview";return mt(zd,G),G}),T(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":a(O==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:a(O==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?O==="preview"?e.jsx(go,{size:14}):e.jsx(po,{size:14}):a(O==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Kn&&S.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{pe(M=>{const G=M==="preview"?"source":"preview";return qm(k,n,G),G}),T(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":a(W==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:a(W==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?W==="preview"?e.jsx(go,{size:14}):e.jsx(po,{size:14}):a(W==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),ur&&e.jsx("button",{type:"button",onClick:()=>{je.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":a(Ae?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:a(Ae?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(Nd,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:()=>s(Pe,Er),...It(Cr,Er),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Vr||Ts?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:a("rightSidebar.insertReference",{reference:Cr}),children:a(Ts?"rightSidebar.copied":Vr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Cr)},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:a("rightSidebar.copyReference",{reference:Cr}),"aria-label":a("rightSidebar.copyFileRef"),children:e.jsx(ah,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{yn()},disabled:te.status==="pending"||S.kind==="loading"||S.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.message??a("rightSidebar.downloadFailed"):a("rightSidebar.downloadFile"),"aria-label":a("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(tt,{size:13,className:"animate-spin"}):e.jsx(Eh,{size:14})})]})]}),Ce&&zt&&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(Wn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:xt,type:"search",value:rt,onChange:M=>pn(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),Nr(M.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:a("rightSidebar.findInFilePlaceholder"),"aria-label":a("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:dt.length>0?`${Ut+1}/${dt.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Nr(-1),disabled:dt.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":a("rightSidebar.previousSearchMatch"),title:`${a("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(vd,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Nr(1),disabled:dt.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":a("rightSidebar.nextSearchMatch"),title:`${a("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Mh,{size:13})}),e.jsx("button",{type:"button",onClick:Ur,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":a("rightSidebar.closeFileSearch"),title:`${a("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Dt,{size:13})})]}),vt&&!(p&&(Kr||ur))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[vt.size!==null&&e.jsx("span",{children:a("rightSidebar.byteCount",{count:vt.size.toLocaleString()})}),"truncated"in vt&&vt.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:a("rightSidebar.previewTruncated")}),"mimeType"in vt&&e.jsx("span",{children:vt.mimeType}),"dimensions"in S&&S.dimensions&&e.jsxs("span",{children:[S.dimensions.width," × ",S.dimensions.height]})]}),!(p&&(Kr||ur))&&!wt&&S.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:qn?a("rightSidebar.edaPickHint"):Mt?a("rightSidebar.csvTablePreview"):Ms||qt?a("rightSidebar.kicadProjectPickHint"):qr?a("rightSidebar.videoPreviewHint"):Ya?a("rightSidebar.imagePreviewHint"):Kr?j?a("rightSidebar.selectedLineHint",{lineLabel:hr??""}):a("rightSidebar.markdownPreviewHint"):ur?a("rightSidebar.htmlPreviewHint"):j?a("rightSidebar.selectedLineHint",{lineLabel:hr??""}):a("rightSidebar.multiLineHint")})})]}),S.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:S.mode==="eda"?a("rightSidebar.edaLoading"):S.mode==="image"?a("rightSidebar.loadingImage"):S.mode==="model3d"?a("rightSidebar.model3dLoading"):S.mode==="video"?a("rightSidebar.loadingVideo"):"Loading file…"}):S.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:S.message}),e.jsx("button",{type:"button",onClick:xn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:a("common.retry")})]}):S.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:a("rightSidebar.binaryPreviewHint")})}):S.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:S.meta.mimeType==="image/svg+xml"?e.jsx(Dd,{blobUrl:S.objectUrl,filePath:Pe,viewLabel:"SVG 文件",onInsertAnnotation:d}):e.jsx(zu,{src:S.objectUrl,alt:Ht.name,vector:!1,onLoad:M=>{const G=M.currentTarget;Y(oe=>oe.kind==="image"?{...oe,dimensions:{width:G.naturalWidth,height:G.naturalHeight}}:oe)},onError:()=>Y({kind:"error",message:a("rightSidebar.imageLoadFailed")})})}):S.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(Qm,{url:S.url,onLoadError:()=>Y({kind:"error",message:a("rightSidebar.videoLoadFailed")})})}):S.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(ap,{blobUrl:S.objectUrl,filePath:S.sourcePath,view:S.view,board:Pe.toLowerCase().endsWith(".kicad_pcb"),onViewChange:ie,onInsertAnnotation:t??d,onRefresh:xn,interactive3d:ue?e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(Zc,{blobUrl:ue.objectUrl,ext:".glb",fileName:Ht.name,filePath:ue.sourcePath,features:null,onInsertFeature:t??d,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:M=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(M)?M:"PCB板体/铜箔/丝印",active:S.view==="pcb-3d"})}):void 0})}):S.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(Zc,{blobUrl:S.objectUrl,ext:S.ext,fileName:Ht.name,filePath:S.sourcePath,features:A,onInsertFeature:t??d,onRefresh:xn})})}):S.kind==="text"&&Mt?e.jsx(lp,{content:S.content,filePath:Pe,onInsertAnnotation:t??d},Pe):S.kind==="text"&&(Ms||qt)?e.jsx(up,{content:S.content,filePath:Pe,localState:qt,onInsertAnnotation:t??d},Pe):Kr?e.jsxs("div",{ref:re,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:$e,style:{touchAction:"pan-x pan-y"},children:[e.jsx($u,{content:S.content,filePath:S.sourcePath,rootPath:k,lineRange:j,onLineRangeClick:mr,onLineRangeDrag:Vt,scrollTop:ne,outlineOpen:g,outlineCloseSignal:f,onOutlineOpen:y,onOutlineClose:w,lightboxOpen:$,lightboxCloseSignal:E,onLightboxOpen:_,onLightboxClose:L,onLocalLinkOpen:Yt}),j&&ee&&e.jsxs("button",{type:"button",onClick:wn,...It($r,Tt),style:{top:ee.top,left:ee.left,transform:"translateY(-50%)"},className:ud(p,fr),title:`Insert markdown reference: ${Ar}`,children:[e.jsx(_a,{size:p?13:11}),Mr?a("rightSidebar.copied"):Yr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:hr??""})]})]}):ur?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(bp,{ref:je,src:ih(Pe),title:`${Ht.name} preview`,exitFullscreenLabel:a("rightSidebar.htmlFullscreenExit"),onFullscreenChange:_e},`${Pe}:${Kt}:${Bt}`)}):S.kind==="text"?e.jsxs("div",{ref:re,onScroll:Yn,className:`${Fo} 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:[dr.length>0?e.jsx("div",{className:"min-w-full",children:dr.map((M,G)=>{const oe=G+1,ve=!!(j&&oe>=j.start&&oe<=j.end),Ie=z&&z.length===dr.length?z[G]:null;return e.jsxs("div",{ref:Ee=>{Ee?V.current.set(oe,Ee):V.current.delete(oe)},role:"button","data-file-preview-line":oe,tabIndex:0,onClick:Ee=>vn(Ee,oe),onKeyDown:Ee=>{Ee.key!=="Enter"&&Ee.key!==" "||(Ee.preventDefault(),vn(Ee,oe))},style:{gridTemplateColumns:`${Va}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${ve?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Cr}:${oe}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${ve?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:oe}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ie??(M||" ")})]},G)})}):"Empty file.",j&&ee&&e.jsxs("button",{type:"button",onClick:wn,...It($r,Tt),style:{top:ee.top,left:ee.left,transform:"translateY(-50%)"},className:ud(p,fr),title:`Insert code reference: ${Ar}`,children:[e.jsx(_a,{size:p?13:11}),Mr?a("rightSidebar.copied"):Yr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:hr??""})]})]}):null]})}function Jg({isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c=!1,onTogglePinned:m,rightSidebarFilePreviewOpen:h=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:g,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:y=!1,rightSidebarRepoPickerCloseSignal:w,onOpenRightSidebarRepoPicker:$,onCloseRightSidebarRepoPicker:E,markdownOutlineOpen:_=!1,markdownOutlineCloseSignal:L,onOpenMarkdownOutline:j,onCloseMarkdownOutline:T,markdownImageLightboxOpen:C=!1,markdownImageLightboxCloseSignal:F,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D}){const{t:a,locale:k}=gt(),[B,S]=i.useState(""),[Y,le]=i.useState(null),ie=ae(r=>r.rightSearchOpen),ue=ae(r=>r.setRightSearchOpen),K=ae(r=>r.rightSidebarLayoutPreference),X=ae(r=>r.setRightSidebarLayoutPreference),[A,I]=i.useState(()=>qp()),[V,re]=i.useState("."),[ee,ge]=i.useState(""),[O,xe]=i.useState(!1),[W,pe]=i.useState(!1),[je,Ae]=i.useState(!1),[_e,Rt]=i.useState(!1),fe=i.useDeferredValue(B),[ne,N]=i.useState(null),[Z,Se]=i.useState([]),[be,De]=i.useState([]),[he,Ge]=i.useState(null),[z,ce]=i.useState(null),[te,Te]=i.useState(null),[Ce,_t]=i.useState(null),[rt,pn]=i.useState(()=>Ze(Kc,bs)??!1),[dt,or]=i.useState(()=>Ze(qc,bs)??!1),[Ut,gn]=i.useState(()=>Ze(Vc,bs)??!1),[xt,It]=i.useState(()=>Ze(qi,Op)??""),[Gr,lr]=i.useState(0),[Kt,Et]=i.useState(!1),[cr,Bt]=i.useState(!1),$s=i.useRef(null),xn=i.useRef(null),[Un,zt]=i.useState(!1),[Ur,bt]=i.useState(null),[Nr,Pe]=i.useState(null),[Ht,Cr]=i.useState(()=>ed(Ui)),[dr,Va]=i.useState(()=>ed(Uc)),[vt,Es]=i.useState(()=>Hp()),[Mt,Ms]=i.useState(()=>Wp()),[qt,Kr]=i.useState(()=>Up()),Kn="words",[ur,Ya]=i.useState(0),[wt,qr]=i.useState([]),[qn,Vn]=i.useState([]),[Ar,$r]=i.useState(!1),[Er,Tt]=i.useState(null),[Vr,Yr]=i.useState([]),[Ts,Mr]=i.useState(!1),[fr,hr]=i.useState([]),[bn,vn]=i.useState([]),[mr,Vt]=i.useState(!1),[$e,Yt]=i.useState(null),[Xr,Yn]=i.useState([]),[wn,yn]=i.useState({}),[M,G]=i.useState(!1),[oe,ve]=i.useState(null),[Ie,Ee]=i.useState(null),[He,Le]=i.useState(null),[Je,nt]=i.useState(null),[Xt,pr]=i.useState(!1),[kn,Zr]=i.useState(""),Xn=i.useDeferredValue(kn),[Zt,Qt]=i.useState([]),[Sn,Qr]=i.useState(!1),[Q,Fe]=i.useState(!1),[Jt,er]=i.useState(null),[Xa,jn]=i.useState(!1),tr=i.useRef(null),Tr=i.useRef(0),Oo=i.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Hu,Ps]=i.useState(null),[Zn,Wo]=i.useState(()=>Ze(Ki,bs)??!1),[Za,Qa]=i.useState(!1),[Ls,Go]=i.useState([]),[gr,Fs]=i.useState({}),[yt,Ds]=i.useState({}),[Pr,Uo]=i.useState(!0),[Ko,qo]=i.useState(()=>new Set),[Ke,Jr]=i.useState(null),[Ja,en]=i.useState(null),[Ou,xr]=i.useState(!1),[Vo,br]=i.useState(0),[,ei]=i.useState(0),[ti,_s]=i.useState(!1),[rr,ri]=i.useState(!1),[Wu,Yo]=i.useState(()=>ae.getState().rightTab==="diff"),[Me,Qn]=i.useState(null),[Rn,Jn]=i.useState(null),[at,Lr]=i.useState(null),[Xo,it]=i.useState(null),[Nn,Zo]=i.useState(null),[ni,Gu]=i.useState(()=>Date.now()),[Uu,Ku]=i.useState(!1),[tn,Is]=i.useState(!1),[Bs,Qo]=i.useState(""),[es,si]=i.useState(""),[rn,ai]=i.useState(""),[nn,ii]=i.useState(""),[Jo,Cn]=i.useState(null),[zs,Hs]=i.useState(!1),[el,oi]=i.useState(!1),[tl,rl]=i.useState(!1),[Os,qu]=i.useState({key:null,nonce:0}),nl=i.useRef(null),sl=i.useRef(null),J=Wh(n,c,K),Vu=Zd(J,c,qt),[li,ci]=i.useState(()=>tg(n)),di=ae(r=>r.rightTab),sn=ae(r=>r.setRightTab),v=ae(r=>r.rootPath),An=ae(r=>r.explorerRoot),al=ae(r=>r.pinnedExplorerRootsCache),il=ae(r=>r.hydratePinnedExplorerRoots),ol=ae(r=>r.syncPinnedExplorerRoots),Pt=ae(r=>r.setExplorerRoot),ll=ae(r=>r.resetExplorerToProject),$n=ae(r=>r.pinExplorerRoot),an=ae(r=>r.unpinExplorerRoot),Ue=ae(r=>r.selectedFilePath),Xe=ae(r=>r.selectFile),ui=ae(r=>r.showHiddenFiles),Yu=ae(r=>r.toggleShowHiddenFiles),ye=ae(r=>r.changedFiles),Ws=ae(r=>r.setChangedFiles),Gs=ae(r=>r.invalidateDirectoryCache),Xu=ae(r=>r.setDirectorySortMode),cl=ae(r=>r.applyFileWatchEvents),dl=ae(r=>r.reconcileDirectoryCache),ul=ae(r=>r.bumpFileWatchEpoch),Nt=ae(r=>r.gitBundleLoading),Us=ae(r=>r.gitBundleSlow),En=ae(r=>r.gitBundleError),Fr=ae(r=>r.gitBundleLastLoadedAt),fl=ae(r=>r.beginGitBundleLoading),hl=ae(r=>r.setGitBundleSlowFor),fi=ae(r=>r.finishGitBundleLoading),ml=ae(r=>r.resetGitBundleLoading),hi=ae(r=>r.setGitBundleError),pl=ae(r=>r.markGitBundleLoaded),me=An??v,gl=i.useMemo(()=>me?Sp(me,V):"",[me,V]),ts=i.useMemo(()=>kp(ee),[ee]),xl=i.useMemo(()=>({excludePatterns:ts,caseSensitive:W,wholeWord:je,regex:_e}),[W,ts,_e,je]),Ks=ae(r=>me?r.fileSortModes[me]??"name":"name"),qs=ae(r=>!!(me&&r.directoryCache.has(me))),Mn=i.useRef(null),Ct=i.useRef(0),[bl]=i.useState(()=>++qg),vr=i.useRef(null),Dr=i.useRef(null),Vs=i.useRef(0),Ot=i.useRef(new Map),wr=i.useRef(new Map),_r=i.useRef(new Set),rs=i.useRef(new Set),on=i.useRef(0),Ir=i.useRef(null),Tn=i.useRef(0),Pn=i.useRef(null),Ln=i.useRef(0),Br=i.useRef(null),mi=i.useRef(new Set),pi=i.useRef(null),gi=i.useRef(null),Ys=i.useRef(null),xi=i.useRef(null);i.useEffect(()=>{if(Nn===null)return;const r=Math.max(0,Date.now()-Nn),o=r<6e4?1e3:r<36e5?6e4:r<864e5?36e5:864e5,u=Math.max(50,o-r%o),x=window.setTimeout(()=>Gu(Date.now()),u);return()=>window.clearTimeout(x)},[ni,Nn]);const Xs=i.useRef(null),yr=i.useRef(null),Zs=i.useRef(null),ns=i.useRef(null),Re=i.useCallback(r=>ae.getState().rootPath===r,[]);i.useEffect(()=>{if(!t||typeof window>"u")return;const r=o=>{const u=Zg(o.target);u&&Ta("global_change_row_event",{...Qg(o),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:ae.getState().selectedFilePath,rightTab:ae.getState().rightTab,activeGitRepoRoot:he,changedFiles:ae.getState().changedFiles.size})};return window.addEventListener("pointerdown",r,{capture:!0}),window.addEventListener("click",r,{capture:!0}),()=>{window.removeEventListener("pointerdown",r,{capture:!0}),window.removeEventListener("click",r,{capture:!0})}},[he,t]);const vl=i.useCallback(async(r=v??void 0)=>{if(!r)return null;if(_r.current.has(r)||rs.current.has(r))return Ye("untracked_skip_cached",{cwd:r,rootPath:v,completed:_r.current.has(r),running:rs.current.has(r)}),null;const o=v,u=Vs.current+1;Vs.current=u,Ot.current.set(r,u);const x=`right-sidebar-git-untracked:${r}`,b=new AbortController;wr.current.set(r,b),rs.current.add(r),Ye("untracked_start",{requestId:u,cwd:r,rootPath:v});try{let R=await Nc(r,b.signal,x),P=0;for(;R.status==="running"&&P<120;){if(Ot.current.get(r)!==u||b.signal.aborted)return Ye("untracked_stale_result",{requestId:u,activeRequestId:Ot.current.get(r),cwd:r,status:R.status}),null;if(!Re(o))return Ye("untracked_root_changed",{requestId:u,cwd:r,expectedRootPath:o,currentRootPath:ae.getState().rootPath}),null;await new Promise(q=>window.setTimeout(q,P<10?1e3:3e3)),P+=1,R=await Nc(r,b.signal,x)}if(Ot.current.get(r)!==u||!Re(o))return Ye("untracked_stale_result",{requestId:u,activeRequestId:Ot.current.get(r),cwd:r,expectedRootPath:o,currentRootPath:ae.getState().rootPath,files:R.files.length,status:R.status}),null;if(R.status==="done")return Ws(Pu(ae.getState().changedFiles,R.files)),R.files.length>0&&Se(q=>{const Ve=new Map(q.map(we=>[we.root,we])).get(r);if(!Ve)return q;const Be=Fg(Ve.files,R.files),se=q.map(we=>we.root===r?{...we,files:Be,context:we.context?{...we.context,changedFiles:Be.map($t=>({path:$t.path,absolutePath:$t.absolutePath,status:$t.status})),truncated:!1}:we.context,untrackedDeferred:!1}:we);De(Lu(se,v));const ze=se.find(we=>we.root===v);return ze?.context&&N(we=>we?.root===ze.root?{...we,...ze.context}:we),se}),_r.current.add(r),Ye("untracked_apply",{requestId:u,cwd:r,files:R.files.length}),R;const H=R.error||(R.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return _r.current.add(r),Ye("untracked_error",{requestId:u,cwd:r,message:H,code:R.code,status:R.status}),null}catch(R){if(Ot.current.get(r)!==u||!Re(o)||ir(R))return Ye("untracked_aborted",{requestId:u,activeRequestId:Ot.current.get(r),cwd:r,expectedRootPath:o,currentRootPath:ae.getState().rootPath,message:R instanceof Error?R.message:String(R)}),null;const P=R instanceof Error?R.message:"Failed to scan untracked files";return _r.current.add(r),Ye("untracked_error",{requestId:u,cwd:r,message:P}),null}finally{wr.current.get(r)===b&&wr.current.delete(r),Ot.current.get(r)===u&&Ot.current.delete(r),rs.current.delete(r)}},[ne,Re,v,Ws]),Wt=i.useMemo(()=>{const r=new Set(be.map(u=>u.root)),o=Vr.filter(u=>r.has(u));return o.length>0?o:he?[he]:[]},[he,Vr,be]),wl=Wt.length===0,ln=i.useMemo(()=>Wt.map(r=>Z.find(o=>o.root===r)).filter(r=>!!r),[Wt,Z]),Zu=i.useMemo(()=>be.map(r=>({root:r.root,label:r.label,branch:r.branch??null})),[be]),nr=i.useCallback(async()=>{if(!v){qr([]),Vn([]);return}const r=v,o=Tn.current+1;Tn.current=o,Pn.current?.abort();const u=new AbortController;Pn.current=u,$r(wt.length===0),Tt(null);try{const x=Wt.length>0?await Promise.all(Wt.map(b=>Cc({workspaceRoot:v,repoRoot:b},u.signal))).then(b=>({records:b.flatMap(R=>R.records),walkthroughs:b.flatMap(R=>R.walkthroughs??[])})):await Cc({workspaceRoot:v},u.signal);if(Tn.current!==o||!Re(r))return;qr(x.records),Vn(x.walkthroughs??[])}catch(x){if(Tn.current!==o||!Re(r)||ir(x))return;Tt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{Pn.current===u&&(Pn.current=null),Tn.current===o&&Re(r)&&$r(!1)}},[wt.length,Wt,Re,v]),Qs=i.useCallback(async(r,o,u)=>{if(!r&&!v){hr([]),vn([]);return}const x=v,b=Ln.current+1;Ln.current=b,Br.current?.abort();const R=new AbortController;Br.current=R;try{const P=r?[r]:Array.from(new Set([v,...Z.map(q=>q.root)].filter(q=>!!q))),H=await Promise.all(P.map(q=>lh({repoRoot:q,baseRef:o,branchName:u},R.signal))).then(q=>{const Ne=new Map,Ve=new Map;for(const Be of q){for(const se of Be.records)Ne.set(se.id,se);for(const se of Be.walkthroughs??[])Ve.set(se.id,se)}return{records:Array.from(Ne.values()),walkthroughs:Array.from(Ve.values())}});if(Ln.current!==b||!Re(x))return;hr(H.records),vn(H.walkthroughs??[])}catch(P){if(Ln.current!==b||!Re(x)||ir(P))return;console.warn("[RightSidebar] Failed to load branch explanations",P)}finally{Br.current===R&&(Br.current=null)}},[Z,Re,v]),zr=i.useCallback((r,o={})=>{if(!Re(v)){Ye("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:ae.getState().rootPath,bundleRoot:r.context?.root,files:r.files.length});return}Ye(r.files.length===0?"empty_bundle":"apply",{rootPath:v,available:r.available,files:r.files.length,repositories:r.repositories?.map(se=>({root:se.root,relativeRoot:se.relativeRoot,files:se.files.length,available:se.available,error:se.error})),repoFilters:r.repoFilters?.map(se=>({root:se.root,label:se.label,count:se.count})),cached:r.cached,stale:r.stale,cacheAgeMs:r.cacheAgeMs,untrackedDeferred:r.untrackedDeferred,error:r.error});let u=Qd(r),x=r.repoFilters??[],b=r.files;const R=ae.getState().changedFiles;if(!!(o.cacheOnly&&!r.cached&&r.files.length===0&&u.length===0)&&(R.size>0||Z.length>0||ne)){Ye("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:R.size,currentRepositories:Z.length});return}const H=fd(R.values(),v),q=fd(r.files,v),Ne=u.some(se=>se.root!==v);if(!!(o.background&&R.size>0&&(r.files.length===0&&!r.error||H>0&&q===0&&!Ne))){Ye("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:R.size,nextFiles:r.files.length,currentNestedCount:H,nextNestedCount:q,nextRepositories:u.map(se=>({root:se.root,relativeRoot:se.relativeRoot,files:se.files.length})),cached:r.cached,stale:r.stale,error:r.error});return}if(o.replaceRepoRoot){const se=Fu(R.values(),Z,r,o.replaceRepoRoot,v);b=se.files,u=se.repositories,x=se.repoFilters}if(Ws(Tu(b)),Se(u),De(x),o.syncActiveRepo!==!1){const se=o.activeRepoRoot!==void 0?o.activeRepoRoot:he??Jc(v),ze=Yp({...r,repositories:u,repoFilters:x},se);Ge(ze),Yi(v,ze)}typeof r.cacheUpdatedAt=="number"&&Zo(r.cacheUpdatedAt),N(se=>{if(o.replaceRepoRoot&&o.replaceRepoRoot!==v)return se;if(!r.context)return null;const ze=se?.root??v;return!se?.available||ze!==(r.context.root??v)?r.context:{...se,...r.context}}),o.reloadDiff&&Ya(se=>se+1);const Be=ae.getState().selectedFilePath;if(Be&&!Be.startsWith("/")&&!b.some(se=>se.path===Be||se.absolutePath===Be)&&Xe(null),Cr(se=>{const ze=new Set(b.map($t=>ht($t,v)).filter(Boolean)),we=new Set;for(const $t of se)ze.has($t)&&we.add($t);return Xi(Ui,we),we}),o.loadDeferred!==!1){const se=u.filter(ze=>ze.untrackedDeferred&&ze.root).map(ze=>ze.root);for(const ze of se)vl(ze)}o.loadAudit!==!1&&nr()},[he,Re,nr,vl,v,Xe,Ws]);i.useEffect(()=>{ml(),pi.current=null,gi.current=v;const r=[],o=[],x=Jc(v);Ct.current+=1,on.current+=1,Vs.current+=1,vr.current?.abort(),jt(On(Dr.current?.cwd??v??void 0)),Dr.current=null,vr.current=null,Ir.current?.abort(),jt("right-sidebar-git-details"),Ir.current=null;for(const q of wr.current.values())q.abort();for(const q of wr.current.keys())jt(`right-sidebar-git-untracked:${q}`);wr.current.clear(),Ot.current.clear(),Tn.current+=1,Pn.current?.abort(),Pn.current=null,Ln.current+=1,Br.current?.abort(),Br.current=null,Tr.current+=1,tr.current?.abort(),jt("right-sidebar-recent-commits"),tr.current=null,qr([]),Vn([]),$r(!1),Tt(null),Yr([]),Mr(!1),hr([]),vn([]),Vt(!1),Yt(null),G(!1),ve(null),Ee(null),Le(null),nt(null),pr(!1),Zr(""),Qt([]),Qr(!1),Fe(!1),er(null),jn(!1),Ps(null),Jr(null),en(null),Wo(!1),mt(Ki,!1),Qa(!1);const b=v?td()[v]:null,R=b?.previewEntries??[],P=b?.selectedPreviewKey??null,H=P?R.find(q=>q.key===P)??null:null;Go(b?.selectedRepoRoots??[]),Fs(b?.repoTargetBranches??{}),Ds(b?.repoBaseBranches??{}),Yn(R),yn(b?.previewScrollTops??{}),H&&b?.previewDetailOpen&&(H.diff.hunks?.length??0)>0&&(Yt(H.diff),Jr(H.key),en(b.selectedPreviewFileKey??(H.diff.hunks?.[0]?`${H.diff.hunks[0].filePath}\0${H.diff.hunks[0].hunkHeader}\0${H.diff.hunks[0].hunkIndex}`:null)),Vt(!0)),Uo(b?.includeUncommitted??!0),pi.current=v,Is(!1),Ge(x??null),_r.current.clear(),rs.current.clear(),Qn(null),Jn(null),Lr(null),it(null),Zo(null),Se(r),De(o),N(null),xi.current=null},[ml,v]);const Fn=i.useCallback(async(r=v??void 0,o={})=>{if(!r)return null;const u=v,x=o.includeNested??!0,b=o.refresh??o.reloadDiff??!1,R=o.cacheOnly??!1,P=o.background??!1;b&&_r.current.clear();const H=Dr.current;if(H&&H.cwd===r&&H.includeNested===x&&H.refresh===b&&H.cacheOnly===R)return Ye("reuse_pending",{cwd:r,includeNested:x,refresh:b,cacheOnly:R}),H.promise;const q=Ct.current+1;Ct.current=q;const Ne=`right-sidebar:${bl}:${q}`;vr.current?.abort();const Ve=On(r);jt(Ve);const Be=new AbortController;vr.current=Be;let se=null;P||fl(Ne),hi(null),Ye("start",{requestId:q,cwd:r,rootPath:v,requestSlotId:Ve,includeNested:x,refresh:b,cacheOnly:R,background:P,existingChanges:ye.size,lastLoadedAt:Fr}),!P&&typeof window<"u"&&(se=window.setTimeout(()=>{Ct.current===q&&hl(Ne,!0)},Tp));const ze=(async()=>{const we=await wa(r,Be.signal,{includeNested:x,refresh:b,cacheOnly:R,action:b?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:Ve,requestTimeoutMs:b?null:void 0});return Ig(we)?(Ye("cancelled_result_ignored",{requestId:q,activeRequestId:Ct.current,cwd:r,error:we.error??we.context?.error}),null):Ct.current!==q||!Re(u)?(Ye("stale_result",{requestId:q,activeRequestId:Ct.current,cwd:r,expectedRootPath:u,currentRootPath:ae.getState().rootPath,files:we.files.length,repositories:we.repositories?.length??0}),null):(zr(we,{reloadDiff:o.reloadDiff,syncActiveRepo:x,background:P,cacheOnly:R,replaceRepoRoot:o.replaceRepoRoot}),we)})();Dr.current={cwd:r,includeNested:x,refresh:b,cacheOnly:R,promise:ze};try{const we=await ze;return Ct.current===q&&we&&Re(u)?pl({cached:we.cached,stale:we.stale,cacheAgeMs:we.cacheAgeMs,nestedDeferred:!x||we.nestedDeferred,untrackedDeferred:we.untrackedDeferred}):Ct.current===q&&Re(u)&&fi(Ne),we}catch(we){return Ct.current!==q||!Re(u)||ir(we)?(Ye("aborted",{requestId:q,activeRequestId:Ct.current,cwd:r,expectedRootPath:u,currentRootPath:ae.getState().rootPath,message:we instanceof Error?we.message:String(we)}),null):(Ye("error",{requestId:q,cwd:r,includeNested:x,refresh:b,background:P,message:we instanceof Error?we.message:String(we)}),P||(N(null),hi(we instanceof Error?we.message:"Failed to load Git changes")),null)}finally{se!==null&&window.clearTimeout(se),vr.current===Be&&(vr.current=null),Dr.current?.promise===ze&&(Dr.current=null),!P&&Ct.current===q&&Re(u)&&fi(Ne)}},[zr,fl,ye.size,fi,bl,Fr,Re,pl,v,hi,hl]),ss=i.useCallback(async()=>{v&&await Fn(v,{reloadDiff:!0,includeNested:!0,refresh:!0})},[Fn,v]),bi=i.useCallback(async(r=v??void 0)=>{if(!r)return null;const o=v,u=on.current+1;on.current=u,Ir.current?.abort(),jt("right-sidebar-git-details");const x=new AbortController;Ir.current=x,Is(!0);try{const b=await Ac(r,x.signal,"load_git_details","right-sidebar-git-details");return on.current!==u||!Re(o)?null:(Se(R=>R.map(P=>P.root===b.root?{...P,available:b.available,context:b,error:b.error}:P)),N(R=>R?.root&&b.root&&R.root!==b.root?R:!R?.available||!b.available?b:{...R,...b}),b)}catch(b){return ir(b)||!Re(o)||on.current===u&&it(b instanceof Error?b.message:"Failed to load Git details"),null}finally{Ir.current===x&&(Ir.current=null),on.current===u&&Re(o)&&Is(!1)}},[Re,v]);i.useEffect(()=>{if(!t){Ct.current+=1,on.current+=1,Vs.current+=1,vr.current?.abort(),jt(On(Dr.current?.cwd??v??void 0)),Dr.current=null,vr.current=null,Ir.current?.abort(),jt("right-sidebar-git-details"),Ir.current=null;for(const r of wr.current.values())r.abort();for(const r of wr.current.keys())jt(`right-sidebar-git-untracked:${r}`);wr.current.clear(),Ot.current.clear(),Ln.current+=1,Br.current?.abort(),Br.current=null,Tr.current+=1,tr.current?.abort(),jt("right-sidebar-recent-commits"),tr.current=null,Is(!1),G(!1),ve(null),Ee(null),Le(null),nt(null),pr(!1),Zr(""),Qt([]),Qr(!1),Fe(!1),er(null),jn(!1),S(""),ue(!1),bt(null),ri(!1),J&&Yo(!1)}},[J,t,ue]),i.useEffect(()=>{if(!ie)return;const r=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(r)},[ie]),i.useEffect(()=>{J||xr(!1)},[J]);const as=i.useCallback(r=>{ei(r);const o=Zs.current;o&&(o.update(),o.slideTo(r,0),window.requestAnimationFrame(()=>{o.update(),o.slideTo(r,0)}))},[]);i.useEffect(()=>{if(J)if(xr(h),h&&Ue){br(1);const r=yr.current;r&&(r.update(),r.activeIndex!==1&&(ns.current=1,r.slideTo(1,0)))}else{br(0);const r=yr.current;r&&r.activeIndex!==0&&(ns.current=0,r.slideTo(0,0)),bt(null)}},[J,h,v,Ue]),i.useEffect(()=>{if(p!==void 0&&!h){br(0);const r=yr.current;r&&r.activeIndex!==0&&(ns.current=0,r.slideTo(0,0)),xr(!1),bt(null)}},[p,h]),i.useEffect(()=>{w!==void 0&&ce(null)},[w]),i.useEffect(()=>{!J&&h&&f?.()},[J,f,h]),i.useEffect(()=>{ci(r=>So(r,n))},[n]);const Qu=i.useCallback(r=>{J||(r.preventDefault(),Xs.current={startX:r.clientX,startWidth:li,pointerId:r.pointerId},r.currentTarget.setPointerCapture(r.pointerId))},[li,J]),Ju=i.useCallback(r=>{const o=Xs.current;if(!o||o.pointerId!==r.pointerId)return;const u=So(o.startWidth+r.clientX-o.startX,n);ci(u),vs(xs,u,Mp)},[n]),yl=i.useCallback(r=>{const o=Xs.current;if(!(!o||o.pointerId!==r.pointerId)){Xs.current=null,hs(xs);try{r.currentTarget.releasePointerCapture(r.pointerId)}catch{}}},[]),Js=!!(v&&Fr!==null&&pd(ne)),kr=Js?"files":di,We=kr==="git",Dn=kr==="files",ot=kr==="diff";i.useEffect(()=>{if(!J){_s(!0);return}if(!t){const o=window.setTimeout(()=>{_s(!1)},Lp);return()=>window.clearTimeout(o)}_s(!1);const r=window.setTimeout(()=>{_s(!0)},Pp);return()=>window.clearTimeout(r)},[J,t]),i.useEffect(()=>{if(!J||!ot)return;const r=Zs.current;if(!r)return;const o=window.requestAnimationFrame(()=>{r.update()});return()=>window.cancelAnimationFrame(o)},[ot,J]),i.useEffect(()=>{if(!Js||!v||Nt)return;const r=window.setTimeout(()=>{Fn(v,{includeNested:!0,background:!0})},3e3);return()=>window.clearTimeout(r)},[Js,v,Nt,Fn]),i.useEffect(()=>{if(!(t&&(We||ot))||!v||Nt||!qs||xi.current===v)return;xi.current=v;const o=We&&!J?0:Vi,u=window.setTimeout(()=>{Fn(v,{includeNested:!0,background:!0})},o);return()=>{window.clearTimeout(u)}},[ot,Nt,We,J,t,Fn,qs,v]),i.useEffect(()=>{!t||!We||(!J||ti)&&ri(!0)},[We,J,t,ti]),i.useEffect(()=>{if(!t||We)return;const r=window.setTimeout(()=>{ri(!0)},Vi);return()=>window.clearTimeout(r)},[We,t]),i.useEffect(()=>{ot&&Yo(!0)},[ot]);const kl=i.useCallback(r=>{me&&Eg(me,r.currentTarget.scrollTop)},[me]);i.useEffect(()=>()=>{vr.current?.abort(),hs(Po),hs(Lo),hs(xs),hs(qi)},[]),i.useEffect(()=>{if(!me||!qs)return;const r=Eu()[me]?.top;if(typeof r!="number")return;let o=window.requestAnimationFrame(()=>{Mn.current&&(Mn.current.scrollTop=r),o=window.requestAnimationFrame(()=>{Mn.current&&(Mn.current.scrollTop=r)})});return()=>window.cancelAnimationFrame(o)},[me,qs]),i.useEffect(()=>{if(!t)return;const r=new AbortController;return ch(r.signal).then(o=>rl(!!o.available)).catch(()=>rl(!1)),()=>r.abort()},[t]);const is=i.useCallback(r=>{if(le(null),Xe(r),bt(null),J){xr(!0),br(1),yr.current?.slideTo(1),g?.();return}},[J,g,Xe]),Sl=i.useCallback((r,o)=>{if(le(null),Xe(r),Pe(o),J){xr(!0),br(1),yr.current?.slideTo(1),g?.();return}},[J,g,Xe]),os=i.useCallback(async(r,o)=>{const u=o||An||v;if(!(!u||r.length===0)){Hs(!0);try{await zi(u,r),Gs(u,!1)}catch(x){it(x instanceof Error?x.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>it(null),4e3)}finally{Hs(!1)}}},[An,v,Gs,a]),jl=i.useCallback(async r=>{try{await dh(r)}catch(o){it(o instanceof Error?o.message:a("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>it(null),4e3)}},[a]),ea=i.useCallback(r=>{r.preventDefault(),r.stopPropagation(),r.dataTransfer.types.includes("Files")&&oi(!0)},[]),Rl=i.useCallback(r=>{r.preventDefault(),r.stopPropagation(),oi(!1)},[]),Nl=i.useCallback(r=>{r.preventDefault(),r.stopPropagation(),oi(!1);const o=r.dataTransfer.files;o.length>0&&os(Array.from(o))},[os]),Cl=i.useCallback(r=>{Te(r),window.setTimeout(()=>Te(o=>o===r?null:o),1400)},[]),Sr=i.useCallback(r=>{_t(r),window.setTimeout(()=>_t(o=>o===r?null:o),1400)},[]);i.useEffect(()=>{mt(Kc,rt)},[rt]),i.useEffect(()=>{mt(qc,dt)},[dt]),i.useEffect(()=>{mt(Vc,Ut)},[Ut]),i.useEffect(()=>{vs(qi,xt,Np)},[xt]),i.useEffect(()=>(il().catch(()=>{}),Mc(r=>{r.type==="pinned-explorer-roots"&&ol(r.pinnedExplorerRoots)})),[il,ol]);const Al=i.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ta=i.useRef(null),cn=i.useRef(null),[$l,vi]=i.useState(!1);i.useEffect(()=>{if(!t)return;vi(!1);let r=!1;uh().then(u=>{r||(ta.current=u.text,It(x=>u.text&&u.text!==x?u.text:x),vi(!0))}).catch(()=>{r||vi(!0)});const o=Mc(u=>{u.type==="context-draft"&&u.origin!==Al.current&&(ta.current=u.text,It(u.text))});return()=>{r=!0,o(),cn.current!==null&&(window.clearTimeout(cn.current),cn.current=null)}},[t]),i.useEffect(()=>{if(!$l||ta.current===xt)return;cn.current!==null&&window.clearTimeout(cn.current);const r=xt;cn.current=window.setTimeout(()=>{cn.current=null,fh(r,Al.current).then(()=>{ta.current=r}).catch(()=>{})},500)},[xt,$l]);const _n=i.useCallback((r,o,u)=>{r&&(rt?(It(x=>Gm(x,r)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(or(!1),lr(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?r+u:r,focus:!0}})),Cl(o))},[rt,Cl]),ra=i.useCallback(r=>{const o=ka(r,v);return Th(o,v)},[v]),wi=kd(Sr),Hr=i.useCallback((r,o)=>{const u=ka(r,v);_n(Ph(u,v),o??`path:${u}`)},[v,_n]),ef=i.useCallback(async r=>{Hs(!0);try{await Lh(r,zi,o=>{Hr(o,`path:${o}`)}),J&&!rt&&s()}catch(o){it(o instanceof Error?o.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>it(null),4e3)}finally{Hs(!1)}},[rt,Hr,J,s,a]),jr=i.useCallback((r,o)=>{if(!r)return;const u=r.includes(`
|
|
61
|
-
`)?`
|
|
62
|
-
`:void 0;_n(r.endsWith(`
|
|
63
|
-
`)||r.endsWith(" ")?r:`${r} `,o,u)},[_n]),El=i.useRef(jr);El.current=jr;const yi=i.useRef(!0);i.useEffect(()=>(yi.current=!0,()=>{yi.current=!1}),[]);const ki=i.useRef(new Set),Ml=i.useCallback((r,o,u)=>{if(ki.current.has(o))return;const x=_c.getState().activeSessionId;ki.current.add(o),km(r,o,u,{insert:jr,upload:async(b,R)=>(await zi("/tmp",[b],R)).files[0]?.path,isCurrent:()=>yi.current&&El.current===jr&&x===_c.getState().activeSessionId}).finally(()=>ki.current.delete(o))},[jr]),Or=i.useCallback((r,o,u)=>{o&&_n(o.endsWith(" ")?o:`${o} `,u??`context:${r}`,`
|
|
64
|
-
`)},[_n]),Tl=i.useCallback(r=>{const o=Um(xt,r);if(!o)return;const u=r&&xt.trim().includes(`
|
|
65
|
-
`),x=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let b=!1;const R=q=>{b||(b=!0,window.removeEventListener("termdock-insert-reference-ack",P),window.clearTimeout(H),q?(zt(!1),It(""),Ut&&or(!0)):(zt(!0),or(!1)))},P=q=>{const Ne=q.detail;Ne?.nonce===x&&R(Ne.ok===!0)},H=window.setTimeout(()=>R(!1),1500);window.addEventListener("termdock-insert-reference-ack",P),zt(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:o,focus:!0,paste:u,nonce:x}}))},[Ut,xt]),qe=i.useMemo(()=>v?ct(v):a("rightSidebar.workspace"),[v,a]),tf=i.useMemo(()=>ct(me)||qe,[me,qe]),na=i.useMemo(()=>ro(me),[me]),sa=i.useMemo(()=>v?al[v]??[]:[],[al,v]),dn=i.useMemo(()=>new Set(sa.map(r=>r.path)),[sa]),ls=!!(me&&dn.has(me)),Si=!!(v&&me&&me!==v),rf=!!(v&&An&&An!==v),At=me?`path:${me}`:null,Pl="context:change-audit",nf=i.useCallback(()=>{na&&Pt(na)},[na,Pt]),Ll=i.useCallback(()=>{ll()},[ll]),sf=i.useCallback(()=>{me&&(Gs(me,!0),ul())},[ul,me,Gs]),af=i.useCallback(()=>{!me||!Si||(ls?an(me):$n(me,"directory"))},[Si,me,ls,$n,an]),Fl=i.useCallback(r=>{Pt(r),S("")},[Pt]),Dl=i.useCallback(r=>{me&&(re(jp(me,r)),ue(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[me,ue]),_l=i.useCallback(r=>{!v||r===v||(dn.has(r)?an(r):$n(r,"directory"))},[$n,dn,v,an]),Il=i.useCallback(r=>{!v||!r||(dn.has(r)?an(r):$n(r,"file"))},[$n,dn,v,an]),Bl=ae(r=>r.expandedPaths),ji=i.useMemo(()=>{const r=new Set;if(Dn&&me){r.add(me);const o=`${me.replace(/\/+$/,"")}/`;for(const u of Bl)u.startsWith(o)&&r.add(u)}if(Dn&&v&&Ue){const o=Ue.startsWith("/")?Ue:`${v}/${Ue}`,u=ro(o);u&&r.add(u)}return Dm(r).join(`
|
|
66
|
-
`)},[Bl,Dn,me,v,Ue]),un=i.useRef(new Map);i.useEffect(()=>{const r=ji?ji.split(`
|
|
67
|
-
`):[];if(!t||r.length===0){Cn(null);return}const o=new AbortController;let u=!1,x=0,b=0;Cn(null);const R=async()=>{let P=0;for(;!u&&!o.signal.aborted;){let H=null;try{Cn(null),await yh(r,Ne=>{const{applicableEvents:Ve,unavailableReason:Be}=Im(Ne);Ve.length>0&&cl(Ve);for(const se of Ve){if(se.type!=="rescan-required")continue;const ze=ae.getState();if(!ze.directoryCache.has(se.path))continue;un.current.get(se.path)?.abort();const $t=new AbortController;un.current.set(se.path,$t);const jc=`file-watch-rescan:${se.path}`;jt(jc),kh(se.path,$t.signal,ze.showHiddenFiles,"watch_rescan",jc,ze.fileSortModes[se.path]??"name").then(ds=>{un.current.get(se.path)===$t&&dl(se.path,ds.entries)}).catch(ds=>{ir(ds)||Cn(ds instanceof Error?ds.message:"File refresh unavailable")}).finally(()=>{un.current.get(se.path)===$t&&un.current.delete(se.path)})}Be&&Cn(Be)},o.signal),H=new Error("File watch stream ended")}catch(Ne){H=Ne}if(u||o.signal.aborted||ir(H))return;Cn(H instanceof Error?H.message:"File watching unavailable");const q=Yc[Math.min(P,Yc.length-1)];P+=1,await new Promise(Ne=>{b=window.setTimeout(Ne,q)})}};return x=window.setTimeout(()=>{u||R()},Vi),()=>{u=!0,window.clearTimeout(x),window.clearTimeout(b),o.abort();for(const P of un.current.values())P.abort();un.current.clear()}},[cl,t,dl,ji]),i.useEffect(()=>{if(!v||pi.current!==v)return;if(gi.current===v){gi.current=null;return}const r=td();vs(Ud,{...r,[v]:{selectedRepoRoots:Ls,repoTargetBranches:gr,repoBaseBranches:yt,previewEntries:Xr,selectedPreviewKey:$e&&mr?Ke:null,selectedPreviewFileKey:$e&&mr?Ja:null,previewDetailOpen:!!($e&&mr),previewScrollTops:wn,previewMobileSlideIndex:1,includeUncommitted:Pr,updatedAt:Date.now()}},Rp)},[mr,Pr,$e,Xr,wn,yt,gr,Ls,v,Ja,Ke]);const et=i.useMemo(()=>md(ye.values()),[ye]),ut=i.useMemo(()=>{const r=new Map;for(const o of Z)r.set(o.root,o);return r},[Z]),kt=i.useMemo(()=>he?be.find(r=>r.root===he)??null:null,[he,be]),sr=i.useMemo(()=>Ue?Array.from(ye.values()).find(r=>r.path===Ue||r.absolutePath===Ue)??null:null,[ye,Ue]),ft=i.useMemo(()=>{const r=new Map;for(const o of Z)o.available&&o.context?.available&&r.set(o.root,o);return r.size===0&&ne?.available&&ne.root&&r.set(ne.root,{id:ne.root,root:ne.root,relativeRoot:".",name:qe,depth:0,nested:!1,available:!0,files:Array.from(ye.values()).filter(o=>ht(o,v)===ne.root),context:ne}),Array.from(r.values()).sort((o,u)=>o.root===v?-1:u.root===v?1:(o.relativeRoot||o.name).localeCompare(u.relativeRoot||u.name)).map(o=>{const u=o.relativeRoot==="."?qe:o.relativeRoot||o.name||ct(o.root),x=hd(o.files),b=o.files.length;return{value:o.root,label:u,meta:[o.context?.branch,b>0?a("rightSidebar.repoChangedCount",{count:b}):null,x>0?a("rightSidebar.repoStagedCount",{count:x}):null].filter(Boolean).join(" · ")}})},[ye,ne,Z,qe,v,a]),ke=i.useMemo(()=>he&&ft.some(r=>r.value===he)?he:sr?.repoRoot&&ft.some(r=>r.value===sr.repoRoot)?sr.repoRoot:ft.length===1||ft.length>1?ft[0].value:null,[he,ft,sr?.repoRoot]),zl=ke?ut.get(ke)??null:null,de=zl?.context?.available?zl.context:ke===ne?.root?ne:null,Oe=ft.length>0&&!ke,Hl=i.useMemo(()=>Oe?[]:ke?Array.from(ye.values()).filter(r=>ht(r,v)===ke):Array.from(ye.values()),[ke,ye,Oe,v]),fn=i.useMemo(()=>md(Hl),[Hl]),Ri=!!(de?.available&&de.root&&ke&&de.root===ke),of=ke?ft.find(r=>r.value===ke)?.label??ct(ke):a("rightSidebar.gitRepositoryPlaceholder"),lf=Ri?de?.branch??"HEAD":Oe?a("rightSidebar.selectRepositoryForGitActions"):tn?a("rightSidebar.gitActionRunning"):"HEAD",In=!!(de?.available&&de.root===ke&&de.status);i.useEffect(()=>{Oo.current={count:Zt.length,loading:Sn,loadingMore:Q,hasMore:Xa}},[Zt.length,Xa,Sn,Q]),i.useEffect(()=>{Tr.current+=1,tr.current?.abort(),jt("right-sidebar-recent-commits"),tr.current=null,Zr(""),Qt([]),Qr(!1),Fe(!1),er(null),jn(!1)},[ke]);const cs=i.useCallback(async(r={})=>{if(!v||!ke||Oe)return;const o=r.reset??!1,u=Oo.current,x=o?0:u.count;if(!o&&(u.loading||u.loadingMore||!u.hasMore))return;const b=Tr.current+1;Tr.current=b,tr.current?.abort(),jt("right-sidebar-recent-commits");const R=new AbortController;tr.current=R,o?Qr(!0):Fe(!0),er(null);try{const P=await hh({cwd:v,repoRoot:ke,limit:Fp,skip:x,query:Xn.trim(),requestSlotId:"right-sidebar-recent-commits"},R.signal);if(Tr.current!==b)return;if(!P.available){er(P.error??"Recent commits are unavailable"),o&&Qt([]),jn(!1);return}Qt(H=>o?P.commits:[...H,...P.commits]),jn(P.hasMore)}catch(P){if(Tr.current!==b||ir(P))return;er(P instanceof Error?P.message:"Failed to load recent commits"),o&&Qt([]),jn(!1)}finally{tr.current===R&&(tr.current=null),Tr.current===b&&(Qr(!1),Fe(!1))}},[ke,Xn,Oe,v]);i.useEffect(()=>{Xt&&cs({reset:!0})},[Xn,cs,Xt]);const cf=i.useCallback(r=>{const o=r.currentTarget;o.scrollTop+o.clientHeight<o.scrollHeight-48||cs({reset:!1})},[cs]);i.useEffect(()=>{!ke||!ne?.available||!We||!rr||In||tn||Oe||bi(ke)},[ke,ne?.available,In,tn,We,rr,bi,Oe]),i.useEffect(()=>{!t||!ot&&!We||!v||nr()},[ot,We,t,nr,v]),i.useEffect(()=>{!t||!We||!rr||!Zn||!v||Qs(null)},[Zn,We,rr,t,Qs,v]);const df=i.useMemo(()=>{if(!he)return 0;const r=be.findIndex(o=>o.root===he);return r>=0?r+1:0},[he,be]),Ol=i.useCallback(r=>{if(!r)return null;const o=Array.from(ye.values()).filter(u=>ht(u,v)===r).sort((u,x)=>u.path.localeCompare(x.path))[0];return o?lt(o):null},[ye,v]),hn=be.length>1,aa=i.useMemo(()=>[{root:null,label:a("rightSidebar.allRepositories"),count:ye.size,branch:null},...be.map(r=>({root:r.root,label:r.label,count:r.count,branch:r.branch??null}))],[ye.size,be,a]),Wl=aa[df]??aa[0],ia=!!he;i.useEffect(()=>{he&&!ft.some(r=>r.value===he)&&(Ge(null),Yi(v,null)),Yr(r=>r.filter(o=>be.some(u=>u.root===o)))},[he,ft,be,v]);const uf=i.useMemo(()=>{const r=new Set;de?.branch&&r.add(de.branch);for(const o of de?.branches??[])r.add(o);return Array.from(r).map(o=>({value:o,label:o,meta:o===de?.branch?a("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,a]),Gl=i.useMemo(()=>{const r=new Set;de?.upstreamRemote&&r.add(de.upstreamRemote);for(const o of de?.remotes??[])r.add(o);return Array.from(r).map(o=>({value:o,label:o,meta:o===de?.upstreamRemote?a("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,a]),Ul=Gl.length>1,ff=i.useMemo(()=>{const r=[],o=new Set,u=(b,R)=>{!b||o.has(b)||(o.add(b),r.push({value:b,label:b,meta:R}))};u(de?.upstreamBranch,de?.upstreamBranch?a("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?a("rightSidebar.pushCurrentBranchBadge"):void 0);for(const b of de?.branches??[])u(b,b===de?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");const x=de?.upstreamRemote;for(const b of de?.remoteBranches??[]){const R=b.indexOf("/"),P=R>=0?b.slice(0,R):null,H=R>=0?b.slice(R+1):b;(!x||P===x)&&u(H,"remote")}return r},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,a]),Lt=i.useMemo(()=>ft.map(r=>{const o=ut.get(r.value);return{root:r.value,label:r.label,branch:o?.context?.branch??null}}),[ft,ut]);i.useEffect(()=>{Lt.length!==0&&(Fs(r=>{let o=!1;const u={...r},x=new Set(Lt.map(b=>b.root));for(const b of Object.keys(u))x.has(b)||(delete u[b],o=!0);for(const b of Lt)!u[b.root]&&b.branch&&(u[b.root]=b.branch,o=!0);return o?u:r}),Ds(r=>{let o=!1;const u={...r},x=new Set(Lt.map(b=>b.root));for(const b of Object.keys(u))x.has(b)||(delete u[b],o=!0);for(const b of Lt){const R=ut.get(b.root)?.context;if(u[b.root]&&eu(u[b.root],R?.branch)&&(delete u[b.root],o=!0),u[b.root])continue;const P=sd(R);P&&(u[b.root]=P,o=!0)}return o?u:r}))},[Lt,ut]);const oa=i.useMemo(()=>{const r=new Set(Lt.map(o=>o.root));return Ls.filter(o=>r.has(o))},[Ls,Lt]),la=oa.length===0,ar=i.useMemo(()=>la?Lt:Lt.filter(r=>oa.includes(r.root)),[Lt,oa,la]),Gt=i.useMemo(()=>ar.filter(r=>!!yt[r.root]?.trim()),[yt,ar]),Kl=i.useMemo(()=>ar.filter(r=>!yt[r.root]?.trim()),[yt,ar]),ql=i.useCallback(async r=>{if(!r||mi.current.has(r))return;const o=ut.get(r)?.context;if((o?.branches?.length??0)>0||(o?.remoteBranches?.length??0)>0||o?.upstream)return;const u=v;mi.current.add(r),qo(x=>new Set(x).add(r));try{const x=await Ac(r,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${r}`);if(!x.available||!Re(u))return;Se(b=>b.map(R=>R.root===r?{...R,available:!0,context:{...R.context,...x},error:void 0}:R)),Fs(b=>b[r]||!x.branch?b:{...b,[r]:x.branch}),Ds(b=>{if(b[r])return b;const R=sd(x);return R?{...b,[r]:R}:b})}catch(x){ir(x)||console.warn("[RightSidebar] Failed to load branch audit repo details",r,x)}finally{mi.current.delete(r),qo(x=>{const b=new Set(x);return b.delete(r),b})}},[ut,Re,v]);i.useEffect(()=>{if(Za)for(const r of ar)ql(r.root)},[Za,ar,ql]),i.useEffect(()=>{!Ri||!de||(si(de.branch||(de.branches?.[0]??"")),ai(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),ii(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Ri]);const Vl=i.useMemo(()=>{if(Oe)return{text:a("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!In||tn)return{text:a("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:a("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const r=de.ahead??0,o=de.behind??0;return r>0&&o>0?{text:a("rightSidebar.pushDivergedCount",{ahead:r,behind:o}),className:"bg-destructive/10 text-destructive"}:r>0?{text:a("rightSidebar.pushAheadCount",{count:r}),className:"bg-accent/10 text-accent"}:o>0?{text:a("rightSidebar.pushBehindCount",{count:o}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:a("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,In,tn,Oe,a]),hf=i.useCallback(r=>{if(r&&!J){const o=r.currentTarget.getBoundingClientRect();ce({x:Math.min(o.left,window.innerWidth-352),y:Math.min(o.bottom+6,window.innerHeight-64)})}else ce(null);$?.()},[J,$]),Ni=i.useCallback(()=>{ce(null),E?.()},[E]);function Yl(){if(!hn)return null;const r=Wl?.label??a("rightSidebar.allRepositories"),o=Wl?.count??ye.size,u=ct(r)||r;return e.jsxs("button",{type:"button",onClick:hf,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 ${y?"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":y,title:r,children:[e.jsx(Rr,{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] ${o>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:o}),e.jsx(Ss,{size:12,className:"shrink-0"})]})}function mf(){if(!y||!hn||typeof document>"u")return null;const r=typeof window>"u"?1024:window.innerWidth,o=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(z?.x??r-368,r-352)),x=Math.max(12,Math.min(z?.y??80,o-420)),b=J?void 0:{left:u,top:x},R=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${J?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Ni,children:e.jsxs("div",{className:J?"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:b,onClick:P=>P.stopPropagation(),children:[e.jsxs("div",{className:J?"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:J?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:a("rightSidebar.repositories")}),!J&&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:aa.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${ye.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:ye.size})]})]}),e.jsx("button",{type:"button",onClick:Ni,className:J?"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":a("rightSidebar.close"),children:e.jsx(Dt,{size:J?16:14})})]}),e.jsx("div",{className:J?"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:aa.map(P=>{const H=(P.root??null)===he,q=ct(P.label)||P.label;return e.jsxs("button",{type:"button",onClick:()=>{pc(P.root),Ni()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${J?"px-3 py-2":"px-2 py-1.5"} ${H?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:P.label,role:"option","aria-selected":H,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${H?"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 ${H?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(Rr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${J?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:q}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:P.root===null?a("rightSidebar.allRepositories"):P.label})]}),P.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:P.branch}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${P.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:P.count})]},P.root??"all")})})]})});return Bd(R,J,document.body)}function pf(){return mf()}function Xl(r){const o=ht(r,v),u=r.absolutePath||(o?`${o}/${r.path}`:r.path),x=Da(u,o??v);return{key:lt(r),path:r.path,absolutePath:u,displayName:x.name,displayDir:x.dir,oldPath:r.oldPath,status:r.status,title:u}}function Zl(r){return r.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:a("rightSidebar.changedFromPath",{path:r.oldPath})}):null}function Ql(r,o){const u=ka(r,v),x=`path:${u}`,b=te===x,R=Ce===x,P=b||R;return e.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),Hr(u,x)},...wi(ra(u),x),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${P?"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"} ${P?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:o,children:e.jsx("span",{className:"whitespace-nowrap",children:a(R?"rightSidebar.copied":b?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Jl(r){const o=ht(r,v),u=r.absolutePath||(o?`${o}/${r.path}`:r.path),x=Hf(r),b=ao(r);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Bg,{actions:x,running:Me,completed:Rn?.path===b?Rn:null}),Ql(u,a("rightSidebar.insertThisFile"))]})}function ec(r,o){const u=o.root??v;if(!u)return null;const x=ka(r,u);return Ql(x,a("fileTree.insertRefTitle"))}function Ci(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":a("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>cc("unified"),"aria-pressed":qt==="unified",title:a("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${qt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>cc("split"),"aria-pressed":qt==="split",title:a("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${qt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("diffViewer.split")})]})}function tc(){return da.map(r=>{const o=hd(r.files.map(([,R])=>R)),u=!he&&(da.length>1||r.label!==qe),x=!!(r.root&&Ht.has(r.root));return{key:r.root??r.label,root:r.root,label:r.label,branch:r.branch,collapsed:x,files:r.files.map(([,R])=>Xl(R)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${x?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Lf(r.root),"aria-expanded":!x,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:x?e.jsx(ya,{size:13}):e.jsx(Ss,{size:13})}),e.jsx(Rr,{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:r.label}),r.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:r.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:r.files.length}),o>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:o})]}),r.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),xa("stage-all",r.root,r.label)},disabled:!!Me,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:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),xa("stash-all",r.root,r.label)},disabled:!!Me,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:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]})]}):null}})}function rc(){return ye.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:a("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:ua.map(([,r])=>{const o=ht(r,v),u=r.absolutePath||(o?`${o}/${r.path}`:r.path);return{key:lt(r),path:r.path,absolutePath:u,status:r.status,repoRoot:o,displayName:Da(u,o).name,displayDir:Da(u,o).dir,auditRecords:wt}})}function nc(r){const o=Array.from(ye.values()).find(b=>lt(b)===r.key),u=o?ht(o,v):null,x=Rm(wt,u,o?.path??r.path);return e.jsx(xo,{changeStatus:r.status,auditStatus:x,renderChangeBadge:b=>e.jsx(ws,{status:b})})}const ca=i.useCallback(r=>{if(J)return null;const o=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(o.length===0)return null;const x=r.getBoundingClientRect().top+48;let b=null,R=Number.POSITIVE_INFINITY;for(const H of o){const q=H.getBoundingClientRect();if(q.bottom<x)continue;const Ne=Math.abs(q.top-x);Ne<R&&(b=H,R=Ne)}const P=b?.dataset.diffSelectionPath??b?.dataset.diffStreamItem??null;return P?(Ys.current===P&&ae.getState().selectedFilePath===P||(Ys.current=P,Xe(P)),P):null},[J,Xe]),gf=!!(!Me&&ke&&!Oe&&(de?.upstream||rn.trim()&&nn.trim())),xf=!!(!Me&&ke&&!Oe&&(de?.upstream||rn.trim()&&nn.trim())),bf=!!(!Me&&ke&&!Oe&&es.trim()&&es.trim()!==de?.branch),Ft=i.useMemo(()=>{const r=fe.trim().toLowerCase(),o=Array.from(ye.entries()).filter(([,u])=>!he||ht(u,v)===he).sort(([u],[x])=>u.localeCompare(x));return r?o.filter(([u,x])=>`${u} ${x.path} ${x.status} ${x.repoRelativeRoot??""} ${x.repoName??""}`.toLowerCase().includes(r)):o},[he,ye,fe,v]);i.useEffect(()=>{Ta("selected_file_state",{selectedFilePath:Ue,selectedChangedFilePath:sr?.path??null,selectedChangedFileAbsolutePath:sr?.absolutePath??null,selectedChangedFileRepoRoot:sr?.repoRoot??null,rootPath:v,activeGitRepoRoot:he,rightTab:di,effectiveRightTab:kr,diffPaneActive:ot,changedFiles:ye.size,filteredChangedFiles:Ft.length,gitBundleLoading:Nt,gitBundleLastLoadedAt:Fr})},[he,ye.size,ot,kr,Ft.length,Fr,Nt,di,v,sr?.absolutePath,sr?.path,sr?.repoRoot,Ue]);const da=i.useMemo(()=>{const r=new Map;for(const o of Ft){const[,u]=o,x=ht(u,v),b=_g(u)||qe,R=x??b,P=x?ut.get(x):void 0,H=r.get(R)??{root:x,label:b,branch:P?.context?.branch,files:[]};H.files.push(o),r.set(R,H)}return Array.from(r.values()).sort((o,u)=>o.label===qe?-1:u.label===qe?1:o.label.localeCompare(u.label))},[Ft,ut,qe,v]),ua=i.useMemo(()=>{const r=[],o=new Map;for(const u of Ft)o.set(lt(u[1]),u);for(const u of da){if(u.root&&Ht.has(u.root))continue;if(vt!=="tree"){r.push(...u.files);continue}const x=u.files.map(([,b])=>Xl(b));for(const b of Gh(x)){const R=o.get(b.key);R&&r.push(R)}}return r},[Ht,vt,da,Ft]);i.useEffect(()=>{if(!ot||ua.length===0||J)return;const r=[],o=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&ca(u))return;const x=document.querySelector("[data-diff-stream-item]"),b=x?.dataset.diffSelectionPath??x?.dataset.diffStreamItem??null;if(b){Ys.current=b,Xe(b);return}const R=ua[0]?.[1];if(!R)return;const P=lt(R);Ys.current=P,Xe(P)};for(const u of[80,240,600,1200])r.push(window.setTimeout(o,u));return()=>r.forEach(u=>window.clearTimeout(u))},[ot,J,ua,Xe,ca]);const Ai=i.useMemo(()=>{const r=P=>`'${P.replace(/'/g,"'\\''")}'`,o=Wt.length>0?ln:Z.filter(P=>P.files.length>0),u=o.length>0?o:v?[{root:v,relativeRoot:".",name:qe}]:[],x=u.length>0?u.map(P=>`- ${P.relativeRoot==="."?".":P.relativeRoot} (${P.root})`).join(`
|
|
68
|
-
`):`- ${v?".":""}`,b=u.length>0?u.map(P=>` td audit-export ${r(P.root)}`).join(`
|
|
69
|
-
`):" td audit-export",R=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??""}`,"目标仓库:",x,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",b,"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 后批量注入:",R,'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(`
|
|
70
|
-
`)},[Wt.length,ln,Z,qe,v]),vf=i.useCallback((r="generate")=>{if(hn&&Vr.length===0&&!he){Mr(!0);return}const o=r==="generate"?Ai:[r==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Ai].join(`
|
|
71
|
-
`);Ye("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:Wt,mode:r,hasAuditListCommand:o.includes("td audit-list"),promptLength:o.length}),Or(a("rightSidebar.insertChangeAuditPrompt"),o,`${Pl}:${r}`),nr(),d||s()},[he,Ai,Vr.length,Wt,Or,nr,s,d,v,hn,a]),fa=i.useCallback(async r=>{try{await $c({ids:[r]}),qr(o=>o.filter(u=>u.id!==r))}catch{nr()}},[nr]),wf=i.useCallback(async()=>{if(wt.length===0)return;const r=wt.map(o=>o.id);try{await $c({ids:r}),qr(o=>o.filter(u=>!r.includes(u.id))),Tt(null)}catch(o){const u=o instanceof Error?o.message:"Failed to clear change audit explanations";Tt(a("rightSidebar.changeAuditClearFailed",{message:u})),nr()}},[wt,nr,a]),yf=i.useCallback(async r=>{if(r.records.length===0)return;const o=r.records.map(u=>u.id);try{await mh({ids:o}),hr(u=>u.filter(x=>!o.includes(x.id))),Ke===r.key&&(Jr(null),Vt(!1))}catch(u){it(a("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),Qs(null)}},[Qs,Ke,a]),kf=i.useCallback(r=>{Yr(o=>r===null?(Mr(!1),[]):o.includes(r)?o.filter(u=>u!==r):[...o,r])},[]),Sf=i.useCallback(r=>{Go(o=>r===null?(Qa(!1),[]):o.includes(r)?o.filter(u=>u!==r):[...o,r])},[]),$i=i.useMemo(()=>{if(!rr)return[];const r=o=>{const u=o.diff??"";let x=0,b=0;for(const R of u.split(`
|
|
72
|
-
`))R.startsWith("+++")||R.startsWith("---")||(R.startsWith("+")&&(x+=1),R.startsWith("-")&&(b+=1));return{filePath:o.filePath,oldPath:o.oldPath,newPath:o.newPath,hunkHeader:o.hunkHeader,hunkIndex:o.hunkIndex??0,fingerprint:o.fingerprint,additions:x,deletions:b,diff:u}};return $e?($e.hunks??[]).map(o=>{const u=fr.find(x=>x.repoRoot===$e.repoRoot&&x.baseRef===$e.baseRef&&(x.branchName??null)===($e.currentBranch??null)&&x.filePath===o.filePath&&x.hunkHeader===o.hunkHeader&&(x.hunkIndex??0)===o.hunkIndex&&x.fingerprint===o.fingerprint)??null;return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex}`,hunk:o,current:u,stale:null}}):Ke?fr.filter(o=>rd(o)===Ke).map(o=>{const u=r(o);return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex??0}`,hunk:u,current:o,stale:null}}):[]},[$e,fr,rr,Ke]),Ei=fr.length>0,Bn=i.useMemo(()=>{if(!rr)return[];const r=new Map;for(const o of fr){const u=o.repoRoot,x=ut.get(u),b=x?.relativeRoot==="."?qe:x?.relativeRoot||x?.name||ct(u),R=rd(o),P=r.get(R)??{key:R,repoRoot:u,repoLabel:b,baseRef:o.baseRef,branchName:o.branchName??null,headRef:o.headRef??null,diffFingerprint:o.diffFingerprint??null,records:[],latestInjectedAt:0};P.records.push(o),P.latestInjectedAt=Math.max(P.latestInjectedAt,o.injectedAt??0),r.set(R,P)}return Array.from(r.values()).sort((o,u)=>u.latestInjectedAt-o.latestInjectedAt)},[fr,ut,rr,qe]),Mi=i.useMemo(()=>Ke?Bn.find(r=>r.key===Ke)??null:null,[Bn,Ke]),ha=$e?{repoRoot:$e.repoRoot??"",repoLabel:$e.repoRoot?ut.get($e.repoRoot)?.relativeRoot==="."?qe:ut.get($e.repoRoot)?.relativeRoot||ut.get($e.repoRoot)?.name||ct($e.repoRoot):qe,baseRef:$e.baseRef??$e.baseBranch??"",branchName:$e.currentBranch??null,headRef:$e.headRef??null,diffFingerprint:$e.diffFingerprint??null}:Mi,jf=i.useMemo(()=>(Ie?.hunks??[]).map(r=>({key:`${r.filePath}\0${r.hunkHeader}\0${r.hunkIndex}`,hunk:r,current:null,stale:null})),[Ie?.hunks]),Rf=i.useMemo(()=>{if($e)return[];const r=Mi;return r?bn.filter(o=>o.repoRoot===r.repoRoot&&o.baseRef===r.baseRef&&(o.branchName??null)===r.branchName&&(!r.diffFingerprint||o.diffFingerprint===r.diffFingerprint)):[]},[$e,bn,Mi]),Nf=i.useCallback(r=>{const o=$i.find(u=>u.hunk.filePath===r.filePath||(r.repoRoot?`${r.repoRoot}/${u.hunk.filePath}`===r.filePath:!1));o&&(en(o.key),window.setTimeout(()=>mn(r),90),window.setTimeout(()=>mn(r),320),window.setTimeout(()=>mn(r),760))},[$i]),Ti=i.useMemo(()=>{const r=b=>`'${b.replace(/'/g,"'\\''")}'`,o=Gt,u=o.length>0?o.map(b=>`- ${b.label} (${b.root}),目标分支:${gr[b.root]||b.branch||"(current branch)"},基线分支:${yt[b.root]||"(not set)"}`).join(`
|
|
73
|
-
`):`- ${v?".":""}`,x=o.length>0?o.map(b=>{const R=gr[b.root]||b.branch||"",P=yt[b.root]||"",H=b.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[R?` git -C ${r(b.root)} switch ${r(R)}`:` # ${b.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${r(P)} ${r(b.root)} > ~/.termdock/branch-audit/branch-audit-export-${H}.json`].join(`
|
|
74
|
-
`)}).join(`
|
|
75
|
-
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,`包含本地未提交更改:${Pr?"是":"否"}`,"目标仓库:",u,"","操作指令:",Pr?"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。导出内容需要包含目标分支相对基线分支的提交改动,以及当前工作区 staged/unstaged/untracked 改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:":"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。不要包含本地 staged/unstaged/untracked 改动;如果导出结果里混入了本地工作区改动,生成解释时必须忽略这些本地改动,只解释目标分支相对基线分支的提交改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:",x,"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(`
|
|
76
|
-
`)},[Pr,Gt,yt,gr,v]),Cf=i.useCallback((r="generate")=>{const o=r==="generate"?Ti:[r==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ti].join(`
|
|
77
|
-
`);Or(a("rightSidebar.branchAuditShort"),o,`context:branch-audit-scope:${r}`),d||s()},[Ti,Or,s,d,a]),Af=i.useCallback(async()=>{if(!v||Gt.length===0)return;const r=v;G(!0),ve(null),Yt(null),Ee(null);try{const o=await Promise.all(Gt.map(async H=>{const q=yt[H.root]?.trim();if(!q)throw new Error(a("rightSidebar.branchAuditMissingBase",{repo:H.label}));const Ne=(gr[H.root]||H.branch||"").trim();return ph({cwd:v,repoRoot:H.root,base:q,head:Ne&&Ne!==H.branch?Ne:null,includeUncommitted:Pr,requestSlotId:`right-sidebar-branch-preview:${H.root}`})}));if(!Re(r))return;const u=o.find(H=>!H.available);if(u){ve(u.error??"Branch diff is unavailable");return}const x=o.length===1?o[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:o.map(H=>H.baseRef??H.baseBranch).filter(Boolean).join(", "),currentBranch:o.map(H=>H.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:o.map(H=>H.headRef).filter(Boolean).join(", "),diffFingerprint:o.map(H=>H.diffFingerprint).filter(Boolean).join("+"),stat:o.map(H=>H.stat).filter(Boolean).join(`
|
|
78
|
-
`),files:o.flatMap((H,q)=>{const Ne=Gt[q];return(H.files??[]).map(Ve=>`${Ne?.label??H.repoRoot??"repo"}/${Ve}`)}),hunks:o.flatMap((H,q)=>{const Ve=Gt[q]?.label??H.repoRoot??"repo";return(H.hunks??[]).map(Be=>({...Be,filePath:`${Ve}/${Be.filePath}`,oldPath:Be.oldPath?`${Ve}/${Be.oldPath}`:Be.oldPath,newPath:Be.newPath?`${Ve}/${Be.newPath}`:Be.newPath}))}),commits:o.flatMap(H=>H.commits??[]),commitCount:o.reduce((H,q)=>H+(q.commitCount??q.commits?.length??0),0),diff:o.map(H=>H.diff).filter(Boolean).join(`
|
|
79
|
-
`),truncated:o.some(H=>H.truncated)};if((x.hunks??[]).length===0){ve(a("rightSidebar.branchAuditDiffEmpty"));return}const b=Date.now(),R=["preview",x.repoRoot??v,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??b].join("\0"),P=Gt.length===1?Gt[0].label:`${Gt.length} repos`;Yt(x),Yn(H=>[{key:R,diff:x,repoLabel:P,createdAt:b},...H.filter(q=>q.key!==R)].slice(0,8)),yn(H=>H[R]===void 0?H:{...H,[R]:0}),Jr(R),en(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),Vt(!0)}catch(o){if(!Re(r)||ir(o))return;ve(o instanceof Error?o.message:"Failed to load branch diff")}finally{Re(r)&&G(!1)}},[Pr,Gt,yt,gr,Re,v,a]),$f=i.useCallback(r=>{Yt(r.diff),ve(null),Jr(r.key),en(r.diff.hunks?.[0]?`${r.diff.hunks[0].filePath}\0${r.diff.hunks[0].hunkHeader}\0${r.diff.hunks[0].hunkIndex}`:null),Vt(!0)},[]),Ef=i.useCallback(r=>{Yn(o=>o.filter(u=>u.key!==r)),yn(o=>{if(!(r in o))return o;const u={...o};return delete u[r],u}),Ke===r&&(Jr(null),Yt(null),Vt(!1))},[Ke]),Mf=i.useCallback(r=>{const o=Bn.find(u=>u.key===r);o&&(Yt(null),ve(null),Jr(r),en(o.records[0]?.filePath??null),Vt(!0))},[Bn]),Tf=i.useCallback(async r=>{if(!v||!ke)return;const[o]=r.split(/\s+/);if(o){Le(o),nt(null),Ee(null);try{const u=await gh({cwd:v,repoRoot:ke,commit:o,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){nt(u.error??"Commit diff is unavailable");return}Ee(u);const x=u.hunks?.[0];Ps(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){nt(u instanceof Error?u.message:"Failed to load commit diff")}finally{Le(null)}}},[ke,v]),Pf=i.useCallback(r=>{if(!$e||!Ke)return;const o=Math.max(0,Math.round(r));yn(u=>Math.abs((u[Ke]??0)-o)<24?u:{...u,[Ke]:o})},[$e,Ke]);i.useEffect(()=>{!J||!mr||!$e||as(1)},[mr,$e,J,as]);const sc=i.useCallback(r=>{r&&qu(o=>Uh(o,r))},[]),ac=Os.key===Ue?Os.key:null,ma=i.useCallback(r=>{const o=ae.getState(),u=Xg();Ta("select_diff_file",{interactionId:u,path:r,previousSelectedFilePath:o.selectedFilePath,rootPath:o.rootPath,activeGitRepoRoot:he,changedFiles:o.changedFiles.size,gitBundleLoading:o.gitBundleLoading,gitBundleLastLoadedAt:o.gitBundleLastLoadedAt,rightTab:o.rightTab}),Xe(r),sn("diff"),J&&r&&as(1),sc(r),queueMicrotask(()=>{const x=ae.getState();Ta("select_diff_file_after",{interactionId:u,requestedPath:r,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:he})})},[he,J,sc,Xe,sn,as]),ic=i.useCallback(r=>{const o=Array.from(ye.values()).find(u=>{const x=ht(u,v),b=lt(u);return u.path===r.filePath||b===r.filePath||u.absolutePath===r.filePath||(x?`${x}/${u.path}`===r.filePath:!1)||r.repoRoot&&x===r.repoRoot&&u.path===r.filePath});if(o){ma(lt(o)),window.setTimeout(()=>mn(r),90),window.setTimeout(()=>mn(r),320),window.setTimeout(()=>mn(r),760);return}mn(r)},[ye,v,ma]),oc=i.useCallback(({slideToDetail:r,fullscreen:o,toggleFullscreen:u}={})=>qn.length>0?e.jsx(jd,{walkthroughs:qn,repoRoot:he,fullscreen:o,onToggleFullscreen:u,onNavigate:x=>{J&&window.requestAnimationFrame(()=>r?.()),ic(x)}}):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(Rs,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),a("rightSidebar.changeWalkthroughEmpty")]}),[he,qn,ic,J,a]),Lf=i.useCallback(r=>{r&&Cr(o=>{const u=new Set(o);return u.has(r)?u.delete(r):u.add(r),Xi(Ui,u),u})},[]),lc=i.useCallback(r=>{Va(o=>{const u=new Set(o);return u.has(r)?u.delete(r):u.add(r),Xi(Uc,u),u})},[]),pa=i.useCallback(r=>{Es(r),mt(Hd,r)},[]);i.useEffect(()=>{ia||vt!=="ai"||pa("tree")},[vt,pa,ia]);const Pi=i.useCallback(()=>{Ms(r=>{const o=!r;return mt(Od,o),o})},[]),cc=i.useCallback(r=>{Kr(r),mt(Wd,r)},[]),{whitespace:dc,context:uc}=qh(),fc=i.useMemo(()=>({algorithm:"histogram",whitespace:dc,context:uc}),[dc,uc]),hc=i.useCallback(r=>{I(r),mt(Gd,r)},[]),ga=i.useCallback(async(r,o,u,x)=>{let b=r;for(;b.ok&&b.status==="running";)await new Promise(P=>window.setTimeout(P,1500)),b=await Ec({jobId:b.jobId,cwd:o.cwd,action:o.action});if(!b.ok)throw new Error("Git action status is unavailable");if(b.status==="error")throw new Error(b.error||b.message||"Git action failed");const R={action:o.action,path:x,label:u};return Jn(R),window.setTimeout(()=>Jn(P=>P?.action===R.action&&P.path===R.path?null:P),1400),b},[]),st=i.useCallback(async(r,o,u)=>{const x=v;v&&_r.current.delete(v),it(null),Jn(null),Qn({action:r.action,path:u});try{const b=await xh(r),R=await ga(b,r,o,u);if(!Re(x))return!1;const P=v?await wa(v,void 0,{includeNested:!0,cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:On(v)}).catch(()=>R.bundle):R.bundle;return Re(x)?(P&&zr(P,{reloadDiff:!0,cacheOnly:!0}),Lr(null),!0):!1}catch(b){return Jn(null),it(a("rightSidebar.gitActionFailed",{message:b instanceof Error?b.message:"Unknown error"})),!1}finally{Re(x)&&Qn(null)}},[zr,Re,v,a,ga]),mc=i.useCallback(async r=>{const o=v,u=await bh(r);if(!Re(o))return;const x=v?await wa(v,void 0,{includeNested:!0,cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:On(v)}).catch(()=>u.bundle):u.bundle;Re(o)&&x&&zr(x,{reloadDiff:!0,cacheOnly:!0})},[zr,Re,v]),xa=i.useCallback((r,o,u)=>{if(o){if(r==="stage-all"){st({action:"stage-all",cwd:o},a("rightSidebar.stageAll"),`repo:${o}`);return}Lr({kind:"stash-all",repoRoot:o,repoLabel:u})}},[st,a]),pc=i.useCallback(r=>{Ge(r),Yi(v,r),si(""),ai(""),ii(""),Xe(Ol(r)),We||sn("diff")},[Ol,We,v,Xe,sn]),Ff=i.useCallback(async()=>{if(!ke||Oe){it(a("rightSidebar.selectRepositoryForGitActions"));return}const r=es.trim();!r||r===de?.branch||await st({action:"switch-branch",cwd:ke,branch:r},a("rightSidebar.switchBranch"))},[de?.branch,ke,Oe,st,es,a]),gc=i.useCallback(async()=>{if(!ke||Oe){it(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Bs.trim();if(!r)return;await st({action:"commit",cwd:ke,message:r},a("rightSidebar.commitChanges"))&&Qo("")},[ke,Bs,Oe,st,a]),Df=i.useCallback(async()=>{if(!ke||Oe){it(a("rightSidebar.selectRepositoryForGitActions"));return}const r=rn.trim(),o=nn.trim();await st({action:"push",cwd:ke,...r?{remote:r}:{},...o?{branch:o}:{}},a("rightSidebar.pushChanges"))},[ke,nn,rn,Oe,st,a]),_f=i.useCallback(async()=>{if(!ke||Oe){it(a("rightSidebar.selectRepositoryForGitActions"));return}const r=rn.trim(),o=nn.trim();await st({action:"pull",cwd:ke,...r?{remote:r}:{},...o?{branch:o}:{}},a("rightSidebar.pullChanges"))},[ke,nn,rn,Oe,st,a]);i.useEffect(()=>{if(!We||!ke||Me)return;let r=!1;const o={push:a("rightSidebar.pushChanges"),pull:a("rightSidebar.pullChanges"),commit:a("rightSidebar.commitChanges"),"switch-branch":a("rightSidebar.switchBranch"),"stage-all":a("rightSidebar.stageAll"),"stash-all":a("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(r)return;const x=await Ec({cwd:ke,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const b={action:u,cwd:ke},R=o[u]??u;Qn({action:u});try{const P=await ga(x,b,R);if(r||!Re(v))return;const H=v?await wa(v,void 0,{includeNested:!0,cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:On(v)}).catch(()=>P.bundle):P.bundle;H&&zr(H,{reloadDiff:!0,cacheOnly:!0})}catch(P){r||it(a("rightSidebar.gitActionFailed",{message:P instanceof Error?P.message:"Unknown error"}))}finally{r||Qn(null)}return}})(),()=>{r=!0}},[ke,zr,We,Re,v,Me,a,ga]);const Li=Rn?.action==="commit",Fi=Rn?.action==="switch-branch",Di=Rn?.action==="pull",_i=Rn?.action==="push",ba=We||Uu,Ii=la?a("rightSidebar.changeAuditScopeAll"):ar.length===1?ar[0].label:`${ar.length} repos`,If=ar.length>0,xc=Gt.length>0,Bf=v?e.jsx(cd,{open:Za,onOpenChange:Qa,showScopePicker:!0,selectedAll:la,repos:Lt,selectedRoots:oa,onToggleRepo:Sf,onGenerate:()=>Cf(Ei?"regenerate":"generate"),disabled:!If,generateDisabled:!xc,inserted:te?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:a(Ei?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.branchAuditGenerateTitle"),ariaLabel:a("rightSidebar.branchAuditShort"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ii,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a(Ei?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Af()},secondaryDisabled:!xc||M,secondaryLabel:a("rightSidebar.branchAuditViewDiff"),secondaryTitle:a("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:M,loading:Ko.size>0,statusTitle:Ko.size>0?a("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsxs("label",{className:"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:a("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:a("rightSidebar.includeUncommittedHint")})]}),e.jsx("input",{type:"checkbox",checked:Pr,onChange:r=>Uo(r.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),Kl.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:a("rightSidebar.missingBaseReposSkipped",{repositories:Kl.map(r=>r.label).join(k==="zh"?"、":", ")})})]}),renderRepoExtra:r=>{const o=ut.get(r.root),u=[],x=new Set,b=(q,Ne)=>{!q||x.has(q)||(x.add(q),u.push({value:q,label:q,meta:Ne}))};b(gr[r.root]||o?.context?.branch,a("rightSidebar.pushCurrentBranchBadge"));for(const q of o?.context?.branches??[])b(q,q===o?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):a("rightSidebar.localBranch"));for(const q of o?.context?.remoteBranches??[])b(q,a("rightSidebar.remoteBranch"));const R=[],P=new Set,H=(q,Ne)=>{!q||P.has(q)||(P.add(q),R.push({value:q,label:q,meta:Ne}))};H(yt[r.root],yt[r.root]?a("rightSidebar.pushUpstreamBadge"):void 0),H(o?.context?.upstream,o?.context?.upstream?a("rightSidebar.pushUpstreamBadge"):void 0);for(const q of o?.context?.remoteBranches??[])H(q,"remote");for(const q of o?.context?.branches??[])H(q,q===o?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(Hn,{label:a("rightSidebar.currentBranchLabel"),value:gr[r.root]||o?.context?.branch||"",options:u,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),onChange:q=>{Fs(Ne=>({...Ne,[r.root]:q}))}}),e.jsx(Hn,{label:a("rightSidebar.branchAuditBaseLabel"),value:yt[r.root]||"",options:R,placeholder:a("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:a("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:a("rightSidebar.branchAuditBaseEmpty"),onChange:q=>{Ds(Ne=>({...Ne,[r.root]:q}))}})]})}}):null,bc=gs(wt.reduce((r,o)=>Math.max(r,o.injectedAt??0),0),k),zf=v?e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>Wo(r=>{const o=!r;return mt(Ki,o),o}),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":Zn,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(Rs,{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:a("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:Ii})]}),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 ${Zn?"rotate-90":""}`,children:e.jsx(ya,{size:13})})]}),Zn&&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:[a("rightSidebar.changeAuditScopeLabel"),": ",Ii]}),Bf]}),oe&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:oe}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Xr.map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ke===r.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:()=>$f(r),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:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-muted-foreground",children:[r.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.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:r.diff.baseRef??r.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:a("rightSidebar.branchAuditViewDiff")})]}),gs(r.createdAt,k)&&e.jsx("div",{className:"mt-1 truncate text-[10px] text-muted-foreground/70",children:gs(r.createdAt,k)})]}),e.jsx("button",{type:"button",onClick:()=>Ef(r.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:a("common.delete"),"aria-label":a("common.delete"),children:e.jsx(Pa,{size:12})})]},r.key)),Bn.length>0?Bn.slice(0,Math.max(0,8-Xr.length)).map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ke===r.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:()=>Mf(r.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:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-muted-foreground",children:[r.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.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:r.baseRef}),r.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diffFingerprint})]}),gs(r.latestInjectedAt,k)&&e.jsx("div",{className:"mt-1 truncate text-[10px] text-muted-foreground/70",children:a("rightSidebar.branchAuditGeneratedAt",{time:gs(r.latestInjectedAt,k)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{yf(r)},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:a("rightSidebar.branchAuditClearTitle"),"aria-label":a("rightSidebar.branchAuditClearTitle"),children:e.jsx(Pa,{size:12})})]},r.key)):Xr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,vc=rr&&v&&In?e.jsxs("div",{className:ba?"overflow-visible":"overflow-hidden",children:[zf,e.jsxs("button",{type:"button",onClick:()=>{We||Ku(r=>{const o=!r;return o&&ke&&!In&&!tn&&bi(ke),o})},"aria-expanded":ba,className:`group flex w-full items-center gap-2 px-1 py-1.5 text-left transition ${We?"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(Rr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex min-w-[4.5rem] items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${fn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[tn&&e.jsx(tt,{size:10,className:"animate-spin"}),fn.staged>0?a("rightSidebar.stagedCount",{count:fn.staged}):a("rightSidebar.noStagedChangesShort")]}),!We&&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 ${ba?"rotate-90":""}`,children:e.jsx(ya,{size:13})})]})]}),ba&&e.jsxs("div",{className:"space-y-0",children:[ft.length>1&&e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",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-[11px] font-semibold text-foreground",children:a("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:of})]})}),e.jsx(Hn,{label:a("rightSidebar.gitRepositoryLabel"),value:ke??"",options:ft,placeholder:a("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:a("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:a("rightSidebar.gitRepositoryEmpty"),disabled:!!Me,onChange:r=>{pc(r||null)}}),Oe&&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:a("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",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-[11px] font-semibold text-foreground",children:a("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:lf})]}),e.jsxs("button",{type:"button",onClick:()=>{Ff()},disabled:!bf,className:`relative inline-flex h-7 shrink-0 items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Fi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Me?.action==="switch-branch"||Fi?"opacity-0":"",children:a("rightSidebar.switchBranch")}),Me?.action==="switch-branch"&&e.jsx(tt,{size:12,className:"absolute animate-spin"}),Fi&&Me?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(Hn,{label:a("rightSidebar.currentBranchLabel"),value:es,options:uf,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),disabled:!!Me,onChange:si})]}),e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",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-[11px] font-semibold text-foreground",children:a("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:Oe?a("rightSidebar.selectRepositoryForGitActions"):fn.staged>0?a("rightSidebar.commitReadyHint",{count:fn.staged}):a("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{gc()},disabled:!!Me||Oe||fn.staged===0||!Bs.trim(),className:`relative inline-flex h-7 shrink-0 items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition active:scale-95 ${Li?"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:Oe?a("rightSidebar.selectRepositoryForGitActions"):fn.staged===0?a("rightSidebar.commitNeedsStaged"):a("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Me?.action==="commit"||Li?"opacity-0":"",children:a("rightSidebar.commitChanges")}),Me?.action==="commit"&&e.jsx(tt,{size:12,className:"absolute animate-spin"}),Li&&Me?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Bs,onChange:r=>Qo(r.target.value),onKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),gc())},placeholder:a("rightSidebar.commitMessagePlaceholder"),disabled:!!Me,className:"w-full rounded-md border border-border/15 bg-surface-2 px-2.5 py-1.5 text-[12px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary/35 focus:ring-1 focus:ring-primary/25 disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>pr(r=>!r),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":Xt,children:[e.jsx("span",{className:"min-w-0 text-[11px] font-semibold text-foreground",children:a("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Sn&&e.jsx(tt,{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 ${Xt?"rotate-90":""}`,children:e.jsx(ya,{size:13})})]})]}),Xt&&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(Wn,{size:12,className:"shrink-0"}),e.jsx("input",{value:kn,onChange:r=>Zr(r.target.value),placeholder:a("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}),kn&&e.jsx("button",{type:"button",onClick:()=>Zr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Dt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:cf,children:[Zt.length>0?Zt.map(r=>{const[o,...u]=r.split(/\s+/),x=u.join(" ")||r;return e.jsxs("button",{type:"button",onClick:()=>{Tf(r)},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:x,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:o}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),He===o&&e.jsx(tt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},r)}):Sn?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:a("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.recentCommitsEmpty")}),Q&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(tt,{size:12,className:"animate-spin"})}),Xa&&!Q&&Zt.length>0&&e.jsx("button",{type:"button",onClick:()=>{cs({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:a("rightSidebar.recentCommitsLoadMore")})]})]}),Je&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Je}),Jt&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Jt})]}),e.jsxs("div",{className:"px-1 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:a("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{_f()},disabled:!gf,className:`relative inline-flex h-7 min-w-[3.25rem] items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Di?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Me?.action==="pull"||Di?"opacity-0":"",children:a("rightSidebar.pullChanges")}),Me?.action==="pull"&&e.jsx(tt,{size:12,className:"absolute animate-spin"}),Di&&Me?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Df()},disabled:!xf,className:`relative inline-flex h-7 min-w-[3.25rem] items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${_i?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Me?.action==="push"||_i?"opacity-0":"",children:a("rightSidebar.pushChanges")}),Me?.action==="push"&&e.jsx(tt,{size:12,className:"absolute animate-spin"}),_i&&Me?.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] ${Vl.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:Vl.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 ${Ul?"grid-cols-2":"grid-cols-1"}`,children:[Ul&&e.jsx(Hn,{label:a("rightSidebar.pushRemoteLabel"),value:rn,options:Gl,placeholder:a("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:a("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:a("rightSidebar.pushNoRemotes"),disabled:!!Me,onChange:ai}),e.jsx(Hn,{label:a("rightSidebar.pushBranchLabel"),value:nn,options:ff,placeholder:a("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:a("rightSidebar.pushBranchSearchPlaceholder"),emptyText:a("rightSidebar.pushNoBranches"),disabled:!!Me,onChange:ii})]})]})]})]}):null,Hf=i.useCallback(r=>{const o=ht(r,v);if(!o)return[];const u=ao(r),x=[];return r.canStage&&x.push({key:"stage-file",label:a("rightSidebar.stageFile"),onClick:()=>{st({action:"stage-file",cwd:o,paths:[r.path]},a("rightSidebar.stageFile"),u)}}),r.canUnstage&&x.push({key:"unstage-file",label:a("rightSidebar.unstageFile"),onClick:()=>{st({action:"unstage-file",cwd:o,paths:[r.path]},a("rightSidebar.unstageFile"),u)}}),r.canStash&&x.push({key:"stash-file",label:a("rightSidebar.stashFile"),onClick:()=>{st({action:"stash-file",cwd:o,paths:[r.path]},a("rightSidebar.stashFile"),u)}}),r.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:a("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Lr({kind:"restore",file:r,phrase:""})}),x},[v,st,a]),Of=i.useCallback(()=>{if(h){f?.();return}br(0),yr.current?.slideTo(0),xr(!1),bt(null)},[f,h]),wc=i.useCallback(r=>{if(S(""),Pt(r),Xe(null),bt(null),le(null),J){h&&f?.(),br(0),yr.current?.slideTo(0),xr(!1);return}},[J,f,h,Xe,Pt]);i.useEffect(()=>{const r=o=>{const u=o.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;S(""),bt(null);const b=!!(v&&(x===v||x.startsWith(`${v}/`)));if(u.kind==="file"){const R=ro(x);is(x),Pt(b?null:R),le(P=>({path:x,nonce:(P?.nonce??0)+1}));return}Xe(null),b?(Pt(null),le(R=>({path:x,nonce:(R?.nonce??0)+1}))):(le(null),Pt(x)),J&&(h&&f?.(),br(0),yr.current?.slideTo(0),xr(!1))};return window.addEventListener(Tc,r),()=>window.removeEventListener(Tc,r)},[is,J,f,h,v,Xe,Pt]),i.useEffect(()=>{t||(Et(!1),Bt(!1))},[t]),i.useEffect(()=>{if(!Kt&&!cr)return;const r=o=>{o instanceof globalThis.KeyboardEvent&&o.key!=="Escape"||o instanceof globalThis.MouseEvent&&o.target instanceof Node&&($s.current?.contains(o.target)||xn.current?.contains(o.target))||(Et(!1),Bt(!1))};return window.addEventListener("mousedown",r),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",r)}},[cr,Kt]);const yc=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:nf,disabled:!na,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":a("rightSidebar.parentFolder"),title:a("rightSidebar.parentFolder"),children:e.jsx(vd,{size:14})}),e.jsx("button",{type:"button",onClick:Ll,disabled:!v||An===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":a("rightSidebar.backToProjectRoot"),title:a("rightSidebar.backToProjectRoot"),children:e.jsx(Fc,{size:14})}),e.jsx("button",{type:"button",onClick:sf,disabled:!me,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":a("rightSidebar.refreshFiles"),title:Jo?a("rightSidebar.fileWatchUnavailable",{message:Jo}):a("rightSidebar.refreshFiles"),children:e.jsx(fo,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:me??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:tf}),Ks==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:a("fileTree.sortedByModified"),"aria-label":a("fileTree.sortedByModified"),children:e.jsx(Pc,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>me&&Hr(me,At??void 0),disabled:!me,...me&&At?wi(ra(me),At):{},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 ${At&&(te===At||Ce===At)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":a(At&&Ce===At?"rightSidebar.copied":At&&te===At?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:a("rightSidebar.insertCurrentFolder"),children:At&&(te===At||Ce===At)?e.jsx(co,{size:13}):e.jsx(_a,{size:13})}),e.jsxs("div",{ref:xn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Et(!1),Bt(r=>!r)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${cr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":cr,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(uo,{size:14})}),cr&&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:()=>{Bt(!1),af()},disabled:!Si,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${ls?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ls?e.jsx(Hi,{size:14}):e.jsx(Sa,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ls?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),Yu()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${ui?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ui?e.jsx(Zh,{size:14}):e.jsx(po,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ui?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!me,onClick:()=>{me&&(Bt(!1),Xu(me,Ks==="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:[Ks==="modified"?e.jsx(Fh,{size:14}):e.jsx(Pc,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(Ks==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),v&&(sa.length>0||rf)&&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:a("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Ll,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-full px-2 py-0.5 font-medium transition active:scale-95 ${me===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(Fc,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:qe})]}),sa.map(r=>{const o=r.path,u=r.kind==="file",x=u?Ue===o:me===o;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-full transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o,children:[e.jsxs("button",{type:"button",onClick:()=>u?is(o):Pt(o),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(go,{size:10,className:"shrink-0"}):e.jsx(Sa,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ct(o)})]}),e.jsx("button",{type:"button",onClick:()=>an(o),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":a("rightSidebar.unpinFolder",{name:ct(o)}),title:a("rightSidebar.unpinFolder",{name:ct(o)}),children:e.jsx(Dt,{size:9})})]},o)})]}),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"})]}),Bi=i.useMemo(()=>{if(Nn===null)return null;const r=typeof navigator>"u"?void 0:navigator.language,o=Math.max(0,Math.floor((ni-Nn)/1e3)),u=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),[x,b]=o<60?[-o,"second"]:o<3600?[-Math.floor(o/60),"minute"]:o<86400?[-Math.floor(o/3600),"hour"]:[-Math.floor(o/86400),"day"];return u.format(x,b)},[ni,Nn]),kc=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Bi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:a("rightSidebar.gitLastUpdated",{time:Bi}),children:Bi}):null,e.jsx("button",{type:"button",onClick:()=>{ss()},disabled:Nt,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":a("rightSidebar.refreshGit"),title:a("rightSidebar.refreshGit"),children:e.jsx(fo,{size:13,className:Nt?"animate-spin":""})})]}):null,Wf=wl?a("rightSidebar.changeAuditScopeAll"):ln.length===1?ln[0].relativeRoot==="."?qe:ln[0].relativeRoot||ln[0].name:`${ln.length} repos`,Sc=v?e.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[e.jsx(cd,{open:Ts,onOpenChange:Mr,showScopePicker:hn,selectedAll:wl,repos:Zu,selectedRoots:Wt,onToggleRepo:kf,onGenerate:()=>vf(),disabled:!v,inserted:te===Pl,buttonLabel:a("rightSidebar.changeAuditShort"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:a("rightSidebar.insertChangeAuditPrompt"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Wf,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a("rightSidebar.changeAuditShort"),loading:Ar,error:!!Er,statusTitle:Er??(Ar?a("rightSidebar.changeAuditLoading"):wt.length>0?`${a("rightSidebar.changeAuditLoaded",{count:wt.length})}${bc?` · ${a("rightSidebar.changeAuditLoadedAt",{time:bc})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{wf()},disabled:Ar||wt.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${wt.length>0?"":"invisible"}`,title:a("rightSidebar.clearChangeAuditTitle"),"aria-label":a("rightSidebar.clearChangeAudit"),children:e.jsx(Pa,{size:12})})]}):null,va=ye.size>0||ne?.available||Fr?e.jsxs("div",{className:"flex flex-wrap items-center gap-1 text-[10px] font-medium",children:[ne?.available&&ne.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:ne.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ne.branch})]}),et.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[et.modified,"M"]}),et.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",et.added]}),et.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",et.deleted]}),et.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[et.renamed,"R"]}),et.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[et.copied,"C"]}),et.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[et.untracked,"U"]}),et.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[et.conflicted,"!"]}),et.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[et.other,"?"]}),et.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:a("rightSidebar.stagedCountShort",{count:et.staged})}),ne?.available&&v&&ye.size>0&&Z.length<=1&&e.jsx("button",{type:"button",onClick:()=>{st({action:"stage-all",cwd:v},a("rightSidebar.stageAll"))},disabled:!!Me,className:"rounded-full bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),ne?.available&&v&&ye.size>0&&Z.length<=1&&e.jsx("button",{type:"button",onClick:()=>Lr({kind:"stash-all",repoRoot:v,repoLabel:qe}),disabled:!!Me,className:"rounded-full bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}):null;return e.jsxs(Dh,{side:"right",isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c,children:[wi.popoverNode,e.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",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:qe}),(!J||ti)&&ne?.available&&ne.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:ne.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:ne.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const r=!ie;ue(r),r?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):S("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ie?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleSearch"),title:a("common.search"),children:e.jsx(Wn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":rt,onClick:()=>{pn(r=>!r),or(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${rt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleContextDraft"),title:a("rightSidebar.contextDraftTitle"),children:[e.jsx(lm,{size:14}),!rt&&xt.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:nl,type:"file",multiple:!0,className:"hidden",onChange:r=>{const o=r.target.files;!o||o.length===0||(os(Array.from(o)),r.target.value="")}}),e.jsx("input",{ref:sl,type:"file",accept:"image/*",className:"hidden",onChange:r=>{const o=r.target.files?.[0];r.target.value="",o&&ef(o)}}),m&&e.jsx("button",{type:"button",onClick:m,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${c?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:c?e.jsx(Hi,{size:14}):e.jsx(Sa,{size:14})}),e.jsxs("div",{ref:$s,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Bt(!1),Et(r=>!r)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Kt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Kt,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(uo,{size:15})}),Kt&&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:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Et(!1),nl.current?.click()},disabled:zs,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:[zs?e.jsx(tt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(xm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Et(!1),sl.current?.click()},disabled:zs,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:[zs?e.jsx(tt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(rm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.insertLocalImage")})]}),m&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Et(!1),m()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${c?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[c?e.jsx(Hi,{size:14}):e.jsx(Sa,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),c&&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":a("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:a("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",a("rightSidebar.layoutModeAuto")],["narrow",a("rightSidebar.layoutModeNarrow")],["wide",a("rightSidebar.layoutModeWide")]].map(([r,o])=>{const u=K===r;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{X(r),Et(!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:o},r)})})]})]})]}),e.jsx("button",{type:"button",onClick:s,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":a("rightSidebar.close"),children:e.jsx(Dt,{size:14})})]}),ie&&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(Wn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:B,onChange:r=>S(r.target.value),placeholder:a(A==="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 ${J?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>hc("name"),"aria-pressed":A==="name",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${A==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>hc("content"),"aria-pressed":A==="content",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${A==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeContent")})]}),B&&e.jsx("button",{type:"button",onClick:()=>S(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Dt,{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(_h,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:V,onChange:r=>re(r.target.value),onKeyDown:r=>{r.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:a("rightSidebar.searchScopePlaceholder"),"aria-label":a("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),V!=="."&&e.jsx("button",{type:"button",onClick:()=>re("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.resetSearchScope"),children:e.jsx(Dt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>xe(r=>!r),"aria-expanded":O,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${O||ts.length>0||W||je||_e?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:a("rightSidebar.searchOptions"),"aria-label":a("rightSidebar.searchOptions"),children:[e.jsx(Ih,{size:13}),ts.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:ts.length})]})]}),O&&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:a("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:ee,onChange:r=>ge(r.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchExcludePlaceholder"),"aria-label":a("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),ee&&e.jsx("button",{type:"button",onClick:()=>ge(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":a("rightSidebar.clearSearchExclude"),children:e.jsx(Dt,{size:11})})]}),A==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":a("rightSidebar.contentSearchOptions"),children:[[W,()=>pe(r=>!r),Yh,a("rightSidebar.matchCase")],[je,()=>Ae(r=>!r),vm,a("rightSidebar.matchWholeWord")],[_e,()=>Rt(r=>!r),dm,a("rightSidebar.useRegex")]].map(([r,o,u,x])=>e.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${r?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),x]},x))})]})]}),Js?null:e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>sn("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Rr,{size:12}),a("rightSidebar.tabGit"),Nt&&kr==="git"?e.jsx(tt,{size:12,className:"animate-spin text-muted-foreground"}):null]}),e.jsxs("button",{type:"button",onClick:()=>sn("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Ed,{size:12}),a("rightSidebar.tabChanges"),Nt?e.jsx(tt,{size:12,className:"animate-spin text-muted-foreground"}):ye.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:ye.size}):null]}),e.jsxs("button",{type:"button",onClick:()=>sn("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Hh,{size:12}),a("rightSidebar.tabFiles")]})]}),e.jsx("div",{className:"h-2"}),Xo&&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:Xo})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(to,{active:We,mounted:rr,fallback:e.jsx(ps,{slow:!1}),children:Ie?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Bc,{items:jf,selectedKey:Hu,onSelect:Ps,emptyText:a("rightSidebar.noChanges"),mobile:J,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a("rightSidebar.recentCommitsTitle"),headerMeta:`${Ie.headRef??""}${Ie.commits?.[0]?` · ${Ie.commits[0]}`:""}`,onClose:()=>{Ee(null),Ps(null)},closeLabel:a("common.back"),wrap:Mt,onToggleWrap:J?Pi:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:te,copiedReferenceKey:Ce,onClearAuditRecord:fa})}):mr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Bc,{items:$i,selectedKey:Ja,onSelect:en,emptyText:a($e?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:J,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a($e?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:ha?`${ha.repoLabel} · ${ha.branchName??"HEAD"} → ${ha.baseRef}`:void 0,onClose:()=>{Vt(!1),Yt(null)},closeLabel:a("common.back"),wrap:Mt,onToggleWrap:J?Pi:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:te,copiedReferenceKey:Ce,onClearAuditRecord:fa,walkthroughs:Rf,onWalkthroughNavigate:Nf,initialDetailScrollTop:$e&&Ke?wn[Ke]:void 0,onDetailScrollPositionChange:Pf,externalSwiperRef:J?Zs:void 0,onMobileSlideChange:J?ei:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain px-2 py-2",children:vc||(Nt?e.jsx(ps,{slow:Us}):En?e.jsx(Ma,{message:En,onRetry:()=>{ss()}}):pd(ne)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):ne?.available===!1?e.jsx(Ma,{message:ne.error??a("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ss()}}):v?e.jsx(ps,{slow:Us}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}))})}),e.jsx(to,{active:Dn,children:J?e.jsxs(yd,{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:r=>{yr.current=r,r.slideTo(Vo,0)},onSlideChange:r=>{if(br(r.activeIndex),ns.current===r.activeIndex){ns.current=null;return}r.activeIndex===0&&(xr(!1),bt(null),f?.())},children:[e.jsx(ho,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Mn,onScroll:kl,onDragOver:ea,onDragEnter:ea,onDragLeave:Rl,onDrop:Nl,className:"h-full overflow-y-auto overscroll-contain bg-surface relative",children:[el&&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:a("rightSidebar.dropToUpload")})}),!B.trim()&&yc,e.jsx(Lc,{rootPath:me??"",onFileSelect:is,onPathReference:Hr,getReferenceText:ra,onReferenceCopied:Sr,insertedReferenceKey:te,copiedReferenceKey:Ce,onDirectoryRoot:Fl,onSearchFromDirectory:Dl,onDirectoryPinToggle:_l,onFilePinToggle:Il,pinnedPaths:dn,selectedFilePath:Ue,query:fe,searchRootPath:gl,searchOptions:xl,searchMode:A,onContentMatchSelect:Sl,onDirectoryDropFiles:(r,o)=>os(o,r),revealDirectory:Y,canOpenInFileBrowser:tl,onOpenInFileBrowser:jl})]})}),e.jsx(ho,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(To,{filePath:Dn&&(Ou||Vo===1)?Ue:null,onInsertReference:Hr,onInsertText:jr,onInsertFeature:jr,onReviewReference:Ml,onReferenceCopied:Sr,onClose:Of,onDirectoryLinkOpen:wc,isMobile:!0,lineRange:Ur,onLineRangeChange:bt,insertedReferenceKey:te,copiedReferenceKey:Ce,scrollToLine:Nr,onScrollToLineHandled:()=>Pe(null),markdownOutlineOpen:_,markdownOutlineCloseSignal:L,onOpenMarkdownOutline:j,onCloseMarkdownOutline:T,markdownImageLightboxOpen:C,markdownImageLightboxCloseSignal:F,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Mn,onScroll:kl,onDragOver:ea,onDragEnter:ea,onDragLeave:Rl,onDrop:Nl,className:"shrink-0 overflow-y-auto overscroll-contain bg-surface relative",style:{width:li},children:[el&&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:a("rightSidebar.dropToUpload")})}),!B.trim()&&yc,e.jsx(Lc,{rootPath:me??"",onFileSelect:is,onPathReference:Hr,getReferenceText:ra,onReferenceCopied:Sr,insertedReferenceKey:te,copiedReferenceKey:Ce,onDirectoryRoot:Fl,onSearchFromDirectory:Dl,onDirectoryPinToggle:_l,onFilePinToggle:Il,pinnedPaths:dn,selectedFilePath:Ue,query:fe,searchRootPath:gl,searchOptions:xl,searchMode:A,onContentMatchSelect:Sl,onDirectoryDropFiles:(r,o)=>os(o,r),revealDirectory:Y,canOpenInFileBrowser:tl,onOpenInFileBrowser:jl})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("rightSidebar.resizeFileTree"),title:a("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:Qu,onPointerMove:Ju,onPointerUp:yl,onPointerCancel:yl,onDoubleClick:()=>{ci(yo),mt(xs,yo)},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(To,{filePath:Dn?Ue:null,onInsertReference:Hr,onInsertText:jr,onInsertFeature:jr,onReviewReference:Ml,onReferenceCopied:Sr,onDirectoryLinkOpen:wc,isMobile:!1,lineRange:Ur,onLineRangeChange:bt,insertedReferenceKey:te,copiedReferenceKey:Ce,scrollToLine:Nr,onScrollToLineHandled:()=>Pe(null),markdownOutlineOpen:_,markdownOutlineCloseSignal:L,onOpenMarkdownOutline:j,onCloseMarkdownOutline:T,markdownImageLightboxOpen:C,markdownImageLightboxCloseSignal:F,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D})})]})}),e.jsx(to,{active:ot,mounted:Wu||ot,children:()=>J?e.jsx(mo,{mobile:!0,backLabel:a("rightSidebar.backToChangeList"),externalSwiperRef:Zs,onMobileSlideChange:ei,groups:Ft.length>0?tc():[],mode:vt,onModeChange:pa,selectedKey:Ue,scrollToKey:ac,scrollToKeyNonce:Os.nonce,compact:!1,collapsedDirectoryKeys:dr,onToggleDirectory:lc,onSelectFile:r=>{const o=Array.from(ye.values()).find(u=>lt(u)===r.key);o&&ma(lt(o))},renderLeading:nc,renderTrailing:r=>{const o=Array.from(ye.values()).find(u=>lt(u)===r.key);return o?Jl(o):null},renderDirectoryTrailing:ec,renderSubtitle:r=>{const o=Array.from(ye.values()).find(u=>lt(u)===r.key);return o?Zl(o):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:r=>v&&e.jsxs("div",{className:"px-0 py-0",children:[va&&e.jsx("div",{className:"mb-2",children:va}),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:a("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Ft.length,"/",ye.size]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Yl(),r,c&&Ci(),Sc,kc]}),kt&&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:kt.label}),kt.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:kt.branch})]}),!kt&&hn&&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(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:ia?(r=>oc(r)):void 0,emptyContent:Nt&&ye.size===0&&Fr===null?e.jsx(ps,{slow:Us}):En&&ye.size===0?e.jsx(Ma,{message:En,onRetry:()=>{ss()}}):ye.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ft.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>as(0),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:a("rightSidebar.backToChangeList"),children:[e.jsx(ks,{size:14}),a("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[c&&Ci(),e.jsxs("button",{type:"button",onClick:Pi,"aria-pressed":Mt,title:a("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 ${Mt?"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:a(Mt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:rc(),activePane:ot,wrap:Mt,showScrollHint:!Mt,diffViewType:Vu,inlineMode:Kn,diffOptions:fc,reloadKey:ur,renderStreamBadge:r=>e.jsx(ws,{status:r}),onHunkGitAction:mc,onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:te,copiedReferenceKey:Ce,onClearAuditRecord:fa,onDetailScroll:ca}):e.jsx(mo,{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:a("rightSidebar.backToChangeList"),groups:Ft.length>0?tc():[],mode:vt,onModeChange:pa,selectedKey:Ue,scrollToKey:ac,scrollToKeyNonce:Os.nonce,compact:!0,collapsedDirectoryKeys:dr,onToggleDirectory:lc,onSelectFile:r=>{const o=Array.from(ye.values()).find(u=>lt(u)===r.key);o&&ma(lt(o))},renderLeading:nc,renderTrailing:r=>{const o=Array.from(ye.values()).find(u=>lt(u)===r.key);return o?Jl(o):null},renderDirectoryTrailing:ec,renderSubtitle:r=>{const o=Array.from(ye.values()).find(u=>lt(u)===r.key);return o?Zl(o):null},aiContent:ia?(r=>oc(r)):void 0,emptyContent:Nt&&ye.size===0&&Fr===null?e.jsx(ps,{slow:Us}):En&&ye.size===0?e.jsx(Ma,{message:En,onRetry:()=>{ss()}}):ye.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ft.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderListHeader:r=>v&&e.jsxs("div",{className:"px-0 py-0",children:[va&&e.jsx("div",{className:"mb-2",children:va}),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:a("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Ft.length,"/",ye.size]})})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Yl(),r,Ci(),Sc,kc]}),kt&&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:kt.label}),kt.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:kt.branch}),e.jsx("button",{type:"button",onClick:()=>xa("stage-all",kt.root,kt.label),disabled:!!Me,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:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>xa("stash-all",kt.root,kt.label),disabled:!!Me,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:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}),!kt&&hn&&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(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),files:rc(),activePane:ot,wrap:Mt,showScrollHint:!Mt,diffViewType:qt,inlineMode:Kn,diffOptions:fc,reloadKey:ur,renderStreamBadge:r=>e.jsx(ws,{status:r}),onHunkGitAction:mc,onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:te,copiedReferenceKey:Ce,onClearAuditRecord:fa,onDetailScroll:ca})})]}),t&&rt&&e.jsx(Wm,{value:xt,collapsed:dt,autoCollapseAfterSend:Ut,focusRequest:Gr,insertError:Un?a("rightSidebar.contextDraftInsertFailed"):null,onChange:r=>{zt(!1),It(r)},onCollapsedChange:or,onAutoCollapseAfterSendChange:gn,onDisable:()=>pn(!1),onClear:()=>It(""),onInsert:()=>Tl(!1),onInsertAndSend:()=>Tl(!0),labels:{title:a("rightSidebar.contextDraftTitle"),hint:a("rightSidebar.contextDraftHint"),placeholder:a("rightSidebar.contextDraftPlaceholder"),collapse:a("rightSidebar.contextDraftCollapse"),expand:a("rightSidebar.contextDraftExpand"),disable:a("rightSidebar.contextDraftDisable"),clear:a("rightSidebar.contextDraftClear"),insert:a("rightSidebar.contextDraftInsert"),insertAndSend:a("rightSidebar.contextDraftInsertAndSend"),inserted:a("rightSidebar.contextDraftInserted"),sent:a("rightSidebar.contextDraftSent"),send:a("rightSidebar.contextDraftSend"),appended:a("rightSidebar.contextDraftAppended"),resize:a("rightSidebar.contextDraftResize"),autoCollapseAfterSend:a("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:r=>a("rightSidebar.contextDraftCharacterCount",{count:r})}}),pf(),at&&typeof document<"u"&&Wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Lr(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:r=>r.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:at.kind==="restore"?a("rightSidebar.confirmRestoreTitle"):a("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:at.kind==="restore"?a("rightSidebar.confirmRestoreDescription",{path:bd(at.file.absolutePath,v)}):a("rightSidebar.confirmStashAllDescription")}),at.kind==="restore"&&e.jsx("input",{value:at.phrase,onChange:r=>Lr({...at,phrase:r.target.value}),placeholder:a("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:()=>Lr(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:a("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Me||at.kind==="restore"&&at.phrase.trim()!==a("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(at.kind==="restore"){const r=ht(at.file,v);if(!r)return;st({action:"restore-worktree-file",cwd:r,paths:[at.file.path],confirm:{acknowledged:!0,phrase:at.phrase}},a("rightSidebar.restoreFile"),ao(at.file))}else{const r=at.repoRoot??v;if(!r)return;st({action:"stash-all",cwd:r},a("rightSidebar.stashAll"),`repo:${r}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${at.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:a(Me?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const ux=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:To,MarkdownImageLightbox:Au,MarkdownPreview:$u,RightSidebar:Jg,__testParseMarkdownListBlock:gg,buildMarkdownPreviewBlocks:Cg,buildMarkdownPreviewRenderResult:Bo,computeMarkdownImageDisplayBox:uu,getMarkdownHeadingOutline:Cu,getMarkdownHeadingPathAtLine:Nu,getNextMarkdownPreviewLineRange:Pg,isSvgImageSrc:Ka,mountRightSidebarRepoPickerOverlay:Bd,replaceGitRepositorySnapshot:Fu,resolveMarkdownLocalLinkTarget:du,resolveRightSidebarDiffViewType:Zd,shouldCloseMarkdownImageLightboxDrag:Su},Symbol.toStringTag,{value:"Module"}));export{po as E,Fc as H,sm as M,ux as R,Zh as a,im as b,wm as c,dx as m};
|