termdock 1.4.276 → 1.4.278
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-Cq29NTOz.js → App-B9sF3w2s.js} +3 -3
- package/dist/client/assets/App-B9sF3w2s.js.br +0 -0
- package/dist/client/assets/App-B9sF3w2s.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-t4NOgjxM.js → ChangeWalkthroughPanel-CxZUvDAd.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-CxZUvDAd.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-CxZUvDAd.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-CxQvsac8.js → DagPlayground-qCvoNctr.js} +1 -1
- package/dist/client/assets/DagPlayground-qCvoNctr.js.br +0 -0
- package/dist/client/assets/DagPlayground-qCvoNctr.js.gz +0 -0
- package/dist/client/assets/{DiffLab-B5_y5WUP.js → DiffLab-AvAzGn0O.js} +18 -2
- package/dist/client/assets/DiffLab-AvAzGn0O.js.br +0 -0
- package/dist/client/assets/DiffLab-AvAzGn0O.js.gz +0 -0
- package/dist/client/assets/{DiffReview-J3wlEpHg.js → DiffReview-BPoTVb4U.js} +1 -1
- package/dist/client/assets/DiffReview-BPoTVb4U.js.br +0 -0
- package/dist/client/assets/DiffReview-BPoTVb4U.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-DZI1-J1D.js → DiffReviewLab-RlgTF9t-.js} +1 -1
- package/dist/client/assets/DiffReviewLab-RlgTF9t-.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-RlgTF9t-.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-CgtVILev.js → DiffViewer-DS97bKwR.js} +2 -2
- package/dist/client/assets/DiffViewer-DS97bKwR.js.br +0 -0
- package/dist/client/assets/DiffViewer-DS97bKwR.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-CFe_gbXI.js → ModelPreview-LnA0nAyy.js} +1 -1
- package/dist/client/assets/ModelPreview-LnA0nAyy.js.br +0 -0
- package/dist/client/assets/ModelPreview-LnA0nAyy.js.gz +0 -0
- package/dist/client/assets/{RightSidebar-iy7-XSSb.js → RightSidebar-DlvXEZl2.js} +29 -29
- package/dist/client/assets/RightSidebar-DlvXEZl2.js.br +0 -0
- package/dist/client/assets/RightSidebar-DlvXEZl2.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-CXXSvKzJ.js → abnfDiagram-VCTEODGH-CKpti1m8.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-CKpti1m8.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CKpti1m8.js.gz +0 -0
- package/dist/client/assets/{app-DbY083Oo.js → app-BC9ahlMu.js} +3 -3
- package/dist/client/assets/app-BC9ahlMu.js.br +0 -0
- package/dist/client/assets/app-BC9ahlMu.js.gz +0 -0
- package/dist/client/assets/{arc-cp7SkvLQ.js → arc-gNPtq3yt.js} +1 -1
- package/dist/client/assets/arc-gNPtq3yt.js.br +0 -0
- package/dist/client/assets/arc-gNPtq3yt.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-C644wSuo.js → architectureDiagram-5GKGNRK7-CdHXpqBK.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CdHXpqBK.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CdHXpqBK.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-D5KyGuKi.js → blockDiagram-I7D4REHJ-CeP54cee.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-CeP54cee.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CeP54cee.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-me7O251H.js → c4Diagram-7LVT6UL2-cHCmhbQI.js} +1 -1
- package/dist/client/assets/{c4Diagram-7LVT6UL2-me7O251H.js.br → c4Diagram-7LVT6UL2-cHCmhbQI.js.br} +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-cHCmhbQI.js.gz +0 -0
- package/dist/client/assets/channel-C7g_1K_7.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-BwXplC7w.js → chunk-2Q5K7J3B-DI4xUq0S.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-Cxv0b7hH.js → chunk-5VM5RSS4-tDcJlq2o.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-DocSLwjs.js → chunk-F27PBJKO-BScDIuh8.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-BScDIuh8.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-BScDIuh8.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-Crh3XcBw.js → chunk-IMKFNOWR-lJFiouZv.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-lJFiouZv.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-lJFiouZv.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-DhvxSds2.js → chunk-JWPE2WC7-6bwXWmfF.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-CTsXvY77.js → chunk-POPQ4Y6H-B6XqN-3a.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-B6tUp675.js → chunk-SVP7TREG-WJuXEZfd.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-WJuXEZfd.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-WJuXEZfd.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-Cq3Ij5FB.js → chunk-TICWLB2K-D9MEdoJ8.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-D9MEdoJ8.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-D9MEdoJ8.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-BFnmmnaf.js → chunk-XXDRQBXY-C0iba-a6.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-qGK4bnbQ.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-qGK4bnbQ.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CH79v5Nm.js → cose-bilkent-JH36ORCC-BhskeAQC.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-BhskeAQC.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-BhskeAQC.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-DPtsHlxo.js → cynefin-OW5HDTMX-D1PqlYP5.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-D1PqlYP5.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-D1PqlYP5.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Ynazqz1w.js → cynefinDiagram-5FMLGOSQ-CkT7s5fS.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CkT7s5fS.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CkT7s5fS.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-DfM9ezHp.js → dagre-GXQ25YYZ-P4Bn1-Ql.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-P4Bn1-Ql.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-P4Bn1-Ql.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-B_h8RQqw.js → diagram-S7CK7UJ4-CYHkiLlh.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-CYHkiLlh.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-CYHkiLlh.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-pPwb9I5q.js → diagram-UQ7AKVKN-By1GhFmd.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-By1GhFmd.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-By1GhFmd.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-CBpO8J25.js → diagram-VSXAHHWV-HFZdQWuL.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-HFZdQWuL.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-HFZdQWuL.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-DNyQxlf3.js → diagram-VX7I27RA-CpRS0TR1.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-CpRS0TR1.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CpRS0TR1.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-dAyb1bjd.js → diagram-Z3DM3KII-Bt-lhQfM.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-Bt-lhQfM.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-Bt-lhQfM.js.gz +0 -0
- package/dist/client/assets/{diffWorker-CXk6Uh2K.js → diffWorker-BP4IBsm9.js} +19 -19
- package/dist/client/assets/diffWorker-BP4IBsm9.js.br +0 -0
- package/dist/client/assets/diffWorker-BP4IBsm9.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-DMacuimR.js → ebnfDiagram-PWID7BFC-C_SFbWHg.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C_SFbWHg.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C_SFbWHg.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-DryfjFD1.js → erDiagram-RLTQ6QDP-0BzWKWfz.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-0BzWKWfz.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-0BzWKWfz.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-c6F7RHIg.js → flowDiagram-HODETNUW-BHGqf2cx.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-BHGqf2cx.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BHGqf2cx.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-j2F3mG_i.js → ganttDiagram-EL5Y4UJY-BLLXXOMB.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BLLXXOMB.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BLLXXOMB.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-BKuMofhC.js → gestureArbiter-D6__mga9.js} +1 -1
- package/dist/client/assets/gestureArbiter-D6__mga9.js.br +0 -0
- package/dist/client/assets/gestureArbiter-D6__mga9.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-wHkJC0Y4.js → gitGraphDiagram-WWUBYQGX-PyDAJiNT.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-PyDAJiNT.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-PyDAJiNT.js.gz +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-CMjoG3lb.js → infoDiagram-27XIBGKW-Bx6hiRnS.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-Di0_L7ly.js → ishikawaDiagram-5VMMS53U-M7j62WoM.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-M7j62WoM.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-M7j62WoM.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-Bxe0PyVR.js → journeyDiagram-3NMN7TZE-BpwCPT97.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-BpwCPT97.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-BpwCPT97.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-CV4lZYuw.js → kanban-definition-UXKFOSKX-Yzel2tIk.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-Yzel2tIk.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-Yzel2tIk.js.gz +0 -0
- package/dist/client/assets/{layout-Dr592wOu.js → layout-DIOtDzMT.js} +1 -1
- package/dist/client/assets/layout-DIOtDzMT.js.br +0 -0
- package/dist/client/assets/{layout-Dr592wOu.js.gz → layout-DIOtDzMT.js.gz} +0 -0
- package/dist/client/assets/{linear-C68vc9xn.js → linear-CYTKiHh3.js} +1 -1
- package/dist/client/assets/{linear-C68vc9xn.js.br → linear-CYTKiHh3.js.br} +0 -0
- package/dist/client/assets/linear-CYTKiHh3.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-2nIFOgS5.js → mermaid.core-GZ0ccUut.js} +5 -5
- package/dist/client/assets/mermaid.core-GZ0ccUut.js.br +0 -0
- package/dist/client/assets/mermaid.core-GZ0ccUut.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-DNHcj6nu.js → mindmap-definition-YA3MSWOX-BjFnhjnX.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BjFnhjnX.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BjFnhjnX.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-LVdEOMqV.js → passwordBootstrap-DDWRw8xD.js} +1 -1
- package/dist/client/assets/passwordBootstrap-DDWRw8xD.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-DDWRw8xD.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-H95jp1fe.js → pegDiagram-XKGWAZYB-B_2bhup_.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-B_2bhup_.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-B_2bhup_.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-CSTb71Ib.js → pieDiagram-E7YTZNPT-DxRHY5Bw.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-DxRHY5Bw.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DxRHY5Bw.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Cj0bkb73.js → quadrantDiagram-AXDQQJYC-DGZSe-or.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DGZSe-or.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DGZSe-or.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-CaYCI8KZ.js → railroadDiagram-O6MQD6OU-B6tcRTjp.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-B6tcRTjp.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-B6tcRTjp.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-oAK_YNlu.js → referenceLongPress-D794nQPp.js} +1 -1
- package/dist/client/assets/referenceLongPress-D794nQPp.js.br +0 -0
- package/dist/client/assets/referenceLongPress-D794nQPp.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-DpvXahus.js → requirementDiagram-BXWQKSXE-A6KwdefC.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-A6KwdefC.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-A6KwdefC.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-h5n85VQj.js → sankeyDiagram-P5KCCOFB-dn2opeBy.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-dn2opeBy.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-dn2opeBy.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-BHJ1nrRd.js → sequenceDiagram-WJ2MYXX4-jmahfErT.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-jmahfErT.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-jmahfErT.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-DX2fcAbk.js → sizeCapture-INFHLROL-C0nrDu34.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-C0nrDu34.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-C0nrDu34.js.gz +0 -0
- package/dist/client/assets/{sparkles-DheyoSzk.js → sparkles-d-iJvm_O.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-CC2yYkck.js → stateDiagram-D77RDMKH-DVFj20gA.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-DVFj20gA.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DVFj20gA.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CdA1e29U.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-_T5qwTlD.js → swimlanes-42K2YHIH-Bjw982EH.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-Bjw982EH.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-Bjw982EH.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DewEb_kK.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-BqFoa3XX.js → timeline-definition-24CTP7MA-P48yIIwD.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-P48yIIwD.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-P48yIIwD.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-BbXTlgzI.js → triangle-alert-D8tYRSDm.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-CSpiX1Bh.js → vennDiagram-4TSXK5OY-BI3GejUb.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-BI3GejUb.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-BI3GejUb.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-cGdw8Ed4.js → wardleyDiagram-VM6X3IG4-CMNFkEQF.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-CMNFkEQF.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-CMNFkEQF.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-Du4geU5J.js → xychartDiagram-S5SC5T6Z-BJ-0OPt3.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BJ-0OPt3.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BJ-0OPt3.js.gz +0 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/package.json +1 -1
- package/runtime-manifest.json +2 -2
- package/dist/client/assets/App-Cq29NTOz.js.br +0 -0
- package/dist/client/assets/App-Cq29NTOz.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-t4NOgjxM.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-t4NOgjxM.js.gz +0 -0
- package/dist/client/assets/DagPlayground-CxQvsac8.js.br +0 -0
- package/dist/client/assets/DagPlayground-CxQvsac8.js.gz +0 -0
- package/dist/client/assets/DiffLab-B5_y5WUP.js.br +0 -0
- package/dist/client/assets/DiffLab-B5_y5WUP.js.gz +0 -0
- package/dist/client/assets/DiffReview-J3wlEpHg.js.br +0 -0
- package/dist/client/assets/DiffReview-J3wlEpHg.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-DZI1-J1D.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-DZI1-J1D.js.gz +0 -0
- package/dist/client/assets/DiffViewer-CgtVILev.js.br +0 -0
- package/dist/client/assets/DiffViewer-CgtVILev.js.gz +0 -0
- package/dist/client/assets/ModelPreview-CFe_gbXI.js.br +0 -0
- package/dist/client/assets/ModelPreview-CFe_gbXI.js.gz +0 -0
- package/dist/client/assets/RightSidebar-iy7-XSSb.js.br +0 -0
- package/dist/client/assets/RightSidebar-iy7-XSSb.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CXXSvKzJ.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CXXSvKzJ.js.gz +0 -0
- package/dist/client/assets/app-DbY083Oo.js.br +0 -0
- package/dist/client/assets/app-DbY083Oo.js.gz +0 -0
- package/dist/client/assets/arc-cp7SkvLQ.js.br +0 -0
- package/dist/client/assets/arc-cp7SkvLQ.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C644wSuo.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C644wSuo.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-D5KyGuKi.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-D5KyGuKi.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-me7O251H.js.gz +0 -0
- package/dist/client/assets/channel-D7fov9Fv.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-DocSLwjs.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-DocSLwjs.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Crh3XcBw.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Crh3XcBw.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-B6tUp675.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-B6tUp675.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-Cq3Ij5FB.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-Cq3Ij5FB.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-DhMDhp7_.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DhMDhp7_.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-CH79v5Nm.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-CH79v5Nm.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-DPtsHlxo.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-DPtsHlxo.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Ynazqz1w.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Ynazqz1w.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-DfM9ezHp.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-DfM9ezHp.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-B_h8RQqw.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-B_h8RQqw.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-pPwb9I5q.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-pPwb9I5q.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-CBpO8J25.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-CBpO8J25.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-DNyQxlf3.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-DNyQxlf3.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-dAyb1bjd.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-dAyb1bjd.js.gz +0 -0
- package/dist/client/assets/diffWorker-CXk6Uh2K.js.br +0 -0
- package/dist/client/assets/diffWorker-CXk6Uh2K.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DMacuimR.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DMacuimR.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DryfjFD1.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DryfjFD1.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-c6F7RHIg.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-c6F7RHIg.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-j2F3mG_i.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-j2F3mG_i.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-BKuMofhC.js.br +0 -0
- package/dist/client/assets/gestureArbiter-BKuMofhC.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-wHkJC0Y4.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-wHkJC0Y4.js.gz +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Di0_L7ly.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Di0_L7ly.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Bxe0PyVR.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Bxe0PyVR.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-CV4lZYuw.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-CV4lZYuw.js.gz +0 -0
- package/dist/client/assets/layout-Dr592wOu.js.br +0 -0
- package/dist/client/assets/linear-C68vc9xn.js.gz +0 -0
- package/dist/client/assets/mermaid.core-2nIFOgS5.js.br +0 -0
- package/dist/client/assets/mermaid.core-2nIFOgS5.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-DNHcj6nu.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-DNHcj6nu.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-LVdEOMqV.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-LVdEOMqV.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-H95jp1fe.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-H95jp1fe.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CSTb71Ib.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CSTb71Ib.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Cj0bkb73.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Cj0bkb73.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CaYCI8KZ.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CaYCI8KZ.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-oAK_YNlu.js.br +0 -0
- package/dist/client/assets/referenceLongPress-oAK_YNlu.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DpvXahus.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DpvXahus.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-h5n85VQj.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-h5n85VQj.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BHJ1nrRd.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BHJ1nrRd.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DX2fcAbk.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DX2fcAbk.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-CC2yYkck.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-CC2yYkck.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-C4wTnOPJ.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-_T5qwTlD.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-_T5qwTlD.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DKcGlYxN.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-BqFoa3XX.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BqFoa3XX.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CSpiX1Bh.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CSpiX1Bh.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-cGdw8Ed4.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-cGdw8Ed4.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Du4geU5J.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Du4geU5J.js.gz +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-
|
|
2
|
-
import{a6 as Ar,cM as St,bi as e,g as co,cW as Lt,bA as mt,a as Os,aR as du,C as Ui,c as Us,X as Yt,cJ as so,b6 as Vh,G as Ns,ap as qh,cQ as J,ba as Yh,bc as dl,bd as Xh,be as uu,bb as Ms,aC as Jh,E as Qh,i as Zh,b9 as em,bC as tm,bE as rm,bF as nm,b1 as sm,bD as cd,F as Ct,f as am,L as Nt,x as om,b as im,cL as vi,b0 as dd,ay as ud,au as lm,aG as yi,aH as fd,cX as Ds,al as Es,aI as cm,cK as Wa,bu as dm,cv as hd,aA as um,cH as fm,c3 as hm,aL as mm,R as md,Q as pm,av as pd,az as gm,aE as gd,c5 as bm,t as bd,d as Ga,m as xd,y as fu,ag as xm,_ as Hs,bZ as vm,cU as ym,bp as wm,aj as km}from"./app-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-LnA0nAyy.js","assets/app-BC9ahlMu.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-DeTcW7aT.css","assets/App-B9sF3w2s.js","assets/gestureArbiter-D6__mga9.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-D8tYRSDm.js","assets/referenceLongPress-D794nQPp.js","assets/DiffReview-BPoTVb4U.js","assets/sparkles-d-iJvm_O.js","assets/DiffViewer-DS97bKwR.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-CxZUvDAd.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-GZ0ccUut.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a6 as Ar,cM as St,bi as e,g as co,cW as Lt,bA as mt,a as Os,aR as du,C as Ui,c as Us,X as Yt,cJ as so,b6 as Vh,G as Ns,ap as qh,cQ as J,ba as Yh,bc as dl,bd as Xh,be as uu,bb as Ms,aC as Jh,E as Qh,i as Zh,b9 as em,bC as tm,bE as rm,bF as nm,b1 as sm,bD as cd,F as Ct,f as am,L as Nt,x as om,b as im,cL as vi,b0 as dd,ay as ud,au as lm,aG as yi,aH as fd,cX as Ds,al as Es,aI as cm,cK as Wa,bu as dm,cv as hd,aA as um,cH as fm,c3 as hm,aL as mm,R as md,Q as pm,av as pd,az as gm,aE as gd,c5 as bm,t as bd,d as Ga,m as xd,y as fu,ag as xm,_ as Hs,bZ as vm,cU as ym,bp as wm,aj as km}from"./app-BC9ahlMu.js";import{b as a,r as qr}from"./dnd-BCFAPC0L.js";import{q as hu,k as Sm,r as vd,v as ao,g as jm,V as Rm,P as Cm,o as Nm,i as Mm,M as Em,R as Hi,w as mu,x as $m,S as Jn,D as Lm,e as pu,c as Pm,N as gu,A as wi,J as Am,E as wn,y as Tm,z as Im,I as Dm,K as Fm,B as yd,O as wd,T as kd,H as Sd,f as jd,n as ki,m as Ka,d as _m,s as Bm,l as Om,h as Um,t as Hm,F as Rd,C as zm,a as Wm,G as Gm}from"./App-B9sF3w2s.js";import{a as Cd,S as Nd,b as bu,c as zi,F as Km}from"./gestureArbiter-D6__mga9.js";import{D as Wi,C as Fs,L as xu,f as Vm,n as qm}from"./DiffReview-BPoTVb4U.js";import{T as Ym,L as uo,M as vu,G as Pr}from"./triangle-alert-D8tYRSDm.js";import{S as zs}from"./sparkles-d-iJvm_O.js";import{C as yu,M as wu}from"./ChangeWalkthroughPanel-CxZUvDAd.js";import{r as ku,s as Su,l as ju,a as Md,h as Gi,u as Xm,g as Ki,b as Ru}from"./DiffViewer-DS97bKwR.js";import{u as Cu,G as Nu}from"./referenceLongPress-D794nQPp.js";const Jm=[["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"}]],Qm=Ar("case-sensitive",Jm);const Zm=[["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"}]],ep=Ar("eye-off",Zm);const tp=[["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"}]],Vi=Ar("eye",tp);const rp=[["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"}]],qi=Ar("file-text",rp);const np=[["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"}]],sp=Ar("image-plus",np);const ap=[["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"}]],op=Ar("regex",ap);const ip=[["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"}]],lp=Ar("scan",ip);const cp=[["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"}]],dp=Ar("upload",cp);const up=[["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"}]],fp=Ar("whole-word",up);function Ed({children:r,actions:n}){const{t:s}=St(),[l,u]=a.useState(!1),d=a.useId(),h=a.useRef(null);return e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:h,type:"button","aria-expanded":l,"aria-controls":d,onClick:()=>u(g=>!g),className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${l?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx(co,{size:14}),s("sidebar.moreActions")]})]}),l&&e.jsx("div",{id:d,role:"region","aria-label":s("sidebar.moreActions"),className:"mt-2 flex flex-wrap items-center gap-2 rounded-xl border border-border/15 bg-surface-2 p-2 [&_button]:min-h-9",onKeyDown:g=>{g.key!=="Escape"||!g.currentTarget.contains(g.target)||(g.stopPropagation(),u(!1),h.current?.focus())},children:n})]})}async function hp(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function mp({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:u,load:d}){a.useEffect(()=>{if(!r||!n||s||u.current===n)return;const h=window.setTimeout(()=>{u.current=n,d(n)},l);return()=>window.clearTimeout(h)},[r,n,s,l,u,d])}function pp(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,u=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!u)return Promise.resolve(null);const d=r instanceof HTMLImageElement?1400/Math.max(l,u):Math.min(1,1400/Math.max(l,u)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(l*d)),h.height=Math.max(1,Math.round(u*d));const g=h.getContext("2d");if(!g)return Promise.resolve(null);const m=getComputedStyle(document.documentElement);if(g.fillStyle=m.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,h.width,h.height),g.drawImage(r,0,0,h.width,h.height),s){const b=Math.max(10,Math.min(16,h.width/35));g.font=`${b}px sans-serif`;const f=[];let j="";for(const w of s.split(" "))j&&g.measureText(`${j} ${w}`).width>h.width-20?(f.push(j),j=w):j=j?`${j} ${w}`:w;j&&f.push(j),g.fillStyle=m.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,h.width,f.length*(b+4)+12),g.fillStyle=m.getPropertyValue("--foreground").trim()||"black",f.forEach((w,M)=>g.fillText(w,10,8+b+M*(b+4)))}if(n){const b=n.xPercent*h.width/100,f=n.yPercent*h.height/100,j=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),w=j*1.6;g.strokeStyle=m.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,j/3),g.beginPath(),g.arc(b,f,j,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(b-w,f),g.lineTo(b+w,f),g.moveTo(b,f-w),g.lineTo(b,f+w),g.stroke()}return new Promise(b=>h.toBlob(b,"image/png"))}catch{return Promise.resolve(null)}}function gp(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
3
|
`)}function mx(r,n,s){const l=n*Math.PI/360,u=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(r,1e-6)/Math.sin(u)*1.15}async function bp(r,n,s,l){if(!s?.snapshot){l.isCurrent()&&l.insert(r,n);return}const u=new Date().toISOString(),d=new AbortController;let h,g;try{g=await Promise.race([(async()=>{const m=await s.snapshot;if(!(!m||d.signal.aborted||!l.isCurrent()))return l.upload(new File([m],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),d.signal)})(),new Promise(m=>{h=setTimeout(()=>{d.abort(),m(void 0)},3e3)})])}catch{}finally{clearTimeout(h),d.abort()}l.isCurrent()&&l.insert(g?gp(r,"",u,g):r,n)}function xp(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function $d(r,n){return`${r??""}\0${n}`}function vp(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=$d(n,s);let u=0,d=0;for(const h of r){const g=[h.filePath,h.newPath,h.oldPath].filter(b=>typeof b=="string"&&b.length>0);(g.some(b=>$d(h.repoRoot,b)===l)||g.some(b=>xp(b,s)))&&(u+=1)}return{explained:u,stale:d}}function yp({status:r}){if(!r)return null;const n=r.stale>0&&r.explained===0;if(!(r.explained>0||r.stale>0))return null;const l=n?"AI audit explanation is stale":"AI audit explanation available";return e.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${n?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:l,"aria-label":l,children:n?e.jsx(Ym,{size:10}):e.jsx(zs,{size:10})})}function Yi({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(yp,{status:n})]})}const Mu="termdock:right-sidebar:diff-change-list-mode:v1";function wp(r){return r==="list"||r==="tree"}function kp(){return mt(Mu,wp)??"tree"}function Sp(r){for(const l of r){const u=l.hunk;if(u.oldPath&&u.newPath&&u.oldPath!==u.newPath)return"renamed";if(!u.oldPath&&u.newPath)return"added";if(u.oldPath&&!u.newPath)return"deleted"}const n=r.some(l=>l.hunk.additions>0),s=r.some(l=>l.hunk.deletions>0);return n&&!s?"added":!n&&s?"deleted":"modified"}function jp(r){const n=new Map;for(const l of r){const u=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};u.items.push(l),u.additions+=l.hunk.additions,u.deletions+=l.hunk.deletions,l.current&&(u.explained+=1),l.stale&&(u.stale+=1),n.set(l.hunk.filePath,u)}const s=Array.from(n.values()).sort((l,u)=>l.filePath.localeCompare(u.filePath));for(const l of s)l.changeType=Sp(l.items);return s}function Rp(r){const n=r.filePath.split("/").pop()??r.filePath;return{key:r.key,path:r.filePath,displayName:n,displayDir:r.filePath.includes("/")?r.filePath.slice(0,-n.length-1):"",status:r.changeType,title:r.filePath}}function Cp(r,n){const s=r.filter(d=>d.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],u=new Set;for(const[d,h]of s.entries()){const g=h.split(`
|
|
4
4
|
`),m=g.findIndex(j=>j.startsWith("@@ "));if(m<0){l.push(...g);continue}d===0&&l.push(...g.slice(0,m));const b=n[d];let f=m;for(;f>=0&&f<g.length;){const j=g.findIndex((E,$)=>$>f&&E.startsWith("@@ ")),w=j>=0?j:g.length,M=g.slice(f,w),I=M[0]??"",_=b?I===b:!0,B=I||b||M.join(`
|
|
5
5
|
`);_&&!u.has(B)&&(l.push(...M),u.add(B)),f=j}}return l.join(`
|
|
6
|
-
`)}function Np({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Cp(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),u=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),d=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-d.length-1):"",g=s.items[0]?.repoRoot??u[0]?.repoRoot??null;return{key:s.key,path:s.filePath,oldPath:s.items[0]?.hunk.oldPath??void 0,absolutePath:g?`${g}/${s.items[0]?.repositoryPath??s.filePath}`:s.filePath,status:s.changeType,repoRoot:g,displayName:d,displayDir:h,diffOverride:l,oldSourceRef:s.items[0]?.current?.headRef?`${s.items[0].current.baseRef}...${s.items[0].current.headRef}`:s.items[0]?.stale?.headRef?`${s.items[0].stale.baseRef}...${s.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(s.items.flatMap(m=>m.hunk.previewRevert?[[m.hunk.hunkHeader,m.hunk.previewRevert]]:[])),auditRecords:u,onInsertDiffReference:n}})}function Mp(r,n,s){const l=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const d=r.getBoundingClientRect().top+48;let h=null,g=Number.POSITIVE_INFINITY;for(const b of l){const f=b.getBoundingClientRect();if(f.bottom<d)continue;const j=Math.abs(f.top-d);j<g&&(h=b,g=j)}const m=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!m||m===n||s(m),m}function Ld({items:r,selectedKey:n,onSelect:s,emptyText:l,mobile:u=!1,backLabel:d="Back",headerTitle:h,headerMeta:g,onClose:m,closeLabel:b="Back",wrap:f=!0,diffViewType:j,inlineMode:w,viewControls:M,onToggleWrap:I,wrapTitle:_,wrapOnLabel:B="Wrap on",wrapOffLabel:E="Wrap off",desktopLayout:$="split",onInsertDiffReference:L,onReferenceCopied:T,renderPathReference:U,insertedReferenceKey:D,copiedReferenceKey:p,onClearAuditRecord:i,onRefresh:O,localOptions:C,onHunkGitAction:K,error:de,refreshing:te,actionsBusy:xe,refreshLabel:W,refreshTitle:
|
|
7
|
-
`)[0]??"",K=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current),U.current!==null&&window.clearTimeout(U.current)},[]),a.useEffect(()=>{let N=!1;const q=Si();return du().then(he=>{if(N)return;const
|
|
6
|
+
`)}function Np({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Cp(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),u=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),d=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-d.length-1):"",g=s.items[0]?.repoRoot??u[0]?.repoRoot??null;return{key:s.key,path:s.filePath,oldPath:s.items[0]?.hunk.oldPath??void 0,absolutePath:g?`${g}/${s.items[0]?.repositoryPath??s.filePath}`:s.filePath,status:s.changeType,repoRoot:g,displayName:d,displayDir:h,diffOverride:l,oldSourceRef:s.items[0]?.current?.headRef?`${s.items[0].current.baseRef}...${s.items[0].current.headRef}`:s.items[0]?.stale?.headRef?`${s.items[0].stale.baseRef}...${s.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(s.items.flatMap(m=>m.hunk.previewRevert?[[m.hunk.hunkHeader,m.hunk.previewRevert]]:[])),auditRecords:u,onInsertDiffReference:n}})}function Mp(r,n,s){const l=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const d=r.getBoundingClientRect().top+48;let h=null,g=Number.POSITIVE_INFINITY;for(const b of l){const f=b.getBoundingClientRect();if(f.bottom<d)continue;const j=Math.abs(f.top-d);j<g&&(h=b,g=j)}const m=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!m||m===n||s(m),m}function Ld({items:r,selectedKey:n,onSelect:s,emptyText:l,mobile:u=!1,backLabel:d="Back",headerTitle:h,headerMeta:g,onClose:m,closeLabel:b="Back",wrap:f=!0,diffViewType:j,inlineMode:w,viewControls:M,onToggleWrap:I,wrapTitle:_,wrapOnLabel:B="Wrap on",wrapOffLabel:E="Wrap off",desktopLayout:$="split",onInsertDiffReference:L,onReferenceCopied:T,renderPathReference:U,insertedReferenceKey:D,copiedReferenceKey:p,onClearAuditRecord:i,onRefresh:O,localOptions:C,onHunkGitAction:K,error:de,refreshing:te,actionsBusy:xe,refreshLabel:W,refreshTitle:X,walkthroughs:P=[],onWalkthroughNavigate:F,initialDetailScrollTop:V,onDetailScrollPositionChange:re,scrollToKey:ie,scrollToKeyNonce:ye,externalSwiperRef:pe,onMobileSlideChange:De}){const{t:N}=St(),q=a.useMemo(()=>jp(r),[r]),he=a.useMemo(()=>new Map(q.map(oe=>[oe.key,oe])),[q]),[Le,Ze]=a.useState(()=>kp()),[Pe,at]=a.useState(()=>new Set),[Be,R]=a.useState({key:null,nonce:0}),ee=q.find(oe=>oe.explained>0||oe.stale>0)?.key??q[0]?.key??null,le=n&&q.some(oe=>oe.key===n)?n:ee,Ee=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:q.map(Rp)}],[q]),Ne=a.useMemo(()=>Np({groups:q,onInsertDiffReference:L}),[q,L]),We=a.useRef(ee),ce=a.useRef(s);We.current=ee,ce.current=s,a.useEffect(()=>{!n&&We.current&&ce.current(We.current)},[n]);const Ae=I?e.jsxs("button",{type:"button",onClick:I,"aria-pressed":f,title:_,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?B:E})]}):null,tt=C?.map(oe=>e.jsxs("label",{title:oe.disabled?N("rightSidebar.includeUncommittedCurrentBranchOnly"):oe.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:oe.checked,disabled:te||xe||oe.disabled&&!oe.checked,onChange:Ie=>oe.onChange(Ie.target.checked),className:"accent-primary"}),e.jsxs("span",{children:[oe.label," · ",N("rightSidebar.includeUncommitted"),oe.disabled&&e.jsx("span",{className:"block text-[10px]",children:N("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},oe.key)),Te=de?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:de}):null,ke=O?e.jsxs("button",{type:"button",onClick:O,disabled:te||xe,title:X??W,"aria-label":X??W,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx(hu,{size:12,className:te?"animate-spin":""}),W&&e.jsx("span",{children:W})]}):null,rt=oe=>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:[h&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),g&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:g})]}),m&&e.jsxs("button",{type:"button",onClick:m,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(Os,{size:14}),b]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[oe,tt,ke,M,Ae,Te]})]});if(r.length===0){const oe=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!h&&!m?oe:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[rt(null),oe]})}const nt=I||O?({slideToList:oe})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:oe,children:[e.jsx(Os,{size:14}),d]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[tt,ke,M,I&&e.jsxs("button",{type:"button",onClick:I,"aria-pressed":f,title:_,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?B:E})]})]}),Te]}):void 0;return e.jsx(Wi,{mobile:u,preserveScrollOnUpdate:!!C?.length,desktopLayout:$,backLabel:d,groups:Ee,selectedKey:le,mode:Le,onModeChange:oe=>{Ze(oe),oe!=="ai"&&Lt(Mu,oe)},compact:u,collapsedDirectoryKeys:Pe,onToggleDirectory:oe=>{at(Ie=>{const ze=new Set(Ie);return ze.has(oe)?ze.delete(oe):ze.add(oe),ze})},onSelectFile:oe=>{s(oe.key),R(Ie=>({key:oe.key,nonce:Ie.nonce+1}))},renderLeading:oe=>{const Ie=he.get(oe.key);return e.jsx(Yi,{changeStatus:oe.status,auditStatus:Ie,renderChangeBadge:ze=>e.jsx(Fs,{status:ze})})},renderTrailing:oe=>{const Ie=he.get(oe.key);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[Ie&&e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",Ie.additions," -",Ie.deletions]}),U?.(oe.path,"file")]})},renderDirectoryTrailing:oe=>U?.(oe,"directory"),renderListHeader:rt,aiContent:({slideToDetail:oe,fullscreen:Ie,toggleFullscreen:ze})=>P.length>0&&F?e.jsx(yu,{walkthroughs:P,repoRoot:P[0]?.repoRoot,fullscreen:Ie,onToggleFullscreen:ze,onNavigate:_t=>{u&&window.requestAnimationFrame(oe),F(_t)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:N("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:nt,externalSwiperRef:pe,onMobileSlideChange:De,detailContainerClassName:u?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:V,scrollToKey:ie??Be.key,scrollToKeyNonce:ie==null?Be.nonce:ye,onDetailScroll:oe=>{Mp(oe,le,s),re?.(oe.scrollTop)},files:Ne,activePane:!0,wrap:f,diffViewType:j,inlineMode:w,renderStreamBadge:(oe,Ie)=>{const ze=he.get(Ie.key);return e.jsx(Yi,{changeStatus:oe,auditStatus:ze,renderChangeBadge:_t=>e.jsx(Fs,{status:_t})})},onInsertDiffReference:L,onReferenceCopied:T,insertedReferenceKey:D,copiedReferenceKey:p,onClearAuditRecord:i,onHunkGitAction:te?void 0:K,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function Ep(r){return r.replace(/\/+$/,"")||"/"}function $p(r){return[...new Set(Array.from(r,Ep))].sort((n,s)=>n.localeCompare(s))}function Lp(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function Pp(r){let n=null;return{applicableEvents:r.filter(l=>{const u=l.type==="rescan-required"&&!Lp(l.reason);return u&&l.reason&&!n&&(n=l.reason),!u}),unavailableReason:n}}const Ap=1400,Tp=1200,Eu=44,Ip=.7;function Si(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Xi(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Dp(r){try{const n=window.localStorage.getItem(Xi(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Eu?s:null}catch{return null}}function Pd(r,n){try{n===null?window.localStorage.removeItem(Xi(r)):window.localStorage.setItem(Xi(r),String(n))}catch{}}function Va(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Fp({value:r,collapsed:n,labels:s,focusRequest:l,insertError:u,autoCollapseAfterSend:d,onChange:h,onCollapsedChange:g,onAutoCollapseAfterSendChange:m,onDisable:b,onClear:f,onInsert:j,onInsertAndSend:w}){const[M,I]=a.useState(null),[_,B]=a.useState(!1),[E,$]=a.useState(()=>Dp(Si())),L=a.useRef(E),T=a.useRef(null),U=a.useRef(null),D=a.useRef(r),p=a.useRef(null),i=a.useRef(null),O=!!r.trim(),C=r.trim().split(`
|
|
7
|
+
`)[0]??"",K=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current),U.current!==null&&window.clearTimeout(U.current)},[]),a.useEffect(()=>{let N=!1;const q=Si();return du().then(he=>{if(N)return;const Le=he.contextDraftHeight?.[q]??null;Pd(q,Le),L.current=Le,$(Le)}).catch(()=>{}),()=>{N=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const N=p.current;if(!N)return;Va()||N.focus(),N.setSelectionRange(N.value.length,N.value.length),N.scrollTop=N.scrollHeight}},[l]),a.useEffect(()=>{const N=D.current;D.current=r,!(!n||r.length<=N.length)&&(B(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,B(!1)},Tp))},[r,n]),a.useEffect(()=>{if(n)return;const N=p.current;N&&(N.style.height=E!==null?`${E}px`:"")},[r,n,E]),a.useEffect(()=>{if(n)return;const N=p.current;!N||document.activeElement===N||(N.scrollTop=N.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||Va())return;const N=p.current;!N||document.activeElement===N||(N.focus(),N.setSelectionRange(N.value.length,N.value.length))},[n]);const de=a.useRef(null);a.useLayoutEffect(()=>{if(!Va())return;const N=window.visualViewport;if(!N)return;const q=()=>{const he=de.current;if(!he)return;if(N.height>=window.innerHeight*.75){he.style.transform="";return}const Le=he.getBoundingClientRect(),Ze=Math.round(N.height-Le.bottom);he.style.transform=Ze!==0?`translateY(${Ze}px)`:""};return q(),N.addEventListener("resize",q),N.addEventListener("scroll",q),()=>{N.removeEventListener("resize",q),N.removeEventListener("scroll",q),de.current&&(de.current.style.transform="")}},[n]);const te=N=>{I(N),T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,I(null)},Ap)},xe=N=>{g(!1),Va()&&window.requestAnimationFrame(()=>{const q=p.current;if(!q)return;q.focus();const he=q.value.length;q.setSelectionRange(he,he),window.requestAnimationFrame(()=>{q.setSelectionRange(he,he)})})},W=()=>{j(),te("inserted")},X=()=>{O&&(w(),te("sent"))},P=N=>{if(N.key==="Escape"){N.preventDefault(),g(!0);return}N.key!=="Enter"||!N.metaKey&&!N.ctrlKey||(N.preventDefault(),X())},F=N=>{N.preventDefault()},V=N=>{N.preventDefault();const q=p.current;q&&(i.current={startY:N.clientY,startHeight:q.getBoundingClientRect().height},N.currentTarget.setPointerCapture?.(N.pointerId))},re=N=>{const q=i.current;if(!q)return;const he=window.visualViewport?.height??window.innerHeight,Le=Math.round(Math.min(Math.max(q.startHeight+(q.startY-N.clientY),Eu),he*Ip));L.current=Le,$(Le)},ie=N=>{const q=Si();Pd(q,N),so({contextDraftHeight:{[q]:N}}).catch(()=>{})},ye=()=>{i.current&&(i.current=null,L.current!==null&&ie(L.current))},pe=()=>{L.current=null,$(null),ie(null)},De=r.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(r.length)});return n?e.jsx("section",{ref:de,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:()=>xe(),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(Sm,{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] ${u?"text-destructive":_?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:u??(_?s.appended:O?C:s.title)})]}),De,e.jsx("button",{type:"button",onClick:X,disabled:!O,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:M==="sent"?e.jsx(Ui,{size:12}):e.jsx(vd,{size:12})})]})}):e.jsxs("section",{ref:de,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:ye,onPointerCancel:ye,onDoubleClick:pe,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:F,onClick:()=>g(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[e.jsx(Us,{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}),De]}),e.jsx("button",{type:"button",role:"switch","aria-checked":d,onPointerDown:F,onClick:()=>m(!d),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 ${d?"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 ${d?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:F,onClick:b,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(Yt,{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:p,value:r,onChange:N=>h(N.target.value),onKeyDown:P,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:F,onClick:f,disabled:!O,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(ao,{size:11})}),u?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:u}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:F,onClick:W,disabled:!O,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(jm,{size:11}),e.jsx("span",{children:M==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:F,onClick:X,disabled:!O,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} · ${K}`,children:[M==="sent"?e.jsx(Ui,{size:11}):e.jsx(vd,{size:11}),e.jsx("span",{children:M==="sent"?s.sent:s.send})]})]})]})})]})}function _p(r,n){const s=n.trim();if(!s)return r;if(!r.trim())return s;const l=r.endsWith(`
|
|
8
8
|
|
|
9
9
|
`)?"":r.endsWith(`
|
|
10
10
|
`)?`
|
|
11
11
|
`:`
|
|
12
12
|
|
|
13
|
-
`;return`${r}${l}${s}`}function Bp(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}const Ji="termdock:right-sidebar:html-view-mode-by-file:v1";function Op(r){return r==="preview"||r==="source"}function $u(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Op)}function Lu(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Ad(r,n){const s=Lu(r,n);return s?mt(Ji,$u)?.[s]??"source":"source"}function Up(r,n,s){const l=Lu(r,n);if(!l)return;const u=mt(Ji,$u)??{};Lt(Ji,{...u,[l]:s})}function Hp(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const zp=1500,Td=256*1024*1024;async function Wp(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",u=s.body?.getReader();if(!u){const g=await s.blob();if(g.size>Td)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(g)}const d=[];let h=0;try{for(;;){const{done:g,value:m}=await u.read();if(g)break;if(h+=m.byteLength,h>Td)throw new Error("Media too large for encrypted fallback");d.push(m)}}catch(g){throw await u.cancel().catch(()=>{}),g}return URL.createObjectURL(new Blob(d,{type:l}))}function vo(r,n){const s=Hp(r),[l,u]=a.useState(()=>!!navigator.serviceWorker?.controller),[d,h]=a.useState(void 0),g=a.useRef(n);return g.current=n,a.useEffect(()=>{if(!s||l)return;const m=navigator.serviceWorker,b=()=>u(!!m?.controller);return m?.addEventListener("controllerchange",b),b(),()=>m?.removeEventListener("controllerchange",b)},[s,l]),a.useEffect(()=>{if(!s||l){h(void 0);return}let m=!1,b;const f=new AbortController,j=window.setTimeout(()=>{Wp(r,f.signal).then(w=>{if(m){URL.revokeObjectURL(w);return}b=w,h(w)}).catch(()=>{m||f.signal.aborted||g.current?.()})},zp);return()=>{m=!0,window.clearTimeout(j),f.abort(),b&&URL.revokeObjectURL(b)}},[s,l,r]),!s||l?r:d}function ji(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),u=n%60,d=String(l).padStart(2,"0"),h=String(u).padStart(2,"0");return s>0?`${s}:${d}:${h}`:`${d}:${h}`}function Gp(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const qr=2,Kp=8,Vp=60,qa=5,Id=.05,qp=900;function Yp(r){return!Number.isFinite(r)||r<=0?qr:Math.min(Kp,qr+Math.floor(r/Vp))}const Xp=350,Jp=6,Qp=90;function Zp({url:r,onLoadError:n}){const s=vo(r,n),{t:l}=St(),u=a.useRef(null),d=a.useRef(null),h=a.useRef(null),g=a.useRef(null),m=a.useRef(!1),b=a.useRef(null),f=a.useRef(null),j=a.useRef(0),w=a.useRef(!1),M=a.useRef(!1),I=a.useRef(!1),_=a.useRef(null),B=a.useRef(null),E=a.useRef(!1),$=a.useRef(1),L=a.useRef(!1),[T,U]=a.useState(0),[D,p]=a.useState(0),[i,O]=a.useState(!1),[C,K]=a.useState(!1),[de,te]=a.useState(null),[xe,W]=a.useState(!1),[Y,P]=a.useState(0),[F,V]=a.useState(!1),[re,ie]=a.useState({width:0,height:0}),[ye,pe]=a.useState(qr),[Ie,N]=a.useState(1),[q,he]=a.useState(null),$e=a.useRef(qr),Qe=a.useRef(null),Le=a.useCallback(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),at=a.useCallback(()=>{Le();const H=B.current;if(B.current=null,!E.current)return!1;const se=h.current;if(se&&(se.playbackRate=$.current,H))try{se.releasePointerCapture?.(H.id)}catch{}return E.current=!1,$e.current=qr,W(!1),!0},[Le]);a.useEffect(()=>()=>{b.current!==null&&cancelAnimationFrame(b.current),f.current!==null&&clearTimeout(f.current),Qe.current!==null&&clearTimeout(Qe.current),Le();const H=h.current;H&&E.current&&(H.playbackRate=$.current)},[Le]),a.useEffect(()=>{const H=d.current;if(!H||typeof ResizeObserver>"u")return;const se=new ResizeObserver(([ve])=>{ve&&ie({width:ve.contentRect.width,height:ve.contentRect.height})});return se.observe(H),()=>se.disconnect()},[]),a.useEffect(()=>{const H=()=>V(document.fullscreenElement===u.current);return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]);const _e=a.useCallback((H,se=!1)=>{const ve=h.current;if(!ve)return!1;const Ge=Number.isFinite(ve.duration)?ve.duration:H,pt=Math.min(Math.max(H,0),Ge);if(p(pt),Math.abs(ve.currentTime-pt)<1/120)return!1;const hr=ve.fastSeek;return se&&typeof hr=="function"?hr.call(ve,pt):ve.currentTime=pt,!0},[]),R=a.useCallback(()=>{b.current===null&&(b.current=requestAnimationFrame(()=>{b.current=null;const H=h.current;if(!H||!w.current||M.current||H.seeking)return;const se=I.current;I.current=!1,M.current=_e(j.current,!se)}))},[_e]),ee=a.useCallback(H=>{const se=g.current,ve=h.current;if(!se||!ve)return;const Ge=se.getBoundingClientRect(),pt=Gp(H,Ge,ve.duration);j.current=pt,te(pt),I.current=!1,R(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,I.current=!0,R()},Qp)},[R]),le=a.useCallback(()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),I.current=!1,M.current=!1,_e(j.current)},[_e]),Me=a.useCallback(H=>{const se=h.current;if(!(!se||!Number.isFinite(se.duration)||se.duration<=0)){m.current=!se.paused,se.pause(),w.current=!0,K(!0);try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}ee(H.clientX)}},[ee]),Ce=a.useCallback(()=>{w.current=!1,le(),K(!1),te(null);const H=h.current;H&&m.current&&!H.ended&&H.play().catch(()=>{}),m.current=!1},[le]),ze=a.useCallback(()=>{const H=h.current;if(H){if(L.current){L.current=!1;return}H.paused?H.play().catch(()=>{}):H.pause()}},[]),ce=a.useCallback(H=>{const se=h.current;if(!se)return;const ve=Math.min(1,Math.max(0,Math.round((se.volume+H)*100)/100));se.volume=ve,ve>0&&(se.muted=!1),N(ve),he(ve),Qe.current!==null&&clearTimeout(Qe.current),Qe.current=setTimeout(()=>{Qe.current=null,he(null)},qp)},[]),Pe=a.useCallback(H=>{const se=h.current;if(se){if(H.key==="ArrowLeft"){H.preventDefault(),_e(se.currentTime-(H.shiftKey?qa*2:qa));return}if(H.key==="ArrowRight"){H.preventDefault(),_e(se.currentTime+(H.shiftKey?qa*2:qa));return}if(H.key==="ArrowUp"){H.preventDefault(),ce(Id);return}if(H.key==="ArrowDown"){H.preventDefault(),ce(-Id);return}(H.key===" "||H.key==="Spacebar"||H.key==="k"||H.key==="K")&&(H.preventDefault(),se.paused?se.play().catch(()=>{}):se.pause())}},[_e,ce]),et=a.useCallback(H=>{const se=h.current;!se||se.paused||H.button!==0||(Le(),B.current={id:H.pointerId,x:H.clientX,y:H.clientY},_.current=setTimeout(()=>{_.current=null;const ve=B.current;if($.current=se.playbackRate,se.playbackRate=qr,$e.current=qr,pe(qr),E.current=!0,W(!0),ve)try{se.setPointerCapture?.(ve.id)}catch{}},Xp))},[Le]),Ae=a.useCallback(H=>{const se=B.current;if(!se||se.id!==H.pointerId)return;if(!E.current){Math.hypot(H.clientX-se.x,H.clientY-se.y)>Jp&&(Le(),B.current=null);return}const ve=Yp(H.clientX-se.x);if(ve===$e.current)return;$e.current=ve,pe(ve);const Ge=h.current;Ge&&(Ge.playbackRate=ve)},[Le]),ke=a.useCallback(()=>{at()&&(L.current=!0)},[at]);a.useEffect(()=>(window.addEventListener("pointerup",ke),window.addEventListener("pointercancel",ke),window.addEventListener("blur",ke),()=>{window.removeEventListener("pointerup",ke),window.removeEventListener("pointercancel",ke),window.removeEventListener("blur",ke)}),[ke]);const tt=a.useCallback(async()=>{const H=u.current,se=h.current;if(!(!H||!se))try{document.fullscreenElement===H?await document.exitFullscreen():H.requestFullscreen?await H.requestFullscreen():se.webkitEnterFullscreen?.()}catch{se.webkitEnterFullscreen?.()}},[]),rt=a.useCallback(()=>P(H=>(H+90)%360),[]),oe=a.useCallback(H=>{const se=h.current;if(!se||!Number.isFinite(se.duration))return;const ve=H.shiftKey?10:5;let Ge=null;H.key==="ArrowLeft"?Ge=se.currentTime-ve:H.key==="ArrowRight"?Ge=se.currentTime+ve:H.key==="Home"?Ge=0:H.key==="End"&&(Ge=se.duration),Ge!==null&&(H.preventDefault(),_e(Ge))},[_e]),Te=C&&de!==null?de:D,He=T>0?Math.min(1,Math.max(0,Te/T)):0,Bt=(Y===90||Y===270)&&re.width>0&&re.height>0?{width:`${re.height}px`,height:`${re.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:u,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":Y,children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:h,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${xe?` ${Cd}`:""}`,style:{...Bt,transform:`translate(-50%, -50%) rotate(${Y}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...xe?{[Nd]:""}:{},onClick:ze,onKeyDown:Pe,onVolumeChange:H=>N(H.currentTarget.volume),onPointerDown:et,onPointerMove:Ae,onPointerUp:ke,onPointerCancel:ke,onContextMenu:H=>{E.current&&H.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:H=>p(H.currentTarget.currentTime),onSeeked:H=>{const se=H.currentTarget;if(p(se.currentTime),M.current=!1,!w.current)return;const ve=se.requestVideoFrameCallback;typeof ve=="function"?ve.call(se,()=>{w.current&&R()}):requestAnimationFrame(()=>{w.current&&R()})},onLoadedMetadata:H=>U(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onDurationChange:H=>U(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),xe&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(ye)})}),q!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(Rm,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Ie*100)})]}),C&&de!==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:`${He*100}%`},"data-testid":"file-preview-video-scrub-time",children:ji(de)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Cd}`,[Nd]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:ze,"aria-label":l(i?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(i?"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:i?e.jsx(Cm,{size:14}):e.jsx(Nm,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(T),"aria-valuenow":Math.floor(Te),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:Me,onPointerMove:H=>{C&&ee(H.clientX)},onPointerUp:Ce,onPointerCancel:Ce,onKeyDown:oe,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:`${He*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:`${He*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[ji(Te)," / ",ji(T)]}),e.jsx("button",{type:"button",onClick:rt,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(hu,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{tt()},"aria-label":l(F?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(F?"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:F?e.jsx(Mm,{size:14}):e.jsx(Em,{size:14})})]})})]})}function eg(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function yo({anchor:r,children:n,disabled:s=!1,onClick:l,title:u}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:d=>{d.stopPropagation(),l()},title:u,style:eg(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(uo,{size:11}),n]})}function tg(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const u=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(u)||u<=0)return null;const d=l.width*u,h=l.height*u,g=s.left+(s.width-d)/2,m=s.top+(s.height-h)/2,b=r-g,f=n-m;if(b<0||f<0||b>d||f>h)return null;const j=b/d*100,w=f/h*100;return{x:l.x+l.width*j/100,y:l.y+l.height*w/100,xPercent:j,yPercent:w}}function rg(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function ng(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const u of Array.from(l.attributes)){const d=u.name.toLowerCase(),h=u.value.trim();(d.startsWith("on")||(d==="href"||d.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(u.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function sg(r,n,s){let l=null;for(const u of Array.from(r.querySelectorAll("text"))){const d=(u.textContent??"").replace(/\s+/g," ").trim();if(!d)continue;const h=Number(u.getAttribute("x")),g=Number(u.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(g))continue;const m=Math.hypot(h-n,g-s);(!l||m<l.distance)&&(l={text:d,distance:m})}return l?.text.slice(0,120)}function Pu({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const u=a.useRef(null),d=a.useRef(null),[h,g]=a.useState(null),[m,b]=a.useState(null),[f,j]=a.useState(1),[w,M]=a.useState(!1),[I,_]=a.useState(null),B=a.useRef(new Map),E=a.useRef(null),$=a.useRef(!1),L=a.useRef(null),T=a.useRef(f);T.current=f,a.useEffect(()=>{const P=new AbortController;return g(null),b(null),_(null),j(1),fetch(r,{signal:P.signal}).then(F=>F.text()).then(F=>g(ng(F))).catch(F=>{P.signal.aborted||b(F instanceof Error?F.message:"SVG preview failed")}),()=>P.abort()},[r]),a.useEffect(()=>{if(!w)return;const P=F=>{F.key==="Escape"&&M(!1)};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[w]),a.useLayoutEffect(()=>{const P=d.current,F=P?.querySelector("[data-svg-document] > svg");if(!P||!F)return;let V;try{V=F.getBBox()}catch{return}if(!V.width||!V.height)return;const re=Math.max(2,Math.min(V.width,V.height)*.025);F.setAttribute("viewBox",`${V.x-re} ${V.y-re} ${V.width+2*re} ${V.height+2*re}`),F.style.width=`${f*100}%`,F.style.height=`${f*100}%`,F.style.minWidth=`${f*100}%`,F.style.minHeight=`${f*100}%`,F.style.display="block"},[h,f]);const U=a.useMemo(()=>I?rg(n,s,I):null,[n,I,s]),D=P=>{if($.current){$.current=!1;return}const F=d.current,V=F?.querySelector("[data-svg-document] > svg"),re=u.current;if(!F||!V||!re)return;const ie=V.viewBox.baseVal,ye=tg(P.clientX,P.clientY,V.getBoundingClientRect(),ie);if(!ye)return;const pe=re.getBoundingClientRect();_({...ye,nearestText:sg(V,ye.x,ye.y),stageX:P.clientX-pe.left,stageY:P.clientY-pe.top,stageXPercent:(P.clientX-pe.left)/pe.width*100,stageYPercent:(P.clientY-pe.top)/pe.height*100})},p=P=>Math.max(1,Math.min(12,P)),i=(P,F)=>{const V=p(F),re=P.querySelector("[data-svg-document] > svg");if(!re)return V;const ie=`${V*100}%`;return re.style.width=ie,re.style.height=ie,re.style.minWidth=ie,re.style.minHeight=ie,T.current=V,V},O=(P,F,V,re)=>{const ie=T.current,ye=P.getBoundingClientRect(),pe=V-ye.left,Ie=re-ye.top,N=(P.scrollLeft+pe)/ie,q=(P.scrollTop+Ie)/ie,he=i(P,F);return P.scrollLeft=N*he-pe,P.scrollTop=q*he-Ie,he},C=()=>{const P=Array.from(B.current.values());return P.length>=2?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0},K=P=>{if(P.pointerType==="mouse"&&P.button!==0)return;const F=d.current;F&&(B.current.set(P.pointerId,{x:P.clientX,y:P.clientY}),F.setPointerCapture?.(P.pointerId),B.current.size>=2?(E.current={kind:"pinch",startX:P.clientX,startY:P.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startDistance:C(),startZoom:T.current,moved:!1},$.current=!0):T.current>1&&(E.current={kind:"pan",startX:P.clientX,startY:P.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}))},de=P=>{if(!B.current.has(P.pointerId))return;B.current.set(P.pointerId,{x:P.clientX,y:P.clientY});const F=d.current,V=E.current;if(!(!F||!V)){if(B.current.size>=2&&V.kind==="pinch"){const re=C();if(!V.startDistance||!re)return;const ie=p(V.startZoom*re/V.startDistance);if(Math.abs(ie-T.current)<.01)return;const ye=Array.from(B.current.values()),pe=(ye[0].x+ye[1].x)/2,Ie=(ye[0].y+ye[1].y)/2;V.moved=!0,$.current=!0,O(F,ie,pe,Ie),P.preventDefault();return}if(V.kind==="pan"&&B.current.size===1){const re=P.clientX-V.startX,ie=P.clientY-V.startY;if(!V.moved&&Math.hypot(re,ie)<6)return;V.moved=!0,$.current=!0,F.scrollLeft=V.startScrollLeft-re,F.scrollTop=V.startScrollTop-ie,P.preventDefault()}}},te=P=>{const F=d.current,V=E.current,re=B.current.size===1&&!V?.moved;B.current.delete(P.pointerId);try{F?.releasePointerCapture?.(P.pointerId)}catch{}if(B.current.size===1&&V?.kind==="pinch"){const pe=Array.from(B.current.values())[0];E.current=F?{kind:"pan",startX:pe.x,startY:pe.y,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}:null;return}if(B.current.size>0||(E.current=null,V?.kind==="pinch"&&j(T.current),!re||$.current))return;const ie=Date.now(),ye=L.current;ye&&ie-ye.time<350&&Math.hypot(P.clientX-ye.x,P.clientY-ye.y)<24?(L.current=null,$.current=!0,j(pe=>pe>1?1:2.5)):L.current={time:ie,x:P.clientX,y:P.clientY}},xe=P=>{if(!P.ctrlKey&&!P.metaKey)return;const F=d.current;if(!F)return;P.preventDefault();const V=O(F,T.current*Math.exp(-P.deltaY*.01),P.clientX,P.clientY);j(V)},W=()=>{j(1),T.current=1,d.current&&(d.current.scrollLeft=0,d.current.scrollTop=0)},Y=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:u,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:d,role:"button",tabIndex:0,onClick:D,onDoubleClick:P=>{P.preventDefault(),j(F=>F>1?1:2.5)},onPointerDown:K,onPointerMove:de,onPointerUp:te,onPointerCancel:te,onWheel:xe,onScroll:()=>_(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:m?e.jsx("div",{className:"p-4 text-sm text-destructive",children:m}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),I&&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:I.stageX,top:I.stageY}}),I&&U&&e.jsx(yo,{anchor:{xPercent:I.stageXPercent,yPercent:I.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${I.x.toFixed(2)}:${I.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:P=>{P.stopPropagation(),W()},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(lp,{size:14})}),e.jsx("button",{type:"button","aria-label":w?"退出全屏 SVG":"全屏 SVG",title:w?"退出全屏 SVG":"全屏 SVG",onClick:P=>{P.stopPropagation(),M(F=>!F)},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(wu,{size:14}):e.jsx(vu,{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:I?`SVG (${I.x.toFixed(2)}, ${I.y.toFixed(2)}) · ${I.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return w?Yr.createPortal(Y,document.body):Y}function oo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function ag(r,n,s,l){const u=[`电子标注: ${r}`,`视图: ${oo(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(u.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&u.push(`显示层: ${l.layer}`),l.nearest)){const d=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");u.push(`最近对象: ${l.nearest.label}${d?`(${d})`:""}`)}return`"${u.join(" / ")}"`}function og({blobUrl:r,filePath:n,view:s,board:l,onViewChange:u,onInsertAnnotation:d,onRefresh:h,interactive3d:g}){const{t:m}=St(),b=a.useRef(null),f=a.useRef(null),j=a.useRef(null),[w,M]=a.useState(null),[I,_]=a.useState(!1);a.useEffect(()=>(j.current?.abort(),M(null),_(!1),()=>j.current?.abort()),[r,s]);const B=a.useMemo(()=>w?ag(n,s,w,w.inspection):null,[n,w,s]),E=L=>{const T=b.current,U=f.current;if(!T||!U||!U.naturalWidth||!U.naturalHeight)return;const D=T.getBoundingClientRect(),p=U.getBoundingClientRect(),i=Math.min(p.width/U.naturalWidth,p.height/U.naturalHeight),O=U.naturalWidth*i,C=U.naturalHeight*i,K=p.left+(p.width-O)/2,de=p.top+(p.height-C)/2,te=L.clientX-K,xe=L.clientY-de;if(te<0||xe<0||te>O||xe>C)return;const W={xPercent:Math.max(0,Math.min(100,te/O*100)),yPercent:Math.max(0,Math.min(100,xe/C*100)),stageXPercent:(L.clientX-D.left)/D.width*100,stageYPercent:(L.clientY-D.top)/D.height*100,inspecting:l&&s!=="pcb-3d"};if(M(W),j.current?.abort(),!W.inspecting)return;const Y=new AbortController;j.current=Y,Vh(n,s,W.xPercent,W.yPercent,Y.signal).then(P=>M(F=>F===W?{...F,inspection:P,inspecting:!1}:F)).catch(()=>{Y.signal.aborted||M(P=>P===W?{...P,inspection:{available:!1},inspecting:!1}:P)})},$=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:$.map(L=>e.jsx("button",{type:"button",onClick:()=>u(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:oo(L)},L))}),e.jsx("button",{type:"button",onClick:h,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:m("rightSidebar.edaRefresh"),"aria-label":m("rightSidebar.edaRefresh"),children:e.jsx(Hi,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:b,role:"button",tabIndex:0,onClick:E,onKeyDown:L=>{L.key!=="Enter"&&L.key!==" "||(L.preventDefault(),M({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:m("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:r,alt:`${n} ${oo(s)}`,onLoad:()=>_(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${I?"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&&B&&e.jsx(yo,{anchor:{xPercent:w.stageXPercent,yPercent:w.stageYPercent},disabled:w.inspecting,title:m("rightSidebar.edaInsertAnnotation"),onClick:()=>{d?.(B,`eda:${s}:${w.xPercent.toFixed(1)}:${w.yPercent.toFixed(1)}`,{snapshot:f.current?pp(f.current,w):Promise.resolve(null)}),M(null)},children:m("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?m("rightSidebar.edaInspecting"):w.inspection?.available?m("rightSidebar.edaPickedBoardPosition",{x:w.inspection.xMm?.toFixed(2)??"—",y:w.inspection.yMm?.toFixed(2)??"—",object:w.inspection.nearest?.label??m("rightSidebar.edaNoNearbyObject")}):m("rightSidebar.edaPickedPosition",{x:w.xPercent.toFixed(1),y:w.yPercent.toFixed(1)}):m("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Pu,{blobUrl:r,filePath:n,viewLabel:oo(s),onInsertAnnotation:d})})]})}function ig(r){const n=[];let s=[],l="",u=!1;for(let d=0;d<r.length;d+=1){const h=r[d];u?h==='"'&&r[d+1]==='"'?(l+='"',d+=1):h==='"'?u=!1:l+=h:h==='"'?u=!0:h===","?(s.push(l),l=""):h===`
|
|
13
|
+
`;return`${r}${l}${s}`}function Bp(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}const Ji="termdock:right-sidebar:html-view-mode-by-file:v1";function Op(r){return r==="preview"||r==="source"}function $u(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Op)}function Lu(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Ad(r,n){const s=Lu(r,n);return s?mt(Ji,$u)?.[s]??"source":"source"}function Up(r,n,s){const l=Lu(r,n);if(!l)return;const u=mt(Ji,$u)??{};Lt(Ji,{...u,[l]:s})}function Hp(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const zp=1500,Td=256*1024*1024;async function Wp(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",u=s.body?.getReader();if(!u){const g=await s.blob();if(g.size>Td)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(g)}const d=[];let h=0;try{for(;;){const{done:g,value:m}=await u.read();if(g)break;if(h+=m.byteLength,h>Td)throw new Error("Media too large for encrypted fallback");d.push(m)}}catch(g){throw await u.cancel().catch(()=>{}),g}return URL.createObjectURL(new Blob(d,{type:l}))}function vo(r,n){const s=Hp(r),[l,u]=a.useState(()=>!!navigator.serviceWorker?.controller),[d,h]=a.useState(void 0),g=a.useRef(n);return g.current=n,a.useEffect(()=>{if(!s||l)return;const m=navigator.serviceWorker,b=()=>u(!!m?.controller);return m?.addEventListener("controllerchange",b),b(),()=>m?.removeEventListener("controllerchange",b)},[s,l]),a.useEffect(()=>{if(!s||l){h(void 0);return}let m=!1,b;const f=new AbortController,j=window.setTimeout(()=>{Wp(r,f.signal).then(w=>{if(m){URL.revokeObjectURL(w);return}b=w,h(w)}).catch(()=>{m||f.signal.aborted||g.current?.()})},zp);return()=>{m=!0,window.clearTimeout(j),f.abort(),b&&URL.revokeObjectURL(b)}},[s,l,r]),!s||l?r:d}function ji(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),u=n%60,d=String(l).padStart(2,"0"),h=String(u).padStart(2,"0");return s>0?`${s}:${d}:${h}`:`${d}:${h}`}function Gp(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const Vr=2,Kp=8,Vp=60,qa=5,Id=.05,qp=900;function Yp(r){return!Number.isFinite(r)||r<=0?Vr:Math.min(Kp,Vr+Math.floor(r/Vp))}const Xp=350,Jp=6,Qp=90;function Zp({url:r,onLoadError:n}){const s=vo(r,n),{t:l}=St(),u=a.useRef(null),d=a.useRef(null),h=a.useRef(null),g=a.useRef(null),m=a.useRef(!1),b=a.useRef(null),f=a.useRef(null),j=a.useRef(0),w=a.useRef(!1),M=a.useRef(!1),I=a.useRef(!1),_=a.useRef(null),B=a.useRef(null),E=a.useRef(!1),$=a.useRef(1),L=a.useRef(!1),[T,U]=a.useState(0),[D,p]=a.useState(0),[i,O]=a.useState(!1),[C,K]=a.useState(!1),[de,te]=a.useState(null),[xe,W]=a.useState(!1),[X,P]=a.useState(0),[F,V]=a.useState(!1),[re,ie]=a.useState({width:0,height:0}),[ye,pe]=a.useState(Vr),[De,N]=a.useState(1),[q,he]=a.useState(null),Le=a.useRef(Vr),Ze=a.useRef(null),Pe=a.useCallback(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),at=a.useCallback(()=>{Pe();const H=B.current;if(B.current=null,!E.current)return!1;const ae=h.current;if(ae&&(ae.playbackRate=$.current,H))try{ae.releasePointerCapture?.(H.id)}catch{}return E.current=!1,Le.current=Vr,W(!1),!0},[Pe]);a.useEffect(()=>()=>{b.current!==null&&cancelAnimationFrame(b.current),f.current!==null&&clearTimeout(f.current),Ze.current!==null&&clearTimeout(Ze.current),Pe();const H=h.current;H&&E.current&&(H.playbackRate=$.current)},[Pe]),a.useEffect(()=>{const H=d.current;if(!H||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(([ve])=>{ve&&ie({width:ve.contentRect.width,height:ve.contentRect.height})});return ae.observe(H),()=>ae.disconnect()},[]),a.useEffect(()=>{const H=()=>V(document.fullscreenElement===u.current);return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]);const Be=a.useCallback((H,ae=!1)=>{const ve=h.current;if(!ve)return!1;const Ke=Number.isFinite(ve.duration)?ve.duration:H,pt=Math.min(Math.max(H,0),Ke);if(p(pt),Math.abs(ve.currentTime-pt)<1/120)return!1;const hr=ve.fastSeek;return ae&&typeof hr=="function"?hr.call(ve,pt):ve.currentTime=pt,!0},[]),R=a.useCallback(()=>{b.current===null&&(b.current=requestAnimationFrame(()=>{b.current=null;const H=h.current;if(!H||!w.current||M.current||H.seeking)return;const ae=I.current;I.current=!1,M.current=Be(j.current,!ae)}))},[Be]),ee=a.useCallback(H=>{const ae=g.current,ve=h.current;if(!ae||!ve)return;const Ke=ae.getBoundingClientRect(),pt=Gp(H,Ke,ve.duration);j.current=pt,te(pt),I.current=!1,R(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,I.current=!0,R()},Qp)},[R]),le=a.useCallback(()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),I.current=!1,M.current=!1,Be(j.current)},[Be]),Ee=a.useCallback(H=>{const ae=h.current;if(!(!ae||!Number.isFinite(ae.duration)||ae.duration<=0)){m.current=!ae.paused,ae.pause(),w.current=!0,K(!0);try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}ee(H.clientX)}},[ee]),Ne=a.useCallback(()=>{w.current=!1,le(),K(!1),te(null);const H=h.current;H&&m.current&&!H.ended&&H.play().catch(()=>{}),m.current=!1},[le]),We=a.useCallback(()=>{const H=h.current;if(H){if(L.current){L.current=!1;return}H.paused?H.play().catch(()=>{}):H.pause()}},[]),ce=a.useCallback(H=>{const ae=h.current;if(!ae)return;const ve=Math.min(1,Math.max(0,Math.round((ae.volume+H)*100)/100));ae.volume=ve,ve>0&&(ae.muted=!1),N(ve),he(ve),Ze.current!==null&&clearTimeout(Ze.current),Ze.current=setTimeout(()=>{Ze.current=null,he(null)},qp)},[]),Ae=a.useCallback(H=>{const ae=h.current;if(ae){if(H.key==="ArrowLeft"){H.preventDefault(),Be(ae.currentTime-(H.shiftKey?qa*2:qa));return}if(H.key==="ArrowRight"){H.preventDefault(),Be(ae.currentTime+(H.shiftKey?qa*2:qa));return}if(H.key==="ArrowUp"){H.preventDefault(),ce(Id);return}if(H.key==="ArrowDown"){H.preventDefault(),ce(-Id);return}(H.key===" "||H.key==="Spacebar"||H.key==="k"||H.key==="K")&&(H.preventDefault(),ae.paused?ae.play().catch(()=>{}):ae.pause())}},[Be,ce]),tt=a.useCallback(H=>{const ae=h.current;!ae||ae.paused||H.button!==0||(Pe(),B.current={id:H.pointerId,x:H.clientX,y:H.clientY},_.current=setTimeout(()=>{_.current=null;const ve=B.current;if($.current=ae.playbackRate,ae.playbackRate=Vr,Le.current=Vr,pe(Vr),E.current=!0,W(!0),ve)try{ae.setPointerCapture?.(ve.id)}catch{}},Xp))},[Pe]),Te=a.useCallback(H=>{const ae=B.current;if(!ae||ae.id!==H.pointerId)return;if(!E.current){Math.hypot(H.clientX-ae.x,H.clientY-ae.y)>Jp&&(Pe(),B.current=null);return}const ve=Yp(H.clientX-ae.x);if(ve===Le.current)return;Le.current=ve,pe(ve);const Ke=h.current;Ke&&(Ke.playbackRate=ve)},[Pe]),ke=a.useCallback(()=>{at()&&(L.current=!0)},[at]);a.useEffect(()=>(window.addEventListener("pointerup",ke),window.addEventListener("pointercancel",ke),window.addEventListener("blur",ke),()=>{window.removeEventListener("pointerup",ke),window.removeEventListener("pointercancel",ke),window.removeEventListener("blur",ke)}),[ke]);const rt=a.useCallback(async()=>{const H=u.current,ae=h.current;if(!(!H||!ae))try{document.fullscreenElement===H?await document.exitFullscreen():H.requestFullscreen?await H.requestFullscreen():ae.webkitEnterFullscreen?.()}catch{ae.webkitEnterFullscreen?.()}},[]),nt=a.useCallback(()=>P(H=>(H+90)%360),[]),oe=a.useCallback(H=>{const ae=h.current;if(!ae||!Number.isFinite(ae.duration))return;const ve=H.shiftKey?10:5;let Ke=null;H.key==="ArrowLeft"?Ke=ae.currentTime-ve:H.key==="ArrowRight"?Ke=ae.currentTime+ve:H.key==="Home"?Ke=0:H.key==="End"&&(Ke=ae.duration),Ke!==null&&(H.preventDefault(),Be(Ke))},[Be]),Ie=C&&de!==null?de:D,ze=T>0?Math.min(1,Math.max(0,Ie/T)):0,Bt=(X===90||X===270)&&re.width>0&&re.height>0?{width:`${re.height}px`,height:`${re.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:u,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":X,children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:h,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${xe?` ${Cd}`:""}`,style:{...Bt,transform:`translate(-50%, -50%) rotate(${X}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...xe?{[Nd]:""}:{},onClick:We,onKeyDown:Ae,onVolumeChange:H=>N(H.currentTarget.volume),onPointerDown:tt,onPointerMove:Te,onPointerUp:ke,onPointerCancel:ke,onContextMenu:H=>{E.current&&H.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:H=>p(H.currentTarget.currentTime),onSeeked:H=>{const ae=H.currentTarget;if(p(ae.currentTime),M.current=!1,!w.current)return;const ve=ae.requestVideoFrameCallback;typeof ve=="function"?ve.call(ae,()=>{w.current&&R()}):requestAnimationFrame(()=>{w.current&&R()})},onLoadedMetadata:H=>U(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onDurationChange:H=>U(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),xe&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(ye)})}),q!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(Rm,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(De*100)})]}),C&&de!==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:`${ze*100}%`},"data-testid":"file-preview-video-scrub-time",children:ji(de)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Cd}`,[Nd]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:We,"aria-label":l(i?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(i?"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:i?e.jsx(Cm,{size:14}):e.jsx(Nm,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(T),"aria-valuenow":Math.floor(Ie),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:Ee,onPointerMove:H=>{C&&ee(H.clientX)},onPointerUp:Ne,onPointerCancel:Ne,onKeyDown:oe,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:`${ze*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:`${ze*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[ji(Ie)," / ",ji(T)]}),e.jsx("button",{type:"button",onClick:nt,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(hu,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{rt()},"aria-label":l(F?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(F?"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:F?e.jsx(Mm,{size:14}):e.jsx(Em,{size:14})})]})})]})}function eg(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function yo({anchor:r,children:n,disabled:s=!1,onClick:l,title:u}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:d=>{d.stopPropagation(),l()},title:u,style:eg(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(uo,{size:11}),n]})}function tg(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const u=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(u)||u<=0)return null;const d=l.width*u,h=l.height*u,g=s.left+(s.width-d)/2,m=s.top+(s.height-h)/2,b=r-g,f=n-m;if(b<0||f<0||b>d||f>h)return null;const j=b/d*100,w=f/h*100;return{x:l.x+l.width*j/100,y:l.y+l.height*w/100,xPercent:j,yPercent:w}}function rg(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function ng(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const u of Array.from(l.attributes)){const d=u.name.toLowerCase(),h=u.value.trim();(d.startsWith("on")||(d==="href"||d.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(u.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function sg(r,n,s){let l=null;for(const u of Array.from(r.querySelectorAll("text"))){const d=(u.textContent??"").replace(/\s+/g," ").trim();if(!d)continue;const h=Number(u.getAttribute("x")),g=Number(u.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(g))continue;const m=Math.hypot(h-n,g-s);(!l||m<l.distance)&&(l={text:d,distance:m})}return l?.text.slice(0,120)}function Pu({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const u=a.useRef(null),d=a.useRef(null),[h,g]=a.useState(null),[m,b]=a.useState(null),[f,j]=a.useState(1),[w,M]=a.useState(!1),[I,_]=a.useState(null),B=a.useRef(new Map),E=a.useRef(null),$=a.useRef(!1),L=a.useRef(null),T=a.useRef(f);T.current=f,a.useEffect(()=>{const P=new AbortController;return g(null),b(null),_(null),j(1),fetch(r,{signal:P.signal}).then(F=>F.text()).then(F=>g(ng(F))).catch(F=>{P.signal.aborted||b(F instanceof Error?F.message:"SVG preview failed")}),()=>P.abort()},[r]),a.useEffect(()=>{if(!w)return;const P=F=>{F.key==="Escape"&&M(!1)};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[w]),a.useLayoutEffect(()=>{const P=d.current,F=P?.querySelector("[data-svg-document] > svg");if(!P||!F)return;let V;try{V=F.getBBox()}catch{return}if(!V.width||!V.height)return;const re=Math.max(2,Math.min(V.width,V.height)*.025);F.setAttribute("viewBox",`${V.x-re} ${V.y-re} ${V.width+2*re} ${V.height+2*re}`),F.style.width=`${f*100}%`,F.style.height=`${f*100}%`,F.style.minWidth=`${f*100}%`,F.style.minHeight=`${f*100}%`,F.style.display="block"},[h,f]);const U=a.useMemo(()=>I?rg(n,s,I):null,[n,I,s]),D=P=>{if($.current){$.current=!1;return}const F=d.current,V=F?.querySelector("[data-svg-document] > svg"),re=u.current;if(!F||!V||!re)return;const ie=V.viewBox.baseVal,ye=tg(P.clientX,P.clientY,V.getBoundingClientRect(),ie);if(!ye)return;const pe=re.getBoundingClientRect();_({...ye,nearestText:sg(V,ye.x,ye.y),stageX:P.clientX-pe.left,stageY:P.clientY-pe.top,stageXPercent:(P.clientX-pe.left)/pe.width*100,stageYPercent:(P.clientY-pe.top)/pe.height*100})},p=P=>Math.max(1,Math.min(12,P)),i=(P,F)=>{const V=p(F),re=P.querySelector("[data-svg-document] > svg");if(!re)return V;const ie=`${V*100}%`;return re.style.width=ie,re.style.height=ie,re.style.minWidth=ie,re.style.minHeight=ie,T.current=V,V},O=(P,F,V,re)=>{const ie=T.current,ye=P.getBoundingClientRect(),pe=V-ye.left,De=re-ye.top,N=(P.scrollLeft+pe)/ie,q=(P.scrollTop+De)/ie,he=i(P,F);return P.scrollLeft=N*he-pe,P.scrollTop=q*he-De,he},C=()=>{const P=Array.from(B.current.values());return P.length>=2?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0},K=P=>{if(P.pointerType==="mouse"&&P.button!==0)return;const F=d.current;F&&(B.current.set(P.pointerId,{x:P.clientX,y:P.clientY}),F.setPointerCapture?.(P.pointerId),B.current.size>=2?(E.current={kind:"pinch",startX:P.clientX,startY:P.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startDistance:C(),startZoom:T.current,moved:!1},$.current=!0):T.current>1&&(E.current={kind:"pan",startX:P.clientX,startY:P.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}))},de=P=>{if(!B.current.has(P.pointerId))return;B.current.set(P.pointerId,{x:P.clientX,y:P.clientY});const F=d.current,V=E.current;if(!(!F||!V)){if(B.current.size>=2&&V.kind==="pinch"){const re=C();if(!V.startDistance||!re)return;const ie=p(V.startZoom*re/V.startDistance);if(Math.abs(ie-T.current)<.01)return;const ye=Array.from(B.current.values()),pe=(ye[0].x+ye[1].x)/2,De=(ye[0].y+ye[1].y)/2;V.moved=!0,$.current=!0,O(F,ie,pe,De),P.preventDefault();return}if(V.kind==="pan"&&B.current.size===1){const re=P.clientX-V.startX,ie=P.clientY-V.startY;if(!V.moved&&Math.hypot(re,ie)<6)return;V.moved=!0,$.current=!0,F.scrollLeft=V.startScrollLeft-re,F.scrollTop=V.startScrollTop-ie,P.preventDefault()}}},te=P=>{const F=d.current,V=E.current,re=B.current.size===1&&!V?.moved;B.current.delete(P.pointerId);try{F?.releasePointerCapture?.(P.pointerId)}catch{}if(B.current.size===1&&V?.kind==="pinch"){const pe=Array.from(B.current.values())[0];E.current=F?{kind:"pan",startX:pe.x,startY:pe.y,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}:null;return}if(B.current.size>0||(E.current=null,V?.kind==="pinch"&&j(T.current),!re||$.current))return;const ie=Date.now(),ye=L.current;ye&&ie-ye.time<350&&Math.hypot(P.clientX-ye.x,P.clientY-ye.y)<24?(L.current=null,$.current=!0,j(pe=>pe>1?1:2.5)):L.current={time:ie,x:P.clientX,y:P.clientY}},xe=P=>{if(!P.ctrlKey&&!P.metaKey)return;const F=d.current;if(!F)return;P.preventDefault();const V=O(F,T.current*Math.exp(-P.deltaY*.01),P.clientX,P.clientY);j(V)},W=()=>{j(1),T.current=1,d.current&&(d.current.scrollLeft=0,d.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:u,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:d,role:"button",tabIndex:0,onClick:D,onDoubleClick:P=>{P.preventDefault(),j(F=>F>1?1:2.5)},onPointerDown:K,onPointerMove:de,onPointerUp:te,onPointerCancel:te,onWheel:xe,onScroll:()=>_(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:m?e.jsx("div",{className:"p-4 text-sm text-destructive",children:m}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),I&&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:I.stageX,top:I.stageY}}),I&&U&&e.jsx(yo,{anchor:{xPercent:I.stageXPercent,yPercent:I.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${I.x.toFixed(2)}:${I.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:P=>{P.stopPropagation(),W()},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(lp,{size:14})}),e.jsx("button",{type:"button","aria-label":w?"退出全屏 SVG":"全屏 SVG",title:w?"退出全屏 SVG":"全屏 SVG",onClick:P=>{P.stopPropagation(),M(F=>!F)},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(wu,{size:14}):e.jsx(vu,{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:I?`SVG (${I.x.toFixed(2)}, ${I.y.toFixed(2)}) · ${I.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return w?qr.createPortal(X,document.body):X}function oo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function ag(r,n,s,l){const u=[`电子标注: ${r}`,`视图: ${oo(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(u.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&u.push(`显示层: ${l.layer}`),l.nearest)){const d=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");u.push(`最近对象: ${l.nearest.label}${d?`(${d})`:""}`)}return`"${u.join(" / ")}"`}function og({blobUrl:r,filePath:n,view:s,board:l,onViewChange:u,onInsertAnnotation:d,onRefresh:h,interactive3d:g}){const{t:m}=St(),b=a.useRef(null),f=a.useRef(null),j=a.useRef(null),[w,M]=a.useState(null),[I,_]=a.useState(!1);a.useEffect(()=>(j.current?.abort(),M(null),_(!1),()=>j.current?.abort()),[r,s]);const B=a.useMemo(()=>w?ag(n,s,w,w.inspection):null,[n,w,s]),E=L=>{const T=b.current,U=f.current;if(!T||!U||!U.naturalWidth||!U.naturalHeight)return;const D=T.getBoundingClientRect(),p=U.getBoundingClientRect(),i=Math.min(p.width/U.naturalWidth,p.height/U.naturalHeight),O=U.naturalWidth*i,C=U.naturalHeight*i,K=p.left+(p.width-O)/2,de=p.top+(p.height-C)/2,te=L.clientX-K,xe=L.clientY-de;if(te<0||xe<0||te>O||xe>C)return;const W={xPercent:Math.max(0,Math.min(100,te/O*100)),yPercent:Math.max(0,Math.min(100,xe/C*100)),stageXPercent:(L.clientX-D.left)/D.width*100,stageYPercent:(L.clientY-D.top)/D.height*100,inspecting:l&&s!=="pcb-3d"};if(M(W),j.current?.abort(),!W.inspecting)return;const X=new AbortController;j.current=X,Vh(n,s,W.xPercent,W.yPercent,X.signal).then(P=>M(F=>F===W?{...F,inspection:P,inspecting:!1}:F)).catch(()=>{X.signal.aborted||M(P=>P===W?{...P,inspection:{available:!1},inspecting:!1}:P)})},$=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:$.map(L=>e.jsx("button",{type:"button",onClick:()=>u(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:oo(L)},L))}),e.jsx("button",{type:"button",onClick:h,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:m("rightSidebar.edaRefresh"),"aria-label":m("rightSidebar.edaRefresh"),children:e.jsx(Hi,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:b,role:"button",tabIndex:0,onClick:E,onKeyDown:L=>{L.key!=="Enter"&&L.key!==" "||(L.preventDefault(),M({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:m("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:r,alt:`${n} ${oo(s)}`,onLoad:()=>_(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${I?"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&&B&&e.jsx(yo,{anchor:{xPercent:w.stageXPercent,yPercent:w.stageYPercent},disabled:w.inspecting,title:m("rightSidebar.edaInsertAnnotation"),onClick:()=>{d?.(B,`eda:${s}:${w.xPercent.toFixed(1)}:${w.yPercent.toFixed(1)}`,{snapshot:f.current?pp(f.current,w):Promise.resolve(null)}),M(null)},children:m("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?m("rightSidebar.edaInspecting"):w.inspection?.available?m("rightSidebar.edaPickedBoardPosition",{x:w.inspection.xMm?.toFixed(2)??"—",y:w.inspection.yMm?.toFixed(2)??"—",object:w.inspection.nearest?.label??m("rightSidebar.edaNoNearbyObject")}):m("rightSidebar.edaPickedPosition",{x:w.xPercent.toFixed(1),y:w.yPercent.toFixed(1)}):m("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Pu,{blobUrl:r,filePath:n,viewLabel:oo(s),onInsertAnnotation:d})})]})}function ig(r){const n=[];let s=[],l="",u=!1;for(let d=0;d<r.length;d+=1){const h=r[d];u?h==='"'&&r[d+1]==='"'?(l+='"',d+=1):h==='"'?u=!1:l+=h:h==='"'?u=!0:h===","?(s.push(l),l=""):h===`
|
|
14
14
|
`?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=h}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function lg(r,n,s,l,u){const d=n[u]||`第${u+1}列`,h=s[u]??"",g=n.map((m,b)=>`${m||`第${b+1}列`}=${s[b]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${l+1} / 列: ${d} / 值: ${h} / 记录: ${g}"`}function cg({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=St(),u=a.useMemo(()=>ig(r),[r]),d=u[0]??[],h=u.slice(1),g=a.useRef(null),[m,b]=a.useState(null),f=m?h[m.row]:null,j=m&&f?lg(n,d,f,m.row+1,m.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:g,className:"relative min-h-0 flex-1",children:[e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),d.map((w,M)=>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:M+1})},`${w}:${M}`))]})}),e.jsx("tbody",{children:h.map((w,M)=>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:M+1}),d.map((I,_)=>{const B=m?.row===M&&m.column===_;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${B?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:E=>{const $=g.current?.getBoundingClientRect(),L=E.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const T=E.clientX||L.left+L.width/2,U=E.clientY||L.top+L.height/2;b({row:M,column:_,xPercent:(T-$.left)/$.width*100,yPercent:(U-$.top)/$.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:${M}:${_}`)})]},`row:${M}`))})]})}),m&&j&&e.jsx(yo,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(j,`csv:${n}:${m.row+1}:${m.column+1}`),b(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:m&&f?l("rightSidebar.csvSelectedCell",{row:m.row+1,column:d[m.column]||m.column+1}):l("rightSidebar.csvPickHint",{rows:h.length,columns:d.length})})})]})}function Yn(r,n){let s=r;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function dg(r,n){const s=JSON.parse(r),l=Yn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(Yn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Yn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Yn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const u=Yn(s,["net_settings","classes"]),d=Array.isArray(u)?u.find(g=>g&&typeof g=="object"&&g.name==="Default"):void 0,h=Yn(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(u)?u.length:0)},{label:"默认间距",value:d?.clearance!==void 0?`${d.clearance} mm`:"未设置"},{label:"默认线宽",value:d?.track_width!==void 0?`${d.track_width} mm`:"未设置"},{label:"默认过孔",value:d?.via_diameter!==void 0?`${d.via_diameter} / ${d.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(h)?h.length:0)}]}function ug(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function fg({content:r,filePath:n,localState:s,onInsertAnnotation:l}){const{t:u}=St(),d=a.useRef(null),[h,g]=a.useState(null),m=a.useMemo(()=>{try{return{items:dg(r,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[r,s]),b=h===null?null:m.items[h.index];return m.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:u("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:d,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:m.items.map((f,j)=>e.jsxs("button",{type:"button",onClick:w=>{const M=d.current?.getBoundingClientRect(),I=w.currentTarget.getBoundingClientRect();if(!M?.width||!M.height)return;const _=w.clientX||I.left+I.width/2,B=w.clientY||I.top+I.height/2;g({index:j,xPercent:(_-M.left)/M.width*100,yPercent:(B-M.top)/M.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 ${h?.index===j?"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:u("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),b&&h&&e.jsx(yo,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:u("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(ug(n,b),`kicad-project:${n}:${b.label}`),g(null)},children:u("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:b?`${b.label}: ${b.value}`:u("rightSidebar.kicadProjectPickHint")})})]})}const hg=`/** ES Module Shims Wasm @version 2.8.4 */
|
|
15
15
|
(function () {
|
|
16
16
|
|
|
@@ -1632,15 +1632,15 @@ function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
|
1632
1632
|
window.addEventListener('error', report, true);
|
|
1633
1633
|
window.addEventListener('unhandledrejection', report);
|
|
1634
1634
|
}
|
|
1635
|
-
`,Ya="/api/terminal/fs/preview/",pg=8*1024*1024,gg=32*1024*1024,bg=128,xg="data:,";function $t(r){throw new Error(r)}function vg(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Dd(r,n,s){let l="",u=0;for(const d of r.matchAll(n))l+=r.slice(u,d.index)+await s(d),u=d.index+d[0].length;return l+r.slice(u)}async function Au(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!Ns(l.pathname)?.startsWith(Ya))&&$t("预览地址不是有效的本地文件入口");const u=crypto.randomUUID(),d=`https://termdock-preview.invalid/${u}/`,h=[],g=W=>{!h.includes(W)&&h.length<20&&h.push(W)},m=new Set,b=[],f=new Set,j=new Map,w=new Map;let M=0,I=!1;const _=new Set,B=()=>{I=!0;for(const W of[..._])W();m.clear(),b.length=0};async function E(W){W.ok||$t(`预览资源读取失败(${W.status})`);const
|
|
1636
|
-
installPreviewRuntime(`+[u,d,[...f],
|
|
1637
|
-
`+P.documentElement.outerHTML;return{html:
|
|
1638
|
-
`);const w=u.length;u+=f.data,l.push({node:f,start:w,end:u.length,group:j}),d=j}const g=u.toLocaleLowerCase(),m=[];let b=0;for(;b<=g.length-s.length;){const f=g.indexOf(s,b);if(f<0)break;const j=f+s.length,w=l.find(I=>I.start<=f&&I.end>f),M=l.find(I=>I.start<j&&I.end>=j);if(w&&M&&w.group===M.group){const I=document.createRange();I.setStart(w.node,f-w.start),I.setEnd(M.node,j-M.start),m.push(I)}b=f+Math.max(s.length,1)}return m}function Iu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Xa(){const r=Iu();r?.delete(Tu),r?.delete(Qi)}function Fd(r,n){const s=Iu();if(!s||typeof Highlight>"u")return;s.set(Tu,new Highlight(...r));const l=r[n];l?s.set(Qi,new Highlight(l)):s.delete(Qi)}function _d(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function jg(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Rg(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Cg(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Du(r,n,s){return n?r:Yr.createPortal(r,s)}const ul="termdock:right-sidebar:file-tree-scroll:v1",fl="termdock:right-sidebar:file-preview-reading-state:v1",Ts="termdock:right-sidebar:file-tree-width:v1",Fu="termdock:right-sidebar:markdown-view-mode:v1",_u="termdock:right-sidebar:diff-change-list-mode:v1",Bu="termdock:right-sidebar:diff-wrap:v1",Ou="termdock:diff-viewer:view-type:v1",Uu="termdock:right-sidebar:file-search-mode:v1",Ri="termdock:right-sidebar:collapsed-git-repo-groups:v1",Bd="termdock:right-sidebar:collapsed-diff-directories:v1",Ci="termdock:right-sidebar:branch-audit-module-open:v1",Hu="termdock:right-sidebar:branch-audit-module:v1",Ng=150,Od="termdock:right-sidebar:context-draft-enabled:v1",Ud="termdock:right-sidebar:context-draft-collapsed:v1",Hd="termdock:right-sidebar:context-draft-auto-collapse:v1",Ni="termdock:right-sidebar:context-draft-text:v1",Mg=300,Eg=20,$g=120,Lg=250,Pg=250,Ag=120,Tg=700,Mi=600,Ig=6e4;function $s(r){return!!(r&&J.getState().nestedGitScanRoots[r])}const zd=[2e3,5e3,15e3,3e4],Dg=320,Fg=500,_g=20,Bg=12e3,Zi=300,Wd=240,Og=560,zu="border-r px-2 py-1.5 sm:px-3 sm:py-2",fo="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Wu=`${zu} border-b border-border/15 font-semibold last:border-r-0`,Gu=`${zu} border-border/10 align-top text-muted-foreground last:border-r-0`,hl="termdock-file-preview-horizontal-scroll",Gd=a.lazy(()=>Hs(()=>import("./ModelPreview-CFe_gbXI.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Ku=`${hl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Vu(r,n,s){return r&&!n?"unified":s}const Ug=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Hg(r){return r==="preview"||r==="source"}function zg(r){return r==="list"||r==="tree"||r==="ai"}function Kd(){return mt(Fu,Hg)??"preview"}function Wg(){return mt(_u,zg)??"tree"}function Is(r){return typeof r=="boolean"}function Gg(r){return typeof r=="string"}function Kg(){return mt(Bu,Is)??!0}function Vg(r){return r==="unified"||r==="split"}function qg(){return mt(Ou,Vg)??"unified"}function Yg(r){return r==="name"||r==="content"||r==="regex"}function Xg(){return mt(Uu,Yg)??"name"}function qu(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:kt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Jg(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function el(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Yu(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function tl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Vd(r){const n=mt(r,tl);return n?new Set(n):new Set}function Ei(r,n){Lt(r,[...n])}function Qg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function Zg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||tl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Qg))&&(n.commits===void 0||tl(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 eb(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&Zg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function tb(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(eb))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function qd(){return mt(Hu,tb)??{}}function Yd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Xd(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Xu(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Xd(s)===Xd(l)}function Jd(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Xu(l,n))??""}function rl(r,n){const s=Math.max(Wd,n-320),l=Math.min(Og,s);return Math.min(l,Math.max(Wd,r))}function rb(r){return typeof r=="number"&&Number.isFinite(r)}function nb(r){return rl(mt(Ts,rb)??Zi,r)}function Ju(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Ls(r){return Ug.has(Ju(r))}function Qu(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function nl(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Qu(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Zu(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const ef=a.createContext(null);function io(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function tf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function rf(r){return r.replace(/\s+#+\s*$/,"").trim()}function sl(r,n){const l=tf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",u=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,u+1),u===0?l:`${l}-${u}`}function Qd(r){return tf(r)||r.trim()}function ho(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=ol(n[2]);return s?{id:io(n[1]),definition:{href:s.href,title:s.title}}:null}function sb(r){const n=new Map;for(const s of r){const l=ho(s);l&&n.set(l.id,l.definition)}return n}function nf(r){return r.trim().toLowerCase()}function sf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:nf(n[1]),text:n[2]}:null}function ab(r){const n=new Map;let s=null;for(const l of r){const u=sf(l);if(u){s=u.id,n.set(u.id,{id:u.id,text:u.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const d=n.get(s);d&&(d.text=`${d.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function af(r){const n=new Set;let s=!1;return r.forEach((l,u)=>{if(sf(l)){n.add(u),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(u);return}l.trim()&&(s=!1)}),n}function ob(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const u=r[s].trim();if(u.startsWith("<!--")){if(n[s]="",!u.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function of(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function _s(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const d of n.split("/"))if(!(!d||d===".")){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function ml(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const u=l.indexOf("#"),d=u>=0?l.slice(0,u):l,h=u>=0?l.slice(u+1):"",g=d.split("?",1)[0];if(!g)return null;let m,b=null;try{m=decodeURIComponent(g),b=h?decodeURIComponent(h):null}catch{return null}const f=s?_s(s):null;let j;if(m.startsWith("/")){const w=f&&(m===f||m.startsWith(`${f}/`));j=_s(f&&!w?`${f}/${m.slice(1)}`:m)}else{if(!n)return null;j=_s(`${of(n)}/${m}`)}return f&&j!==f&&!j.startsWith(`${f}/`)?null:{path:j,fragment:b,directory:/\/$/.test(g)}}function pl(r,n,s,l,u){const d=r.trim();if(!d||/^(?:javascript|data):/i.test(d))return null;if(/^https?:\/\//i.test(d))return d;if(!l(d.split(/[?#]/,1)[0]))return null;let h;if(d.startsWith("/")){const g=s&&(d===s||d.startsWith(`${s}/`));h=_s(s&&!g?`${s}/${d.slice(1)}`:d)}else{if(!n)return null;h=_s(`${of(n)}/${d}`)}return u(h)}function ib(r,n,s){return pl(r,n,s,dl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function lb(r,n,s){return pl(r,n,s,uu,fu)}const al=128,cb=360,$i=480;function wo(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function lf(r,n,s,l,u=0){if(!n||!s)return null;let d,h;return u>0?(d=l>0?Math.min(u,l):u,h=s*d/n):wo(r)?(h=Math.min(Math.max(s,al),cb),d=n*h/s):(d=n,h=s),l>0&&d>l&&(h=h*l/d,d=l),h>$i&&(d=d*$i/h,h=$i),{width:Math.max(1,Math.round(d)),height:Math.max(1,Math.round(h))}}function db(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function cf(r){const n=db(r),s=J(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function ub({src:r,alt:n,title:s,requestedWidthPx:l}){const u=wo(r),d=cf(r),h=vo(d),g=a.useRef(null),[m,b]=a.useState(!1),[f,j]=a.useState(0),[w,M]=a.useState({status:"loading"}),[I,_]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current,L=$?.parentElement?.parentElement??$?.parentElement;if(!L)return;const T=()=>j(L.clientWidth);if(T(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(T);return U.observe(L),()=>U.disconnect()},[]),a.useEffect(()=>{if(m)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){b(!0);return}const L=new IntersectionObserver(T=>{T.some(U=>U.isIntersecting)&&(b(!0),L.disconnect())},{rootMargin:"400px"});return L.observe($),()=>L.disconnect()},[m]),a.useEffect(()=>{if(!m)return;const $=new AbortController;let L=null;M({status:"loading"});const T=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return km(d,{signal:$.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const D=Number(U.headers.get("X-Image-Width"))||0,p=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:D,height:p}}).then(({blob:U,width:D,height:p})=>{$.signal.aborted||(L=URL.createObjectURL(U),D>0&&p>0&&_({width:D,height:p}),M({status:"ready",objectUrl:L}))}).catch(()=>{const U=$.signal.reason;$.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||M({status:"fallback"})}).finally(()=>{window.clearTimeout(T)}),()=>{window.clearTimeout(T),$.abort(),L&&URL.revokeObjectURL(L)}},[m,d]);const B=lf(r,I?.width??0,I?.height??0,f,l??0),E=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:al*2,height:al});return e.jsx("div",{ref:g,className:"block max-w-full",style:B?{width:B.width,height:B.height}:void 0,children:w.status==="ready"?e.jsx("img",{src:w.objectUrl,alt:n,title:s,decoding:"async",className:`${u?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&_({width:L.naturalWidth,height:L.naturalHeight})}}):w.status==="fallback"?e.jsx("img",{src:h,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&_({width:L.naturalWidth,height:L.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:E.width,height:E.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Bs(r,n,s,l,u,d){const h=ib(s,u.markdownFilePath,u.rootPath);if(!h)return d?.fallbackText??``;const g=u.images.length;u.images.push({kind:"image",src:h,alt:n,title:l});const m=e.jsx(ub,{src:h,alt:n,title:l,requestedWidthPx:d?.requestedWidthPx});return u.onImageOpen&&d?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:b=>{b.stopPropagation(),u.onImageOpen?.(g)},children:m},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:m},r)}function Li(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Zd(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function ol(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const df="",fb=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function hb(r){return r.replace(fb,(n,s)=>`${df}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function eu(r){return r.replace(new RegExp(`${df}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function mb(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const uf={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 Ja=null;function ff(){return Ja||(Ja=Hs(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw Ja=null,r})),Ja}function hf({html:r}){const{t:n}=St(),[s,l]=a.useState(null);return a.useEffect(()=>{let u=!1;return l(null),ff().then(d=>{u||l(d.sanitize(r,uf))}).catch(()=>{u||l("")}),()=>{u=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function pb({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),ff().then(u=>{l||s(u.sanitize(r,uf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function mf(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let Qa=null;function gb(){return Qa||(Qa=Promise.all([Hs(()=>import("./katex-DnlPpQZa.js"),[]),Hs(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([r])=>r.default??r).catch(r=>{throw Qa=null,r})),Qa}function Ws({tex:r,display:n=!1}){const[s,l]=a.useState(null),[u,d]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),d(!1),gb().then(m=>{g||l(m.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||d(!0)}),()=>{g=!0}},[n,r]),u)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const h=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:h,dangerouslySetInnerHTML:{__html:s}})}function gl(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function tu(r){const n=gl(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function bb(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=gl(s),u=l.get("src")?.trim()??"",d=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),g=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:u,fallbackText:g,widthPx:d?Number(d[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function xb({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:u}=St(),[d,h]=a.useState(!1),g=vo(r,()=>h(!0));return g?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:d?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||u("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:g,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function vb(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const h=r.slice(0,r.indexOf(">")+1),g=gl(h).get("href")?.trim()??"",m=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:b,alt:f,title:j,widthPx:w}=tu(m);if(!b)return null;const M=pl(b,s.markdownFilePath,s.rootPath,dl,$=>$);if(!M)return null;const I=g?ml(g,s.markdownFilePath,s.rootPath):null,B=!!!(I&&I.path===M)&&g?Zu(g):null,E=Bs(n,f??"",b,j,s,{requestedWidthPx:w,interactive:B?!1:void 0});return B?e.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:E},n):E}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:h,alt:g,title:m,widthPx:b}=tu(r);return h?Bs(n,g??"",h,m,s,{fallbackText:r,requestedWidthPx:b}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:h,fallbackText:g,widthPx:m,controls:b}=bb(r);if(!h)return null;const f=lb(h,s.markdownFilePath,s.rootPath);return f?e.jsx(xb,{url:f,fallbackText:g,widthPx:m,hasControls:b},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx(pb,{html:r},n):null;const u=l[1].toLowerCase(),d=ut(l[2],`${n}-${u}`,!0,s);return u==="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:d},n):u==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:d},n):u==="sub"?e.jsx("sub",{children:d},n):e.jsx("sup",{children:d},n)}function ut(r,n,s=!0,l){const u=hb(r),d=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<\s*img\b[^>]*>|<\s*video\b[^>]*>[\s\S]*?<\/video\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let g=0,m;for(;(m=d.exec(u))!==null;){m.index>g&&h.push(eu(u.slice(g,m.index)));const b=m[0],f=`${n}-${m.index}`,j=b.startsWith("<")?vb(b,f,l):null;if(j)h.push(j);else if(b.startsWith("\\(")&&b.endsWith("\\)"))h.push(e.jsx(Ws,{tex:b.slice(2,-2)},f));else if(b.startsWith("$")&&b.endsWith("$"))h.push(e.jsx(Ws,{tex:b.slice(1,-1)},f));else if(b.startsWith("`")){const w=b.match(/^`+/)?.[0].length??1;h.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:mb(b.slice(w,-w))},f))}else if(b.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ut(b.slice(2,-2),`${f}-del`,s,l)},f));else if(b.startsWith("**")||b.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ut(b.slice(2,-2),`${f}-strong`,s,l)},f));else if(b.startsWith("*")||b.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:ut(b.slice(1,-1),`${f}-em`,s,l)},f));else if(b.startsWith("![")){const w=b.match(/^!\[([^\]]*)\]\((.*)\)$/),M=b.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),I=b.match(/^!\[([^\]]+)\]$/);if(w){const _=ol(w[2]);h.push(_?Bs(f,w[1],_.href,_.title,l):b)}else if(M){const _=M[2]||M[1],B=l.referenceDefinitions.get(io(_));h.push(B?Bs(f,M[1],B.href,B.title,l):b)}else if(I){const _=l.referenceDefinitions.get(io(I[1]));h.push(_?Bs(f,I[1],_.href,_.title,l):b)}else h.push(b)}else if(b.startsWith("[^")){const w=nf(b.slice(2,-1)),M=l.footnoteDefinitions.get(w);h.push(M?e.jsx("sup",{id:`fnref-${M.id}`,title:M.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${M.id}`,className:"text-primary no-underline",children:M.index})},f):b)}else if(b.startsWith("<http")){const w=b.slice(1,-1);h.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(b.startsWith("<")&&b.endsWith(">")&&Zd(b.slice(1,-1))){const w=b.slice(1,-1);h.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(Zd(Li(b).linkText)){const{linkText:w,suffix:M}=Li(b);h.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&&h.push(M)}else if(b.startsWith("http")||b.startsWith("www.")){const{linkText:w,suffix:M}=Li(b),I=w.startsWith("www.")?`https://${w}`:w;h.push(e.jsx("a",{href:I,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&&h.push(M)}else{const w=b.match(/^\[([^\]]+)\]\((.*)\)$/),M=b.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),I=b.match(/^\[([^\]]+)\]$/),_=M?M[2]||M[1]:I?.[1]??null,B=_?l.referenceDefinitions.get(io(_)):null,E=w?ol(w[2]):null,$=E?.href??B?.href??null,L=$?Zu($):null,T=w?.[1]??M?.[1]??I?.[1]??"";h.push(L?e.jsx("a",{href:L,title:E?.title??B?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ut(T,`${f}-link`,s,l)},f):b)}g=d.lastIndex}return g<u.length&&h.push(eu(u.slice(g))),h.length>0?h:[r]}function pf(r){return/(?: {2,}|\\)$/.test(r)}function gf(r){return r.replace(/(?: {2,}|\\)$/,"")}function mo(r){return/^(?: {4}|\t)/.test(r)}function bf(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function xf(r,n,s){const l=[];return r.forEach((u,d)=>{const h=pf(u);l.push(...ut(gf(u),`${n}-${d}`,!0,s)),d<r.length-1&&l.push(h?e.jsx("br",{},`${n}-${d}-br`):" ")}),l}function il(r,n,s){const l=[],u=[];return r.forEach((d,h)=>{u.push(pf(d)),l.push(ut(gf(d),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:u}}function ll(r,n,s,l,u){const d=[];return r.forEach((h,g)=>{const m=s[g]??0,b=!!(u&&m>=u.start&&m<=u.end);d.push(e.jsx("span",{"data-md-ref-start":m,"data-md-ref-end":m,"data-selected":b?"true":void 0,children:h},`${l}-ref-${g}`)),g<r.length-1&&d.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),d}function Gs(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",u=!1,d=0,h=0;for(let g=0;g<n.length;g+=1){const m=n[g];if(u){l+=m,u=!1;continue}if(m==="\\"){u=!0;continue}if(m==="`"){const b=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const f=g-b+1;l+="`".repeat(f),d===0?d=f:d===f&&(d=0);continue}if(d===0&&m==="["?h+=1:d===0&&m==="]"&&h>0&&(h-=1),m==="|"&&d===0&&h===0){s.push(l.trim()),l="";continue}l+=m}return u&&(l+="\\"),s.push(l.trim()),s}function vf(r){return Gs(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function po(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function go(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function yf(r,n){return r>96||r>44&&n>.35}function ko(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Ks(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function bl(r,n,s,l,u,d=new Set){const h=[],g=[];let m=n;for(;m<r.length;){const b=r[m];if(u&&(ho(b)||d.has(m))){m+=1;continue}const f=Ks(b),j=ko(b);if(!f){if(j>s&&g.length>0){([...g].reverse().find(_=>_.indent<j)?.item??g[g.length-1].item).paragraphs.push(b.trim());for(const _ of g)_.item.lineEnd=m+1;m+=1;continue}break}if(j<s||j===s&&f.ordered!==l)break;const w={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:m+1,lineEnd:m+1};for(;g.length>0&&g[g.length-1].indent>=j;)g.pop();const M=g[g.length-1]?.item??null;M?M.children.push(w):h.push(w),g.push({indent:j,item:w});for(const I of g)I.item.lineEnd=m+1;m+=1}return{items:h,nextIndex:m}}function yb(r){const n=r.find(l=>Ks(l));if(!n)return[];const s=Ks(n);return s?bl(r,0,ko(n),s.ordered,!0,af(r)).items:[]}function xl(r,n,s,l=0){return r.map((u,d)=>{const h=u.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${d}`,taskItem:!!h,refStart:u.lineStart+l,refEnd:u.lineEnd+l,content:e.jsxs(e.Fragment,{children:[h?e.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ut(h?.[2]??u.content,`li-${n}-${d}`,!0,s),u.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:u.paragraphs.map((g,m)=>e.jsx("p",{children:ut(g,`li-${n}-${d}-p-${m}`,!0,s)},`paragraph-${m}`))})]}),groups:wb(u.children,`${n}-${d}`,s,l)}})}function wb(r,n,s,l=0){const u=[];for(const d of r){const h=u[u.length-1];h&&h.ordered===d.ordered?h.items.push(d):u.push({ordered:d.ordered,items:[d]})}return u.map((d,h)=>({ordered:d.ordered,start:d.ordered?d.items[0]?.start:void 0,items:xl(d.items,`${n}-g${h}`,s,l)}))}function vl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&kb(s.groups,n)]},s.key)})}function kb(r,n){return r.map((s,l)=>{const u=s.ordered?"ol":"ul";return e.jsx(u,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:vl(s.items,n)},`nested-${l}`)})}function Sb(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ut(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function jb(r,n,s,l){const u=[];let d=0;const h=g=>l?.[g]??g+1;for(;d<r.length;){const g=r[d],m=g.trim();if(!m){d+=1;continue}if(/^<details>\s*$/i.test(m)){const E=d;let $="Details";const L=[];for(d+=1;d<r.length&&!/^<\/details>\s*$/i.test(r[d].trim());){const T=r[d].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);T?$=T[1].trim()||$:L.push(r[d].trimStart()),d+=1}d<r.length&&(d+=1),u.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:ut($,`${n}-details-${E}-summary`,!0,s)}),L.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:xf(L,`${n}-details-${E}`,s)})]},`${n}-details-${E}`)});continue}const b=mf(g);if(b){const E=[g],$=d;for(d+=1;d<r.length&&!b.selfContained&&!new RegExp(`</${b.tag}>`,"i").test(r[d]);)E.push(r[d]),d+=1;d<r.length&&!b.selfContained&&(E.push(r[d]),d+=1),u.push({kind:"static",node:e.jsx(hf,{html:E.join(`
|
|
1635
|
+
`,Ya="/api/terminal/fs/preview/",pg=8*1024*1024,gg=32*1024*1024,bg=128,xg="data:,";function $t(r){throw new Error(r)}function vg(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Dd(r,n,s){let l="",u=0;for(const d of r.matchAll(n))l+=r.slice(u,d.index)+await s(d),u=d.index+d[0].length;return l+r.slice(u)}async function Au(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!Ns(l.pathname)?.startsWith(Ya))&&$t("预览地址不是有效的本地文件入口");const u=crypto.randomUUID(),d=`https://termdock-preview.invalid/${u}/`,h=[],g=W=>{!h.includes(W)&&h.length<20&&h.push(W)},m=new Set,b=[],f=new Set,j=new Map,w=new Map;let M=0,I=!1;const _=new Set,B=()=>{I=!0;for(const W of[..._])W();m.clear(),b.length=0};async function E(W){W.ok||$t(`预览资源读取失败(${W.status})`);const X=W.body?.getReader(),P=[];let F=0;try{if(X)for(;;){const ie=await X.read();if(ie.done)break;F+=ie.value.byteLength,M+=ie.value.byteLength,(F>pg||M>gg)&&$t("预览资源超出大小限制"),P.push(ie.value)}}catch(ie){throw await X?.cancel().catch(()=>{}),ie}finally{X?.releaseLock()}const V=new Uint8Array(F);let re=0;for(const ie of P)V.set(ie,re),re+=ie.length;return{bytes:V,type:W.headers.get("content-type")??"application/octet-stream",status:W.status}}let $=l,L;for(let W=0;W<4;W++){const X=await n.fetch($.pathname+$.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(X.status)){L=X;break}const P=X.headers.get("location");await X.body?.cancel(),P||$t("预览重定向缺少目标");const F=new URL(P,$);(F.origin!==s||!Ns(F.pathname)?.startsWith(Ya))&&$t("预览重定向越出文件范围"),$=F}L||$t("预览重定向次数过多");const T=Ns($.pathname),U=T.slice(Ya.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||$t("服务未提供有效的预览资源授权");const D=Ns(l.pathname).slice(Ya.length).split("/");/^[a-f0-9]{32}$/.test(D[0])&&D.shift(),D.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&$t("预览重定向改变了文件范围");const p=T.endsWith("/")?T:T.slice(0,T.lastIndexOf("/")+1),i=new URL($.pathname.endsWith("/")?$.pathname:$.pathname.slice(0,$.pathname.lastIndexOf("/")+1),s);function O(W,X){const P=new URL(W,X);return P.origin!==s?null:(Ns(P.pathname)?.startsWith(p)||$t("已阻止预览访问目录之外的资源"),P)}function C(W){const X=new URL(W,d);(X.origin!==new URL(d).origin||!X.pathname.startsWith(new URL(d).pathname))&&$t("已阻止预览访问服务接口或目录之外的资源");const P=X.pathname.slice(new URL(d).pathname.length)+X.search;return O(P,i)??$t("预览资源无效")}function K(W){const X=W.pathname+W.search,P=j.get(X);if(P)return P;if(I||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(j.size>=bg)return Promise.reject(new Error("预览资源数量超出限制"));const F=n.fetch(X,{signal:n.signal,redirect:"manual"}).then(E);return j.set(X,F),F}function de(W,X){I&&$t("预览已关闭");const P=`termdock-resource-${u}-${b.length}`;return b.push({token:P,data:W,type:X}),m.add(P),P}async function te(W,X,P,F=new Set){if(!W||W.startsWith("#")||/^data:(?:image|font)\//i.test(W)&&P==="resource")return W;try{const V=O(W,X);if(!V){const De=new URL(W,X);return(De.protocol!=="https:"||De.username||De.password||De.origin===new URL(d).origin)&&$t("已阻止不安全的外部资源"),f.add(De.origin),De.href}const re=`${P}:${V.href}`;(F.has(re)||F.size>=8)&&$t("预览资源存在循环或过深引用");const ie=w.get(re);if(ie)return ie;const ye=new Set(F);ye.add(re);const pe=(async()=>{const De=await K(V);return P==="css"?de(await xe(new TextDecoder().decode(De.bytes),V,ye),"text/css"):P==="script"?de(De.bytes,"text/javascript"):de(De.bytes,De.type)})();return w.set(re,pe),await pe}catch(V){return g(V instanceof Error?V.message:"部分预览资源未能加载"),xg}}async function xe(W,X,P){return W=await Dd(W,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async F=>`@import url("${await te(F[1],X,"css",P)}")${F[2]};`),Dd(W,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async F=>{const V=(F[1]??F[2]??F[3]).trim();return m.has(V)?F[0]:`url("${await te(V,X,"resource",P)}")`})}try{const W=await E(L),X=de(hg,"text/javascript"),P=new DOMParser().parseFromString(new TextDecoder().decode(W.bytes),"text/html");P.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(N=>N.remove());for(const N of P.querySelectorAll("*")){if(N.removeAttribute("ping"),N.removeAttribute("srcdoc"),N.hasAttribute("style")&&N.setAttribute("style",await xe(N.getAttribute("style"),$,new Set)),N.tagName==="STYLE"&&(N.textContent=await xe(N.textContent??"",$,new Set)),N.tagName==="A"||N.tagName==="AREA"){const q=N.getAttribute("href");try{if(q&&!q.startsWith("#")){const he=O(q,$);if(he)N.setAttribute("href",new URL(he.pathname.slice(i.pathname.length)+he.search+he.hash,d).href);else{const Le=new URL(q,$);if(Le.protocol!=="https:"){N.removeAttribute("href");continue}f.add(Le.origin),N.setAttribute("href",Le.href)}}}catch(he){N.removeAttribute("href"),g(he instanceof Error?he.message:"预览链接无法加载")}}for(const q of["data","manifest"])N.removeAttribute(q);if(N.tagName==="SCRIPT"&&N.getAttribute("type")==="module"){N.setAttribute("type","module-shim");const q=N.getAttribute("src");if(q){const he=O(q,$);if(he)N.setAttribute("src",new URL(he.pathname.slice(i.pathname.length)+he.search,d).href);else{const Le=new URL(q,$);if(Le.protocol!=="https:"){N.remove();continue}f.add(Le.origin),N.setAttribute("src",Le.href)}}continue}if(N.tagName==="SCRIPT"&&N.getAttribute("type")==="importmap"){N.setAttribute("type","importmap-shim");continue}if(N.tagName==="LINK"){const q=(N.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(q)){N.remove();continue}const he=N.getAttribute("href");he&&N.setAttribute("href",await te(he,$,q==="stylesheet"?"css":"resource"))}if(N.hasAttribute("src")&&N.setAttribute("src",await te(N.getAttribute("src"),$,N.tagName==="SCRIPT"?"script":"resource")),N.hasAttribute("poster")&&N.setAttribute("poster",await te(N.getAttribute("poster"),$,"resource")),N.hasAttribute("srcset")){const q=N.getAttribute("srcset");/data:/i.test(q)?(N.removeAttribute("srcset"),g("混合内嵌图片候选暂不支持安全预览")):N.setAttribute("srcset",(await Promise.all(q.split(",").map(async he=>{const[Le,...Ze]=he.trim().split(/\s+/);return`${await te(Le,$,"resource")} ${Ze.join(" ")}`}))).join(", "))}N.setAttribute("referrerpolicy","no-referrer"),N.removeAttribute("integrity"),N.removeAttribute("crossorigin")}const F=[...f].join(" "),V=P.createElement("meta");V.httpEquiv="Content-Security-Policy",V.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${F}; style-src 'unsafe-inline' blob: ${F}; img-src blob: data: ${F}; font-src blob: data: ${F}; media-src blob: data: ${F}; connect-src blob: ${F} ${[...f].map(N=>N.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const re=P.createElement("base");re.href=d;const ie=P.createElement("meta");ie.name="referrer",ie.content="no-referrer";const ye=P.createElement("script");ye.textContent=mg+`
|
|
1636
|
+
installPreviewRuntime(`+[u,d,[...f],X].map(vg).join(",")+");";const pe=P.createElement("script");pe.src=X,P.head.prepend(V,ie,re,ye,pe);const De=`<!doctype html>
|
|
1637
|
+
`+P.documentElement.outerHTML;return{html:De,shellUrl:`/preview-shell.html#${u}`,errors:h,attach(N,q){const he=new Set,Le=Pe=>{if(Pe.source!==N.contentWindow||Pe.data?.capability!==u)return;if(Pe.data.type==="preview-ready"){N.contentWindow?.postMessage({type:"preview-init",capability:u,html:De,resources:b},"*");return}if(Pe.data.type==="preview-error"){q("部分动态内容被安全预览限制");return}if(Pe.data.type==="preview-navigate"){(async()=>{const Be=C(String(Pe.data.url)),R=await Au(Be.pathname+Be.search,n);if(I){R.dispose();return}const ee=R.attach(N,q);_.add(()=>{ee(),R.dispose()}),N.src=R.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(Be=>q(Be instanceof Error?Be.message:"无法打开预览页面"));return}if(Pe.data.type==="preview-external"){try{const Be=new URL(String(Pe.data.url));Be.protocol==="https:"&&f.has(Be.origin)&&window.open(Be.href,"_blank","noopener,noreferrer")}catch{}return}if(Pe.data.type!=="preview-fetch"||Pe.ports.length!==1)return;const at=Pe.ports[0];if(he.size>=8||!["GET","HEAD"].includes(Pe.data.method)){at.postMessage({error:"预览仅允许读取已授权目录资源"}),at.close();return}he.add(at),(async()=>{const Be=C(String(Pe.data.url)),R=await K(Be);if(!he.has(at)||I)return;const ee=Pe.data.method==="HEAD"?new Uint8Array:R.bytes.slice();at.postMessage({status:R.status,headers:{"content-type":R.type},data:ee.buffer},[ee.buffer])})().catch(()=>{at.postMessage({error:"预览资源不在授权范围或无法加载"}),q("部分动态资源不可用或超出预览目录")}).finally(()=>{he.delete(at),at.close()})};window.addEventListener("message",Le);const Ze=()=>{window.removeEventListener("message",Le);for(const Pe of he)Pe.close();he.clear(),_.delete(Ze)};return _.add(Ze),Ze},dispose:B}}catch(W){throw B(),W}}const yg=a.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:u},d){const h=a.useRef(null),[g,m]=a.useState(null),[b,f]=a.useState(),[j,w]=a.useState("");a.useEffect(()=>{const T=new AbortController;let U;return f(void 0),w(""),(async()=>{const D=await qh();if(U=await Au(n,{fetch:(p,i)=>D.fetch(p,i),signal:T.signal}),T.signal.aborted){U.dispose();return}f(U),U.errors.length&&w(U.errors.join(";"))})().catch(D=>{T.signal.aborted||w(D instanceof Error?D.message:"安全预览加载失败")}),()=>{T.abort(),U?.dispose()}},[n]),a.useEffect(()=>{if(!(!b||!g))return b.attach(g,w)},[b,g]);const[M,I]=a.useState(!1),[_,B]=a.useState(!1),E=M||_;a.useEffect(()=>{u?.(E)},[E,u]),a.useEffect(()=>{const T=()=>{I(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",T),()=>document.removeEventListener("fullscreenchange",T)},[]),a.useEffect(()=>{if(!_)return;const T=U=>{U.key==="Escape"&&B(!1)};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[_]);const $=a.useCallback(async()=>{const T=h.current;if(T){if(_){B(!1);return}if(document.fullscreenElement===T){await document.exitFullscreen();return}if(T.requestFullscreen&&document.fullscreenEnabled!==!1)try{await T.requestFullscreen();return}catch{}B(!0)}},[_]);a.useImperativeHandle(d,()=>({toggleFullscreen:$}),[$]);const L=e.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:E?"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:[E&&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:()=>{$()},"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(wu,{size:15})})]}),j&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:j}),!b&&!j&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:m,src:b?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return _?qr.createPortal(L,document.body):L}),Tu="termdock-file-search-match",Qi="termdock-file-search-current";function wg(r){const n=r.metaKey||r.ctrlKey,s=r.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||r.key==="F3"?r.shiftKey?"previous":"next":r.key==="Escape"?"close":null}function kg(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Sg(r,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let u="",d=null;const h=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const j=kg(f);if(!j)continue;d&&d!==j&&(u+=`
|
|
1638
|
+
`);const w=u.length;u+=f.data,l.push({node:f,start:w,end:u.length,group:j}),d=j}const g=u.toLocaleLowerCase(),m=[];let b=0;for(;b<=g.length-s.length;){const f=g.indexOf(s,b);if(f<0)break;const j=f+s.length,w=l.find(I=>I.start<=f&&I.end>f),M=l.find(I=>I.start<j&&I.end>=j);if(w&&M&&w.group===M.group){const I=document.createRange();I.setStart(w.node,f-w.start),I.setEnd(M.node,j-M.start),m.push(I)}b=f+Math.max(s.length,1)}return m}function Iu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Xa(){const r=Iu();r?.delete(Tu),r?.delete(Qi)}function Fd(r,n){const s=Iu();if(!s||typeof Highlight>"u")return;s.set(Tu,new Highlight(...r));const l=r[n];l?s.set(Qi,new Highlight(l)):s.delete(Qi)}function _d(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function jg(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Rg(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Cg(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Du(r,n,s){return n?r:qr.createPortal(r,s)}const ul="termdock:right-sidebar:file-tree-scroll:v1",fl="termdock:right-sidebar:file-preview-reading-state:v1",Ts="termdock:right-sidebar:file-tree-width:v1",Fu="termdock:right-sidebar:markdown-view-mode:v1",_u="termdock:right-sidebar:diff-change-list-mode:v1",Bu="termdock:right-sidebar:diff-wrap:v1",Ou="termdock:diff-viewer:view-type:v1",Uu="termdock:right-sidebar:file-search-mode:v1",Ri="termdock:right-sidebar:collapsed-git-repo-groups:v1",Bd="termdock:right-sidebar:collapsed-diff-directories:v1",Ci="termdock:right-sidebar:branch-audit-module-open:v1",Hu="termdock:right-sidebar:branch-audit-module:v1",Ng=150,Od="termdock:right-sidebar:context-draft-enabled:v1",Ud="termdock:right-sidebar:context-draft-collapsed:v1",Hd="termdock:right-sidebar:context-draft-auto-collapse:v1",Ni="termdock:right-sidebar:context-draft-text:v1",Mg=300,Eg=20,$g=120,Lg=250,Pg=250,Ag=120,Tg=700,Mi=600,Ig=6e4;function $s(r){return!!(r&&J.getState().nestedGitScanRoots[r])}const zd=[2e3,5e3,15e3,3e4],Dg=320,Fg=500,_g=20,Bg=12e3,Zi=300,Wd=240,Og=560,zu="border-r px-2 py-1.5 sm:px-3 sm:py-2",fo="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Wu=`${zu} border-b border-border/15 font-semibold last:border-r-0`,Gu=`${zu} border-border/10 align-top text-muted-foreground last:border-r-0`,hl="termdock-file-preview-horizontal-scroll",Gd=a.lazy(()=>Hs(()=>import("./ModelPreview-LnA0nAyy.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Ku=`${hl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Vu(r,n,s){return r&&!n?"unified":s}const Ug=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Hg(r){return r==="preview"||r==="source"}function zg(r){return r==="list"||r==="tree"||r==="ai"}function Kd(){return mt(Fu,Hg)??"preview"}function Wg(){return mt(_u,zg)??"tree"}function Is(r){return typeof r=="boolean"}function Gg(r){return typeof r=="string"}function Kg(){return mt(Bu,Is)??!0}function Vg(r){return r==="unified"||r==="split"}function qg(){return mt(Ou,Vg)??"unified"}function Yg(r){return r==="name"||r==="content"||r==="regex"}function Xg(){return mt(Uu,Yg)??"name"}function qu(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:kt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Jg(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function el(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Yu(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function tl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Vd(r){const n=mt(r,tl);return n?new Set(n):new Set}function Ei(r,n){Lt(r,[...n])}function Qg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function Zg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||tl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Qg))&&(n.commits===void 0||tl(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 eb(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&Zg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function tb(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(eb))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function qd(){return mt(Hu,tb)??{}}function Yd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Xd(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Xu(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Xd(s)===Xd(l)}function Jd(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Xu(l,n))??""}function rl(r,n){const s=Math.max(Wd,n-320),l=Math.min(Og,s);return Math.min(l,Math.max(Wd,r))}function rb(r){return typeof r=="number"&&Number.isFinite(r)}function nb(r){return rl(mt(Ts,rb)??Zi,r)}function Ju(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Ls(r){return Ug.has(Ju(r))}function Qu(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function nl(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Qu(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Zu(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const ef=a.createContext(null);function io(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function tf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function rf(r){return r.replace(/\s+#+\s*$/,"").trim()}function sl(r,n){const l=tf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",u=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,u+1),u===0?l:`${l}-${u}`}function Qd(r){return tf(r)||r.trim()}function ho(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=ol(n[2]);return s?{id:io(n[1]),definition:{href:s.href,title:s.title}}:null}function sb(r){const n=new Map;for(const s of r){const l=ho(s);l&&n.set(l.id,l.definition)}return n}function nf(r){return r.trim().toLowerCase()}function sf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:nf(n[1]),text:n[2]}:null}function ab(r){const n=new Map;let s=null;for(const l of r){const u=sf(l);if(u){s=u.id,n.set(u.id,{id:u.id,text:u.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const d=n.get(s);d&&(d.text=`${d.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function af(r){const n=new Set;let s=!1;return r.forEach((l,u)=>{if(sf(l)){n.add(u),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(u);return}l.trim()&&(s=!1)}),n}function ob(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const u=r[s].trim();if(u.startsWith("<!--")){if(n[s]="",!u.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function of(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function _s(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const d of n.split("/"))if(!(!d||d===".")){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function ml(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const u=l.indexOf("#"),d=u>=0?l.slice(0,u):l,h=u>=0?l.slice(u+1):"",g=d.split("?",1)[0];if(!g)return null;let m,b=null;try{m=decodeURIComponent(g),b=h?decodeURIComponent(h):null}catch{return null}const f=s?_s(s):null;let j;if(m.startsWith("/")){const w=f&&(m===f||m.startsWith(`${f}/`));j=_s(f&&!w?`${f}/${m.slice(1)}`:m)}else{if(!n)return null;j=_s(`${of(n)}/${m}`)}return f&&j!==f&&!j.startsWith(`${f}/`)?null:{path:j,fragment:b,directory:/\/$/.test(g)}}function pl(r,n,s,l,u){const d=r.trim();if(!d||/^(?:javascript|data):/i.test(d))return null;if(/^https?:\/\//i.test(d))return d;if(!l(d.split(/[?#]/,1)[0]))return null;let h;if(d.startsWith("/")){const g=s&&(d===s||d.startsWith(`${s}/`));h=_s(s&&!g?`${s}/${d.slice(1)}`:d)}else{if(!n)return null;h=_s(`${of(n)}/${d}`)}return u(h)}function ib(r,n,s){return pl(r,n,s,dl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function lb(r,n,s){return pl(r,n,s,uu,fu)}const al=128,cb=360,$i=480;function wo(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function lf(r,n,s,l,u=0){if(!n||!s)return null;let d,h;return u>0?(d=l>0?Math.min(u,l):u,h=s*d/n):wo(r)?(h=Math.min(Math.max(s,al),cb),d=n*h/s):(d=n,h=s),l>0&&d>l&&(h=h*l/d,d=l),h>$i&&(d=d*$i/h,h=$i),{width:Math.max(1,Math.round(d)),height:Math.max(1,Math.round(h))}}function db(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function cf(r){const n=db(r),s=J(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function ub({src:r,alt:n,title:s,requestedWidthPx:l}){const u=wo(r),d=cf(r),h=vo(d),g=a.useRef(null),[m,b]=a.useState(!1),[f,j]=a.useState(0),[w,M]=a.useState({status:"loading"}),[I,_]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current,L=$?.parentElement?.parentElement??$?.parentElement;if(!L)return;const T=()=>j(L.clientWidth);if(T(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(T);return U.observe(L),()=>U.disconnect()},[]),a.useEffect(()=>{if(m)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){b(!0);return}const L=new IntersectionObserver(T=>{T.some(U=>U.isIntersecting)&&(b(!0),L.disconnect())},{rootMargin:"400px"});return L.observe($),()=>L.disconnect()},[m]),a.useEffect(()=>{if(!m)return;const $=new AbortController;let L=null;M({status:"loading"});const T=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return km(d,{signal:$.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const D=Number(U.headers.get("X-Image-Width"))||0,p=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:D,height:p}}).then(({blob:U,width:D,height:p})=>{$.signal.aborted||(L=URL.createObjectURL(U),D>0&&p>0&&_({width:D,height:p}),M({status:"ready",objectUrl:L}))}).catch(()=>{const U=$.signal.reason;$.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||M({status:"fallback"})}).finally(()=>{window.clearTimeout(T)}),()=>{window.clearTimeout(T),$.abort(),L&&URL.revokeObjectURL(L)}},[m,d]);const B=lf(r,I?.width??0,I?.height??0,f,l??0),E=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:al*2,height:al});return e.jsx("div",{ref:g,className:"block max-w-full",style:B?{width:B.width,height:B.height}:void 0,children:w.status==="ready"?e.jsx("img",{src:w.objectUrl,alt:n,title:s,decoding:"async",className:`${u?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&_({width:L.naturalWidth,height:L.naturalHeight})}}):w.status==="fallback"?e.jsx("img",{src:h,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&_({width:L.naturalWidth,height:L.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:E.width,height:E.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Bs(r,n,s,l,u,d){const h=ib(s,u.markdownFilePath,u.rootPath);if(!h)return d?.fallbackText??``;const g=u.images.length;u.images.push({kind:"image",src:h,alt:n,title:l});const m=e.jsx(ub,{src:h,alt:n,title:l,requestedWidthPx:d?.requestedWidthPx});return u.onImageOpen&&d?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:b=>{b.stopPropagation(),u.onImageOpen?.(g)},children:m},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:m},r)}function Li(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Zd(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function ol(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const df="",fb=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function hb(r){return r.replace(fb,(n,s)=>`${df}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function eu(r){return r.replace(new RegExp(`${df}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function mb(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const uf={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 Ja=null;function ff(){return Ja||(Ja=Hs(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw Ja=null,r})),Ja}function hf({html:r}){const{t:n}=St(),[s,l]=a.useState(null);return a.useEffect(()=>{let u=!1;return l(null),ff().then(d=>{u||l(d.sanitize(r,uf))}).catch(()=>{u||l("")}),()=>{u=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function pb({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),ff().then(u=>{l||s(u.sanitize(r,uf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function mf(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let Qa=null;function gb(){return Qa||(Qa=Promise.all([Hs(()=>import("./katex-DnlPpQZa.js"),[]),Hs(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([r])=>r.default??r).catch(r=>{throw Qa=null,r})),Qa}function Ws({tex:r,display:n=!1}){const[s,l]=a.useState(null),[u,d]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),d(!1),gb().then(m=>{g||l(m.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||d(!0)}),()=>{g=!0}},[n,r]),u)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const h=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:h,dangerouslySetInnerHTML:{__html:s}})}function gl(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function tu(r){const n=gl(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function bb(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=gl(s),u=l.get("src")?.trim()??"",d=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),g=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:u,fallbackText:g,widthPx:d?Number(d[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function xb({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:u}=St(),[d,h]=a.useState(!1),g=vo(r,()=>h(!0));return g?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:d?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||u("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:g,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function vb(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const h=r.slice(0,r.indexOf(">")+1),g=gl(h).get("href")?.trim()??"",m=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:b,alt:f,title:j,widthPx:w}=tu(m);if(!b)return null;const M=pl(b,s.markdownFilePath,s.rootPath,dl,$=>$);if(!M)return null;const I=g?ml(g,s.markdownFilePath,s.rootPath):null,B=!!!(I&&I.path===M)&&g?Zu(g):null,E=Bs(n,f??"",b,j,s,{requestedWidthPx:w,interactive:B?!1:void 0});return B?e.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:E},n):E}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:h,alt:g,title:m,widthPx:b}=tu(r);return h?Bs(n,g??"",h,m,s,{fallbackText:r,requestedWidthPx:b}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:h,fallbackText:g,widthPx:m,controls:b}=bb(r);if(!h)return null;const f=lb(h,s.markdownFilePath,s.rootPath);return f?e.jsx(xb,{url:f,fallbackText:g,widthPx:m,hasControls:b},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx(pb,{html:r},n):null;const u=l[1].toLowerCase(),d=ut(l[2],`${n}-${u}`,!0,s);return u==="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:d},n):u==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:d},n):u==="sub"?e.jsx("sub",{children:d},n):e.jsx("sup",{children:d},n)}function ut(r,n,s=!0,l){const u=hb(r),d=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<\s*img\b[^>]*>|<\s*video\b[^>]*>[\s\S]*?<\/video\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let g=0,m;for(;(m=d.exec(u))!==null;){m.index>g&&h.push(eu(u.slice(g,m.index)));const b=m[0],f=`${n}-${m.index}`,j=b.startsWith("<")?vb(b,f,l):null;if(j)h.push(j);else if(b.startsWith("\\(")&&b.endsWith("\\)"))h.push(e.jsx(Ws,{tex:b.slice(2,-2)},f));else if(b.startsWith("$")&&b.endsWith("$"))h.push(e.jsx(Ws,{tex:b.slice(1,-1)},f));else if(b.startsWith("`")){const w=b.match(/^`+/)?.[0].length??1;h.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:mb(b.slice(w,-w))},f))}else if(b.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ut(b.slice(2,-2),`${f}-del`,s,l)},f));else if(b.startsWith("**")||b.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ut(b.slice(2,-2),`${f}-strong`,s,l)},f));else if(b.startsWith("*")||b.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:ut(b.slice(1,-1),`${f}-em`,s,l)},f));else if(b.startsWith("![")){const w=b.match(/^!\[([^\]]*)\]\((.*)\)$/),M=b.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),I=b.match(/^!\[([^\]]+)\]$/);if(w){const _=ol(w[2]);h.push(_?Bs(f,w[1],_.href,_.title,l):b)}else if(M){const _=M[2]||M[1],B=l.referenceDefinitions.get(io(_));h.push(B?Bs(f,M[1],B.href,B.title,l):b)}else if(I){const _=l.referenceDefinitions.get(io(I[1]));h.push(_?Bs(f,I[1],_.href,_.title,l):b)}else h.push(b)}else if(b.startsWith("[^")){const w=nf(b.slice(2,-1)),M=l.footnoteDefinitions.get(w);h.push(M?e.jsx("sup",{id:`fnref-${M.id}`,title:M.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${M.id}`,className:"text-primary no-underline",children:M.index})},f):b)}else if(b.startsWith("<http")){const w=b.slice(1,-1);h.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(b.startsWith("<")&&b.endsWith(">")&&Zd(b.slice(1,-1))){const w=b.slice(1,-1);h.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(Zd(Li(b).linkText)){const{linkText:w,suffix:M}=Li(b);h.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&&h.push(M)}else if(b.startsWith("http")||b.startsWith("www.")){const{linkText:w,suffix:M}=Li(b),I=w.startsWith("www.")?`https://${w}`:w;h.push(e.jsx("a",{href:I,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&&h.push(M)}else{const w=b.match(/^\[([^\]]+)\]\((.*)\)$/),M=b.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),I=b.match(/^\[([^\]]+)\]$/),_=M?M[2]||M[1]:I?.[1]??null,B=_?l.referenceDefinitions.get(io(_)):null,E=w?ol(w[2]):null,$=E?.href??B?.href??null,L=$?Zu($):null,T=w?.[1]??M?.[1]??I?.[1]??"";h.push(L?e.jsx("a",{href:L,title:E?.title??B?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ut(T,`${f}-link`,s,l)},f):b)}g=d.lastIndex}return g<u.length&&h.push(eu(u.slice(g))),h.length>0?h:[r]}function pf(r){return/(?: {2,}|\\)$/.test(r)}function gf(r){return r.replace(/(?: {2,}|\\)$/,"")}function mo(r){return/^(?: {4}|\t)/.test(r)}function bf(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function xf(r,n,s){const l=[];return r.forEach((u,d)=>{const h=pf(u);l.push(...ut(gf(u),`${n}-${d}`,!0,s)),d<r.length-1&&l.push(h?e.jsx("br",{},`${n}-${d}-br`):" ")}),l}function il(r,n,s){const l=[],u=[];return r.forEach((d,h)=>{u.push(pf(d)),l.push(ut(gf(d),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:u}}function ll(r,n,s,l,u){const d=[];return r.forEach((h,g)=>{const m=s[g]??0,b=!!(u&&m>=u.start&&m<=u.end);d.push(e.jsx("span",{"data-md-ref-start":m,"data-md-ref-end":m,"data-selected":b?"true":void 0,children:h},`${l}-ref-${g}`)),g<r.length-1&&d.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),d}function Gs(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",u=!1,d=0,h=0;for(let g=0;g<n.length;g+=1){const m=n[g];if(u){l+=m,u=!1;continue}if(m==="\\"){u=!0;continue}if(m==="`"){const b=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const f=g-b+1;l+="`".repeat(f),d===0?d=f:d===f&&(d=0);continue}if(d===0&&m==="["?h+=1:d===0&&m==="]"&&h>0&&(h-=1),m==="|"&&d===0&&h===0){s.push(l.trim()),l="";continue}l+=m}return u&&(l+="\\"),s.push(l.trim()),s}function vf(r){return Gs(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function po(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function go(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function yf(r,n){return r>96||r>44&&n>.35}function ko(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Ks(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function bl(r,n,s,l,u,d=new Set){const h=[],g=[];let m=n;for(;m<r.length;){const b=r[m];if(u&&(ho(b)||d.has(m))){m+=1;continue}const f=Ks(b),j=ko(b);if(!f){if(j>s&&g.length>0){([...g].reverse().find(_=>_.indent<j)?.item??g[g.length-1].item).paragraphs.push(b.trim());for(const _ of g)_.item.lineEnd=m+1;m+=1;continue}break}if(j<s||j===s&&f.ordered!==l)break;const w={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:m+1,lineEnd:m+1};for(;g.length>0&&g[g.length-1].indent>=j;)g.pop();const M=g[g.length-1]?.item??null;M?M.children.push(w):h.push(w),g.push({indent:j,item:w});for(const I of g)I.item.lineEnd=m+1;m+=1}return{items:h,nextIndex:m}}function yb(r){const n=r.find(l=>Ks(l));if(!n)return[];const s=Ks(n);return s?bl(r,0,ko(n),s.ordered,!0,af(r)).items:[]}function xl(r,n,s,l=0){return r.map((u,d)=>{const h=u.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${d}`,taskItem:!!h,refStart:u.lineStart+l,refEnd:u.lineEnd+l,content:e.jsxs(e.Fragment,{children:[h?e.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ut(h?.[2]??u.content,`li-${n}-${d}`,!0,s),u.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:u.paragraphs.map((g,m)=>e.jsx("p",{children:ut(g,`li-${n}-${d}-p-${m}`,!0,s)},`paragraph-${m}`))})]}),groups:wb(u.children,`${n}-${d}`,s,l)}})}function wb(r,n,s,l=0){const u=[];for(const d of r){const h=u[u.length-1];h&&h.ordered===d.ordered?h.items.push(d):u.push({ordered:d.ordered,items:[d]})}return u.map((d,h)=>({ordered:d.ordered,start:d.ordered?d.items[0]?.start:void 0,items:xl(d.items,`${n}-g${h}`,s,l)}))}function vl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&kb(s.groups,n)]},s.key)})}function kb(r,n){return r.map((s,l)=>{const u=s.ordered?"ol":"ul";return e.jsx(u,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:vl(s.items,n)},`nested-${l}`)})}function Sb(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ut(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function jb(r,n,s,l){const u=[];let d=0;const h=g=>l?.[g]??g+1;for(;d<r.length;){const g=r[d],m=g.trim();if(!m){d+=1;continue}if(/^<details>\s*$/i.test(m)){const E=d;let $="Details";const L=[];for(d+=1;d<r.length&&!/^<\/details>\s*$/i.test(r[d].trim());){const T=r[d].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);T?$=T[1].trim()||$:L.push(r[d].trimStart()),d+=1}d<r.length&&(d+=1),u.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:ut($,`${n}-details-${E}-summary`,!0,s)}),L.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:xf(L,`${n}-details-${E}`,s)})]},`${n}-details-${E}`)});continue}const b=mf(g);if(b){const E=[g],$=d;for(d+=1;d<r.length&&!b.selfContained&&!new RegExp(`</${b.tag}>`,"i").test(r[d]);)E.push(r[d]),d+=1;d<r.length&&!b.selfContained&&(E.push(r[d]),d+=1),u.push({kind:"static",node:e.jsx(hf,{html:E.join(`
|
|
1639
1639
|
`)},`${n}-html-${$}`)});continue}const f=m.match(/^(```|~~~)\s*(.*)$/);if(f){const E=[],$=f[1],L=f[2]?.trim(),T=d;for(d+=1;d<r.length&&!r[d].trim().startsWith($);)E.push(r[d]),d+=1;d<r.length&&(d+=1),L.toLowerCase()==="mermaid"?u.push({kind:"static",node:e.jsx(kf,{code:E.join(`
|
|
1640
1640
|
`),blockKey:`${n}-code-${T}`},`${n}-code-${T}`)}):["math","latex","tex"].includes(L.toLowerCase())?u.push({kind:"static",node:e.jsx(Ws,{tex:E.join(`
|
|
1641
1641
|
`),display:!0},`${n}-code-${T}`)}):u.push({kind:"code",key:`${n}-code-${T}`,code:E.join(`
|
|
1642
1642
|
`),lang:L,blockKey:`${n}-code-${T}`,codeStartLine:h(T)+1});continue}if(mo(g)){const E=[],$=d;for(;d<r.length&&(mo(r[d])||!r[d].trim());)E.push(r[d].trim()?bf(r[d]):""),d+=1;u.push({kind:"code",key:`${n}-indented-code-${$}`,code:E.join(`
|
|
1643
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${$}`,codeStartLine:h($)});continue}const j=m.match(/^(#{1,6})\s+(.+)$/);if(j){const $=`h${Math.min(6,j[1].length+1)}`,L=rf(j[2]),T=sl(L,s);u.push({kind:"static",node:e.jsx($,{id:T,className:"scroll-mt-16 font-semibold text-foreground",children:ut(L,`${n}-heading-${d}`,!0,s)},`${n}-heading-${d}`)}),d+=1;continue}if(d+1<r.length&&g.includes("|")&&go(r[d+1])){const E=Gs(g),$=vf(r[d+1]),L=[],T=d;for(d+=2;d<r.length&&r[d].includes("|")&&r[d].trim();)L.push(Gs(r[d])),d+=1;u.push({kind:"static",node:e.jsx("div",{className:Ku,"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:E.map((U,D)=>e.jsx("th",{className:`${Wu} ${po($[D]??null)}`,children:e.jsx("div",{className:fo,children:ut(U,`${n}-th-${T}-${D}`,!0,s)})},`h-${D}`))})}),e.jsx("tbody",{children:L.map((U,D)=>e.jsx("tr",{className:"border-t border-border/10",children:E.map((p,i)=>e.jsx("td",{className:`${Gu} ${po($[i]??null)}`,children:e.jsx("div",{className:fo,children:ut(U[i]??"",`${n}-td-${T}-${D}-${i}`,!0,s)})},`c-${i}`))},`r-${D}`))})]})},`${n}-table-${T}`)});continue}const w=Ks(g);if(w){const E=w.ordered,$=ko(g),L=w.start,T=d,U=bl(r,d,$,E,!1);d=U.nextIndex,u.push({kind:"list",keyPrefix:`${n}-list-${T}`,ordered:E,start:E?L:void 0,renders:xl(U.items,`${n}-list-${T}`,s,h(0)-1)});continue}const M=[g.trimStart()],I=[h(d)],_=d;for(d+=1;d<r.length&&r[d].trim()&&!nl(r[d])&&!(d+1<r.length&&r[d].includes("|")&&go(r[d+1]));)M.push(r[d].trimStart()),I.push(h(d)),d+=1;const B=il(M,`${n}-p-${_}`,s);u.push({kind:"paragraph",keyPrefix:`${n}-p-${_}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:I})}return u}function Rb(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:ll(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:vl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(bo,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Za=null,ru=!1;const eo=16,wf=192;function Cb(){return Za||(Za=Hs(()=>import("./mermaid.core-
|
|
1643
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${$}`,codeStartLine:h($)});continue}const j=m.match(/^(#{1,6})\s+(.+)$/);if(j){const $=`h${Math.min(6,j[1].length+1)}`,L=rf(j[2]),T=sl(L,s);u.push({kind:"static",node:e.jsx($,{id:T,className:"scroll-mt-16 font-semibold text-foreground",children:ut(L,`${n}-heading-${d}`,!0,s)},`${n}-heading-${d}`)}),d+=1;continue}if(d+1<r.length&&g.includes("|")&&go(r[d+1])){const E=Gs(g),$=vf(r[d+1]),L=[],T=d;for(d+=2;d<r.length&&r[d].includes("|")&&r[d].trim();)L.push(Gs(r[d])),d+=1;u.push({kind:"static",node:e.jsx("div",{className:Ku,"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:E.map((U,D)=>e.jsx("th",{className:`${Wu} ${po($[D]??null)}`,children:e.jsx("div",{className:fo,children:ut(U,`${n}-th-${T}-${D}`,!0,s)})},`h-${D}`))})}),e.jsx("tbody",{children:L.map((U,D)=>e.jsx("tr",{className:"border-t border-border/10",children:E.map((p,i)=>e.jsx("td",{className:`${Gu} ${po($[i]??null)}`,children:e.jsx("div",{className:fo,children:ut(U[i]??"",`${n}-td-${T}-${D}-${i}`,!0,s)})},`c-${i}`))},`r-${D}`))})]})},`${n}-table-${T}`)});continue}const w=Ks(g);if(w){const E=w.ordered,$=ko(g),L=w.start,T=d,U=bl(r,d,$,E,!1);d=U.nextIndex,u.push({kind:"list",keyPrefix:`${n}-list-${T}`,ordered:E,start:E?L:void 0,renders:xl(U.items,`${n}-list-${T}`,s,h(0)-1)});continue}const M=[g.trimStart()],I=[h(d)],_=d;for(d+=1;d<r.length&&r[d].trim()&&!nl(r[d])&&!(d+1<r.length&&r[d].includes("|")&&go(r[d+1]));)M.push(r[d].trimStart()),I.push(h(d)),d+=1;const B=il(M,`${n}-p-${_}`,s);u.push({kind:"paragraph",keyPrefix:`${n}-p-${_}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:I})}return u}function Rb(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:ll(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:vl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(bo,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Za=null,ru=!1;const eo=16,wf=192;function Cb(){return Za||(Za=Hs(()=>import("./mermaid.core-GZ0ccUut.js").then(r=>r.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(r=>r.default??r).catch(r=>{throw Za=null,r})),Za}function Nb(r){ru||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),ru=!0)}function Mb(r){const n=r.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return r;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,u,d]=l;if(!Number.isFinite(u)||!Number.isFinite(d)||u<=0||d<=0)return r;const h=Math.max(wf,Math.ceil(u)),g=Math.ceil(h/u*d);return r.replace(/<svg\b([^>]*)>/i,(m,b)=>`<svg${b.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${g}">`)}function Eb(r){const n=r?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-eo,u=s.y-eo,d=s.width+eo*2,h=s.height+eo*2,g=Math.max(wf,Math.ceil(d)),m=Math.ceil(g/d*h);n.setAttribute("viewBox",`${l} ${u} ${d} ${h}`),n.setAttribute("width",String(g)),n.setAttribute("height",String(m)),n.removeAttribute("style")}function $b(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return ku(`code.${s}`)??s}function kf({code:r,blockKey:n}){const{t:s}=St(),[l,u]=a.useState(null),[d,h]=a.useState(!1),g=a.useRef(null),m=a.useContext(ef);a.useEffect(()=>{let f=!1;return u(null),h(!1),Cb().then(async j=>{Nb(j);const w=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:M}=await j.render(w,r);f||u(Mb(M))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[n,r]),a.useLayoutEffect(()=>{l&&Eb(g.current)},[l]);const b=a.useCallback(()=>{const f=g.current?.querySelector("svg")?.outerHTML??l;f&&m?.(f)},[m,l]);return d?e.jsx(bo,{code:r,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),b()},children:e.jsx("span",{ref:g,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:l}})}):e.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function bo({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:u}){const d=$b(n),[h,g]=a.useState(null);a.useEffect(()=>{if(!d||!Su(r)){g(null);return}let b=!1;return ju().then(f=>{if(b||!f.registered(d)){b||g(null);return}try{g(Ru(f,r,d))}catch{b||g(null)}}).catch(()=>{b||g(null)}),()=>{b=!0}},[s,r,d]);const m=h??(r||" ").split(`
|
|
1644
1644
|
`).map(b=>[b||" "]);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:`${hl} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:m.map((b,f)=>{const j=l!=null?l+f:null,w=!!(u&&j!=null&&j>=u.start&&j<=u.end);return e.jsxs("span",{"data-md-ref-start":j??void 0,"data-md-ref-end":j??void 0,"data-selected":w?"true":void 0,children:[b,f<m.length-1?`
|
|
1645
1645
|
`:null]},`${s}-line-${f}`)})})})]})}function yl(r,n,s,l,u){r=ob(r);const d=sb(r),h=af(r),g=[],m={markdownFilePath:n,rootPath:s,referenceDefinitions:d,footnoteDefinitions:ab(r),headingSlugCounts:new Map,images:g,onImageOpen:l,footnotesLabel:u?.footnotes??"Footnotes",backToFootnoteLabel:u?.backToFootnote??(w=>`Back to footnote ${w}`)},b=[];let f=0;for(;f<r.length;){const w=r[f],M=w.trim();if(ho(w)||h.has(f)){f+=1;continue}if(!M){f+=1;continue}if(/^<details>\s*$/i.test(M)){const D=f;let p="Details";const i=[];for(f+=1;f<r.length&&!/^<\/details>\s*$/i.test(r[f].trim());){const O=r[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);O?p=O[1].trim()||p:i.push(r[f].trimStart()),f+=1}f<r.length&&(f+=1),b.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:ut(p,`details-${D}-summary`,!0,m)}),i.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:xf(i,`details-${D}`,m)})]})});continue}const I=mf(w);if(I){const D=[w],p=f;for(f+=1;f<r.length&&!I.selfContained&&!new RegExp(`</${I.tag}>`,"i").test(r[f]);)D.push(r[f]),f+=1;f<r.length&&!I.selfContained&&(D.push(r[f]),f+=1),b.push({key:`html-${p}`,startLine:p+1,endLine:f,content:e.jsx(hf,{html:D.join(`
|
|
1646
1646
|
`)})});continue}const _=M.match(/^(```|~~~)\s*(.*)$/);if(_){const D=[],p=_[1],i=_[2]?.trim(),O=f;for(f+=1;f<r.length&&!r[f].trim().startsWith(p);)D.push(r[f]),f+=1;f<r.length&&(f+=1),b.push({key:`code-${O}`,startLine:O+1,endLine:f,fineGrained:i.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(i.toLowerCase()),content:i.toLowerCase()==="mermaid"?e.jsx(kf,{code:D.join(`
|
|
@@ -1648,31 +1648,31 @@ installPreviewRuntime(`+[u,d,[...f],Y].map(vg).join(",")+");";const pe=P.createE
|
|
|
1648
1648
|
`),display:!0}):C=>e.jsx(bo,{code:D.join(`
|
|
1649
1649
|
`),lang:i,blockKey:`code-${O}`,codeStartLine:O+2,lineRange:C})});continue}if(mo(w)){const D=[],p=f;for(f+=0;f<r.length&&(mo(r[f])||!r[f].trim());)D.push(r[f].trim()?bf(r[f]):""),f+=1;b.push({key:`indented-code-${p}`,startLine:p+1,endLine:f,fineGrained:!0,content:i=>e.jsx(bo,{code:D.join(`
|
|
1650
1650
|
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${p}`,codeStartLine:p+1,lineRange:i})});continue}if(M.startsWith("$$")){const D=[],p=f,i=M.replace(/^\$\$\s*/,"");if(i.endsWith("$$")&&i.length>2)D.push(i.replace(/\s*\$\$$/,"")),f+=1;else{for(i&&D.push(i),f+=1;f<r.length&&!r[f].trim().endsWith("$$");)D.push(r[f]),f+=1;if(f<r.length){const O=r[f].trim().replace(/\s*\$\$$/,"");O&&D.push(O),f+=1}}b.push({key:`math-${p}`,startLine:p+1,endLine:f,content:e.jsx(Ws,{tex:D.join(`
|
|
1651
|
-
`),display:!0})});continue}if(f+1<r.length&&M&&!nl(w)&&/^(=+|-+)\s*$/.test(r[f+1].trim())){const D=r[f+1].trim().startsWith("=")?1:2,p=`h${D}`,i=sl(M,m),O={level:D,text:Qd(M),id:i};b.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:O,content:e.jsx(p,{id:i,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:ut(M,`setext-heading-${f}`,!0,m)})}),f+=2;continue}const B=M.match(/^(#{1,6})\s+(.+)$/);if(B){const D=B[1].length,p=rf(B[2]),i={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"},O=`h${D}`,C=sl(p,m),K={level:D,text:Qd(p),id:C};b.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:K,content:e.jsx(O,{id:C,className:`scroll-mt-16 font-semibold text-foreground ${i[D]}`,children:ut(p,`heading-${f}`,!0,m)})}),f+=1;continue}if(Qu(w)){b.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(M.startsWith(">")){const D=[],p=[],i=f;for(;f<r.length&&/^>\s?/.test(r[f].trim());)D.push(r[f].trim().replace(/^>\s?/,"")),p.push(f+1),f+=1;const O=D[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const K=O[1].toUpperCase(),de=O[2]?.trim(),te=[...de?[de]:[],...D.slice(1)],xe=[...de?[p[0]]:[],...p.slice(1)],W=il(te,`callout-${i}`,m);b.push({key:`callout-${i}`,startLine:i+1,endLine:f,fineGrained:!0,content:Y=>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:K}),te.length>0&&e.jsx("div",{children:ll(W.perLine,W.hardBreaks,xe,`callout-${i}`,Y)})]})});continue}const C=jb(D,`quote-${i}`,m,p);b.push({key:`quote-${i}`,startLine:i+1,endLine:f,fineGrained:!0,content:K=>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:Rb(C,K)})});continue}if(f+1<r.length&&w.includes("|")&&go(r[f+1])){const D=Gs(w),p=vf(r[f+1]),i=[],O=f;for(f+=2;f<r.length&&r[f].includes("|")&&r[f].trim();)i.push(Gs(r[f])),f+=1;const C=D.map((de,te)=>ut(de,`th-${O}-${te}`,!0,m)),K=i.map((de,te)=>D.map((xe,W)=>ut(de[W]??"",`td-${O}-${te}-${W}`,!0,m)));b.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:de=>{const te=xe=>!!(de&&xe>=de.start&&xe<=de.end);return e.jsx("div",{className:Ku,"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":O+1,"data-md-ref-start":O+1,"data-md-ref-end":O+1,"data-selected":te(O+1)?"true":void 0,children:C.map((xe,W)=>e.jsx("th",{className:`${Wu} ${po(p[W]??null)}`,children:e.jsx("div",{className:fo,children:xe})},`h-${W}`))})}),e.jsx("tbody",{children:K.map((xe,W)=>{const Y=O+W+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":Y,"data-md-ref-start":Y,"data-md-ref-end":Y,"data-selected":te(Y)?"true":void 0,children:D.map((P,F)=>e.jsx("td",{className:`${Gu} ${po(p[F]??null)}`,children:e.jsx("div",{className:fo,children:xe[F]})},`c-${F}`))},`r-${W}`)})})]})})}});continue}const E=Ks(w);if(E){const D=E.ordered,p=ko(w),i=E.start,O=f,C=bl(r,f,p,D,!0,h);f=C.nextIndex;const K=D?"ol":"ul",de=xl(C.items,`list-${O}`,m);b.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:te=>e.jsx(K,{start:D?i: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:vl(de,te)})});continue}const $=[w.trimStart()],L=[f+1],T=f;for(f+=1;f<r.length&&r[f].trim()&&!nl(r[f])&&!(f+1<r.length&&r[f].includes("|")&&go(r[f+1]));){if(ho(r[f])||h.has(f)){f+=1;continue}$.push(r[f].trimStart()),L.push(f+1),f+=1}const U=il($,`p-${T}`,m);b.push({key:`p-${T}`,startLine:T+1,endLine:f,fineGrained:!0,content:D=>e.jsx("p",{className:"text-muted-foreground",children:ll(U.perLine,U.hardBreaks,L,`p-${T}`,D)})})}const j=Sb(m);return j&&b.push({key:"footnotes",startLine:r.length,endLine:r.length,content:j}),{blocks:b,images:g}}function Lb(r,n,s){return yl(r,n,s).blocks}function Sf(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function jf(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Pb({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const u=cf(r);return e.jsx(Ff,{src:u,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function Rf({images:r,index:n,onChange:s,onClose:l}){const{t:u}=St(),d=r[n],h=r.length>1,g=a.useRef(null),m=a.useRef(null),b=a.useRef(null),f=a.useRef(0),[j,w]=a.useState(!1),[M,I]=a.useState(0),[_,B]=a.useState(!1),E=a.useCallback(()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),$=a.useCallback(()=>{j||Date.now()<f.current||(E(),b.current=window.setTimeout(()=>{b.current=null,l()},450))},[E,j,l]),L=a.useCallback(p=>{if(r.length===0)return;const i=(p+r.length)%r.length;g.current?.slideTo(i),s(i)},[r.length,s]),T=a.useCallback(()=>L(n-1),[L,n]),U=a.useCallback(()=>L(n+1),[L,n]);if(a.useEffect(()=>{E(),I(0),B(!1),w(!1)},[E,n]),a.useEffect(()=>{const p=g.current;p&&(p.allowTouchMove=h&&!j)},[h,j]),a.useEffect(()=>{const p=g.current;!p||p.activeIndex===n||p.slideTo(n,0)},[n]),a.useEffect(()=>E,[E]),a.useEffect(()=>{const p=i=>{if(i.key==="Escape"){i.preventDefault(),l();return}h&&(i.key==="ArrowLeft"?(i.preventDefault(),T()):i.key==="ArrowRight"&&(i.preventDefault(),U()))};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[h,U,T,l]),gu({onDrag:({movement:[p,i],pinching:O})=>{O||j||Math.abs(i)<Math.abs(p)*1.15&&M===0||(B(!0),Math.abs(i)>8&&(f.current=Date.now()+300),I(Math.max(0,i)))},onDragEnd:({movement:[p,i],velocity:[,O],pinching:C,canceled:K})=>{if(B(!1),C||K||j||Math.abs(i)<Math.abs(p)*1.15){I(0);return}if(Math.abs(i)>8&&(f.current=Date.now()+300),yf(i,O)){l();return}I(0)}},{target:m,drag:{filterTaps:!0,pointer:{touch:!0}}}),!d)return null;const D=d.title||d.alt||(d.kind==="mermaid"?u("rightSidebar.mermaidDiagram"):u("rightSidebar.image"));return typeof document>"u"?null:Yr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:D}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:T,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":u("rightSidebar.previousImage"),title:u("common.previous"),children:e.jsx(Os,{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":u("rightSidebar.nextImage"),title:u("common.next"),children:e.jsx(im,{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":u("rightSidebar.closeImagePreview"),title:u("common.close"),children:e.jsx(Yt,{size:18})})]})]}),e.jsx("div",{ref:m,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:$,children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${M}px, 0) scale(${Math.max(.86,1-M/900)})`,opacity:Math.max(.35,1-M/360),transition:_?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(bu,{onSwiper:p=>{g.current=p,p.allowTouchMove=h&&!j},onSlideChange:p=>{p.activeIndex!==n&&s(p.activeIndex)},onSliderMove:()=>{E(),f.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((p,i)=>e.jsx(zi,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:p.kind==="image"?e.jsx(Pb,{src:p.src,alt:p.alt||p.title||u("rightSidebar.markdownImage"),onZoomChange:w,onDoubleTap:E}):e.jsx(qb,{svg:p.svg,title:p.title||p.alt||u("rightSidebar.mermaidDiagram"),onZoomChange:w,onDoubleTap:E})})},`${p.kind}-${i}-${p.alt}`))})})})]})]}),document.body)}function Cf({content:r,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:u,onLineRangeDrag:d,scrollTop:h,outlineOpen:g,outlineCloseSignal:m,onOutlineOpen:b,onOutlineClose:f,lightboxOpen:j,lightboxCloseSignal:w,onLightboxOpen:M,onLightboxClose:I,onLocalLinkOpen:_}){const{t:B}=St(),[E,$]=a.useState(null),[L,T]=a.useState(null),[U,D]=a.useState(1),[p,i]=a.useState(null),O=a.useRef(null),C=a.useRef(null),{blocks:K,images:de}=a.useMemo(()=>yl(r.split(`
|
|
1652
|
-
`),n,s,R=>{T(null),$(R),M?.()},{footnotes:B("rightSidebar.footnotes"),backToFootnote:R=>B("rightSidebar.backToFootnote",{index:R})}),[r,n,s,M,B]),te=a.useMemo(()=>L?[...de,L]:de,[de,L]),xe=a.useCallback(R=>{T({kind:"mermaid",svg:R,alt:"Mermaid diagram",title:"Mermaid diagram"}),$(de.length),M?.()},[de.length,M]);a.useEffect(()=>{$(null),T(null)},[r,n]),a.useEffect(()=>{$(null),T(null)},[w]),a.useEffect(()=>{j||($(null),T(null))},[j]),a.useEffect(()=>{D(1)},[r,n]),a.useLayoutEffect(()=>{const R=O.current;if(!R||K.length===0)return;const ee=Array.from(R.querySelectorAll("[data-markdown-preview-block-start]"));let le=1;const
|
|
1653
|
-
${r}`,F=a.useRef(P),V=a.useRef(null),re=a.useRef(null),ie=a.useRef(!1);a.useEffect(()=>{F.current!==P&&(F.current=P,f?.())},[f,P]),a.useEffect(()=>{m!==void 0&&i(null)},[m]),a.useLayoutEffect(()=>{if(!g){i(null);return}const R=()=>{const ee=C.current;if(!ee)return;const le=ee.getBoundingClientRect(),Me=window.innerWidth;i({top:le.bottom+6,right:Math.max(8,Me-le.right)})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[g,h,W]);const ye=a.useCallback(R=>{const ee=O.current,le=ee?.closest("[data-markdown-preview-scroller]"),Me=ee?.querySelector(`[data-markdown-preview-block-start="${R.startLine}"]`);if(!le||!Me)return;const Ce=le.getBoundingClientRect(),ze=Me.getBoundingClientRect(),Pe=ee?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,et=ze.top-Ce.top+le.scrollTop;le.scrollTo({top:Math.max(0,et-Pe-8),behavior:"smooth"}),D(R.startLine),f?.()},[f]),pe=a.useCallback(R=>{R.pointerType==="mouse"&&R.button!==0||_i(R.target)||(V.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY})},[]),Ie=a.useCallback((R,ee,le)=>{const Me=V.current;if(V.current=null,!Me||Me.pointerId!==R.pointerId)return;const Ce=Math.abs(R.clientX-Me.startX),ze=Math.abs(R.clientY-Me.startY);if(Ce>8||ze>8)return;const ce=R.target;if(_i(ce)||Gi())return;const Pe=cu(ce,ee,le);u(R,Pe.start,Pe.end)},[u]),N=a.useCallback(R=>{V.current?.pointerId===R.pointerId&&(V.current=null)},[]),q=a.useCallback((R,ee)=>{const le=O.current;if(!le||typeof document.elementFromPoint!="function")return null;const Me=document.elementFromPoint(R,ee);if(!(Me instanceof HTMLElement)||!le.contains(Me))return null;const Ce=Me.closest("[data-md-ref-start]");if(Ce){const ke=Number(Ce.dataset.mdRefStart);if(Number.isFinite(ke)&&ke>0)return ke}const ze=Me.closest("[data-markdown-preview-block-start]");if(!ze)return null;const ce=Number(ze.dataset.markdownPreviewBlockStart),Pe=K.find(ke=>ke.startLine===ce);if(!Pe)return Number.isFinite(ce)&&ce>0?ce:null;if(Pe.endLine<=Pe.startLine)return Pe.startLine;const et=ze.getBoundingClientRect(),Ae=et.height>0?Math.min(1,Math.max(0,(ee-et.top)/et.height)):0;return Math.round(Pe.startLine+Ae*(Pe.endLine-Pe.startLine))},[K]),he=a.useCallback(R=>{if(!d||R.pointerType==="mouse"&&R.button!==0)return;const ee=q(R.clientX+24,R.clientY);if(ee!=null){re.current={pointerId:R.pointerId,anchorLine:ee,moved:!1};try{R.currentTarget.setPointerCapture(R.pointerId)}catch{}}},[d,q]),$e=a.useCallback(R=>{const ee=re.current;if(!ee||ee.pointerId!==R.pointerId||!d)return;const le=q(R.clientX+16,R.clientY);le!=null&&(!ee.moved&&le===ee.anchorLine||(ee.moved=!0,ie.current=!0,d(R,Math.min(ee.anchorLine,le),Math.max(ee.anchorLine,le),"move")))},[d,q]),Qe=a.useCallback(R=>{const ee=re.current;if(re.current=null,!ee||ee.pointerId!==R.pointerId||!d||!ee.moved)return;const le=q(R.clientX+16,R.clientY)??ee.anchorLine;d(R,Math.min(ee.anchorLine,le),Math.max(ee.anchorLine,le),"end")},[d,q]),Le=a.useCallback(R=>{re.current?.pointerId===R.pointerId&&(re.current=null)},[]),at={onPointerDown:he,onPointerMove:$e,onPointerUp:Qe,onPointerCancel:Le},_e=()=>ie.current?(ie.current=!1,!0):!1;return K.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:B("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:O,className:"relative min-w-0 max-w-full",onClickCapture:R=>{const ee=R.target instanceof Element?R.target.closest("a[href]"):null;if(!ee||!_)return;const le=ee.getAttribute("href");if(!le)return;const Me=ml(le,n,s);Me&&(R.preventDefault(),_(Me))},children:[W.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:W.map(R=>R.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:W[W.length-1].text}),Y.length>1&&e.jsxs("button",{ref:C,type:"button",onClick:()=>{g?f?.():b?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${g?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":g,"aria-label":B("rightSidebar.markdownOutline"),title:B("rightSidebar.markdownOutline"),children:[e.jsx(xu,{size:12}),e.jsx("span",{children:B("rightSidebar.markdownOutlineShort")})]})]})}),g&&typeof document<"u"&&Yr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:f}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:p?{top:`${p.top}px`,right:`${p.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:Y.map(R=>{const ee=W[W.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>ye(R),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] ${ee?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ee?"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",R.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`desktop-${R.id}-${R.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:B("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":B("rightSidebar.closeMarkdownOutline"),title:B("common.close"),children:e.jsx(Yt,{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:Y.map(R=>{const ee=W[W.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>ye(R),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] ${ee?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ee?"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",R.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`${R.id}-${R.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(ef.Provider,{value:xe,children:K.map(R=>{const ee=!!(l&&R.startLine<=l.end&&R.endLine>=l.start),le=!!(l&&l.start<=R.startLine&&l.end>=R.endLine),Me=R.kind==="table"?!1:R.fineGrained?le:ee,Ce=R.kind==="table"&&l?.start===R.startLine&&l.end===R.endLine;let ze=null;if(R.kind!=="table"&&R.fineGrained&&ee&&!le&&l){const Ae=R.endLine-R.startLine+1,ke=Math.max(l.start,R.startLine),tt=Math.min(l.end,R.endLine),rt=(ke-R.startLine)/Ae,oe=(tt-ke+1)/Ae;ze=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) * ${rt})`,height:`calc((100% - 0.5rem) * ${oe})`}})}const ce=typeof R.content=="function"?R.content(l):R.content,Pe=R.startLine===R.endLine?String(R.startLine):`${R.startLine}-${R.endLine}`,et=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:Ii(Me),"aria-hidden":"true",...at,children:[e.jsx("span",{className:Di(Me)}),ze]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:ce})]});return R.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":R.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 ${Me?"bg-primary/10":""}`,title:`Line ${Pe}`,"aria-label":`Line ${Pe}`,children:[R.kind==="table"?e.jsx("button",{type:"button",className:Ii(Ce,"self"),onClick:Ae=>{Ae.preventDefault(),!_e()&&u(Ae,R.startLine,R.endLine)},title:`Reference table lines ${Pe}`,"aria-label":`Reference table lines ${Pe}`,...at,children:e.jsx("span",{className:Di(Ce,"self")})}):e.jsxs("span",{className:Ii(Me,"none"),"aria-hidden":"true",...at,children:[e.jsx("span",{className:Di(Me,"none")}),ze]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:pe,onPointerUp:Ae=>Ie(Ae,R.startLine,R.endLine),onPointerCancel:N,onKeyDown:Ae=>{Ae.key!=="Enter"&&Ae.key!==" "||(Ae.preventDefault(),u(Ae,R.startLine,R.endLine))},title:`Reference line ${Pe}`,"aria-label":`Reference line ${Pe}`,children:ce})]},R.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":R.startLine,onClick:Ae=>{const ke=Ae.target;if(_i(ke)||Gi()||_e())return;const tt=cu(ke,R.startLine,R.endLine);u(Ae,tt.start,tt.end)},onKeyDown:Ae=>{Ae.key!=="Enter"&&Ae.key!==" "||(Ae.preventDefault(),u(Ae,R.startLine,R.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 ${Me?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Pe}`,"aria-label":`Reference line ${Pe}`,children:et},R.key)})})})]}),j&&E!==null&&te[E]&&e.jsx(Rf,{images:te,index:E,onChange:$,onClose:()=>{$(null),T(null),I?.()}})]})}function Xn({label:r,value:n,options:s,placeholder:l,searchPlaceholder:u,emptyText:d,disabled:h,onChange:g}){const{t:m}=St(),[b,f]=a.useState(!1),[j,w]=a.useState(""),[M,I]=a.useState(null),_=a.useRef(null),B=a.useRef(null),E=j.trim().toLowerCase(),$=a.useMemo(()=>E?s.filter(p=>`${p.label} ${p.meta??""}`.toLowerCase().includes(E)):s,[E,s]),L=s.find(p=>p.value===n),T=()=>{const p=j.trim();p&&(g(p),f(!1),w(""))},U=a.useCallback(()=>{const p=_.current?.getBoundingClientRect();if(!p)return!1;const i=12,O=Math.max(220,Math.min(p.width,window.innerWidth-i*2)),C=Math.min(Math.max(i,p.left),window.innerWidth-O-i),K=window.innerHeight-p.bottom-i,de=p.top-i,te=K>=180||K>=de,xe=Math.max(96,(te?K:de)-4),W=Math.min(320,xe);return I({left:C,top:te?p.bottom+4:Math.max(i,p.top-W-4),width:O,maxHeight:W}),!0},[]),D=()=>{U(),f(!0)};return a.useEffect(()=>{if(!b)return;let p=0;const i=()=>{p||(p=window.requestAnimationFrame(()=>{p=0,U()}))},O=C=>{const K=C.target;K instanceof Node&&(_.current?.contains(K)||B.current?.contains(K)||(f(!1),w("")))};return window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),document.addEventListener("pointerdown",O,!0),()=>{p&&window.cancelAnimationFrame(p),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0),document.removeEventListener("pointerdown",O,!0)}},[b,U]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:_,type:"button",disabled:h,onClick:()=>{if(!h){if(w(""),b){f(!1);return}D()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:L?.label??(n||l)})]}),e.jsx(Us,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${b?"rotate-180":""}`})]}),b&&!h&&typeof document<"u"&&Yr.createPortal(e.jsxs("div",{ref:B,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:p=>p.stopPropagation(),style:{left:M?.left??12,top:M?.top??12,width:M?.width??260,maxHeight:M?.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(Jn,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:j,onChange:p=>w(p.target.value),onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),f(!1),w("");return}p.key==="Enter"&&(p.preventDefault(),T())},onBlur:()=>{j.trim()&&$.length===0&&T()},placeholder:u,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,(M?.maxHeight??320)-46)},children:[j.trim()&&!s.some(p=>p.value===j.trim())&&e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:T,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:j.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:m("common.use")})]}),$.length>0?$.map(p=>e.jsxs("button",{type:"button",onClick:()=>{g(p.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 ${p.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:p.label}),p.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:p.meta})]},p.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:d})]})]}),document.body)]})}function nu({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:u,selectedRoots:d,onToggleRepo:h,onGenerate:g,onSecondaryAction:m,disabled:b,generateDisabled:f,secondaryDisabled:j,inserted:w,buttonLabel:M,insertedLabel:I,title:_,ariaLabel:B,scopeTitle:E,scopeLabel:$,allLabel:L,generateLabel:T,secondaryLabel:U,secondaryTitle:D,secondaryLoading:p,loading:i,error:O,statusTitle:C,extraContent:K,renderRepoExtra:de}){return e.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{s?n(!r):f||g()},disabled:b,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 ${O?"text-destructive hover:bg-destructive/5":w?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":B,title:C??(s?`${E}: ${$}`:_),children:[i?e.jsx(Nt,{size:13,className:"animate-spin"}):e.jsx(zs,{size:13}),e.jsx("span",{children:w?I:M}),s&&e.jsx(Us,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`}),O&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&Yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:te=>te.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:E}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:$})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Yt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[K,e.jsxs("button",{type:"button",onClick:()=>h(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:L}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),u.map(te=>{const xe=d.includes(te.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${xe?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>h(te.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${xe?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:te.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:te.label}),te.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:te.branch})]}),xe&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),de&&(l||xe)&&e.jsx("div",{className:"px-2 pb-2",children:de(te)})]},te.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${m&&U?"sm:grid-cols-2":""}`,children:[m&&U&&e.jsxs("button",{type:"button",onClick:()=>{j||(n(!1),m())},disabled:j,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:[p?e.jsx(Nt,{size:12,className:"animate-spin"}):e.jsx(Nu,{size:12}),U]}),e.jsxs("button",{type:"button",onClick:()=>{f||(n(!1),g())},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(zs,{size:12}),T]})]})]})}),document.body)]})}function Ab(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Nf(){return mt(ul,Ab)??{}}function Tb(r,n){const s=Nf(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,u],[,d])=>d.updatedAt-u.updatedAt).slice(0,Eg);Ds(ul,Object.fromEntries(l),Lg)}function Ib(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function Db(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Ib(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function wl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Mf(){return mt(fl,Db)??{}}function su(r,n){const s=wl(r,n);return s?Mf()[s]??null:null}function Pi(r,n,s){const l=wl(r,n);if(!l)return;const u=Mf(),d=u[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...u,[l]:{...d,...s,updatedAt:Date.now()}}).sort(([,g],[,m])=>m.updatedAt-g.updatedAt).slice(0,$g);Ds(fl,Object.fromEntries(h),Pg)}function to({active:r,mounted:n=!0,fallback:s=null,children:l}){return e.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${r?"block":"hidden"}`,"aria-hidden":!r,children:n?typeof l=="function"?l():l:s})}function Ai({slow:r}){return e.jsx(Gm,{slow:r})}function ro({message:r,onRetry:n}){const{t:s}=St();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function lo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function kt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function Ti(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function Fb(r,n,s){return Ki(r,n,s)}function Ii(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function Di(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function Ef(r){const n=new Map;for(const s of r)n.set(kl(s),s);return n}function $f(r,n){const s=new Map(r);for(const l of n)s.set(kl(l),l);return s}function au(r,n){let s=0;for(const l of r){const u=gt(l,n);u&&n&&u!==n&&(s+=1)}return s}function _b(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Bb(r,n){return Array.from($f(Ef(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Ob(r,n){const s=r.relativeRoot==="."?kt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||kt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:_b(r.files)}}function Lf(r,n){const s=kt(n??"")||n||"";return r.map(l=>Ob(l,n)).sort((l,u)=>s&&l.label===s?-1:s&&u.label===s?1:l.label.localeCompare(u.label))}function Pf(r,n,s,l,u){const d=qu(s),h=d.find(_=>_.root===l)??d[0]??null,g=n.find(_=>_.root===l)??null,m=g?.relativeRoot??h?.relativeRoot??".",b=g?.name??h?.name??(kt(l)||l),f=(h?.files??s.files).map(_=>({..._,repoRoot:l,repoRelativeRoot:m,repoName:b})),j=h?.context??s.context,w={...g??h??{id:l,root:l,relativeRoot:m,name:b,depth:0,nested:!!(u&&l!==u),available:s.available,files:[],context:null},...h??{},id:g?.id??h?.id??l,root:l,displayRoot:g?.displayRoot??h?.displayRoot,relativeRoot:m,name:b,depth:g?.depth??h?.depth??0,nested:g?.nested??h?.nested??!!(u&&l!==u),available:h?.available??s.available,deferred:h?.deferred??!1,files:f,context:j?{...j,root:l,changedFiles:f.map(_=>({path:_.path,absolutePath:_.absolutePath,status:_.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},M=g?n.map(_=>_.root===l?w:_):[...n,w];return{files:Array.from(r).filter(_=>gt(_,u)!==l).concat(f),repositories:M,repoFilters:Lf(M,u)}}function gt(r,n){return r.repoRoot??n}function kl(r){return`${r.repoRoot??""}\0${r.path}`}function wt(r){return r.absolutePath||r.path}function Fi(r){return kl(r)}function Ub(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function ou(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function iu(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Ps(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function As(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function fr(r){return r instanceof DOMException&&r.name==="AbortError"}function Hb(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function lu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function _i(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function cu(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,u=Number(l?.dataset.mdRefStart),d=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(u)&&u>0&&Number.isFinite(d)&&d>0?{start:Math.min(u,d),end:Math.max(u,d)}:{start:n,end:s}}function zb({actions:r,running:n,completed:s}){const{t:l}=St(),[u,d]=a.useState(!1),h=a.useRef(null),g=r.find(b=>n?.action===b.key),m=r.find(b=>s?.action===b.key);return r.length===0?null:(a.useEffect(()=>{if(!u)return;const b=j=>{const w=j.target;w instanceof Node&&h.current?.contains(w)||d(!1)},f=j=>{j.key==="Escape"&&d(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",f)}},[u]),e.jsxs("div",{ref:h,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d(f=>!f)},disabled:r.every(b=>b.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${u?"bg-surface-elevated text-foreground":m?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:g?.label??m?.label??l("rightSidebar.gitQuickActions"),children:g?e.jsx(Nt,{size:13,className:"animate-spin"}):m?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(co,{size:14})}),u&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(b=>{const f=n?.action===b.key,j=s?.action===b.key;return e.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),b.onClick(),d(!1)},disabled:b.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 ${j?"bg-accent/10 text-accent":b.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(Nt,{size:13,className:"animate-spin"}):j?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.label})]},b.key)})})]}))}function Wb(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Af(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&Wb(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function Qn(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const Bi=new WeakMap;function xo(r){const n=Bi.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),Bi.delete(r)},1700);Bi.set(r,s)}function Gb(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let u=null;for(const g of l){if(!Qn(g))continue;const m=g.querySelector(s);if(m&&Qn(m)){u=m;break}}if(u??=Array.from(document.querySelectorAll(s)).find(Qn)??null,!u)return;const d=Af(u);if(!d){u.scrollIntoView({block:"start",behavior:"smooth"}),xo(u);return}const h=u.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop;d.scrollTo({top:Math.max(0,h),behavior:"instant"}),xo(u)}function Sn(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,u=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,d=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,h=[s!==null&&u?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`:null,s!==null&&u?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`: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&&d?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${d}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(I=>!!I),g=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let m=null;for(const I of g)if(Qn(I)){for(const _ of h){const B=I.querySelector(_);if(B&&Qn(B)){m=B;break}}if(m)break}if(m??=h.flatMap(I=>Array.from(document.querySelectorAll(I))).find(Qn)??null,!m){Gb(r.filePath);return}const b=Af(m);if(!b){m.scrollIntoView({block:"center",behavior:"smooth"}),xo(m);return}const f=m.getBoundingClientRect(),j=b.getBoundingClientRect(),M=f.top-j.top+b.scrollTop-Math.max(24,(b.clientHeight-f.height)/2);b.scrollTo({top:Math.max(0,M),behavior:"instant"}),xo(m)}const Tf=1,If=8;function Kb(r){return Math.min(If,Math.max(Tf,r))}function Df({resetKey:r,onZoomChange:n,onDoubleTap:s,children:l}){const u=a.useRef(null),[d,h]=a.useState({scale:1,x:0,y:0}),[g,m]=a.useState(!1),b=a.useRef(null),f=a.useRef(new Set),j=a.useRef(!1),w=a.useRef(null),M=a.useRef(0),I=a.useRef(d);I.current=d,a.useEffect(()=>{h({scale:1,x:0,y:0})},[r]);const _=a.useCallback((L,T,U)=>{const D=u.current;if(!D)return{x:T,y:U};const p=D.firstElementChild instanceof HTMLElement?D.firstElementChild:null,i=p?.clientWidth||D.clientWidth,O=p?.clientHeight||D.clientHeight,C=Math.max(0,(i*L-D.clientWidth)/2),K=Math.max(0,(O*L-D.clientHeight)/2);return{x:Math.min(C,Math.max(-C,T)),y:Math.min(K,Math.max(-K,U))}},[]),B=a.useCallback((L,T,U)=>{h(D=>{const p=Kb(L),i=u.current;if(!i||p===1)return{scale:p,x:0,y:0};const O=i.getBoundingClientRect(),C=(T??O.left+O.width/2)-O.left-O.width/2,K=(U??O.top+O.height/2)-O.top-O.height/2,de=p/D.scale,te=C-(C-D.x)*de,xe=K-(K-D.y)*de;return{scale:p,..._(p,te,xe)}})},[_]),E=a.useCallback((L,T)=>{m(!0),I.current.scale>1?h({scale:1,x:0,y:0}):B(2.5,L,T),window.setTimeout(()=>m(!1),220)},[B]);a.useEffect(()=>{const L=u.current;if(!L)return;const T=p=>{if(p.pointerType==="mouse"&&p.button!==0)return;const i=f.current.size===0;if(f.current.add(p.pointerId),i){const O=Date.now(),C=w.current;if(C&&O-C.time<350&&Math.hypot(p.clientX-C.x,p.clientY-C.y)<24){w.current=null,M.current=O,s?.(),E(p.clientX,p.clientY);return}}if(f.current.size>1){j.current=!0,b.current=null;return}if(!(I.current.scale<=1)){p.preventDefault(),b.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,originX:I.current.x,originY:I.current.y,moved:!1};try{L.setPointerCapture?.(p.pointerId)}catch{}m(!1)}},U=p=>{const i=b.current;if(!i||i.pointerId!==p.pointerId)return;const O=p.clientX-i.startX,C=p.clientY-i.startY;if(!i.moved){if(Math.hypot(O,C)<6)return;i.moved=!0}p.stopPropagation(),p.preventDefault(),h(K=>({...K,..._(K.scale,i.originX+O,i.originY+C)}))},D=p=>{const i=b.current,O=i?.pointerId===p.pointerId&&i.moved;if(i?.pointerId===p.pointerId){i.moved&&p.stopPropagation(),b.current=null;try{L.releasePointerCapture?.(p.pointerId)}catch{}}f.current.delete(p.pointerId)&&f.current.size===0&&(!j.current&&!O&&(w.current={time:Date.now(),x:p.clientX,y:p.clientY}),j.current=!1)};return L.addEventListener("pointerdown",T,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",D,{capture:!0}),window.addEventListener("pointercancel",D,{capture:!0}),()=>{L.removeEventListener("pointerdown",T,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",D,{capture:!0}),window.removeEventListener("pointercancel",D,{capture:!0})}},[_,s,E]),gu({onPinch:({offset:[L],origin:[T,U]})=>{m(!1),B(L,T,U)},onWheel:({event:L,delta:[T,U],ctrlKey:D})=>{if(D){L.preventDefault(),L.stopPropagation(),m(!1),B(I.current.scale*(1-U*.01),L.clientX,L.clientY);return}I.current.scale<=1||(L.preventDefault(),L.stopPropagation(),m(!1),h(p=>({...p,..._(p.scale,p.x-T,p.y-U)})))}},{target:u,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Tf,max:If},from:()=>[I.current.scale,0],rubberband:!0}});const $=d.scale>1;return a.useEffect(()=>{n?.($)},[n,$]),e.jsx("div",{ref:u,"data-sidebar-gesture-ignore":$?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:$?"grab":"zoom-in"},onDoubleClick:L=>{L.stopPropagation(),!(Date.now()-M.current<500)&&(s?.(),E(L.clientX,L.clientY))},children:l({scale:d.scale,zoomed:$,animateTransform:g,transformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0) scale(${d.scale})`,transformOrigin:"center center",transition:g?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0)`,transformOrigin:"center center",transition:g?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Ff({src:r,alt:n,vector:s,onLoad:l,onError:u,onZoomChange:d,onDoubleTap:h}){const g=vo(r,u),[m,b]=a.useState(null),f=s??wo(r);return a.useEffect(()=>{b(null)},[r]),e.jsx(Df,{resetKey:r,onZoomChange:d,onDoubleTap:h,children:({transformStyle:j,vectorTransformStyle:w,scale:M,animateTransform:I})=>{const _=e.jsx("img",{src:g,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:f&&m?{position:"absolute",left:"50%",top:"50%",width:m.width*M,height:m.height*M,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:I?"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"}:m?{...j,width:m.width,height:m.height}:f?w:j,onLoad:B=>{const E=B.currentTarget,$=E.parentElement;if($&&E.naturalWidth>0&&E.naturalHeight>0){const L=Math.max(1,$.clientWidth-2),T=Math.max(1,$.clientHeight-2),U=Math.min(L/E.naturalWidth,T/E.naturalHeight),D=f?U:Math.min(U,1);b({width:Math.max(1,Math.round(E.naturalWidth*D)),height:Math.max(1,Math.round(E.naturalHeight*D))})}l(B)},onError:u});return!f||!m?_:e.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...w,width:m.width,height:m.height},children:_})}})}function Vb({svg:r,title:n,scale:s,vectorTransformStyle:l}){const u=a.useRef(null);return a.useLayoutEffect(()=>{const d=u.current,h=d?.querySelector("svg");if(!d||!h)return;const g=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let j=f[2],w=f[3];if((!Number.isFinite(j)||!Number.isFinite(w)||j<=0||w<=0)&&(j=Number(h.getAttribute("width")),w=Number(h.getAttribute("height"))),!Number.isFinite(j)||!Number.isFinite(w)||j<=0||w<=0)return;const M=Math.max(1,d.clientWidth-24),I=Math.max(1,d.clientHeight-24),_=Math.min(M/j,I/w,1);h.style.width=`${Math.max(1,Math.floor(j*_*s))}px`,h.style.height=`${Math.max(1,Math.floor(w*_*s))}px`,h.style.maxWidth="none",h.style.maxHeight="none",h.style.transform=String(l.transform??""),h.style.transformOrigin="center center",h.style.transition=String(l.transition??"none")};g();const m=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return m?.observe(d),()=>m?.disconnect()},[s,r,l]),e.jsx("div",{ref:u,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function qb({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Df,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:u,scale:d})=>e.jsx(Vb,{svg:r,title:n,scale:d,vectorTransformStyle:u})})}let Yb=0,Xb=0,Jb=0,Qb=0,Zb=0;function Oi(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function dt(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++Xb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function no(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++Qb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ex(){return`diff-ui-${Date.now().toString(36)}-${(++Zb).toString(36)}`}function tx(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function rx(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function cl({onReviewReference:r,filePath:n,onInsertReference:s,onInsertText:l,onInsertFeature:u,onReferenceCopied:d,onClose:h,onDirectoryLinkOpen:g,isMobile:m,markdownOutlineOpen:b,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:j,onCloseMarkdownOutline:w,markdownImageLightboxOpen:M,markdownImageLightboxCloseSignal:I,onOpenMarkdownImageLightbox:_,onCloseMarkdownImageLightbox:B,lineRange:E,onLineRangeChange:$,insertedReferenceKey:L,copiedReferenceKey:T,scrollToLine:U,onScrollToLineHandled:D}){const{t:p}=St(),i=J(A=>A.rootPath),O=J(A=>A.selectFile),[C,K]=a.useState({kind:"idle"}),[de,te]=a.useState("schematic"),[xe,W]=a.useState(null),Y=a.useRef(null),[P,F]=a.useState(null),V=a.useRef(new Map),re=a.useRef(null),[ie,ye]=a.useState(null),[pe,Ie]=a.useState(()=>Kd()),[N,q]=a.useState(()=>Ad(i,n)),he=a.useRef(null),[$e,Qe]=a.useState(!1),[Le,at]=a.useState(null),[_e,R]=a.useState(0),[ee,le]=a.useState([]),[Me,Ce]=a.useState(null),ze=a.useRef(null),ce=a.useRef(n),[Pe,et]=a.useState(null),[Ae,ke]=a.useState({status:"idle"}),[tt,rt]=a.useState(!1),[oe,Te]=a.useState(""),[He,_t]=a.useState([]),[Bt,H]=a.useState(0),se=a.useRef(null),ve=Cu(d),Ge=wl(i,n);a.useEffect(()=>{if(ce.current===n)return;ce.current=n;const A=n&&i&&!n.startsWith("/")?`${i}/${n}`:n;if(ze.current===A){ze.current=null;return}ze.current=null,le([]),Ce(null),rt(!1),Te("")},[n,i]);const pt=n?i&&!n.startsWith("/")?`${i}/${n}`:n:null,hr=J(A=>pt?(A.fileChangeVersions.get(pt)??0)+A.fileWatchEpoch:A.fileWatchEpoch),mr=a.useRef(null),Ot=a.useRef(null),[pr,gr]=a.useState(0),jn=a.useCallback(()=>gr(A=>A+1),[]);a.useEffect(()=>{const A=Y.current;return Y.current=null,W(null),A&&URL.revokeObjectURL(A.objectUrl),()=>{const z=Y.current;Y.current=null,z&&URL.revokeObjectURL(z.objectUrl)}},[pt,hr,pr]),a.useEffect(()=>{if(!n){mr.current=null,K({kind:"idle"});return}const A=i&&!n.startsWith("/")?`${i}/${n}`:n,z=new AbortController,ue=++Yb,Se=`right-sidebar-file-preview:${ue}`,Ze=performance.now();let De=!1;const Ke=(Q,qe={})=>{De||(De=!0,Oi("end",{loadingId:ue,reason:Q,durationMs:Math.round(performance.now()-Ze),filePath:n,fullPath:A,rootPath:i,...qe}))};let Fe=null;const Ve=Yh(A),ft=Ve?A.toLowerCase().endsWith(".kicad_pcb")?de==="schematic"?"pcb-front":de:"schematic":de,Mn=!Ve&&dl(A),sr=!Ve&&!Mn&&Xh(A),as=!Ve&&!Mn&&!sr&&uu(A),en=Ls(A),tn=Ms(A),Or=Ve?"eda":Mn?"image":sr?"model3d":as?"video":"text",rn=mr.current!==A;if(mr.current=A,rn){Oi("start",{loadingId:ue,filePath:n,fullPath:A,rootPath:i,mode:Or,externalVersion:hr}),ke({status:"idle"}),K({kind:"loading",mode:Or}),Ot.current=null;const Q=su(i,n);$(Q?.lineRange??null),Ie(en?Kd():"source"),q(tn?Ad(i,n):"source"),Ve&&te(Jh(A))}rn||K(Q=>Q.kind==="error"?{kind:"loading",mode:Or}:Q);const nn=window.setTimeout(()=>{De||z.signal.aborted||Oi("still_active",{loadingId:ue,filePath:n,fullPath:A,rootPath:i,mode:Or,durationMs:Math.round(performance.now()-Ze),isPathChange:rn})},3e3),os=window.setTimeout(()=>{if(De||z.signal.aborted)return;const Q=Ve?p("rightSidebar.edaTimeout"):sr?p("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";z.abort(new DOMException(Q,"TimeoutError")),K({kind:"error",message:Q}),Ke("stuck_timeout",{error:Q})},Ve?Qh+5e3:sr?Zh+5e3:em(A)?35e3:Bg);if(Ve){const Q=ft==="pcb-3d"?Y.current:null;Q?(K(Q),Ke("eda_3d_client_cache_hit",{bytes:Q.meta.size,view:Q.view,mimeType:Q.meta.mimeType})):tm(A,ft,z.signal,"view_file",Se).then(qe=>{if(z.signal.aborted)return;Fe=URL.createObjectURL(qe.blob);const Tt={kind:"eda",sourcePath:qe.path||A,objectUrl:Fe,view:qe.view,meta:{size:qe.size,mimeType:qe.mimeType,modified:qe.modified}};if(qe.view==="pcb-3d"){const ar=Y.current;ar&&ar.objectUrl!==Fe&&URL.revokeObjectURL(ar.objectUrl),Y.current=Tt,W(Tt),Fe=null}K(Tt),Ke("eda_loaded",{bytes:qe.size,view:qe.view,mimeType:qe.mimeType})}).catch(qe=>{z.signal.aborted||(K({kind:"error",message:qe instanceof Error&&/timed out/i.test(qe.message)?p("rightSidebar.edaTimeout"):qe instanceof Error?qe.message:p("rightSidebar.edaLoadFailed")}),Ke("error",{error:qe instanceof Error?qe.message:String(qe)}))})}else if(Mn)rm(A,z.signal,"view_file",Se).then(Q=>{Fe=URL.createObjectURL(Q.blob),K({kind:"image",objectUrl:Fe,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),Ke("image_loaded",{bytes:Q.size,mimeType:Q.mimeType})}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error?Q.message:p("rightSidebar.imageLoadFailed")}),Ke("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(sr)nm(A,z.signal,"view_file",Se).then(Q=>{z.signal.aborted||(Fe=URL.createObjectURL(Q.blob),K({kind:"model3d",sourcePath:Q.path||A,objectUrl:Fe,ext:Q.ext,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),Ke("model3d_loaded",{bytes:Q.size,ext:Q.ext}))}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error&&(Q.name==="TimeoutError"||/timed out/i.test(Q.message))?p("rightSidebar.model3dTimeout"):Q instanceof Error?Q.message:p("rightSidebar.model3dLoadFailed")}),Ke("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(as){const Q=sm(A)??"",qe=fu(A);K(Tt=>Tt.kind==="video"&&Tt.url===qe?Tt:{kind:"video",url:qe,meta:{size:null,mimeType:Q,modified:null}}),Ke("video_ready",{mimeType:Q})}else cd(A,z.signal,"view_file",Se).then(Q=>{if(!z.signal.aborted){if(Q.binary){K({kind:"binary"});return}K({kind:"text",content:Q.content,sourcePath:Q.path||A,meta:{size:Q.size,truncated:Q.truncated}}),Ke("text_loaded",{bytes:Q.size,truncated:!!Q.truncated})}}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error?Q.message:"Failed to read file"}),Ke("error",{error:Q instanceof Error?Q.message:String(Q)}))});return()=>{z.abort(),Ct(Se),window.clearTimeout(nn),window.clearTimeout(os),Fe&&URL.revokeObjectURL(Fe),Ke("cleanup")}},[n,i,hr,pr,$,p,de]),a.useEffect(()=>{if(C.kind!=="model3d"||!n){F(null);return}let A=!1;const z=n.lastIndexOf("/"),ue=z>=0?n.slice(z+1):n,Se=z>=0?n.slice(0,z):"",Ze=Se.lastIndexOf("/"),De=Ze>=0?Se.slice(0,Ze):"",Ke=ue.replace(/\.(stl|glb|gltf)$/i,""),Fe=`${De?`${De}/`:""}features/${Ke}.json`;return cd(Fe).then(Ve=>{if(!A)try{const ft=JSON.parse(Ve.content);F(ft.version===1&&Array.isArray(ft.features)&&ft.features.length>0?ft.features:null)}catch{F(null)}}).catch(()=>{A||F(null)}),()=>{A=!0}},[C,n]),a.useEffect(()=>{if(C.kind!=="text"){et(null);return}const A=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=ku(A),ue=C.content,Se=Ls(A??"")&&pe==="preview",Ze=Ms(A??"")&&N==="preview";if(!z||Se||Ze||!Su(ue)){et(null);return}let De=!1;const Ke=Fe=>{if(De||!Fe.registered(z)){De||et(null);return}try{et(Ru(Fe,ue,z))}catch{et(null)}};return Le?Ke(Le):(et(null),ju().then(Fe=>{De||(at(Fe),Ke(Fe))}).catch(()=>{})),()=>{De=!0}},[C,Le,n,i,pe,N]),a.useLayoutEffect(()=>{if(!Ge||C.kind!=="text")return;const A=`${Ge}:${pe}:${N}`;if(Ot.current===A)return;const z=su(i,n);if(Ot.current=A,!z)return;const ue=requestAnimationFrame(()=>{const Se=re.current;if(!Se)return;const Ze=pe==="preview"?z.markdownTop??z.top:z.top;Se.scrollTo({top:Math.max(0,Ze??0),left:Math.max(0,z.left??0)}),R(pe==="preview"?Math.max(0,Ze??0):0)});return()=>cancelAnimationFrame(ue)},[n,pe,N,C.kind,Ge,i]),a.useEffect(()=>{Ge&&Pi(i,n,{lineRange:E})},[n,E,Ge,i]),a.useEffect(()=>{if(U==null||C.kind!=="text")return;ye(null),$({start:U,end:U});const A=U,z=requestAnimationFrame(()=>{const ue=V.current.get(A);ue&&ue.scrollIntoView({block:"center"}),D?.()});return()=>cancelAnimationFrame(z)},[U,C,$,D]);const Rn=a.useCallback(A=>{const z=re.current;if(!z)return!1;const ue=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(A):A.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=z.querySelector(`#${ue}`);return Se?(Se.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const A=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=C.kind==="text"&&Ls(A??"")&&pe==="preview";if(!Me||!z)return;const ue=requestAnimationFrame(()=>{Rn(Me)&&Ce(null)});return()=>cancelAnimationFrame(ue)},[n,Rn,pe,Me,C,i]),a.useLayoutEffect(()=>{const A=re.current;if(!A||!E){ye(null);return}if(ie)return;const z=C.kind==="image"||C.kind==="loading"&&C.mode==="image",ue=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,Se=C.kind==="text"&&Ls(ue??"")&&pe==="preview",Ze=C.kind==="text"&&Ms(ue??"")&&N==="preview";if(C.kind!=="text"||z||Se||Ze){ye(null);return}const De=()=>{const Fe=V.current.get(E.end);if(!Fe||!A){ye(null);return}const Ve=Fe.offsetTop+Fe.offsetHeight/2,ft=A.scrollLeft+Math.max(8,A.clientWidth-120);ye({top:Ve,left:ft})};De();const Ke=new ResizeObserver(()=>De());return Ke.observe(A),()=>Ke.disconnect()},[E,ie,C,pe,N,n,i,Pe]);const Tr=C.kind==="text"&&!(Ms(pt??"")&&N==="preview")&&!pt?.toLowerCase().endsWith(".csv")&&!pt?.toLowerCase().endsWith(".kicad_pro")&&!pt?.toLowerCase().endsWith(".kicad_prl"),br=a.useCallback(()=>{rt(!1),Te(""),_t([]),H(0),Xa()},[]),Cn=a.useCallback(()=>{Tr&&(rt(!0),requestAnimationFrame(()=>{se.current?.focus(),se.current?.select()}))},[Tr]),bt=a.useCallback(A=>{H(z=>He.length===0?0:(z+A+He.length)%He.length)},[He.length]);if(a.useEffect(()=>{const A=z=>{const ue=wg(z);if(ue==="open"&&Tr){z.preventDefault(),Cn();return}tt&&(ue==="close"?(z.preventDefault(),br()):(ue==="next"||ue==="previous")&&(z.preventDefault(),bt(ue==="previous"?-1:1)))};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[br,tt,bt,Cn,Tr]),a.useLayoutEffect(()=>{if(Xa(),!tt||!oe.trim()||!re.current){_t([]),H(0);return}const A=Sg(re.current,oe);return _t(A),H(0),Fd(A,0),_d(A[0]),Xa},[tt,oe,Pe,pe,C]),a.useEffect(()=>{tt&&(Fd(He,Bt),_d(He[Bt]))},[Bt,He,tt]),a.useEffect(()=>Xa,[]),!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:p("rightSidebar.selectFilePrompt")});const We=i&&!n.startsWith("/")?`${i}/${n}`:n,Pt=lo(We,i),xr=mu(We,i),vr=C.kind==="text"&&C.content?C.content.split(`
|
|
1654
|
-
`):[],Vs=Math.max(2,String(vr.length).length)+1,yr=C.kind==="text"||C.kind==="image"||C.kind==="model3d"||C.kind==="video"||C.kind==="eda"?C.meta:null,wr=Ls(
|
|
1651
|
+
`),display:!0})});continue}if(f+1<r.length&&M&&!nl(w)&&/^(=+|-+)\s*$/.test(r[f+1].trim())){const D=r[f+1].trim().startsWith("=")?1:2,p=`h${D}`,i=sl(M,m),O={level:D,text:Qd(M),id:i};b.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:O,content:e.jsx(p,{id:i,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:ut(M,`setext-heading-${f}`,!0,m)})}),f+=2;continue}const B=M.match(/^(#{1,6})\s+(.+)$/);if(B){const D=B[1].length,p=rf(B[2]),i={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"},O=`h${D}`,C=sl(p,m),K={level:D,text:Qd(p),id:C};b.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:K,content:e.jsx(O,{id:C,className:`scroll-mt-16 font-semibold text-foreground ${i[D]}`,children:ut(p,`heading-${f}`,!0,m)})}),f+=1;continue}if(Qu(w)){b.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(M.startsWith(">")){const D=[],p=[],i=f;for(;f<r.length&&/^>\s?/.test(r[f].trim());)D.push(r[f].trim().replace(/^>\s?/,"")),p.push(f+1),f+=1;const O=D[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const K=O[1].toUpperCase(),de=O[2]?.trim(),te=[...de?[de]:[],...D.slice(1)],xe=[...de?[p[0]]:[],...p.slice(1)],W=il(te,`callout-${i}`,m);b.push({key:`callout-${i}`,startLine:i+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:K}),te.length>0&&e.jsx("div",{children:ll(W.perLine,W.hardBreaks,xe,`callout-${i}`,X)})]})});continue}const C=jb(D,`quote-${i}`,m,p);b.push({key:`quote-${i}`,startLine:i+1,endLine:f,fineGrained:!0,content:K=>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:Rb(C,K)})});continue}if(f+1<r.length&&w.includes("|")&&go(r[f+1])){const D=Gs(w),p=vf(r[f+1]),i=[],O=f;for(f+=2;f<r.length&&r[f].includes("|")&&r[f].trim();)i.push(Gs(r[f])),f+=1;const C=D.map((de,te)=>ut(de,`th-${O}-${te}`,!0,m)),K=i.map((de,te)=>D.map((xe,W)=>ut(de[W]??"",`td-${O}-${te}-${W}`,!0,m)));b.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:de=>{const te=xe=>!!(de&&xe>=de.start&&xe<=de.end);return e.jsx("div",{className:Ku,"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":O+1,"data-md-ref-start":O+1,"data-md-ref-end":O+1,"data-selected":te(O+1)?"true":void 0,children:C.map((xe,W)=>e.jsx("th",{className:`${Wu} ${po(p[W]??null)}`,children:e.jsx("div",{className:fo,children:xe})},`h-${W}`))})}),e.jsx("tbody",{children:K.map((xe,W)=>{const X=O+W+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":te(X)?"true":void 0,children:D.map((P,F)=>e.jsx("td",{className:`${Gu} ${po(p[F]??null)}`,children:e.jsx("div",{className:fo,children:xe[F]})},`c-${F}`))},`r-${W}`)})})]})})}});continue}const E=Ks(w);if(E){const D=E.ordered,p=ko(w),i=E.start,O=f,C=bl(r,f,p,D,!0,h);f=C.nextIndex;const K=D?"ol":"ul",de=xl(C.items,`list-${O}`,m);b.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:te=>e.jsx(K,{start:D?i: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:vl(de,te)})});continue}const $=[w.trimStart()],L=[f+1],T=f;for(f+=1;f<r.length&&r[f].trim()&&!nl(r[f])&&!(f+1<r.length&&r[f].includes("|")&&go(r[f+1]));){if(ho(r[f])||h.has(f)){f+=1;continue}$.push(r[f].trimStart()),L.push(f+1),f+=1}const U=il($,`p-${T}`,m);b.push({key:`p-${T}`,startLine:T+1,endLine:f,fineGrained:!0,content:D=>e.jsx("p",{className:"text-muted-foreground",children:ll(U.perLine,U.hardBreaks,L,`p-${T}`,D)})})}const j=Sb(m);return j&&b.push({key:"footnotes",startLine:r.length,endLine:r.length,content:j}),{blocks:b,images:g}}function Lb(r,n,s){return yl(r,n,s).blocks}function Sf(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function jf(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Pb({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const u=cf(r);return e.jsx(Ff,{src:u,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function Rf({images:r,index:n,onChange:s,onClose:l}){const{t:u}=St(),d=r[n],h=r.length>1,g=a.useRef(null),m=a.useRef(null),b=a.useRef(null),f=a.useRef(0),[j,w]=a.useState(!1),[M,I]=a.useState(0),[_,B]=a.useState(!1),E=a.useCallback(()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),$=a.useCallback(()=>{j||Date.now()<f.current||(E(),b.current=window.setTimeout(()=>{b.current=null,l()},450))},[E,j,l]),L=a.useCallback(p=>{if(r.length===0)return;const i=(p+r.length)%r.length;g.current?.slideTo(i),s(i)},[r.length,s]),T=a.useCallback(()=>L(n-1),[L,n]),U=a.useCallback(()=>L(n+1),[L,n]);if(a.useEffect(()=>{E(),I(0),B(!1),w(!1)},[E,n]),a.useEffect(()=>{const p=g.current;p&&(p.allowTouchMove=h&&!j)},[h,j]),a.useEffect(()=>{const p=g.current;!p||p.activeIndex===n||p.slideTo(n,0)},[n]),a.useEffect(()=>E,[E]),a.useEffect(()=>{const p=i=>{if(i.key==="Escape"){i.preventDefault(),l();return}h&&(i.key==="ArrowLeft"?(i.preventDefault(),T()):i.key==="ArrowRight"&&(i.preventDefault(),U()))};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[h,U,T,l]),gu({onDrag:({movement:[p,i],pinching:O})=>{O||j||Math.abs(i)<Math.abs(p)*1.15&&M===0||(B(!0),Math.abs(i)>8&&(f.current=Date.now()+300),I(Math.max(0,i)))},onDragEnd:({movement:[p,i],velocity:[,O],pinching:C,canceled:K})=>{if(B(!1),C||K||j||Math.abs(i)<Math.abs(p)*1.15){I(0);return}if(Math.abs(i)>8&&(f.current=Date.now()+300),yf(i,O)){l();return}I(0)}},{target:m,drag:{filterTaps:!0,pointer:{touch:!0}}}),!d)return null;const D=d.title||d.alt||(d.kind==="mermaid"?u("rightSidebar.mermaidDiagram"):u("rightSidebar.image"));return typeof document>"u"?null:qr.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," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:T,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":u("rightSidebar.previousImage"),title:u("common.previous"),children:e.jsx(Os,{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":u("rightSidebar.nextImage"),title:u("common.next"),children:e.jsx(im,{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":u("rightSidebar.closeImagePreview"),title:u("common.close"),children:e.jsx(Yt,{size:18})})]})]}),e.jsx("div",{ref:m,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:$,children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${M}px, 0) scale(${Math.max(.86,1-M/900)})`,opacity:Math.max(.35,1-M/360),transition:_?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(bu,{onSwiper:p=>{g.current=p,p.allowTouchMove=h&&!j},onSlideChange:p=>{p.activeIndex!==n&&s(p.activeIndex)},onSliderMove:()=>{E(),f.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((p,i)=>e.jsx(zi,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:p.kind==="image"?e.jsx(Pb,{src:p.src,alt:p.alt||p.title||u("rightSidebar.markdownImage"),onZoomChange:w,onDoubleTap:E}):e.jsx(qb,{svg:p.svg,title:p.title||p.alt||u("rightSidebar.mermaidDiagram"),onZoomChange:w,onDoubleTap:E})})},`${p.kind}-${i}-${p.alt}`))})})})]})]}),document.body)}function Cf({content:r,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:u,onLineRangeDrag:d,scrollTop:h,outlineOpen:g,outlineCloseSignal:m,onOutlineOpen:b,onOutlineClose:f,lightboxOpen:j,lightboxCloseSignal:w,onLightboxOpen:M,onLightboxClose:I,onLocalLinkOpen:_}){const{t:B}=St(),[E,$]=a.useState(null),[L,T]=a.useState(null),[U,D]=a.useState(1),[p,i]=a.useState(null),O=a.useRef(null),C=a.useRef(null),{blocks:K,images:de}=a.useMemo(()=>yl(r.split(`
|
|
1652
|
+
`),n,s,R=>{T(null),$(R),M?.()},{footnotes:B("rightSidebar.footnotes"),backToFootnote:R=>B("rightSidebar.backToFootnote",{index:R})}),[r,n,s,M,B]),te=a.useMemo(()=>L?[...de,L]:de,[de,L]),xe=a.useCallback(R=>{T({kind:"mermaid",svg:R,alt:"Mermaid diagram",title:"Mermaid diagram"}),$(de.length),M?.()},[de.length,M]);a.useEffect(()=>{$(null),T(null)},[r,n]),a.useEffect(()=>{$(null),T(null)},[w]),a.useEffect(()=>{j||($(null),T(null))},[j]),a.useEffect(()=>{D(1)},[r,n]),a.useLayoutEffect(()=>{const R=O.current;if(!R||K.length===0)return;const ee=Array.from(R.querySelectorAll("[data-markdown-preview-block-start]"));let le=1;const Ee=28;for(const Ne of ee)if(Ne.offsetTop-h<=Ee)le=Number(Ne.dataset.markdownPreviewBlockStart)||le;else break;D(Ne=>Ne===le?Ne:le)},[K,h]);const W=a.useMemo(()=>Sf(K,U),[U,K]),X=a.useMemo(()=>jf(K),[K]),P=`${n??""}
|
|
1653
|
+
${r}`,F=a.useRef(P),V=a.useRef(null),re=a.useRef(null),ie=a.useRef(!1);a.useEffect(()=>{F.current!==P&&(F.current=P,f?.())},[f,P]),a.useEffect(()=>{m!==void 0&&i(null)},[m]),a.useLayoutEffect(()=>{if(!g){i(null);return}const R=()=>{const ee=C.current;if(!ee)return;const le=ee.getBoundingClientRect(),Ee=window.innerWidth;i({top:le.bottom+6,right:Math.max(8,Ee-le.right)})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[g,h,W]);const ye=a.useCallback(R=>{const ee=O.current,le=ee?.closest("[data-markdown-preview-scroller]"),Ee=ee?.querySelector(`[data-markdown-preview-block-start="${R.startLine}"]`);if(!le||!Ee)return;const Ne=le.getBoundingClientRect(),We=Ee.getBoundingClientRect(),Ae=ee?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,tt=We.top-Ne.top+le.scrollTop;le.scrollTo({top:Math.max(0,tt-Ae-8),behavior:"smooth"}),D(R.startLine),f?.()},[f]),pe=a.useCallback(R=>{R.pointerType==="mouse"&&R.button!==0||_i(R.target)||(V.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY})},[]),De=a.useCallback((R,ee,le)=>{const Ee=V.current;if(V.current=null,!Ee||Ee.pointerId!==R.pointerId)return;const Ne=Math.abs(R.clientX-Ee.startX),We=Math.abs(R.clientY-Ee.startY);if(Ne>8||We>8)return;const ce=R.target;if(_i(ce)||Gi())return;const Ae=cu(ce,ee,le);u(R,Ae.start,Ae.end)},[u]),N=a.useCallback(R=>{V.current?.pointerId===R.pointerId&&(V.current=null)},[]),q=a.useCallback((R,ee)=>{const le=O.current;if(!le||typeof document.elementFromPoint!="function")return null;const Ee=document.elementFromPoint(R,ee);if(!(Ee instanceof HTMLElement)||!le.contains(Ee))return null;const Ne=Ee.closest("[data-md-ref-start]");if(Ne){const ke=Number(Ne.dataset.mdRefStart);if(Number.isFinite(ke)&&ke>0)return ke}const We=Ee.closest("[data-markdown-preview-block-start]");if(!We)return null;const ce=Number(We.dataset.markdownPreviewBlockStart),Ae=K.find(ke=>ke.startLine===ce);if(!Ae)return Number.isFinite(ce)&&ce>0?ce:null;if(Ae.endLine<=Ae.startLine)return Ae.startLine;const tt=We.getBoundingClientRect(),Te=tt.height>0?Math.min(1,Math.max(0,(ee-tt.top)/tt.height)):0;return Math.round(Ae.startLine+Te*(Ae.endLine-Ae.startLine))},[K]),he=a.useCallback(R=>{if(!d||R.pointerType==="mouse"&&R.button!==0)return;const ee=q(R.clientX+24,R.clientY);if(ee!=null){re.current={pointerId:R.pointerId,anchorLine:ee,moved:!1};try{R.currentTarget.setPointerCapture(R.pointerId)}catch{}}},[d,q]),Le=a.useCallback(R=>{const ee=re.current;if(!ee||ee.pointerId!==R.pointerId||!d)return;const le=q(R.clientX+16,R.clientY);le!=null&&(!ee.moved&&le===ee.anchorLine||(ee.moved=!0,ie.current=!0,d(R,Math.min(ee.anchorLine,le),Math.max(ee.anchorLine,le),"move")))},[d,q]),Ze=a.useCallback(R=>{const ee=re.current;if(re.current=null,!ee||ee.pointerId!==R.pointerId||!d||!ee.moved)return;const le=q(R.clientX+16,R.clientY)??ee.anchorLine;d(R,Math.min(ee.anchorLine,le),Math.max(ee.anchorLine,le),"end")},[d,q]),Pe=a.useCallback(R=>{re.current?.pointerId===R.pointerId&&(re.current=null)},[]),at={onPointerDown:he,onPointerMove:Le,onPointerUp:Ze,onPointerCancel:Pe},Be=()=>ie.current?(ie.current=!1,!0):!1;return K.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:B("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:O,className:"relative min-w-0 max-w-full",onClickCapture:R=>{const ee=R.target instanceof Element?R.target.closest("a[href]"):null;if(!ee||!_)return;const le=ee.getAttribute("href");if(!le)return;const Ee=ml(le,n,s);Ee&&(R.preventDefault(),_(Ee))},children:[W.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:W.map(R=>R.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:W[W.length-1].text}),X.length>1&&e.jsxs("button",{ref:C,type:"button",onClick:()=>{g?f?.():b?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${g?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":g,"aria-label":B("rightSidebar.markdownOutline"),title:B("rightSidebar.markdownOutline"),children:[e.jsx(xu,{size:12}),e.jsx("span",{children:B("rightSidebar.markdownOutlineShort")})]})]})}),g&&typeof document<"u"&&qr.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:p?{top:`${p.top}px`,right:`${p.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(R=>{const ee=W[W.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>ye(R),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] ${ee?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ee?"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",R.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`desktop-${R.id}-${R.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:B("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":B("rightSidebar.closeMarkdownOutline"),title:B("common.close"),children:e.jsx(Yt,{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(R=>{const ee=W[W.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>ye(R),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] ${ee?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ee?"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",R.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`${R.id}-${R.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(ef.Provider,{value:xe,children:K.map(R=>{const ee=!!(l&&R.startLine<=l.end&&R.endLine>=l.start),le=!!(l&&l.start<=R.startLine&&l.end>=R.endLine),Ee=R.kind==="table"?!1:R.fineGrained?le:ee,Ne=R.kind==="table"&&l?.start===R.startLine&&l.end===R.endLine;let We=null;if(R.kind!=="table"&&R.fineGrained&&ee&&!le&&l){const Te=R.endLine-R.startLine+1,ke=Math.max(l.start,R.startLine),rt=Math.min(l.end,R.endLine),nt=(ke-R.startLine)/Te,oe=(rt-ke+1)/Te;We=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) * ${nt})`,height:`calc((100% - 0.5rem) * ${oe})`}})}const ce=typeof R.content=="function"?R.content(l):R.content,Ae=R.startLine===R.endLine?String(R.startLine):`${R.startLine}-${R.endLine}`,tt=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:Ii(Ee),"aria-hidden":"true",...at,children:[e.jsx("span",{className:Di(Ee)}),We]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:ce})]});return R.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":R.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 ${Ee?"bg-primary/10":""}`,title:`Line ${Ae}`,"aria-label":`Line ${Ae}`,children:[R.kind==="table"?e.jsx("button",{type:"button",className:Ii(Ne,"self"),onClick:Te=>{Te.preventDefault(),!Be()&&u(Te,R.startLine,R.endLine)},title:`Reference table lines ${Ae}`,"aria-label":`Reference table lines ${Ae}`,...at,children:e.jsx("span",{className:Di(Ne,"self")})}):e.jsxs("span",{className:Ii(Ee,"none"),"aria-hidden":"true",...at,children:[e.jsx("span",{className:Di(Ee,"none")}),We]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:pe,onPointerUp:Te=>De(Te,R.startLine,R.endLine),onPointerCancel:N,onKeyDown:Te=>{Te.key!=="Enter"&&Te.key!==" "||(Te.preventDefault(),u(Te,R.startLine,R.endLine))},title:`Reference line ${Ae}`,"aria-label":`Reference line ${Ae}`,children:ce})]},R.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":R.startLine,onClick:Te=>{const ke=Te.target;if(_i(ke)||Gi()||Be())return;const rt=cu(ke,R.startLine,R.endLine);u(Te,rt.start,rt.end)},onKeyDown:Te=>{Te.key!=="Enter"&&Te.key!==" "||(Te.preventDefault(),u(Te,R.startLine,R.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 ${Ee?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Ae}`,"aria-label":`Reference line ${Ae}`,children:tt},R.key)})})})]}),j&&E!==null&&te[E]&&e.jsx(Rf,{images:te,index:E,onChange:$,onClose:()=>{$(null),T(null),I?.()}})]})}function Xn({label:r,value:n,options:s,placeholder:l,searchPlaceholder:u,emptyText:d,disabled:h,onChange:g}){const{t:m}=St(),[b,f]=a.useState(!1),[j,w]=a.useState(""),[M,I]=a.useState(null),_=a.useRef(null),B=a.useRef(null),E=j.trim().toLowerCase(),$=a.useMemo(()=>E?s.filter(p=>`${p.label} ${p.meta??""}`.toLowerCase().includes(E)):s,[E,s]),L=s.find(p=>p.value===n),T=()=>{const p=j.trim();p&&(g(p),f(!1),w(""))},U=a.useCallback(()=>{const p=_.current?.getBoundingClientRect();if(!p)return!1;const i=12,O=Math.max(220,Math.min(p.width,window.innerWidth-i*2)),C=Math.min(Math.max(i,p.left),window.innerWidth-O-i),K=window.innerHeight-p.bottom-i,de=p.top-i,te=K>=180||K>=de,xe=Math.max(96,(te?K:de)-4),W=Math.min(320,xe);return I({left:C,top:te?p.bottom+4:Math.max(i,p.top-W-4),width:O,maxHeight:W}),!0},[]),D=()=>{U(),f(!0)};return a.useEffect(()=>{if(!b)return;let p=0;const i=()=>{p||(p=window.requestAnimationFrame(()=>{p=0,U()}))},O=C=>{const K=C.target;K instanceof Node&&(_.current?.contains(K)||B.current?.contains(K)||(f(!1),w("")))};return window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),document.addEventListener("pointerdown",O,!0),()=>{p&&window.cancelAnimationFrame(p),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0),document.removeEventListener("pointerdown",O,!0)}},[b,U]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:_,type:"button",disabled:h,onClick:()=>{if(!h){if(w(""),b){f(!1);return}D()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:L?.label??(n||l)})]}),e.jsx(Us,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${b?"rotate-180":""}`})]}),b&&!h&&typeof document<"u"&&qr.createPortal(e.jsxs("div",{ref:B,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:p=>p.stopPropagation(),style:{left:M?.left??12,top:M?.top??12,width:M?.width??260,maxHeight:M?.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(Jn,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:j,onChange:p=>w(p.target.value),onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),f(!1),w("");return}p.key==="Enter"&&(p.preventDefault(),T())},onBlur:()=>{j.trim()&&$.length===0&&T()},placeholder:u,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,(M?.maxHeight??320)-46)},children:[j.trim()&&!s.some(p=>p.value===j.trim())&&e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:T,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:j.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:m("common.use")})]}),$.length>0?$.map(p=>e.jsxs("button",{type:"button",onClick:()=>{g(p.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 ${p.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:p.label}),p.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:p.meta})]},p.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:d})]})]}),document.body)]})}function nu({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:u,selectedRoots:d,onToggleRepo:h,onGenerate:g,onSecondaryAction:m,disabled:b,generateDisabled:f,secondaryDisabled:j,inserted:w,buttonLabel:M,insertedLabel:I,title:_,ariaLabel:B,scopeTitle:E,scopeLabel:$,allLabel:L,generateLabel:T,secondaryLabel:U,secondaryTitle:D,secondaryLoading:p,loading:i,error:O,statusTitle:C,extraContent:K,renderRepoExtra:de}){return e.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{s?n(!r):f||g()},disabled:b,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 ${O?"text-destructive hover:bg-destructive/5":w?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":B,title:C??(s?`${E}: ${$}`:_),children:[i?e.jsx(Nt,{size:13,className:"animate-spin"}):e.jsx(zs,{size:13}),e.jsx("span",{children:w?I:M}),s&&e.jsx(Us,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`}),O&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&qr.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:te=>te.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:E}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:$})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Yt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[K,e.jsxs("button",{type:"button",onClick:()=>h(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:L}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),u.map(te=>{const xe=d.includes(te.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${xe?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>h(te.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${xe?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:te.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:te.label}),te.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:te.branch})]}),xe&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),de&&(l||xe)&&e.jsx("div",{className:"px-2 pb-2",children:de(te)})]},te.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${m&&U?"sm:grid-cols-2":""}`,children:[m&&U&&e.jsxs("button",{type:"button",onClick:()=>{j||(n(!1),m())},disabled:j,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:[p?e.jsx(Nt,{size:12,className:"animate-spin"}):e.jsx(Nu,{size:12}),U]}),e.jsxs("button",{type:"button",onClick:()=>{f||(n(!1),g())},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(zs,{size:12}),T]})]})]})}),document.body)]})}function Ab(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Nf(){return mt(ul,Ab)??{}}function Tb(r,n){const s=Nf(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,u],[,d])=>d.updatedAt-u.updatedAt).slice(0,Eg);Ds(ul,Object.fromEntries(l),Lg)}function Ib(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function Db(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Ib(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function wl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Mf(){return mt(fl,Db)??{}}function su(r,n){const s=wl(r,n);return s?Mf()[s]??null:null}function Pi(r,n,s){const l=wl(r,n);if(!l)return;const u=Mf(),d=u[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...u,[l]:{...d,...s,updatedAt:Date.now()}}).sort(([,g],[,m])=>m.updatedAt-g.updatedAt).slice(0,$g);Ds(fl,Object.fromEntries(h),Pg)}function to({active:r,mounted:n=!0,fallback:s=null,children:l}){return e.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${r?"block":"hidden"}`,"aria-hidden":!r,children:n?typeof l=="function"?l():l:s})}function Ai({slow:r}){return e.jsx(Gm,{slow:r})}function ro({message:r,onRetry:n}){const{t:s}=St();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function lo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function kt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function Ti(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function Fb(r,n,s){return Ki(r,n,s)}function Ii(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function Di(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function Ef(r){const n=new Map;for(const s of r)n.set(kl(s),s);return n}function $f(r,n){const s=new Map(r);for(const l of n)s.set(kl(l),l);return s}function au(r,n){let s=0;for(const l of r){const u=gt(l,n);u&&n&&u!==n&&(s+=1)}return s}function _b(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Bb(r,n){return Array.from($f(Ef(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Ob(r,n){const s=r.relativeRoot==="."?kt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||kt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:_b(r.files)}}function Lf(r,n){const s=kt(n??"")||n||"";return r.map(l=>Ob(l,n)).sort((l,u)=>s&&l.label===s?-1:s&&u.label===s?1:l.label.localeCompare(u.label))}function Pf(r,n,s,l,u){const d=qu(s),h=d.find(_=>_.root===l)??d[0]??null,g=n.find(_=>_.root===l)??null,m=g?.relativeRoot??h?.relativeRoot??".",b=g?.name??h?.name??(kt(l)||l),f=(h?.files??s.files).map(_=>({..._,repoRoot:l,repoRelativeRoot:m,repoName:b})),j=h?.context??s.context,w={...g??h??{id:l,root:l,relativeRoot:m,name:b,depth:0,nested:!!(u&&l!==u),available:s.available,files:[],context:null},...h??{},id:g?.id??h?.id??l,root:l,displayRoot:g?.displayRoot??h?.displayRoot,relativeRoot:m,name:b,depth:g?.depth??h?.depth??0,nested:g?.nested??h?.nested??!!(u&&l!==u),available:h?.available??s.available,deferred:h?.deferred??!1,files:f,context:j?{...j,root:l,changedFiles:f.map(_=>({path:_.path,absolutePath:_.absolutePath,status:_.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},M=g?n.map(_=>_.root===l?w:_):[...n,w];return{files:Array.from(r).filter(_=>gt(_,u)!==l).concat(f),repositories:M,repoFilters:Lf(M,u)}}function gt(r,n){return r.repoRoot??n}function kl(r){return`${r.repoRoot??""}\0${r.path}`}function wt(r){return r.absolutePath||r.path}function Fi(r){return kl(r)}function Ub(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function ou(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function iu(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Ps(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function As(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function fr(r){return r instanceof DOMException&&r.name==="AbortError"}function Hb(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function lu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function _i(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function cu(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,u=Number(l?.dataset.mdRefStart),d=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(u)&&u>0&&Number.isFinite(d)&&d>0?{start:Math.min(u,d),end:Math.max(u,d)}:{start:n,end:s}}function zb({actions:r,running:n,completed:s}){const{t:l}=St(),[u,d]=a.useState(!1),h=a.useRef(null),g=r.find(b=>n?.action===b.key),m=r.find(b=>s?.action===b.key);return r.length===0?null:(a.useEffect(()=>{if(!u)return;const b=j=>{const w=j.target;w instanceof Node&&h.current?.contains(w)||d(!1)},f=j=>{j.key==="Escape"&&d(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",f)}},[u]),e.jsxs("div",{ref:h,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d(f=>!f)},disabled:r.every(b=>b.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${u?"bg-surface-elevated text-foreground":m?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:g?.label??m?.label??l("rightSidebar.gitQuickActions"),children:g?e.jsx(Nt,{size:13,className:"animate-spin"}):m?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(co,{size:14})}),u&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(b=>{const f=n?.action===b.key,j=s?.action===b.key;return e.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),b.onClick(),d(!1)},disabled:b.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 ${j?"bg-accent/10 text-accent":b.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(Nt,{size:13,className:"animate-spin"}):j?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.label})]},b.key)})})]}))}function Wb(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Af(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&Wb(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function Qn(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const Bi=new WeakMap;function xo(r){const n=Bi.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),Bi.delete(r)},1700);Bi.set(r,s)}function Gb(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let u=null;for(const g of l){if(!Qn(g))continue;const m=g.querySelector(s);if(m&&Qn(m)){u=m;break}}if(u??=Array.from(document.querySelectorAll(s)).find(Qn)??null,!u)return;const d=Af(u);if(!d){u.scrollIntoView({block:"start",behavior:"smooth"}),xo(u);return}const h=u.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop;d.scrollTo({top:Math.max(0,h),behavior:"instant"}),xo(u)}function kn(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,u=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,d=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,h=[s!==null&&u?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`:null,s!==null&&u?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`: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&&d?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${d}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(I=>!!I),g=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let m=null;for(const I of g)if(Qn(I)){for(const _ of h){const B=I.querySelector(_);if(B&&Qn(B)){m=B;break}}if(m)break}if(m??=h.flatMap(I=>Array.from(document.querySelectorAll(I))).find(Qn)??null,!m){Gb(r.filePath);return}const b=Af(m);if(!b){m.scrollIntoView({block:"center",behavior:"smooth"}),xo(m);return}const f=m.getBoundingClientRect(),j=b.getBoundingClientRect(),M=f.top-j.top+b.scrollTop-Math.max(24,(b.clientHeight-f.height)/2);b.scrollTo({top:Math.max(0,M),behavior:"instant"}),xo(m)}const Tf=1,If=8;function Kb(r){return Math.min(If,Math.max(Tf,r))}function Df({resetKey:r,onZoomChange:n,onDoubleTap:s,children:l}){const u=a.useRef(null),[d,h]=a.useState({scale:1,x:0,y:0}),[g,m]=a.useState(!1),b=a.useRef(null),f=a.useRef(new Set),j=a.useRef(!1),w=a.useRef(null),M=a.useRef(0),I=a.useRef(d);I.current=d,a.useEffect(()=>{h({scale:1,x:0,y:0})},[r]);const _=a.useCallback((L,T,U)=>{const D=u.current;if(!D)return{x:T,y:U};const p=D.firstElementChild instanceof HTMLElement?D.firstElementChild:null,i=p?.clientWidth||D.clientWidth,O=p?.clientHeight||D.clientHeight,C=Math.max(0,(i*L-D.clientWidth)/2),K=Math.max(0,(O*L-D.clientHeight)/2);return{x:Math.min(C,Math.max(-C,T)),y:Math.min(K,Math.max(-K,U))}},[]),B=a.useCallback((L,T,U)=>{h(D=>{const p=Kb(L),i=u.current;if(!i||p===1)return{scale:p,x:0,y:0};const O=i.getBoundingClientRect(),C=(T??O.left+O.width/2)-O.left-O.width/2,K=(U??O.top+O.height/2)-O.top-O.height/2,de=p/D.scale,te=C-(C-D.x)*de,xe=K-(K-D.y)*de;return{scale:p,..._(p,te,xe)}})},[_]),E=a.useCallback((L,T)=>{m(!0),I.current.scale>1?h({scale:1,x:0,y:0}):B(2.5,L,T),window.setTimeout(()=>m(!1),220)},[B]);a.useEffect(()=>{const L=u.current;if(!L)return;const T=p=>{if(p.pointerType==="mouse"&&p.button!==0)return;const i=f.current.size===0;if(f.current.add(p.pointerId),i){const O=Date.now(),C=w.current;if(C&&O-C.time<350&&Math.hypot(p.clientX-C.x,p.clientY-C.y)<24){w.current=null,M.current=O,s?.(),E(p.clientX,p.clientY);return}}if(f.current.size>1){j.current=!0,b.current=null;return}if(!(I.current.scale<=1)){p.preventDefault(),b.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,originX:I.current.x,originY:I.current.y,moved:!1};try{L.setPointerCapture?.(p.pointerId)}catch{}m(!1)}},U=p=>{const i=b.current;if(!i||i.pointerId!==p.pointerId)return;const O=p.clientX-i.startX,C=p.clientY-i.startY;if(!i.moved){if(Math.hypot(O,C)<6)return;i.moved=!0}p.stopPropagation(),p.preventDefault(),h(K=>({...K,..._(K.scale,i.originX+O,i.originY+C)}))},D=p=>{const i=b.current,O=i?.pointerId===p.pointerId&&i.moved;if(i?.pointerId===p.pointerId){i.moved&&p.stopPropagation(),b.current=null;try{L.releasePointerCapture?.(p.pointerId)}catch{}}f.current.delete(p.pointerId)&&f.current.size===0&&(!j.current&&!O&&(w.current={time:Date.now(),x:p.clientX,y:p.clientY}),j.current=!1)};return L.addEventListener("pointerdown",T,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",D,{capture:!0}),window.addEventListener("pointercancel",D,{capture:!0}),()=>{L.removeEventListener("pointerdown",T,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",D,{capture:!0}),window.removeEventListener("pointercancel",D,{capture:!0})}},[_,s,E]),gu({onPinch:({offset:[L],origin:[T,U]})=>{m(!1),B(L,T,U)},onWheel:({event:L,delta:[T,U],ctrlKey:D})=>{if(D){L.preventDefault(),L.stopPropagation(),m(!1),B(I.current.scale*(1-U*.01),L.clientX,L.clientY);return}I.current.scale<=1||(L.preventDefault(),L.stopPropagation(),m(!1),h(p=>({...p,..._(p.scale,p.x-T,p.y-U)})))}},{target:u,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Tf,max:If},from:()=>[I.current.scale,0],rubberband:!0}});const $=d.scale>1;return a.useEffect(()=>{n?.($)},[n,$]),e.jsx("div",{ref:u,"data-sidebar-gesture-ignore":$?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:$?"grab":"zoom-in"},onDoubleClick:L=>{L.stopPropagation(),!(Date.now()-M.current<500)&&(s?.(),E(L.clientX,L.clientY))},children:l({scale:d.scale,zoomed:$,animateTransform:g,transformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0) scale(${d.scale})`,transformOrigin:"center center",transition:g?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0)`,transformOrigin:"center center",transition:g?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Ff({src:r,alt:n,vector:s,onLoad:l,onError:u,onZoomChange:d,onDoubleTap:h}){const g=vo(r,u),[m,b]=a.useState(null),f=s??wo(r);return a.useEffect(()=>{b(null)},[r]),e.jsx(Df,{resetKey:r,onZoomChange:d,onDoubleTap:h,children:({transformStyle:j,vectorTransformStyle:w,scale:M,animateTransform:I})=>{const _=e.jsx("img",{src:g,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:f&&m?{position:"absolute",left:"50%",top:"50%",width:m.width*M,height:m.height*M,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:I?"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"}:m?{...j,width:m.width,height:m.height}:f?w:j,onLoad:B=>{const E=B.currentTarget,$=E.parentElement;if($&&E.naturalWidth>0&&E.naturalHeight>0){const L=Math.max(1,$.clientWidth-2),T=Math.max(1,$.clientHeight-2),U=Math.min(L/E.naturalWidth,T/E.naturalHeight),D=f?U:Math.min(U,1);b({width:Math.max(1,Math.round(E.naturalWidth*D)),height:Math.max(1,Math.round(E.naturalHeight*D))})}l(B)},onError:u});return!f||!m?_:e.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...w,width:m.width,height:m.height},children:_})}})}function Vb({svg:r,title:n,scale:s,vectorTransformStyle:l}){const u=a.useRef(null);return a.useLayoutEffect(()=>{const d=u.current,h=d?.querySelector("svg");if(!d||!h)return;const g=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let j=f[2],w=f[3];if((!Number.isFinite(j)||!Number.isFinite(w)||j<=0||w<=0)&&(j=Number(h.getAttribute("width")),w=Number(h.getAttribute("height"))),!Number.isFinite(j)||!Number.isFinite(w)||j<=0||w<=0)return;const M=Math.max(1,d.clientWidth-24),I=Math.max(1,d.clientHeight-24),_=Math.min(M/j,I/w,1);h.style.width=`${Math.max(1,Math.floor(j*_*s))}px`,h.style.height=`${Math.max(1,Math.floor(w*_*s))}px`,h.style.maxWidth="none",h.style.maxHeight="none",h.style.transform=String(l.transform??""),h.style.transformOrigin="center center",h.style.transition=String(l.transition??"none")};g();const m=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return m?.observe(d),()=>m?.disconnect()},[s,r,l]),e.jsx("div",{ref:u,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function qb({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Df,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:u,scale:d})=>e.jsx(Vb,{svg:r,title:n,scale:d,vectorTransformStyle:u})})}let Yb=0,Xb=0,Jb=0,Qb=0,Zb=0;function Oi(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function dt(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++Xb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function no(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++Qb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ex(){return`diff-ui-${Date.now().toString(36)}-${(++Zb).toString(36)}`}function tx(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function rx(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function cl({onReviewReference:r,filePath:n,onInsertReference:s,onInsertText:l,onInsertFeature:u,onReferenceCopied:d,onClose:h,onDirectoryLinkOpen:g,isMobile:m,markdownOutlineOpen:b,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:j,onCloseMarkdownOutline:w,markdownImageLightboxOpen:M,markdownImageLightboxCloseSignal:I,onOpenMarkdownImageLightbox:_,onCloseMarkdownImageLightbox:B,lineRange:E,onLineRangeChange:$,insertedReferenceKey:L,copiedReferenceKey:T,scrollToLine:U,onScrollToLineHandled:D}){const{t:p}=St(),i=J(A=>A.rootPath),O=J(A=>A.selectFile),[C,K]=a.useState({kind:"idle"}),[de,te]=a.useState("schematic"),[xe,W]=a.useState(null),X=a.useRef(null),[P,F]=a.useState(null),V=a.useRef(new Map),re=a.useRef(null),[ie,ye]=a.useState(null),[pe,De]=a.useState(()=>Kd()),[N,q]=a.useState(()=>Ad(i,n)),he=a.useRef(null),[Le,Ze]=a.useState(!1),[Pe,at]=a.useState(null),[Be,R]=a.useState(0),[ee,le]=a.useState([]),[Ee,Ne]=a.useState(null),We=a.useRef(null),ce=a.useRef(n),[Ae,tt]=a.useState(null),[Te,ke]=a.useState({status:"idle"}),[rt,nt]=a.useState(!1),[oe,Ie]=a.useState(""),[ze,_t]=a.useState([]),[Bt,H]=a.useState(0),ae=a.useRef(null),ve=Cu(d),Ke=wl(i,n);a.useEffect(()=>{if(ce.current===n)return;ce.current=n;const A=n&&i&&!n.startsWith("/")?`${i}/${n}`:n;if(We.current===A){We.current=null;return}We.current=null,le([]),Ne(null),nt(!1),Ie("")},[n,i]);const pt=n?i&&!n.startsWith("/")?`${i}/${n}`:n:null,hr=J(A=>pt?(A.fileChangeVersions.get(pt)??0)+A.fileWatchEpoch:A.fileWatchEpoch),mr=a.useRef(null),Ot=a.useRef(null),[pr,gr]=a.useState(0),Sn=a.useCallback(()=>gr(A=>A+1),[]);a.useEffect(()=>{const A=X.current;return X.current=null,W(null),A&&URL.revokeObjectURL(A.objectUrl),()=>{const z=X.current;X.current=null,z&&URL.revokeObjectURL(z.objectUrl)}},[pt,hr,pr]),a.useEffect(()=>{if(!n){mr.current=null,K({kind:"idle"});return}const A=i&&!n.startsWith("/")?`${i}/${n}`:n,z=new AbortController,ue=++Yb,Se=`right-sidebar-file-preview:${ue}`,et=performance.now();let Fe=!1;const Ve=(Q,Ye={})=>{Fe||(Fe=!0,Oi("end",{loadingId:ue,reason:Q,durationMs:Math.round(performance.now()-et),filePath:n,fullPath:A,rootPath:i,...Ye}))};let _e=null;const qe=Yh(A),ft=qe?A.toLowerCase().endsWith(".kicad_pcb")?de==="schematic"?"pcb-front":de:"schematic":de,Nn=!qe&&dl(A),sr=!qe&&!Nn&&Xh(A),as=!qe&&!Nn&&!sr&&uu(A),Zr=Ls(A),en=Ms(A),Or=qe?"eda":Nn?"image":sr?"model3d":as?"video":"text",tn=mr.current!==A;if(mr.current=A,tn){Oi("start",{loadingId:ue,filePath:n,fullPath:A,rootPath:i,mode:Or,externalVersion:hr}),ke({status:"idle"}),K({kind:"loading",mode:Or}),Ot.current=null;const Q=su(i,n);$(Q?.lineRange??null),De(Zr?Kd():"source"),q(en?Ad(i,n):"source"),qe&&te(Jh(A))}tn||K(Q=>Q.kind==="error"?{kind:"loading",mode:Or}:Q);const rn=window.setTimeout(()=>{Fe||z.signal.aborted||Oi("still_active",{loadingId:ue,filePath:n,fullPath:A,rootPath:i,mode:Or,durationMs:Math.round(performance.now()-et),isPathChange:tn})},3e3),os=window.setTimeout(()=>{if(Fe||z.signal.aborted)return;const Q=qe?p("rightSidebar.edaTimeout"):sr?p("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";z.abort(new DOMException(Q,"TimeoutError")),K({kind:"error",message:Q}),Ve("stuck_timeout",{error:Q})},qe?Qh+5e3:sr?Zh+5e3:em(A)?35e3:Bg);if(qe){const Q=ft==="pcb-3d"?X.current:null;Q?(K(Q),Ve("eda_3d_client_cache_hit",{bytes:Q.meta.size,view:Q.view,mimeType:Q.meta.mimeType})):tm(A,ft,z.signal,"view_file",Se).then(Ye=>{if(z.signal.aborted)return;_e=URL.createObjectURL(Ye.blob);const Tt={kind:"eda",sourcePath:Ye.path||A,objectUrl:_e,view:Ye.view,meta:{size:Ye.size,mimeType:Ye.mimeType,modified:Ye.modified}};if(Ye.view==="pcb-3d"){const ar=X.current;ar&&ar.objectUrl!==_e&&URL.revokeObjectURL(ar.objectUrl),X.current=Tt,W(Tt),_e=null}K(Tt),Ve("eda_loaded",{bytes:Ye.size,view:Ye.view,mimeType:Ye.mimeType})}).catch(Ye=>{z.signal.aborted||(K({kind:"error",message:Ye instanceof Error&&/timed out/i.test(Ye.message)?p("rightSidebar.edaTimeout"):Ye instanceof Error?Ye.message:p("rightSidebar.edaLoadFailed")}),Ve("error",{error:Ye instanceof Error?Ye.message:String(Ye)}))})}else if(Nn)rm(A,z.signal,"view_file",Se).then(Q=>{_e=URL.createObjectURL(Q.blob),K({kind:"image",objectUrl:_e,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),Ve("image_loaded",{bytes:Q.size,mimeType:Q.mimeType})}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error?Q.message:p("rightSidebar.imageLoadFailed")}),Ve("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(sr)nm(A,z.signal,"view_file",Se).then(Q=>{z.signal.aborted||(_e=URL.createObjectURL(Q.blob),K({kind:"model3d",sourcePath:Q.path||A,objectUrl:_e,ext:Q.ext,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),Ve("model3d_loaded",{bytes:Q.size,ext:Q.ext}))}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error&&(Q.name==="TimeoutError"||/timed out/i.test(Q.message))?p("rightSidebar.model3dTimeout"):Q instanceof Error?Q.message:p("rightSidebar.model3dLoadFailed")}),Ve("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(as){const Q=sm(A)??"",Ye=fu(A);K(Tt=>Tt.kind==="video"&&Tt.url===Ye?Tt:{kind:"video",url:Ye,meta:{size:null,mimeType:Q,modified:null}}),Ve("video_ready",{mimeType:Q})}else cd(A,z.signal,"view_file",Se).then(Q=>{if(!z.signal.aborted){if(Q.binary){K({kind:"binary"});return}K({kind:"text",content:Q.content,sourcePath:Q.path||A,meta:{size:Q.size,truncated:Q.truncated}}),Ve("text_loaded",{bytes:Q.size,truncated:!!Q.truncated})}}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error?Q.message:"Failed to read file"}),Ve("error",{error:Q instanceof Error?Q.message:String(Q)}))});return()=>{z.abort(),Ct(Se),window.clearTimeout(rn),window.clearTimeout(os),_e&&URL.revokeObjectURL(_e),Ve("cleanup")}},[n,i,hr,pr,$,p,de]),a.useEffect(()=>{if(C.kind!=="model3d"||!n){F(null);return}let A=!1;const z=n.lastIndexOf("/"),ue=z>=0?n.slice(z+1):n,Se=z>=0?n.slice(0,z):"",et=Se.lastIndexOf("/"),Fe=et>=0?Se.slice(0,et):"",Ve=ue.replace(/\.(stl|glb|gltf)$/i,""),_e=`${Fe?`${Fe}/`:""}features/${Ve}.json`;return cd(_e).then(qe=>{if(!A)try{const ft=JSON.parse(qe.content);F(ft.version===1&&Array.isArray(ft.features)&&ft.features.length>0?ft.features:null)}catch{F(null)}}).catch(()=>{A||F(null)}),()=>{A=!0}},[C,n]),a.useEffect(()=>{if(C.kind!=="text"){tt(null);return}const A=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=ku(A),ue=C.content,Se=Ls(A??"")&&pe==="preview",et=Ms(A??"")&&N==="preview";if(!z||Se||et||!Su(ue)){tt(null);return}let Fe=!1;const Ve=_e=>{if(Fe||!_e.registered(z)){Fe||tt(null);return}try{tt(Ru(_e,ue,z))}catch{tt(null)}};return Pe?Ve(Pe):(tt(null),ju().then(_e=>{Fe||(at(_e),Ve(_e))}).catch(()=>{})),()=>{Fe=!0}},[C,Pe,n,i,pe,N]),a.useLayoutEffect(()=>{if(!Ke||C.kind!=="text")return;const A=`${Ke}:${pe}:${N}`;if(Ot.current===A)return;const z=su(i,n);if(Ot.current=A,!z)return;const ue=requestAnimationFrame(()=>{const Se=re.current;if(!Se)return;const et=pe==="preview"?z.markdownTop??z.top:z.top;Se.scrollTo({top:Math.max(0,et??0),left:Math.max(0,z.left??0)}),R(pe==="preview"?Math.max(0,et??0):0)});return()=>cancelAnimationFrame(ue)},[n,pe,N,C.kind,Ke,i]),a.useEffect(()=>{Ke&&Pi(i,n,{lineRange:E})},[n,E,Ke,i]),a.useEffect(()=>{if(U==null||C.kind!=="text")return;ye(null),$({start:U,end:U});const A=U,z=requestAnimationFrame(()=>{const ue=V.current.get(A);ue&&ue.scrollIntoView({block:"center"}),D?.()});return()=>cancelAnimationFrame(z)},[U,C,$,D]);const jn=a.useCallback(A=>{const z=re.current;if(!z)return!1;const ue=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(A):A.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=z.querySelector(`#${ue}`);return Se?(Se.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const A=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=C.kind==="text"&&Ls(A??"")&&pe==="preview";if(!Ee||!z)return;const ue=requestAnimationFrame(()=>{jn(Ee)&&Ne(null)});return()=>cancelAnimationFrame(ue)},[n,jn,pe,Ee,C,i]),a.useLayoutEffect(()=>{const A=re.current;if(!A||!E){ye(null);return}if(ie)return;const z=C.kind==="image"||C.kind==="loading"&&C.mode==="image",ue=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,Se=C.kind==="text"&&Ls(ue??"")&&pe==="preview",et=C.kind==="text"&&Ms(ue??"")&&N==="preview";if(C.kind!=="text"||z||Se||et){ye(null);return}const Fe=()=>{const _e=V.current.get(E.end);if(!_e||!A){ye(null);return}const qe=_e.offsetTop+_e.offsetHeight/2,ft=A.scrollLeft+Math.max(8,A.clientWidth-120);ye({top:qe,left:ft})};Fe();const Ve=new ResizeObserver(()=>Fe());return Ve.observe(A),()=>Ve.disconnect()},[E,ie,C,pe,N,n,i,Ae]);const Tr=C.kind==="text"&&!(Ms(pt??"")&&N==="preview")&&!pt?.toLowerCase().endsWith(".csv")&&!pt?.toLowerCase().endsWith(".kicad_pro")&&!pt?.toLowerCase().endsWith(".kicad_prl"),br=a.useCallback(()=>{nt(!1),Ie(""),_t([]),H(0),Xa()},[]),Rn=a.useCallback(()=>{Tr&&(nt(!0),requestAnimationFrame(()=>{ae.current?.focus(),ae.current?.select()}))},[Tr]),bt=a.useCallback(A=>{H(z=>ze.length===0?0:(z+A+ze.length)%ze.length)},[ze.length]);if(a.useEffect(()=>{const A=z=>{const ue=wg(z);if(ue==="open"&&Tr){z.preventDefault(),Rn();return}rt&&(ue==="close"?(z.preventDefault(),br()):(ue==="next"||ue==="previous")&&(z.preventDefault(),bt(ue==="previous"?-1:1)))};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[br,rt,bt,Rn,Tr]),a.useLayoutEffect(()=>{if(Xa(),!rt||!oe.trim()||!re.current){_t([]),H(0);return}const A=Sg(re.current,oe);return _t(A),H(0),Fd(A,0),_d(A[0]),Xa},[rt,oe,Ae,pe,C]),a.useEffect(()=>{rt&&(Fd(ze,Bt),_d(ze[Bt]))},[Bt,ze,rt]),a.useEffect(()=>Xa,[]),!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:p("rightSidebar.selectFilePrompt")});const Ge=i&&!n.startsWith("/")?`${i}/${n}`:n,Pt=lo(Ge,i),xr=mu(Ge,i),vr=C.kind==="text"&&C.content?C.content.split(`
|
|
1654
|
+
`):[],Vs=Math.max(2,String(vr.length).length)+1,yr=C.kind==="text"||C.kind==="image"||C.kind==="model3d"||C.kind==="video"||C.kind==="eda"?C.meta:null,wr=Ls(Ge),qs=Ge.toLowerCase().endsWith(".csv"),At=Ge.toLowerCase().endsWith(".kicad_pro"),Zn=Ge.toLowerCase().endsWith(".kicad_prl"),Ut=C.kind==="text"&&wr&&pe==="preview",Ys=Ms(Ge),Xt=C.kind==="text"&&Ys&&N==="preview",Xs=C.kind==="image"||C.kind==="loading"&&C.mode==="image",So=C.kind==="model3d"||C.kind==="loading"&&C.mode==="model3d",Mt=C.kind==="video"||C.kind==="loading"&&C.mode==="video",Yr=C.kind==="eda"||C.kind==="loading"&&C.mode==="eda",es=C.kind==="text"?C.sourcePath:Ge,Ir=$m(es,i,E),Dr=(()=>{if(!E||C.kind!=="text"||vr.length===0)return Ir;const A=[];for(let Se=E.start;Se<=E.end;Se+=1)A.push(`${Se} ${vr[Se-1]??""}`);const z=Ju(Ge).replace(/^\./,""),ue="```";return`${Ir}
|
|
1655
1655
|
${ue}${z}
|
|
1656
1656
|
${A.join(`
|
|
1657
1657
|
`)}
|
|
1658
1658
|
${ue}
|
|
1659
|
-
`})(),kr=`path:${We}`,Sr=E?`path:${We}:${E.start}-${E.end}`:kr,Fr=L===kr,_r=L===Sr,Nn=T===kr,ts=T===Sr,Jr=_r||ts,Jt=E?E.start===E.end?`L${E.start}`:`L${E.start}-${E.end}`:null,Br=A=>{const z=re.current;if(!z)return;const ue=z.getBoundingClientRect(),Se=A.currentTarget.getBoundingClientRect(),Ze=A.clientX||Se.left+Se.width/2,Ke=(A.clientY||Se.top+Se.height/2)-ue.top+z.scrollTop,Fe=m?116:132,Ve=z.scrollLeft+Math.max(8,z.clientWidth-Fe),ft=Math.min(Math.max(8,Ze-ue.left+z.scrollLeft+10),Ve);ye({top:Ke,left:ft})},rs=(A,z)=>{Gi()||(Br(A),$(ue=>{const Se=Ki(ue,z,z);return Se||ye(null),Se}))},ns=(A,z,ue)=>{Br(A),$(Se=>{const Ze=Ki(Se,z,ue);return Ze||ye(null),Ze})},jr=(A,z,ue,Se)=>{Se==="end"&&Br(A),$({start:z,end:ue})},nr=A=>{const{scrollTop:z,scrollLeft:ue}=A.currentTarget;R(z),Pi(i,n,{top:z,left:ue,markdownTop:z})},be=A=>{if(A.directory){g?.(A.path);return}if(A.path===We||C.kind==="text"&&A.path===C.sourcePath){A.fragment&&Rn(A.fragment);return}le(z=>[...z,We]),ze.current=A.path,Ce(A.fragment),$(null),O(A.path)},Qt=()=>{const A=ee[ee.length-1];A&&(le(z=>z.slice(0,-1)),ze.current=A,Ce(null),$(null),O(A))},Qr=A=>{const{scrollTop:z,scrollLeft:ue}=A.currentTarget;Pi(i,n,{top:z,left:ue})},Zr=()=>{if(r){r(Dr,Sr);return}E&&l(Dr,Sr)},ss=async()=>{if(!(!We||Ae.status==="pending")&&!(C.kind==="loading"||C.kind==="error")){ke({status:"pending"});try{await xm(We),ke({status:"idle"})}catch(A){ke({status:"error",message:A instanceof Error?A.message:p("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[ve.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${m&&(Ut||Xt)?"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:[m&&h&&e.jsx("button",{type:"button",onClick:h,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":p("rightSidebar.backToFileList"),title:p("rightSidebar.backToFileList"),children:e.jsx(xu,{size:16})}),ee.length>0&&e.jsxs("button",{type:"button",onClick:Qt,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 ${m?"w-9":"px-2.5"}`,"aria-label":p("rightSidebar.backToPreviousPreview"),title:p("rightSidebar.backToPreviousPreview"),children:[e.jsx(Os,{size:15}),!m&&e.jsx("span",{className:"text-[11px] font-medium",children:p("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:We,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Pt.name}),Pt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Pt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Tr&&e.jsx("button",{type:"button",onClick:tt?br:Cn,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 ${tt?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":p("rightSidebar.findInFile"),title:`${p("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Jn,{size:14})}),wr&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{b&&w?.(),Ie(A=>{const z=A==="preview"?"source":"preview";return Lt(Fu,z),z}),$(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 ${m?"w-9 px-0":"px-3"}`,"aria-label":p(pe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:p(pe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:m?pe==="preview"?e.jsx(qi,{size:14}):e.jsx(Vi,{size:14}):p(pe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Ys&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{q(A=>{const z=A==="preview"?"source":"preview";return Up(i,n,z),z}),$(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 ${m?"w-9 px-0":"px-3"}`,"aria-label":p(N==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:p(N==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:m?N==="preview"?e.jsx(qi,{size:14}):e.jsx(Vi,{size:14}):p(N==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Xt&&e.jsx("button",{type:"button",onClick:()=>{he.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":p($e?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:p($e?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(vu,{size:15})}),!m&&e.jsx("button",{type:"button",onClick:()=>s(We,kr),...ve(xr,kr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Fr||Nn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:p("rightSidebar.insertReference",{reference:xr}),children:p(Nn?"rightSidebar.copied":Fr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(xr)},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:p("rightSidebar.copyReference",{reference:xr}),"aria-label":p("rightSidebar.copyFileRef"),children:e.jsx(am,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ss()},disabled:Ae.status==="pending"||C.kind==="loading"||C.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:Ae.status==="error"?Ae.message??p("rightSidebar.downloadFailed"):p("rightSidebar.downloadFile"),"aria-label":p("rightSidebar.downloadFile"),children:Ae.status==="pending"?e.jsx(Nt,{size:13,className:"animate-spin"}):e.jsx(Lm,{size:14})})]})]}),tt&&Tr&&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(Jn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:se,type:"search",value:oe,onChange:A=>Te(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),bt(A.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:p("rightSidebar.findInFilePlaceholder"),"aria-label":p("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:He.length>0?`${Bt+1}/${He.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>bt(-1),disabled:He.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":p("rightSidebar.previousSearchMatch"),title:`${p("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(pu,{size:13})}),e.jsx("button",{type:"button",onClick:()=>bt(1),disabled:He.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":p("rightSidebar.nextSearchMatch"),title:`${p("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Pm,{size:13})}),e.jsx("button",{type:"button",onClick:br,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":p("rightSidebar.closeFileSearch"),title:`${p("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Yt,{size:13})})]}),yr&&!(m&&(Ut||Xt))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[yr.size!==null&&e.jsx("span",{children:p("rightSidebar.byteCount",{count:yr.size.toLocaleString()})}),"truncated"in yr&&yr.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:p("rightSidebar.previewTruncated")}),"mimeType"in yr&&e.jsx("span",{children:yr.mimeType}),"dimensions"in C&&C.dimensions&&e.jsxs("span",{children:[C.dimensions.width," × ",C.dimensions.height]})]}),!(m&&(Ut||Xt))&&!So&&C.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:Xr?p("rightSidebar.edaPickHint"):qs?p("rightSidebar.csvTablePreview"):At||Zn?p("rightSidebar.kicadProjectPickHint"):Mt?p("rightSidebar.videoPreviewHint"):Xs?p("rightSidebar.imagePreviewHint"):Ut?E?p("rightSidebar.selectedLineHint",{lineLabel:Jt??""}):p("rightSidebar.markdownPreviewHint"):Xt?p("rightSidebar.htmlPreviewHint"):E?p("rightSidebar.selectedLineHint",{lineLabel:Jt??""}):p("rightSidebar.multiLineHint")})})]}),C.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:C.mode==="eda"?p("rightSidebar.edaLoading"):C.mode==="image"?p("rightSidebar.loadingImage"):C.mode==="model3d"?p("rightSidebar.model3dLoading"):C.mode==="video"?p("rightSidebar.loadingVideo"):"Loading file…"}):C.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:C.message}),e.jsx("button",{type:"button",onClick:jn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:p("common.retry")})]}):C.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:p("rightSidebar.binaryPreviewHint")})}):C.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:C.meta.mimeType==="image/svg+xml"?e.jsx(Pu,{blobUrl:C.objectUrl,filePath:We,viewLabel:"SVG 文件",onInsertAnnotation:u}):e.jsx(Ff,{src:C.objectUrl,alt:Pt.name,vector:!1,onLoad:A=>{const z=A.currentTarget;K(ue=>ue.kind==="image"?{...ue,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:ue)},onError:()=>K({kind:"error",message:p("rightSidebar.imageLoadFailed")})})}):C.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(Zp,{url:C.url,onLoadError:()=>K({kind:"error",message:p("rightSidebar.videoLoadFailed")})})}):C.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(og,{blobUrl:C.objectUrl,filePath:C.sourcePath,view:C.view,board:We.toLowerCase().endsWith(".kicad_pcb"),onViewChange:te,onInsertAnnotation:r??u,onRefresh:jn,interactive3d:xe?e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.model3dLoading")}),children:e.jsx(Gd,{blobUrl:xe.objectUrl,ext:".glb",fileName:Pt.name,filePath:xe.sourcePath,features:null,onInsertFeature:r??u,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:A=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(A)?A:"PCB板体/铜箔/丝印",active:C.view==="pcb-3d"})}):void 0})}):C.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.model3dLoading")}),children:e.jsx(Gd,{blobUrl:C.objectUrl,ext:C.ext,fileName:Pt.name,filePath:C.sourcePath,features:P,onInsertFeature:r??u,onRefresh:jn})})}):C.kind==="text"&&qs?e.jsx(cg,{content:C.content,filePath:We,onInsertAnnotation:r??u},We):C.kind==="text"&&(At||Zn)?e.jsx(fg,{content:C.content,filePath:We,localState:Zn,onInsertAnnotation:r??u},We):Ut?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:nr,style:{touchAction:"pan-x pan-y"},children:[e.jsx(Cf,{content:C.content,filePath:C.sourcePath,rootPath:i,lineRange:E,onLineRangeClick:ns,onLineRangeDrag:jr,scrollTop:_e,outlineOpen:b,outlineCloseSignal:f,onOutlineOpen:j,onOutlineClose:w,lightboxOpen:M,lightboxCloseSignal:I,onLightboxOpen:_,onLightboxClose:B,onLocalLinkOpen:be}),E&&ie&&e.jsxs("button",{type:"button",onClick:Zr,...ve(Dr,Sr),style:{top:ie.top,left:ie.left,transform:"translateY(-50%)"},className:Md(m,Jr),title:`Insert markdown reference: ${Ir}`,children:[e.jsx(uo,{size:m?13:11}),ts?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Jt??""})]})]}):Xt?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(yg,{ref:he,src:om(We),title:`${Pt.name} preview`,exitFullscreenLabel:p("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Qe},`${We}:${hr}:${pr}`)}):C.kind==="text"?e.jsxs("div",{ref:re,onScroll:Qr,className:`${hl} 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:[vr.length>0?e.jsx("div",{className:"min-w-full",children:vr.map((A,z)=>{const ue=z+1,Se=!!(E&&ue>=E.start&&ue<=E.end),Ze=Pe&&Pe.length===vr.length?Pe[z]:null;return e.jsxs("div",{ref:De=>{De?V.current.set(ue,De):V.current.delete(ue)},role:"button","data-file-preview-line":ue,tabIndex:0,onClick:De=>rs(De,ue),onKeyDown:De=>{De.key!=="Enter"&&De.key!==" "||(De.preventDefault(),rs(De,ue))},style:{gridTemplateColumns:`${Vs}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Se?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${xr}:${ue}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Se?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ue}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ze??(A||" ")})]},z)})}):"Empty file.",E&&ie&&e.jsxs("button",{type:"button",onClick:Zr,...ve(Dr,Sr),style:{top:ie.top,left:ie.left,transform:"translateY(-50%)"},className:Md(m,Jr),title:`Insert code reference: ${Ir}`,children:[e.jsx(uo,{size:m?13:11}),ts?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Jt??""})]})]}):null]})}function nx({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:b,onOpenRightSidebarFilePreview:f,onCloseRightSidebarFilePreview:j,rightSidebarRepoPickerOpen:w=!1,rightSidebarRepoPickerCloseSignal:M,onOpenRightSidebarRepoPicker:I,onCloseRightSidebarRepoPicker:_,markdownOutlineOpen:B=!1,markdownOutlineCloseSignal:E,onOpenMarkdownOutline:$,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T=!1,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p}){const{t:i,locale:O}=St(),[C,K]=a.useState(""),[de,te]=a.useState(null),xe=J(t=>t.rightSearchOpen),W=J(t=>t.setRightSearchOpen),Y=J(t=>t.rightSidebarLayoutPreference),P=J(t=>t.setRightSidebarLayoutPreference),[F,V]=a.useState(()=>Xg()),[re,ie]=a.useState("."),[ye,pe]=a.useState(""),[Ie,N]=a.useState(!1),[q,he]=a.useState(!1),[$e,Qe]=a.useState(!1),[Le,at]=a.useState(!1),_e=a.useDeferredValue(C),[R,ee]=a.useState(null),[le,Me]=a.useState([]),[Ce,ze]=a.useState([]),ce=J(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Pe=J(t=>t.setActiveGitRepo),[et,Ae]=a.useState(null),[ke,tt]=a.useState(null),[rt,oe]=a.useState(null),[Te,He]=a.useState(()=>mt(Od,Is)??!1),[_t,Bt]=a.useState(()=>mt(Ud,Is)??!1),[H,se]=a.useState(()=>mt(Hd,Is)??!1),[ve,Ge]=a.useState(()=>mt(Ni,Gg)??""),[pt,hr]=a.useState(0),[mr,Ot]=a.useState(!1),[pr,gr]=a.useState(!1),jn=a.useRef(null),Rn=a.useRef(null),[Tr,br]=a.useState(!1),[Cn,bt]=a.useState(null),[We,Pt]=a.useState(null),[xr,vr]=a.useState(()=>Vd(Ri)),[Vs,yr]=a.useState(()=>Vd(Bd)),[wr,qs]=a.useState(()=>Wg()),[At,Zn]=a.useState(()=>Kg()),[Ut,Ys]=a.useState(()=>qg()),Xt="words",[Xs,So]=a.useState(0),[Mt,Xr]=a.useState([]),[es,Ir]=a.useState([]),[Dr,kr]=a.useState(!1),[Sr,Fr]=a.useState(null),[_r,Nn]=a.useState([]),[ts,Jr]=a.useState(!1),[Jt,Br]=a.useState([]),[rs,ns]=a.useState([]),[jr,nr]=a.useState(!1),[be,Qt]=a.useState(null),[Qr,Zr]=a.useState([]),[ss,A]=a.useState({}),z=a.useRef(0),[ue,Se]=a.useState(0),[Ze,De]=a.useState(!1),[Ke,Fe]=a.useState(null),[Ve,ft]=a.useState(null),[Mn,sr]=a.useState(null),[as,en]=a.useState(null),[tn,Or]=a.useState(!1),[rn,nn]=a.useState(""),os=a.useDeferredValue(rn),[Q,qe]=a.useState({}),[Tt,ar]=a.useState([]),[Js,is]=a.useState(!1),[Qs,ls]=a.useState(!1),[Sl,En]=a.useState(null),[jo,$n]=a.useState(!1),or=a.useRef(null),Ur=a.useRef(0),jl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[_f,Zs]=a.useState(null),[cs,Rl]=a.useState(()=>mt(Ci,Is)??!1),[Ro,Co]=a.useState(!1),[ea,No]=a.useState([]),[Zt,ta]=a.useState({}),[Et,ra]=a.useState({}),[sn,Mo]=a.useState({}),[Cl,Nl]=a.useState(()=>new Set),[Ye,an]=a.useState(null),[Eo,on]=a.useState(null),[Bf,Rr]=a.useState(!1),[Ml,Cr]=a.useState(0),[,$o]=a.useState(0),[Lo,na]=a.useState(!1),[ir,Po]=a.useState(!1),[Of,El]=a.useState(()=>J.getState().rightTab==="diff"),[Ao,$l]=a.useState(()=>J.getState().rightTab==="android"),[Hr,Ll]=a.useState(!1),sa=vi(t=>t.docks[wi]),Uf=!!sa,[Ue,ds]=a.useState(null),[Ln,us]=a.useState(null),[xt,ln]=a.useState(null),[Pl,vt]=a.useState(null),[Pn,Al]=a.useState(null),[To,Hf]=a.useState(()=>Date.now()),[zf,Wf]=a.useState(!1),[cn,aa]=a.useState(!1),[oa,Tl]=a.useState(""),[An,ia]=a.useState(""),[dn,la]=a.useState(""),[un,ca]=a.useState(""),[Il,Tn]=a.useState(null),[da,ua]=a.useState(!1),[Dl,Io]=a.useState(!1),[Fl,_l]=a.useState(!1),[fa,Gf]=a.useState({key:null,nonce:0}),Bl=a.useRef(null),Ol=a.useRef(null),ne=vm(s,h,Y),Do=Vu(ne,h,Ut),[Fo,_o]=a.useState(()=>nb(s)),Bo=J(t=>t.rightTab),er=J(t=>t.setRightTab),x=J(t=>t.rootPath),In=J(t=>t.explorerRoot),Ul=J(t=>t.pinnedExplorerRootsCache),Hl=J(t=>t.hydratePinnedExplorerRoots),zl=J(t=>t.syncPinnedExplorerRoots),Ht=J(t=>t.setExplorerRoot),Wl=J(t=>t.resetExplorerToProject),Dn=J(t=>t.pinExplorerRoot),fn=J(t=>t.unpinExplorerRoot),ot=J(t=>t.selectedFilePath),it=J(t=>t.selectFile),Oo=J(t=>t.showHiddenFiles),Kf=J(t=>t.toggleShowHiddenFiles),Uo=J(t=>!!(x&&t.nestedGitScanRoots[x])),je=J(t=>t.changedFiles),ha=J(t=>t.setChangedFiles),ma=J(t=>t.invalidateDirectoryCache),Vf=J(t=>t.setDirectorySortMode),Gl=J(t=>t.applyFileWatchEvents),Kl=J(t=>t.reconcileDirectoryCache),Vl=J(t=>t.bumpFileWatchEpoch),zr=J(t=>t.gitBundleLoading),ql=J(t=>t.gitBundleSlow),hn=J(t=>t.gitBundleError),Fn=J(t=>t.gitBundleLastLoadedAt),Yl=J(t=>t.beginGitBundleLoading),Xl=J(t=>t.setGitBundleSlowFor),Ho=J(t=>t.finishGitBundleLoading),pa=J(t=>t.resetGitBundleLoading),zo=J(t=>t.setGitBundleError),Jl=J(t=>t.markGitBundleLoaded),ge=In??x,Ql=a.useMemo(()=>ge?Rg(ge,re):"",[ge,re]),fs=a.useMemo(()=>jg(ye),[ye]),Zl=a.useMemo(()=>({excludePatterns:fs,caseSensitive:q,wholeWord:$e,regex:Le}),[q,fs,Le,$e]),ga=J(t=>ge?t.fileSortModes[ge]??"name":"name"),ec=J(t=>!!(ge&&t.directoryCache.has(ge))),_n=a.useRef(null),jt=a.useRef(0),[tc]=a.useState(()=>++Jb),Nr=a.useRef(null),Wr=a.useRef(null),ba=a.useRef(0),zt=a.useRef(new Map),Wt=a.useRef(new Map),lr=a.useRef(new Set),mn=a.useRef(new Set),pn=a.useRef(0),Gr=a.useRef(null),Bn=a.useRef(0),On=a.useRef(null),Un=a.useRef(0),Kr=a.useRef(null),Wo=a.useRef(new Set),Go=a.useRef(null),Ko=a.useRef(null),xa=a.useRef(null),Vo=a.useRef(null),qo=a.useRef(null),hs=a.useRef(new Set);a.useEffect(()=>{if(Pn===null)return;const t=Math.max(0,Date.now()-Pn),o=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,c=Math.max(50,o-t%o),y=window.setTimeout(()=>Hf(Date.now()),c);return()=>window.clearTimeout(y)},[To,Pn]);const va=a.useRef(null),Mr=a.useRef(null),ya=a.useRef(null),ms=a.useRef(null),Re=a.useCallback(t=>J.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=o=>{const c=tx(o.target);c&&no("global_change_row_event",{...rx(o),selectionPath:c.dataset.diffSelectionPath,filePath:c.dataset.diffFilePath,absolutePath:c.dataset.diffAbsolutePath,repoRoot:c.dataset.diffRepoRoot,status:c.dataset.diffStatus,selectedFilePath:J.getState().selectedFilePath,rightTab:J.getState().rightTab,activeGitRepoRoot:ce,changedFiles:J.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const rc=a.useCallback(async(t=x??void 0)=>{if(!t)return null;if(lr.current.has(t)||mn.current.has(t))return dt("untracked_skip_cached",{cwd:t,rootPath:x,completed:lr.current.has(t),running:mn.current.has(t)}),null;const o=x,c=ba.current+1;ba.current=c,zt.current.set(t,c);const y=`right-sidebar-git-untracked:${t}`,v=new AbortController;Wt.current.set(t,v),mn.current.add(t),dt("untracked_start",{requestId:c,cwd:t,rootPath:x});try{let k=await dd(t,v.signal,y),S=0;for(;k.status==="running"&&S<120;){if(zt.current.get(t)!==c||v.signal.aborted)return dt("untracked_stale_result",{requestId:c,activeRequestId:zt.current.get(t),cwd:t,status:k.status}),null;if(!Re(o))return dt("untracked_root_changed",{requestId:c,cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath}),null;await new Promise(Z=>window.setTimeout(Z,S<10?1e3:3e3)),S+=1,k=await dd(t,v.signal,y)}if(zt.current.get(t)!==c||!Re(o))return dt("untracked_stale_result",{requestId:c,activeRequestId:zt.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return ha($f(J.getState().changedFiles,k.files)),k.files.length>0&&Me(Z=>{const Ee=new Map(Z.map(Ne=>[Ne.root,Ne])).get(t);if(!Ee)return Z;const Xe=Bb(Ee.files,k.files),G=Z.map(Ne=>Ne.root===t?{...Ne,files:Xe,context:Ne.context?{...Ne.context,changedFiles:Xe.map(Oe=>({path:Oe.path,absolutePath:Oe.absolutePath,status:Oe.status})),truncated:!1}:Ne.context,untrackedDeferred:!1}:Ne);ze(Lf(G,x));const X=G.find(Ne=>Ne.root===x);return X?.context&&ee(Ne=>Ne?.root===X.root?{...Ne,...X.context}:Ne),G}),lr.current.add(t),dt("untracked_apply",{requestId:c,cwd:t,files:k.files.length}),k;const ae=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return lr.current.add(t),dt("untracked_error",{requestId:c,cwd:t,message:ae,code:k.code,status:k.status}),null}catch(k){if(zt.current.get(t)!==c||!Re(o)||fr(k))return dt("untracked_aborted",{requestId:c,activeRequestId:zt.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const S=k instanceof Error?k.message:"Failed to scan untracked files";return lr.current.add(t),dt("untracked_error",{requestId:c,cwd:t,message:S}),null}finally{Wt.current.get(t)===v&&Wt.current.delete(t),zt.current.get(t)===c&&zt.current.delete(t),mn.current.delete(t)}},[R,Re,x,ha]),tr=a.useMemo(()=>{const t=new Set(Ce.map(c=>c.root)),o=_r.filter(c=>t.has(c));return o.length>0?o:ce?[ce]:[]},[ce,_r,Ce]),nc=tr.length===0,gn=a.useMemo(()=>tr.map(t=>le.find(o=>o.root===t)).filter(t=>!!t),[tr,le]),qf=a.useMemo(()=>Ce.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[Ce]),cr=a.useCallback(async()=>{if(!x){Xr([]),Ir([]);return}const t=x,o=Bn.current+1;Bn.current=o,On.current?.abort();const c=new AbortController;On.current=c,kr(Mt.length===0),Fr(null);try{const y=tr.length>0?await Promise.all(tr.map(v=>ud({workspaceRoot:x,repoRoot:v},c.signal))).then(v=>({records:v.flatMap(k=>k.records),walkthroughs:v.flatMap(k=>k.walkthroughs??[])})):await ud({workspaceRoot:x},c.signal);if(Bn.current!==o||!Re(t))return;Xr(y.records),Ir(y.walkthroughs??[])}catch(y){if(Bn.current!==o||!Re(t)||fr(y))return;Fr(y instanceof Error?y.message:"Failed to load change audit explanations")}finally{On.current===c&&(On.current=null),Bn.current===o&&Re(t)&&kr(!1)}},[Mt.length,tr,Re,x]),wa=a.useCallback(async(t,o,c)=>{if(!t&&!x){Br([]),ns([]);return}const y=x,v=Un.current+1;Un.current=v,Kr.current?.abort();const k=new AbortController;Kr.current=k;try{const S=t?[t]:Array.from(new Set([x,...le.map(Z=>Z.root)].filter(Z=>!!Z))),ae=await Promise.all(S.map(Z=>lm({repoRoot:Z,baseRef:o,branchName:c},k.signal))).then(Z=>{const me=new Map,Ee=new Map;for(const Xe of Z){for(const G of Xe.records)me.set(G.id,G);for(const G of Xe.walkthroughs??[])Ee.set(G.id,G)}return{records:Array.from(me.values()),walkthroughs:Array.from(Ee.values())}});if(Un.current!==v||!Re(y))return;Br(ae.records),ns(ae.walkthroughs??[])}catch(S){if(Un.current!==v||!Re(y)||fr(S))return;console.warn("[RightSidebar] Failed to load branch explanations",S)}finally{Kr.current===k&&(Kr.current=null)}},[le,Re,x]),Hn=a.useCallback((t,o={})=>{if(!Re(x)){dt("apply_skipped_root_changed",{expectedRootPath:x,currentRootPath:J.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}dt(t.files.length===0?"empty_bundle":"apply",{rootPath:x,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let c=qu(t),y=t.repoFilters??[],v=t.files;const k=J.getState().changedFiles;if(!!(o.cacheOnly&&!t.cached&&t.files.length===0&&c.length===0)&&(k.size>0||le.length>0||R)){dt("cache_only_apply_skipped_empty_backend_cache",{rootPath:x,currentFiles:k.size,currentRepositories:le.length});return}const ae=c.some(X=>X.deferred);if(ae&&!o.replaceWorkspace){const X=new Set(c.filter(Oe=>!Oe.deferred||Oe.root===x).map(Oe=>Oe.root));v=[...Array.from(k.values()).filter(Oe=>!X.has(gt(Oe,x)??"")),...t.files]}const Z=au(k.values(),x),me=au(t.files,x),Ee=c.some(X=>X.root!==x);if(!!(o.background&&!ae&&!o.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||Z>0&&me===0&&!Ee))){dt("background_apply_skipped_degraded_bundle",{rootPath:x,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:Z,nextNestedCount:me,nextRepositories:c.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(o.replaceRepoRoot){const X=Pf(k.values(),le,t,o.replaceRepoRoot,x);v=X.files,c=X.repositories,y=X.repoFilters}if(ha(Ef(v)),Me(c),ze(y),qo.current=x,o.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:Ne}=J.getState(),Oe=X?Ne[X]??null:null,st=o.activeRepoRoot!==void 0?o.activeRepoRoot:Oe,Be=Jg({...t,repositories:c,repoFilters:y},st);Pe(Be)}typeof t.cacheUpdatedAt=="number"&&Al(t.cacheUpdatedAt),ee(X=>{if(o.replaceRepoRoot&&o.replaceRepoRoot!==x)return X;if(!t.context)return null;const Ne=X?.root??x;return!X?.available||Ne!==(t.context.root??x)?t.context:{...X,...t.context}}),o.reloadDiff&&So(X=>X+1);const G=J.getState().selectedFilePath;if(G&&!G.startsWith("/")&&!v.some(X=>X.path===G||X.absolutePath===G)&&it(null),vr(X=>{const Ne=new Set(v.map(st=>gt(st,x)).filter(Boolean)),Oe=new Set;for(const st of X)Ne.has(st)&&Oe.add(st);return Ei(Ri,Oe),Oe}),o.loadDeferred!==!1){const X=c.filter(Ne=>Ne.untrackedDeferred&&Ne.root).map(Ne=>Ne.root);for(const Ne of X)rc(Ne)}o.loadAudit!==!1&&cr()},[Re,cr,rc,x,it,Pe,ha]);a.useEffect(()=>{pa(),Go.current=null,Ko.current=x;const t=[],o=[];jt.current+=1,pn.current+=1,ba.current+=1,Nr.current?.abort(),Ct(Ps(Wr.current?.cwd??x??void 0)),Wr.current=null,Nr.current=null,Gr.current?.abort(),Ct("right-sidebar-git-details"),Gr.current=null;for(const S of Wt.current.values())S.abort();for(const S of Wt.current.keys())Ct(`right-sidebar-git-untracked:${S}`);Wt.current.clear(),zt.current.clear(),Bn.current+=1,On.current?.abort(),On.current=null,Un.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,or.current?.abort(),Ct("right-sidebar-recent-commits"),or.current=null,Xr([]),Ir([]),kr(!1),Fr(null),Nn([]),Jr(!1),Br([]),ns([]),nr(!1),Qt(null),De(!1),Fe(null),ft(null),sr(null),en(null),Or(!1),nn(""),ar([]),is(!1),ls(!1),En(null),$n(!1),Zs(null),an(null),on(null),Rl(!1),Lt(Ci,!1),Co(!1);const c=x?qd()[x]:null,y=c?.previewEntries??[],v=c?.selectedPreviewKey??null,k=v?y.find(S=>S.key===v)??null:null;++z.current,De(!1),No(c?.selectedRepoRoots??[]),ta(c?.repoTargetBranches??{}),ra(c?.repoBaseBranches??{}),Zr(y),A(c?.previewScrollTops??{}),k&&c?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(Qt(k.diff),an(k.key),on(c.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),nr(!0)),Mo(c?.repoIncludeUncommitted??Object.fromEntries(Object.keys(c?.repoTargetBranches??{}).map(S=>[S,c?.includeUncommitted??!0]))),Go.current=x,aa(!1),lr.current.clear(),mn.current.clear(),ds(null),us(null),ln(null),vt(null),Al(null),Me(t),ze(o),ee(null),Vo.current=null,qo.current=null,hs.current.clear()},[pa,x]);const It=a.useCallback(async(t=x??void 0,o={})=>{if(!t)return null;const c=x,y=jt.current;if(await hp(()=>Promise.all([J.getState().hydrateNestedGitScanRoots(),J.getState().hydrateActiveGitRepos()]).then(()=>{})),jt.current!==y||!Re(c))return null;const v=t===x&&$s(x),k=o.includeNested??v,S=o.refresh??o.reloadDiff??!1,ae=o.cacheOnly??!1,Z=o.background??!1,me=k&&(o.discoverOnly??!1);S&&lr.current.clear();const Ee=Wr.current;if(Ee&&Ee.cwd===t&&Ee.includeNested===k&&Ee.refresh===S&&Ee.cacheOnly===ae&&Ee.discoverOnly===me)return dt("reuse_pending",{cwd:t,includeNested:k,refresh:S,cacheOnly:ae,discoverOnly:me}),Ee.promise;const Xe=jt.current+1;jt.current=Xe;const G=`right-sidebar:${tc}:${Xe}`;Nr.current?.abort();const X=Ps(t);Ct(X);const Ne=new AbortController;Nr.current=Ne;let Oe=null;Z||Yl(G),zo(null),dt("start",{requestId:Xe,cwd:t,rootPath:x,requestSlotId:X,includeNested:k,refresh:S,cacheOnly:ae,background:Z,existingChanges:je.size,lastLoadedAt:Fn}),!Z&&typeof window<"u"&&(Oe=window.setTimeout(()=>{jt.current===Xe&&Xl(G,!0)},Tg));const st=(async()=>{const Be=await yi(t,Ne.signal,{includeNested:k,refresh:S,cacheOnly:ae,discoverOnly:me,action:S?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:S?null:void 0});if(Hb(Be)){if(dt("cancelled_result_ignored",{requestId:Xe,activeRequestId:jt.current,cwd:t,error:Be.error??Be.context?.error}),Ne.signal.aborted)return null;throw new Error(Be.error??Be.context?.error??"Failed to load Git changes")}return jt.current!==Xe||!Re(c)?(dt("stale_result",{requestId:Xe,activeRequestId:jt.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,files:Be.files.length,repositories:Be.repositories?.length??0}),null):(Hn(Be,{reloadDiff:o.reloadDiff,syncActiveRepo:o.replaceWorkspace?!0:k,background:Z,cacheOnly:ae,replaceRepoRoot:o.replaceRepoRoot,replaceWorkspace:o.replaceWorkspace}),Be)})();Wr.current={cwd:t,includeNested:k,refresh:S,cacheOnly:ae,discoverOnly:me,promise:st};try{const Be=await st;return jt.current===Xe&&Be&&Re(c)?Jl({cached:Be.cached,stale:Be.stale,cacheAgeMs:Be.cacheAgeMs,nestedDeferred:!k||Be.nestedDeferred,untrackedDeferred:Be.untrackedDeferred}):jt.current===Xe&&Re(c)&&Ho(G),Be}catch(Be){return jt.current!==Xe||!Re(c)||Ne.signal.aborted?(dt("aborted",{requestId:Xe,activeRequestId:jt.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,message:Be instanceof Error?Be.message:String(Be)}),null):(dt("error",{requestId:Xe,cwd:t,includeNested:k,refresh:S,background:Z,message:Be instanceof Error?Be.message:String(Be)}),Z||(ee(null),zo(Be instanceof Error?Be.message:"Failed to load Git changes")),null)}finally{Oe!==null&&window.clearTimeout(Oe),Nr.current===Ne&&(Nr.current=null),Wr.current?.promise===st&&(Wr.current=null),!Z&&jt.current===Xe&&Re(c)&&Ho(G)}},[Hn,Yl,je.size,Ho,tc,Fn,Re,Jl,x,zo,Xl]),ps=a.useCallback(async()=>{x&&await It(x,{reloadDiff:!0,refresh:!0})},[It,x]),Yo=a.useCallback(async(t=x??void 0)=>{if(!t)return null;const o=x,c=pn.current+1;pn.current=c,Gr.current?.abort(),Ct("right-sidebar-git-details");const y=new AbortController;Gr.current=y,aa(!0);try{const v=await fd(t,y.signal,"load_git_details","right-sidebar-git-details");return pn.current!==c||!Re(o)?null:(Me(k=>k.map(S=>S.root===v.root?{...S,available:v.available,context:v,error:v.error}:S)),ee(k=>k?.root&&v.root&&k.root!==v.root?k:!k?.available||!v.available?v:{...k,...v}),v)}catch(v){return fr(v)||!Re(o)||pn.current===c&&vt(v instanceof Error?v.message:"Failed to load Git details"),null}finally{Gr.current===y&&(Gr.current=null),pn.current===c&&Re(o)&&aa(!1)}},[Re,x]);a.useEffect(()=>{if(!r){jt.current+=1,pa(),Vo.current=null,pn.current+=1,ba.current+=1,Nr.current?.abort(),Ct(Ps(Wr.current?.cwd??x??void 0)),Wr.current=null,Nr.current=null,Gr.current?.abort(),Ct("right-sidebar-git-details"),Gr.current=null;for(const t of Wt.current.values())t.abort();for(const t of Wt.current.keys())Ct(`right-sidebar-git-untracked:${t}`);Wt.current.clear(),zt.current.clear(),Un.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,or.current?.abort(),Ct("right-sidebar-recent-commits"),or.current=null,aa(!1),De(!1),Fe(null),ft(null),sr(null),en(null),Or(!1),nn(""),ar([]),is(!1),ls(!1),En(null),$n(!1),K(""),W(!1),bt(null),Po(!1),ne&&El(!1)}},[ne,r,pa,W]),a.useEffect(()=>{if(!xe)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[xe]),a.useEffect(()=>{ne||Rr(!1)},[ne]);const gs=a.useCallback(t=>{$o(t);const o=ya.current;o&&(o.update(),o.slideTo(t,0),window.requestAnimationFrame(()=>{o.update(),o.slideTo(t,0)}))},[]);a.useEffect(()=>{if(ne)if(Rr(m),m&&ot){Cr(1);const t=Mr.current;t&&(t.update(),t.activeIndex!==1&&(ms.current=1,t.slideTo(1,0)))}else{Cr(0);const t=Mr.current;t&&t.activeIndex!==0&&(ms.current=0,t.slideTo(0,0)),bt(null)}},[ne,m,x,ot]),a.useEffect(()=>{if(b!==void 0&&!m){Cr(0);const t=Mr.current;t&&t.activeIndex!==0&&(ms.current=0,t.slideTo(0,0)),Rr(!1),bt(null)}},[b,m]),a.useEffect(()=>{M!==void 0&&Ae(null)},[M]),a.useEffect(()=>{!ne&&m&&j?.()},[ne,j,m]),a.useEffect(()=>{_o(t=>rl(t,s))},[s]);const Yf=a.useCallback(t=>{ne||(t.preventDefault(),va.current={startX:t.clientX,startWidth:Fo,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[Fo,ne]),Xf=a.useCallback(t=>{const o=va.current;if(!o||o.pointerId!==t.pointerId)return;const c=rl(o.startWidth+t.clientX-o.startX,s);_o(c),Ds(Ts,c,Ag)},[s]),sc=a.useCallback(t=>{const o=va.current;if(!(!o||o.pointerId!==t.pointerId)){va.current=null,Es(Ts);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),zn=!!(x&&Fn!==null&&lu(R)),Xo=!!(x&&!hn&&je.size===0&&Fn===null),dr=(()=>{let t=Bo;return t==="android"&&!Hr&&(t="files"),zn&&(t==="git"||t==="diff")&&(t="files"),t})(),lt=dr==="git",Wn=dr==="files",Rt=dr==="diff",Gn=dr==="android",Jf=Am(t=>t.overlay==="sidebar")&&Gn;a.useEffect(()=>{if(!ne){na(!0);return}if(!r){const o=window.setTimeout(()=>{na(!1)},Fg);return()=>window.clearTimeout(o)}na(!1);const t=window.setTimeout(()=>{na(!0)},Dg);return()=>window.clearTimeout(t)},[ne,r]),a.useEffect(()=>{if(!ne||!Rt)return;const t=ya.current;if(!t)return;const o=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(o)},[Rt,ne]),a.useEffect(()=>{if(!zn||!x||zr)return;const t=window.setTimeout(()=>{It(x,{background:!0})},3e3);return()=>window.clearTimeout(t)},[zn,x,zr,It]);const Qf=a.useCallback(t=>{It(t,{discoverOnly:!0})},[It]);mp({active:r&&(lt||Rt),rootPath:x,loading:zr,delay:lt&&!ne?0:Mi,lastStartedRoot:Vo,load:Qf}),a.useEffect(()=>{!r||!lt||(!ne||Lo)&&Po(!0)},[lt,ne,r,Lo]),a.useEffect(()=>{if(!r||lt)return;const t=window.setTimeout(()=>{Po(!0)},Mi);return()=>window.clearTimeout(t)},[lt,r]),a.useEffect(()=>{Rt&&El(!0)},[Rt]),a.useEffect(()=>{!r||!Gn||(n&&sa&&sa.sessionId!==n&&(vi.getState().setDock(wi,null),so({androidPanel:{docked:null}}).catch(()=>{})),$l(!0))},[Gn,r,n,sa]),a.useEffect(()=>{if(r&&Gn||!Ao)return;const t=window.setTimeout(()=>$l(!1),Ig);return()=>window.clearTimeout(t)},[r,Gn,Ao]),a.useEffect(()=>{let t=!1;return du().then(o=>{!t&&o.androidPanel&&Ll(o.androidPanel.enabled===!0)}).catch(()=>{}),()=>{t=!0}},[]);const Zf=a.useCallback(t=>{Ll(t),t?er("android"):J.getState().rightTab==="android"&&er("files"),so({androidPanel:{enabled:t}}).catch(()=>{})},[er]),ac=a.useCallback(t=>{ge&&Tb(ge,t.currentTarget.scrollTop)},[ge]);a.useEffect(()=>()=>{Nr.current?.abort(),Es(ul),Es(fl),Es(Ts),Es(Ni)},[]),a.useEffect(()=>{if(!ge||!ec)return;const t=Nf()[ge]?.top;if(typeof t!="number")return;let o=window.requestAnimationFrame(()=>{_n.current&&(_n.current.scrollTop=t),o=window.requestAnimationFrame(()=>{_n.current&&(_n.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(o)},[ge,ec]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return cm(t.signal).then(o=>_l(!!o.available)).catch(()=>_l(!1)),()=>t.abort()},[r]);const bs=a.useCallback(t=>{if(te(null),it(t),bt(null),ne){Rr(!0),Cr(1),Mr.current?.slideTo(1),f?.();return}},[ne,f,it]),oc=a.useCallback((t,o)=>{if(te(null),it(t),Pt(o),ne){Rr(!0),Cr(1),Mr.current?.slideTo(1),f?.();return}},[ne,f,it]),xs=a.useCallback(async(t,o)=>{const c=o||In||x;if(!(!c||t.length===0)){ua(!0);try{await Wa(c,t),ma(c,!1)}catch(y){vt(y instanceof Error?y.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>vt(null),4e3)}finally{ua(!1)}}},[In,x,ma,i]),ic=a.useCallback(async t=>{try{await dm(t)}catch(o){vt(o instanceof Error?o.message:i("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>vt(null),4e3)}},[i]),ka=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&Io(!0)},[]),lc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Io(!1)},[]),cc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Io(!1);const o=t.dataTransfer.files;o.length>0&&xs(Array.from(o))},[xs]),Jo=a.useCallback(t=>{tt(t),window.setTimeout(()=>tt(o=>o===t?null:o),1400)},[]),Er=a.useCallback(t=>{oe(t),window.setTimeout(()=>oe(o=>o===t?null:o),1400)},[]);a.useEffect(()=>{Lt(Od,Te)},[Te]),a.useEffect(()=>{Lt(Ud,_t)},[_t]),a.useEffect(()=>{Lt(Hd,H)},[H]),a.useEffect(()=>{Ds(Ni,ve,Mg)},[ve]),a.useEffect(()=>(Hl().catch(()=>{}),hd(t=>{t.type==="pinned-explorer-roots"&&zl(t.pinnedExplorerRoots)})),[Hl,zl]);const dc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Sa=a.useRef(null),bn=a.useRef(null),[uc,Qo]=a.useState(!1);a.useEffect(()=>{if(!r)return;Qo(!1);let t=!1;um().then(c=>{t||(Sa.current=c.text,Ge(y=>c.text&&c.text!==y?c.text:y),Qo(!0))}).catch(()=>{t||Qo(!0)});const o=hd(c=>{c.type==="context-draft"&&c.origin!==dc.current&&(Sa.current=c.text,Ge(c.text))});return()=>{t=!0,o(),bn.current!==null&&(window.clearTimeout(bn.current),bn.current=null)}},[r]),a.useEffect(()=>{if(!uc||Sa.current===ve)return;bn.current!==null&&window.clearTimeout(bn.current);const t=ve;bn.current=window.setTimeout(()=>{bn.current=null,fm(t,dc.current).then(()=>{Sa.current=t}).catch(()=>{})},500)},[ve,uc]);const Kn=a.useCallback((t,o,c)=>{if(t){if(hm(c?t+c:t)){Jo(o);return}Te?(Ge(y=>_p(y,t)+(c??"")),window.matchMedia("(pointer: coarse)").matches||(Bt(!1),hr(y=>y+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:c?t+c:t,focus:!0}})),Jo(o)}},[Te,Jo]),ja=a.useCallback(t=>{const o=kn(t,x);return Tm(o,x)},[x]),Zo=Cu(Er),Gt=a.useCallback((t,o)=>{const c=kn(t,x);Kn(Im(c,x),o??`path:${c}`)},[x,Kn]),eh=a.useCallback(async t=>{ua(!0);try{await Dm(t,Wa,o=>{Gt(o,`path:${o}`)}),ne&&!Te&&l()}catch(o){vt(o instanceof Error?o.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>vt(null),4e3)}finally{ua(!1)}},[Te,Gt,ne,l,i]),Ra=a.useRef(!0),ei=a.useRef(n);ei.current=n,a.useEffect(()=>(Ra.current=!0,()=>{Ra.current=!1}),[]);const th=a.useCallback(t=>{Fm.getState().enqueue(t,n??null,x||"/",o=>{if(Te&&Ra.current&&ei.current===n)Gt(o);else return yd(o,n)})},[n,x,Te,Gt]),rh=a.useCallback(async t=>{const c=(await Wa("/tmp",[t])).files[0]?.path;if(!c)throw new Error("截图上传未返回文件路径");Te&&Ra.current&&ei.current===n?Gt(c):await yd(c,n)},[Te,Gt,n]),$r=a.useCallback((t,o)=>{if(!t)return;const c=t.includes(`
|
|
1659
|
+
`})(),kr=`path:${Ge}`,Sr=E?`path:${Ge}:${E.start}-${E.end}`:kr,Fr=L===kr,_r=L===Sr,Cn=T===kr,ts=T===Sr,Xr=_r||ts,Jt=E?E.start===E.end?`L${E.start}`:`L${E.start}-${E.end}`:null,Br=A=>{const z=re.current;if(!z)return;const ue=z.getBoundingClientRect(),Se=A.currentTarget.getBoundingClientRect(),et=A.clientX||Se.left+Se.width/2,Ve=(A.clientY||Se.top+Se.height/2)-ue.top+z.scrollTop,_e=m?116:132,qe=z.scrollLeft+Math.max(8,z.clientWidth-_e),ft=Math.min(Math.max(8,et-ue.left+z.scrollLeft+10),qe);ye({top:Ve,left:ft})},rs=(A,z)=>{Gi()||(Br(A),$(ue=>{const Se=Ki(ue,z,z);return Se||ye(null),Se}))},ns=(A,z,ue)=>{Br(A),$(Se=>{const et=Ki(Se,z,ue);return et||ye(null),et})},jr=(A,z,ue,Se)=>{Se==="end"&&Br(A),$({start:z,end:ue})},nr=A=>{const{scrollTop:z,scrollLeft:ue}=A.currentTarget;R(z),Pi(i,n,{top:z,left:ue,markdownTop:z})},be=A=>{if(A.directory){g?.(A.path);return}if(A.path===Ge||C.kind==="text"&&A.path===C.sourcePath){A.fragment&&jn(A.fragment);return}le(z=>[...z,Ge]),We.current=A.path,Ne(A.fragment),$(null),O(A.path)},Qt=()=>{const A=ee[ee.length-1];A&&(le(z=>z.slice(0,-1)),We.current=A,Ne(null),$(null),O(A))},Jr=A=>{const{scrollTop:z,scrollLeft:ue}=A.currentTarget;Pi(i,n,{top:z,left:ue})},Qr=()=>{if(r){r(Dr,Sr);return}E&&l(Dr,Sr)},ss=async()=>{if(!(!Ge||Te.status==="pending")&&!(C.kind==="loading"||C.kind==="error")){ke({status:"pending"});try{await xm(Ge),ke({status:"idle"})}catch(A){ke({status:"error",message:A instanceof Error?A.message:p("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[ve.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${m&&(Ut||Xt)?"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:[m&&h&&e.jsx("button",{type:"button",onClick:h,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":p("rightSidebar.backToFileList"),title:p("rightSidebar.backToFileList"),children:e.jsx(xu,{size:16})}),ee.length>0&&e.jsxs("button",{type:"button",onClick:Qt,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 ${m?"w-9":"px-2.5"}`,"aria-label":p("rightSidebar.backToPreviousPreview"),title:p("rightSidebar.backToPreviousPreview"),children:[e.jsx(Os,{size:15}),!m&&e.jsx("span",{className:"text-[11px] font-medium",children:p("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ge,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Pt.name}),Pt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Pt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Tr&&e.jsx("button",{type:"button",onClick:rt?br:Rn,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 ${rt?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":p("rightSidebar.findInFile"),title:`${p("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Jn,{size:14})}),wr&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{b&&w?.(),De(A=>{const z=A==="preview"?"source":"preview";return Lt(Fu,z),z}),$(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 ${m?"w-9 px-0":"px-3"}`,"aria-label":p(pe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:p(pe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:m?pe==="preview"?e.jsx(qi,{size:14}):e.jsx(Vi,{size:14}):p(pe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Ys&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{q(A=>{const z=A==="preview"?"source":"preview";return Up(i,n,z),z}),$(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 ${m?"w-9 px-0":"px-3"}`,"aria-label":p(N==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:p(N==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:m?N==="preview"?e.jsx(qi,{size:14}):e.jsx(Vi,{size:14}):p(N==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Xt&&e.jsx("button",{type:"button",onClick:()=>{he.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":p(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:p(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(vu,{size:15})}),!m&&e.jsx("button",{type:"button",onClick:()=>s(Ge,kr),...ve(xr,kr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Fr||Cn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:p("rightSidebar.insertReference",{reference:xr}),children:p(Cn?"rightSidebar.copied":Fr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(xr)},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:p("rightSidebar.copyReference",{reference:xr}),"aria-label":p("rightSidebar.copyFileRef"),children:e.jsx(am,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ss()},disabled:Te.status==="pending"||C.kind==="loading"||C.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??p("rightSidebar.downloadFailed"):p("rightSidebar.downloadFile"),"aria-label":p("rightSidebar.downloadFile"),children:Te.status==="pending"?e.jsx(Nt,{size:13,className:"animate-spin"}):e.jsx(Lm,{size:14})})]})]}),rt&&Tr&&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(Jn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:ae,type:"search",value:oe,onChange:A=>Ie(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),bt(A.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:p("rightSidebar.findInFilePlaceholder"),"aria-label":p("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:ze.length>0?`${Bt+1}/${ze.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>bt(-1),disabled:ze.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":p("rightSidebar.previousSearchMatch"),title:`${p("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(pu,{size:13})}),e.jsx("button",{type:"button",onClick:()=>bt(1),disabled:ze.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":p("rightSidebar.nextSearchMatch"),title:`${p("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Pm,{size:13})}),e.jsx("button",{type:"button",onClick:br,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":p("rightSidebar.closeFileSearch"),title:`${p("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Yt,{size:13})})]}),yr&&!(m&&(Ut||Xt))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[yr.size!==null&&e.jsx("span",{children:p("rightSidebar.byteCount",{count:yr.size.toLocaleString()})}),"truncated"in yr&&yr.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:p("rightSidebar.previewTruncated")}),"mimeType"in yr&&e.jsx("span",{children:yr.mimeType}),"dimensions"in C&&C.dimensions&&e.jsxs("span",{children:[C.dimensions.width," × ",C.dimensions.height]})]}),!(m&&(Ut||Xt))&&!So&&C.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:Yr?p("rightSidebar.edaPickHint"):qs?p("rightSidebar.csvTablePreview"):At||Zn?p("rightSidebar.kicadProjectPickHint"):Mt?p("rightSidebar.videoPreviewHint"):Xs?p("rightSidebar.imagePreviewHint"):Ut?E?p("rightSidebar.selectedLineHint",{lineLabel:Jt??""}):p("rightSidebar.markdownPreviewHint"):Xt?p("rightSidebar.htmlPreviewHint"):E?p("rightSidebar.selectedLineHint",{lineLabel:Jt??""}):p("rightSidebar.multiLineHint")})})]}),C.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:C.mode==="eda"?p("rightSidebar.edaLoading"):C.mode==="image"?p("rightSidebar.loadingImage"):C.mode==="model3d"?p("rightSidebar.model3dLoading"):C.mode==="video"?p("rightSidebar.loadingVideo"):"Loading file…"}):C.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:C.message}),e.jsx("button",{type:"button",onClick:Sn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:p("common.retry")})]}):C.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:p("rightSidebar.binaryPreviewHint")})}):C.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:C.meta.mimeType==="image/svg+xml"?e.jsx(Pu,{blobUrl:C.objectUrl,filePath:Ge,viewLabel:"SVG 文件",onInsertAnnotation:u}):e.jsx(Ff,{src:C.objectUrl,alt:Pt.name,vector:!1,onLoad:A=>{const z=A.currentTarget;K(ue=>ue.kind==="image"?{...ue,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:ue)},onError:()=>K({kind:"error",message:p("rightSidebar.imageLoadFailed")})})}):C.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(Zp,{url:C.url,onLoadError:()=>K({kind:"error",message:p("rightSidebar.videoLoadFailed")})})}):C.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(og,{blobUrl:C.objectUrl,filePath:C.sourcePath,view:C.view,board:Ge.toLowerCase().endsWith(".kicad_pcb"),onViewChange:te,onInsertAnnotation:r??u,onRefresh:Sn,interactive3d:xe?e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.model3dLoading")}),children:e.jsx(Gd,{blobUrl:xe.objectUrl,ext:".glb",fileName:Pt.name,filePath:xe.sourcePath,features:null,onInsertFeature:r??u,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:A=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(A)?A:"PCB板体/铜箔/丝印",active:C.view==="pcb-3d"})}):void 0})}):C.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.model3dLoading")}),children:e.jsx(Gd,{blobUrl:C.objectUrl,ext:C.ext,fileName:Pt.name,filePath:C.sourcePath,features:P,onInsertFeature:r??u,onRefresh:Sn})})}):C.kind==="text"&&qs?e.jsx(cg,{content:C.content,filePath:Ge,onInsertAnnotation:r??u},Ge):C.kind==="text"&&(At||Zn)?e.jsx(fg,{content:C.content,filePath:Ge,localState:Zn,onInsertAnnotation:r??u},Ge):Ut?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:nr,style:{touchAction:"pan-x pan-y"},children:[e.jsx(Cf,{content:C.content,filePath:C.sourcePath,rootPath:i,lineRange:E,onLineRangeClick:ns,onLineRangeDrag:jr,scrollTop:Be,outlineOpen:b,outlineCloseSignal:f,onOutlineOpen:j,onOutlineClose:w,lightboxOpen:M,lightboxCloseSignal:I,onLightboxOpen:_,onLightboxClose:B,onLocalLinkOpen:be}),E&&ie&&e.jsxs("button",{type:"button",onClick:Qr,...ve(Dr,Sr),style:{top:ie.top,left:ie.left,transform:"translateY(-50%)"},className:Md(m,Xr),title:`Insert markdown reference: ${Ir}`,children:[e.jsx(uo,{size:m?13:11}),ts?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Jt??""})]})]}):Xt?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(yg,{ref:he,src:om(Ge),title:`${Pt.name} preview`,exitFullscreenLabel:p("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ze},`${Ge}:${hr}:${pr}`)}):C.kind==="text"?e.jsxs("div",{ref:re,onScroll:Jr,className:`${hl} 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:[vr.length>0?e.jsx("div",{className:"min-w-full",children:vr.map((A,z)=>{const ue=z+1,Se=!!(E&&ue>=E.start&&ue<=E.end),et=Ae&&Ae.length===vr.length?Ae[z]:null;return e.jsxs("div",{ref:Fe=>{Fe?V.current.set(ue,Fe):V.current.delete(ue)},role:"button","data-file-preview-line":ue,tabIndex:0,onClick:Fe=>rs(Fe,ue),onKeyDown:Fe=>{Fe.key!=="Enter"&&Fe.key!==" "||(Fe.preventDefault(),rs(Fe,ue))},style:{gridTemplateColumns:`${Vs}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Se?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${xr}:${ue}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Se?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ue}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:et??(A||" ")})]},z)})}):"Empty file.",E&&ie&&e.jsxs("button",{type:"button",onClick:Qr,...ve(Dr,Sr),style:{top:ie.top,left:ie.left,transform:"translateY(-50%)"},className:Md(m,Xr),title:`Insert code reference: ${Ir}`,children:[e.jsx(uo,{size:m?13:11}),ts?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Jt??""})]})]}):null]})}function nx({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:b,onOpenRightSidebarFilePreview:f,onCloseRightSidebarFilePreview:j,rightSidebarRepoPickerOpen:w=!1,rightSidebarRepoPickerCloseSignal:M,onOpenRightSidebarRepoPicker:I,onCloseRightSidebarRepoPicker:_,markdownOutlineOpen:B=!1,markdownOutlineCloseSignal:E,onOpenMarkdownOutline:$,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T=!1,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p}){const{t:i,locale:O}=St(),[C,K]=a.useState(""),[de,te]=a.useState(null),xe=J(t=>t.rightSearchOpen),W=J(t=>t.setRightSearchOpen),X=J(t=>t.rightSidebarLayoutPreference),P=J(t=>t.setRightSidebarLayoutPreference),[F,V]=a.useState(()=>Xg()),[re,ie]=a.useState("."),[ye,pe]=a.useState(""),[De,N]=a.useState(!1),[q,he]=a.useState(!1),[Le,Ze]=a.useState(!1),[Pe,at]=a.useState(!1),Be=a.useDeferredValue(C),[R,ee]=a.useState(null),[le,Ee]=a.useState([]),[Ne,We]=a.useState([]),ce=J(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Ae=J(t=>t.setActiveGitRepo),[tt,Te]=a.useState(null),[ke,rt]=a.useState(null),[nt,oe]=a.useState(null),[Ie,ze]=a.useState(()=>mt(Od,Is)??!1),[_t,Bt]=a.useState(()=>mt(Ud,Is)??!1),[H,ae]=a.useState(()=>mt(Hd,Is)??!1),[ve,Ke]=a.useState(()=>mt(Ni,Gg)??""),[pt,hr]=a.useState(0),[mr,Ot]=a.useState(!1),[pr,gr]=a.useState(!1),Sn=a.useRef(null),jn=a.useRef(null),[Tr,br]=a.useState(!1),[Rn,bt]=a.useState(null),[Ge,Pt]=a.useState(null),[xr,vr]=a.useState(()=>Vd(Ri)),[Vs,yr]=a.useState(()=>Vd(Bd)),[wr,qs]=a.useState(()=>Wg()),[At,Zn]=a.useState(()=>Kg()),[Ut,Ys]=a.useState(()=>qg()),Xt="words",[Xs,So]=a.useState(0),[Mt,Yr]=a.useState([]),[es,Ir]=a.useState([]),[Dr,kr]=a.useState(!1),[Sr,Fr]=a.useState(null),[_r,Cn]=a.useState([]),[ts,Xr]=a.useState(!1),[Jt,Br]=a.useState([]),[rs,ns]=a.useState([]),[jr,nr]=a.useState(!1),[be,Qt]=a.useState(null),[Jr,Qr]=a.useState([]),[ss,A]=a.useState({}),z=a.useRef(0),[ue,Se]=a.useState(0),[et,Fe]=a.useState(!1),[Ve,_e]=a.useState(null),[qe,ft]=a.useState(null),[Nn,sr]=a.useState(null),[as,Zr]=a.useState(null),[en,Or]=a.useState(!1),[tn,rn]=a.useState(""),os=a.useDeferredValue(tn),[Q,Ye]=a.useState({}),[Tt,ar]=a.useState([]),[Js,is]=a.useState(!1),[Qs,ls]=a.useState(!1),[Sl,Mn]=a.useState(null),[jo,En]=a.useState(!1),or=a.useRef(null),Ur=a.useRef(0),jl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[_f,Zs]=a.useState(null),[cs,Rl]=a.useState(()=>mt(Ci,Is)??!1),[Ro,Co]=a.useState(!1),[ea,No]=a.useState([]),[Zt,ta]=a.useState({}),[Et,ra]=a.useState({}),[nn,Mo]=a.useState({}),[Cl,Nl]=a.useState(()=>new Set),[Xe,sn]=a.useState(null),[Eo,an]=a.useState(null),[Bf,Rr]=a.useState(!1),[Ml,Cr]=a.useState(0),[,$o]=a.useState(0),[Lo,na]=a.useState(!1),[ir,Po]=a.useState(!1),[Of,El]=a.useState(()=>J.getState().rightTab==="diff"),[Ao,$l]=a.useState(()=>J.getState().rightTab==="android"),[Hr,Ll]=a.useState(!1),sa=vi(t=>t.docks[wi]),Uf=!!sa,[Ue,ds]=a.useState(null),[$n,us]=a.useState(null),[xt,on]=a.useState(null),[Pl,vt]=a.useState(null),[Ln,Al]=a.useState(null),[To,Hf]=a.useState(()=>Date.now()),[zf,Wf]=a.useState(!1),[ln,aa]=a.useState(!1),[oa,Tl]=a.useState(""),[Pn,ia]=a.useState(""),[cn,la]=a.useState(""),[dn,ca]=a.useState(""),[Il,An]=a.useState(null),[da,ua]=a.useState(!1),[Dl,Io]=a.useState(!1),[Fl,_l]=a.useState(!1),[fa,Gf]=a.useState({key:null,nonce:0}),Bl=a.useRef(null),Ol=a.useRef(null),ne=vm(s,h,X),Do=Vu(ne,h,Ut),[Fo,_o]=a.useState(()=>nb(s)),Bo=J(t=>t.rightTab),er=J(t=>t.setRightTab),x=J(t=>t.rootPath),Tn=J(t=>t.explorerRoot),Ul=J(t=>t.pinnedExplorerRootsCache),Hl=J(t=>t.hydratePinnedExplorerRoots),zl=J(t=>t.syncPinnedExplorerRoots),Ht=J(t=>t.setExplorerRoot),Wl=J(t=>t.resetExplorerToProject),In=J(t=>t.pinExplorerRoot),un=J(t=>t.unpinExplorerRoot),ot=J(t=>t.selectedFilePath),it=J(t=>t.selectFile),Oo=J(t=>t.showHiddenFiles),Kf=J(t=>t.toggleShowHiddenFiles),Uo=J(t=>!!(x&&t.nestedGitScanRoots[x])),Re=J(t=>t.changedFiles),ha=J(t=>t.setChangedFiles),ma=J(t=>t.invalidateDirectoryCache),Vf=J(t=>t.setDirectorySortMode),Gl=J(t=>t.applyFileWatchEvents),Kl=J(t=>t.reconcileDirectoryCache),Vl=J(t=>t.bumpFileWatchEpoch),zr=J(t=>t.gitBundleLoading),ql=J(t=>t.gitBundleSlow),fn=J(t=>t.gitBundleError),Dn=J(t=>t.gitBundleLastLoadedAt),Yl=J(t=>t.beginGitBundleLoading),Xl=J(t=>t.setGitBundleSlowFor),Ho=J(t=>t.finishGitBundleLoading),pa=J(t=>t.resetGitBundleLoading),zo=J(t=>t.setGitBundleError),Jl=J(t=>t.markGitBundleLoaded),ge=Tn??x,Ql=a.useMemo(()=>ge?Rg(ge,re):"",[ge,re]),fs=a.useMemo(()=>jg(ye),[ye]),Zl=a.useMemo(()=>({excludePatterns:fs,caseSensitive:q,wholeWord:Le,regex:Pe}),[q,fs,Pe,Le]),ga=J(t=>ge?t.fileSortModes[ge]??"name":"name"),ec=J(t=>!!(ge&&t.directoryCache.has(ge))),Fn=a.useRef(null),jt=a.useRef(0),[tc]=a.useState(()=>++Jb),Nr=a.useRef(null),Wr=a.useRef(null),ba=a.useRef(0),zt=a.useRef(new Map),Wt=a.useRef(new Map),lr=a.useRef(new Set),hn=a.useRef(new Set),mn=a.useRef(0),Gr=a.useRef(null),_n=a.useRef(0),Bn=a.useRef(null),On=a.useRef(0),Kr=a.useRef(null),Wo=a.useRef(new Set),Go=a.useRef(null),Ko=a.useRef(null),xa=a.useRef(null),Vo=a.useRef(null),qo=a.useRef(null),hs=a.useRef(new Set);a.useEffect(()=>{if(Ln===null)return;const t=Math.max(0,Date.now()-Ln),o=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,c=Math.max(50,o-t%o),y=window.setTimeout(()=>Hf(Date.now()),c);return()=>window.clearTimeout(y)},[To,Ln]);const va=a.useRef(null),Mr=a.useRef(null),ya=a.useRef(null),ms=a.useRef(null),Ce=a.useCallback(t=>J.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=o=>{const c=tx(o.target);c&&no("global_change_row_event",{...rx(o),selectionPath:c.dataset.diffSelectionPath,filePath:c.dataset.diffFilePath,absolutePath:c.dataset.diffAbsolutePath,repoRoot:c.dataset.diffRepoRoot,status:c.dataset.diffStatus,selectedFilePath:J.getState().selectedFilePath,rightTab:J.getState().rightTab,activeGitRepoRoot:ce,changedFiles:J.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const rc=a.useCallback(async(t=x??void 0)=>{if(!t)return null;if(lr.current.has(t)||hn.current.has(t))return dt("untracked_skip_cached",{cwd:t,rootPath:x,completed:lr.current.has(t),running:hn.current.has(t)}),null;const o=x,c=ba.current+1;ba.current=c,zt.current.set(t,c);const y=`right-sidebar-git-untracked:${t}`,v=new AbortController;Wt.current.set(t,v),hn.current.add(t),dt("untracked_start",{requestId:c,cwd:t,rootPath:x});try{let k=await dd(t,v.signal,y),S=0;for(;k.status==="running"&&S<120;){if(zt.current.get(t)!==c||v.signal.aborted)return dt("untracked_stale_result",{requestId:c,activeRequestId:zt.current.get(t),cwd:t,status:k.status}),null;if(!Ce(o))return dt("untracked_root_changed",{requestId:c,cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath}),null;await new Promise(Z=>window.setTimeout(Z,S<10?1e3:3e3)),S+=1,k=await dd(t,v.signal,y)}if(zt.current.get(t)!==c||!Ce(o))return dt("untracked_stale_result",{requestId:c,activeRequestId:zt.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return ha($f(J.getState().changedFiles,k.files)),k.files.length>0&&Ee(Z=>{const $e=new Map(Z.map(je=>[je.root,je])).get(t);if(!$e)return Z;const Je=Bb($e.files,k.files),G=Z.map(je=>je.root===t?{...je,files:Je,context:je.context?{...je.context,changedFiles:Je.map(Me=>({path:Me.path,absolutePath:Me.absolutePath,status:Me.status})),truncated:!1}:je.context,untrackedDeferred:!1}:je);We(Lf(G,x));const Y=G.find(je=>je.root===x);return Y?.context&&ee(je=>je?.root===Y.root?{...je,...Y.context}:je),G}),lr.current.add(t),dt("untracked_apply",{requestId:c,cwd:t,files:k.files.length}),k;const se=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return lr.current.add(t),dt("untracked_error",{requestId:c,cwd:t,message:se,code:k.code,status:k.status}),null}catch(k){if(zt.current.get(t)!==c||!Ce(o)||fr(k))return dt("untracked_aborted",{requestId:c,activeRequestId:zt.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const S=k instanceof Error?k.message:"Failed to scan untracked files";return lr.current.add(t),dt("untracked_error",{requestId:c,cwd:t,message:S}),null}finally{Wt.current.get(t)===v&&Wt.current.delete(t),zt.current.get(t)===c&&zt.current.delete(t),hn.current.delete(t)}},[R,Ce,x,ha]),tr=a.useMemo(()=>{const t=new Set(Ne.map(c=>c.root)),o=_r.filter(c=>t.has(c));return o.length>0?o:ce?[ce]:[]},[ce,_r,Ne]),nc=tr.length===0,pn=a.useMemo(()=>tr.map(t=>le.find(o=>o.root===t)).filter(t=>!!t),[tr,le]),qf=a.useMemo(()=>Ne.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[Ne]),cr=a.useCallback(async()=>{if(!x){Yr([]),Ir([]);return}const t=x,o=_n.current+1;_n.current=o,Bn.current?.abort();const c=new AbortController;Bn.current=c,kr(Mt.length===0),Fr(null);try{const y=tr.length>0?await Promise.all(tr.map(v=>ud({workspaceRoot:x,repoRoot:v},c.signal))).then(v=>({records:v.flatMap(k=>k.records),walkthroughs:v.flatMap(k=>k.walkthroughs??[])})):await ud({workspaceRoot:x},c.signal);if(_n.current!==o||!Ce(t))return;Yr(y.records),Ir(y.walkthroughs??[])}catch(y){if(_n.current!==o||!Ce(t)||fr(y))return;Fr(y instanceof Error?y.message:"Failed to load change audit explanations")}finally{Bn.current===c&&(Bn.current=null),_n.current===o&&Ce(t)&&kr(!1)}},[Mt.length,tr,Ce,x]),wa=a.useCallback(async(t,o,c)=>{if(!t&&!x){Br([]),ns([]);return}const y=x,v=On.current+1;On.current=v,Kr.current?.abort();const k=new AbortController;Kr.current=k;try{const S=t?[t]:Array.from(new Set([x,...le.map(Z=>Z.root)].filter(Z=>!!Z))),se=await Promise.all(S.map(Z=>lm({repoRoot:Z,baseRef:o,branchName:c},k.signal))).then(Z=>{const me=new Map,$e=new Map;for(const Je of Z){for(const G of Je.records)me.set(G.id,G);for(const G of Je.walkthroughs??[])$e.set(G.id,G)}return{records:Array.from(me.values()),walkthroughs:Array.from($e.values())}});if(On.current!==v||!Ce(y))return;Br(se.records),ns(se.walkthroughs??[])}catch(S){if(On.current!==v||!Ce(y)||fr(S))return;console.warn("[RightSidebar] Failed to load branch explanations",S)}finally{Kr.current===k&&(Kr.current=null)}},[le,Ce,x]),Un=a.useCallback((t,o={})=>{if(!Ce(x)){dt("apply_skipped_root_changed",{expectedRootPath:x,currentRootPath:J.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}dt(t.files.length===0?"empty_bundle":"apply",{rootPath:x,available:t.available,files:t.files.length,repositories:t.repositories?.map(Y=>({root:Y.root,relativeRoot:Y.relativeRoot,files:Y.files.length,available:Y.available,error:Y.error})),repoFilters:t.repoFilters?.map(Y=>({root:Y.root,label:Y.label,count:Y.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let c=qu(t),y=t.repoFilters??[],v=t.files;const k=J.getState().changedFiles;if(!!(o.cacheOnly&&!t.cached&&t.files.length===0&&c.length===0)&&(k.size>0||le.length>0||R)){dt("cache_only_apply_skipped_empty_backend_cache",{rootPath:x,currentFiles:k.size,currentRepositories:le.length});return}const se=c.some(Y=>Y.deferred);if(se&&!o.replaceWorkspace){const Y=new Set(c.filter(Me=>!Me.deferred||Me.root===x).map(Me=>Me.root));v=[...Array.from(k.values()).filter(Me=>!Y.has(gt(Me,x)??"")),...t.files]}const Z=au(k.values(),x),me=au(t.files,x),$e=c.some(Y=>Y.root!==x);if(!!(o.background&&!se&&!o.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||Z>0&&me===0&&!$e))){dt("background_apply_skipped_degraded_bundle",{rootPath:x,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:Z,nextNestedCount:me,nextRepositories:c.map(Y=>({root:Y.root,relativeRoot:Y.relativeRoot,files:Y.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(o.replaceRepoRoot){const Y=Pf(k.values(),le,t,o.replaceRepoRoot,x);v=Y.files,c=Y.repositories,y=Y.repoFilters}if(ha(Ef(v)),Ee(Y=>{if(!se||o.replaceWorkspace)return c;const je=new Map(Y.map(Me=>[Me.root,Me]));return c.map(Me=>{const He=je.get(Me.root);return!Me.deferred||!He?Me:{...Me,available:He.available,files:He.files,context:He.context,deferred:He.deferred,untrackedDeferred:He.untrackedDeferred,error:He.error}})}),We(y),qo.current=x,o.syncActiveRepo!==!1){const{contextKey:Y,activeGitRepos:je}=J.getState(),Me=Y?je[Y]??null:null,He=o.activeRepoRoot!==void 0?o.activeRepoRoot:Me,Oe=Jg({...t,repositories:c,repoFilters:y},He);Ae(Oe)}typeof t.cacheUpdatedAt=="number"&&Al(t.cacheUpdatedAt),ee(Y=>{if(o.replaceRepoRoot&&o.replaceRepoRoot!==x)return Y;if(!t.context)return null;const je=Y?.root??x;return!Y?.available||je!==(t.context.root??x)?t.context:{...Y,...t.context}}),o.reloadDiff&&So(Y=>Y+1);const G=J.getState().selectedFilePath;if(G&&!G.startsWith("/")&&!v.some(Y=>Y.path===G||Y.absolutePath===G)&&it(null),vr(Y=>{const je=new Set(v.map(He=>gt(He,x)).filter(Boolean)),Me=new Set;for(const He of Y)je.has(He)&&Me.add(He);return Ei(Ri,Me),Me}),o.loadDeferred!==!1){const Y=c.filter(je=>je.untrackedDeferred&&je.root).map(je=>je.root);for(const je of Y)rc(je)}o.loadAudit!==!1&&cr()},[Ce,cr,rc,x,it,Ae,ha]);a.useEffect(()=>{pa(),Go.current=null,Ko.current=x;const t=[],o=[];jt.current+=1,mn.current+=1,ba.current+=1,Nr.current?.abort(),Ct(Ps(Wr.current?.cwd??x??void 0)),Wr.current=null,Nr.current=null,Gr.current?.abort(),Ct("right-sidebar-git-details"),Gr.current=null;for(const S of Wt.current.values())S.abort();for(const S of Wt.current.keys())Ct(`right-sidebar-git-untracked:${S}`);Wt.current.clear(),zt.current.clear(),_n.current+=1,Bn.current?.abort(),Bn.current=null,On.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,or.current?.abort(),Ct("right-sidebar-recent-commits"),or.current=null,Yr([]),Ir([]),kr(!1),Fr(null),Cn([]),Xr(!1),Br([]),ns([]),nr(!1),Qt(null),Fe(!1),_e(null),ft(null),sr(null),Zr(null),Or(!1),rn(""),ar([]),is(!1),ls(!1),Mn(null),En(!1),Zs(null),sn(null),an(null),Rl(!1),Lt(Ci,!1),Co(!1);const c=x?qd()[x]:null,y=c?.previewEntries??[],v=c?.selectedPreviewKey??null,k=v?y.find(S=>S.key===v)??null:null;++z.current,Fe(!1),No(c?.selectedRepoRoots??[]),ta(c?.repoTargetBranches??{}),ra(c?.repoBaseBranches??{}),Qr(y),A(c?.previewScrollTops??{}),k&&c?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(Qt(k.diff),sn(k.key),an(c.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),nr(!0)),Mo(c?.repoIncludeUncommitted??Object.fromEntries(Object.keys(c?.repoTargetBranches??{}).map(S=>[S,c?.includeUncommitted??!0]))),Go.current=x,aa(!1),lr.current.clear(),hn.current.clear(),ds(null),us(null),on(null),vt(null),Al(null),Ee(t),We(o),ee(null),Vo.current=null,qo.current=null,hs.current.clear()},[pa,x]);const It=a.useCallback(async(t=x??void 0,o={})=>{if(!t)return null;const c=x,y=jt.current;if(await hp(()=>Promise.all([J.getState().hydrateNestedGitScanRoots(),J.getState().hydrateActiveGitRepos()]).then(()=>{})),jt.current!==y||!Ce(c))return null;const v=t===x&&$s(x),k=o.includeNested??v,S=o.refresh??o.reloadDiff??!1,se=o.cacheOnly??!1,Z=o.background??!1,me=k&&(o.discoverOnly??!1);S&&lr.current.clear();const $e=Wr.current;if($e&&$e.cwd===t&&$e.includeNested===k&&$e.refresh===S&&$e.cacheOnly===se&&$e.discoverOnly===me)return dt("reuse_pending",{cwd:t,includeNested:k,refresh:S,cacheOnly:se,discoverOnly:me}),$e.promise;const Je=jt.current+1;jt.current=Je;const G=`right-sidebar:${tc}:${Je}`;Nr.current?.abort();const Y=Ps(t);Ct(Y);const je=new AbortController;Nr.current=je;let Me=null;Z||Yl(G),zo(null),dt("start",{requestId:Je,cwd:t,rootPath:x,requestSlotId:Y,includeNested:k,refresh:S,cacheOnly:se,background:Z,existingChanges:Re.size,lastLoadedAt:Dn}),!Z&&typeof window<"u"&&(Me=window.setTimeout(()=>{jt.current===Je&&Xl(G,!0)},Tg));const He=(async()=>{const Oe=await yi(t,je.signal,{includeNested:k,refresh:S,cacheOnly:se,discoverOnly:me,action:S?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:Y,requestTimeoutMs:S?null:void 0});if(Hb(Oe)){if(dt("cancelled_result_ignored",{requestId:Je,activeRequestId:jt.current,cwd:t,error:Oe.error??Oe.context?.error}),je.signal.aborted)return null;throw new Error(Oe.error??Oe.context?.error??"Failed to load Git changes")}return jt.current!==Je||!Ce(c)?(dt("stale_result",{requestId:Je,activeRequestId:jt.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,files:Oe.files.length,repositories:Oe.repositories?.length??0}),null):(Un(Oe,{reloadDiff:o.reloadDiff,syncActiveRepo:o.replaceWorkspace?!0:k,background:Z,cacheOnly:se,replaceRepoRoot:o.replaceRepoRoot,replaceWorkspace:o.replaceWorkspace}),Oe)})();Wr.current={cwd:t,includeNested:k,refresh:S,cacheOnly:se,discoverOnly:me,promise:He};try{const Oe=await He;return jt.current===Je&&Oe&&Ce(c)?Jl({cached:Oe.cached,stale:Oe.stale,cacheAgeMs:Oe.cacheAgeMs,nestedDeferred:!k||Oe.nestedDeferred,untrackedDeferred:Oe.untrackedDeferred}):jt.current===Je&&Ce(c)&&Ho(G),Oe}catch(Oe){return jt.current!==Je||!Ce(c)||je.signal.aborted?(dt("aborted",{requestId:Je,activeRequestId:jt.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,message:Oe instanceof Error?Oe.message:String(Oe)}),null):(dt("error",{requestId:Je,cwd:t,includeNested:k,refresh:S,background:Z,message:Oe instanceof Error?Oe.message:String(Oe)}),Z||(ee(null),zo(Oe instanceof Error?Oe.message:"Failed to load Git changes")),null)}finally{Me!==null&&window.clearTimeout(Me),Nr.current===je&&(Nr.current=null),Wr.current?.promise===He&&(Wr.current=null),!Z&&jt.current===Je&&Ce(c)&&Ho(G)}},[Un,Yl,Re.size,Ho,tc,Dn,Ce,Jl,x,zo,Xl]),ps=a.useCallback(async()=>{x&&await It(x,{reloadDiff:!0,refresh:!0})},[It,x]),Yo=a.useCallback(async(t=x??void 0)=>{if(!t)return null;const o=x,c=mn.current+1;mn.current=c,Gr.current?.abort(),Ct("right-sidebar-git-details");const y=new AbortController;Gr.current=y,aa(!0);try{const v=await fd(t,y.signal,"load_git_details","right-sidebar-git-details");return mn.current!==c||!Ce(o)?null:(Ee(k=>k.map(S=>S.root===v.root?{...S,available:v.available,context:v,error:v.error}:S)),ee(k=>k?.root&&v.root&&k.root!==v.root?k:!k?.available||!v.available?v:{...k,...v}),v)}catch(v){return fr(v)||!Ce(o)||mn.current===c&&vt(v instanceof Error?v.message:"Failed to load Git details"),null}finally{Gr.current===y&&(Gr.current=null),mn.current===c&&Ce(o)&&aa(!1)}},[Ce,x]);a.useEffect(()=>{if(!r){jt.current+=1,pa(),Vo.current=null,mn.current+=1,ba.current+=1,Nr.current?.abort(),Ct(Ps(Wr.current?.cwd??x??void 0)),Wr.current=null,Nr.current=null,Gr.current?.abort(),Ct("right-sidebar-git-details"),Gr.current=null;for(const t of Wt.current.values())t.abort();for(const t of Wt.current.keys())Ct(`right-sidebar-git-untracked:${t}`);Wt.current.clear(),zt.current.clear(),On.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,or.current?.abort(),Ct("right-sidebar-recent-commits"),or.current=null,aa(!1),Fe(!1),_e(null),ft(null),sr(null),Zr(null),Or(!1),rn(""),ar([]),is(!1),ls(!1),Mn(null),En(!1),K(""),W(!1),bt(null),Po(!1),ne&&El(!1)}},[ne,r,pa,W]),a.useEffect(()=>{if(!xe)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[xe]),a.useEffect(()=>{ne||Rr(!1)},[ne]);const gs=a.useCallback(t=>{$o(t);const o=ya.current;o&&(o.update(),o.slideTo(t,0),window.requestAnimationFrame(()=>{o.update(),o.slideTo(t,0)}))},[]);a.useEffect(()=>{if(ne)if(Rr(m),m&&ot){Cr(1);const t=Mr.current;t&&(t.update(),t.activeIndex!==1&&(ms.current=1,t.slideTo(1,0)))}else{Cr(0);const t=Mr.current;t&&t.activeIndex!==0&&(ms.current=0,t.slideTo(0,0)),bt(null)}},[ne,m,x,ot]),a.useEffect(()=>{if(b!==void 0&&!m){Cr(0);const t=Mr.current;t&&t.activeIndex!==0&&(ms.current=0,t.slideTo(0,0)),Rr(!1),bt(null)}},[b,m]),a.useEffect(()=>{M!==void 0&&Te(null)},[M]),a.useEffect(()=>{!ne&&m&&j?.()},[ne,j,m]),a.useEffect(()=>{_o(t=>rl(t,s))},[s]);const Yf=a.useCallback(t=>{ne||(t.preventDefault(),va.current={startX:t.clientX,startWidth:Fo,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[Fo,ne]),Xf=a.useCallback(t=>{const o=va.current;if(!o||o.pointerId!==t.pointerId)return;const c=rl(o.startWidth+t.clientX-o.startX,s);_o(c),Ds(Ts,c,Ag)},[s]),sc=a.useCallback(t=>{const o=va.current;if(!(!o||o.pointerId!==t.pointerId)){va.current=null,Es(Ts);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),Hn=!!(x&&Dn!==null&&lu(R)),Xo=!!(x&&!fn&&Re.size===0&&Dn===null),dr=(()=>{let t=Bo;return t==="android"&&!Hr&&(t="files"),Hn&&(t==="git"||t==="diff")&&(t="files"),t})(),lt=dr==="git",zn=dr==="files",Rt=dr==="diff",Wn=dr==="android",Jf=Am(t=>t.overlay==="sidebar")&&Wn;a.useEffect(()=>{if(!ne){na(!0);return}if(!r){const o=window.setTimeout(()=>{na(!1)},Fg);return()=>window.clearTimeout(o)}na(!1);const t=window.setTimeout(()=>{na(!0)},Dg);return()=>window.clearTimeout(t)},[ne,r]),a.useEffect(()=>{if(!ne||!Rt)return;const t=ya.current;if(!t)return;const o=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(o)},[Rt,ne]),a.useEffect(()=>{if(!Hn||!x||zr)return;const t=window.setTimeout(()=>{It(x,{background:!0})},3e3);return()=>window.clearTimeout(t)},[Hn,x,zr,It]);const Qf=a.useCallback(t=>{It(t,{discoverOnly:!0})},[It]);mp({active:r&&(lt||Rt),rootPath:x,loading:zr,delay:lt&&!ne?0:Mi,lastStartedRoot:Vo,load:Qf}),a.useEffect(()=>{!r||!lt||(!ne||Lo)&&Po(!0)},[lt,ne,r,Lo]),a.useEffect(()=>{if(!r||lt)return;const t=window.setTimeout(()=>{Po(!0)},Mi);return()=>window.clearTimeout(t)},[lt,r]),a.useEffect(()=>{Rt&&El(!0)},[Rt]),a.useEffect(()=>{!r||!Wn||(n&&sa&&sa.sessionId!==n&&(vi.getState().setDock(wi,null),so({androidPanel:{docked:null}}).catch(()=>{})),$l(!0))},[Wn,r,n,sa]),a.useEffect(()=>{if(r&&Wn||!Ao)return;const t=window.setTimeout(()=>$l(!1),Ig);return()=>window.clearTimeout(t)},[r,Wn,Ao]),a.useEffect(()=>{let t=!1;return du().then(o=>{!t&&o.androidPanel&&Ll(o.androidPanel.enabled===!0)}).catch(()=>{}),()=>{t=!0}},[]);const Zf=a.useCallback(t=>{Ll(t),t?er("android"):J.getState().rightTab==="android"&&er("files"),so({androidPanel:{enabled:t}}).catch(()=>{})},[er]),ac=a.useCallback(t=>{ge&&Tb(ge,t.currentTarget.scrollTop)},[ge]);a.useEffect(()=>()=>{Nr.current?.abort(),Es(ul),Es(fl),Es(Ts),Es(Ni)},[]),a.useEffect(()=>{if(!ge||!ec)return;const t=Nf()[ge]?.top;if(typeof t!="number")return;let o=window.requestAnimationFrame(()=>{Fn.current&&(Fn.current.scrollTop=t),o=window.requestAnimationFrame(()=>{Fn.current&&(Fn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(o)},[ge,ec]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return cm(t.signal).then(o=>_l(!!o.available)).catch(()=>_l(!1)),()=>t.abort()},[r]);const bs=a.useCallback(t=>{if(te(null),it(t),bt(null),ne){Rr(!0),Cr(1),Mr.current?.slideTo(1),f?.();return}},[ne,f,it]),oc=a.useCallback((t,o)=>{if(te(null),it(t),Pt(o),ne){Rr(!0),Cr(1),Mr.current?.slideTo(1),f?.();return}},[ne,f,it]),xs=a.useCallback(async(t,o)=>{const c=o||Tn||x;if(!(!c||t.length===0)){ua(!0);try{await Wa(c,t),ma(c,!1)}catch(y){vt(y instanceof Error?y.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>vt(null),4e3)}finally{ua(!1)}}},[Tn,x,ma,i]),ic=a.useCallback(async t=>{try{await dm(t)}catch(o){vt(o instanceof Error?o.message:i("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>vt(null),4e3)}},[i]),ka=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&Io(!0)},[]),lc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Io(!1)},[]),cc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Io(!1);const o=t.dataTransfer.files;o.length>0&&xs(Array.from(o))},[xs]),Jo=a.useCallback(t=>{rt(t),window.setTimeout(()=>rt(o=>o===t?null:o),1400)},[]),Er=a.useCallback(t=>{oe(t),window.setTimeout(()=>oe(o=>o===t?null:o),1400)},[]);a.useEffect(()=>{Lt(Od,Ie)},[Ie]),a.useEffect(()=>{Lt(Ud,_t)},[_t]),a.useEffect(()=>{Lt(Hd,H)},[H]),a.useEffect(()=>{Ds(Ni,ve,Mg)},[ve]),a.useEffect(()=>(Hl().catch(()=>{}),hd(t=>{t.type==="pinned-explorer-roots"&&zl(t.pinnedExplorerRoots)})),[Hl,zl]);const dc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Sa=a.useRef(null),gn=a.useRef(null),[uc,Qo]=a.useState(!1);a.useEffect(()=>{if(!r)return;Qo(!1);let t=!1;um().then(c=>{t||(Sa.current=c.text,Ke(y=>c.text&&c.text!==y?c.text:y),Qo(!0))}).catch(()=>{t||Qo(!0)});const o=hd(c=>{c.type==="context-draft"&&c.origin!==dc.current&&(Sa.current=c.text,Ke(c.text))});return()=>{t=!0,o(),gn.current!==null&&(window.clearTimeout(gn.current),gn.current=null)}},[r]),a.useEffect(()=>{if(!uc||Sa.current===ve)return;gn.current!==null&&window.clearTimeout(gn.current);const t=ve;gn.current=window.setTimeout(()=>{gn.current=null,fm(t,dc.current).then(()=>{Sa.current=t}).catch(()=>{})},500)},[ve,uc]);const Gn=a.useCallback((t,o,c)=>{if(t){if(hm(c?t+c:t)){Jo(o);return}Ie?(Ke(y=>_p(y,t)+(c??"")),window.matchMedia("(pointer: coarse)").matches||(Bt(!1),hr(y=>y+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:c?t+c:t,focus:!0}})),Jo(o)}},[Ie,Jo]),ja=a.useCallback(t=>{const o=wn(t,x);return Tm(o,x)},[x]),Zo=Cu(Er),Gt=a.useCallback((t,o)=>{const c=wn(t,x);Gn(Im(c,x),o??`path:${c}`)},[x,Gn]),eh=a.useCallback(async t=>{ua(!0);try{await Dm(t,Wa,o=>{Gt(o,`path:${o}`)}),ne&&!Ie&&l()}catch(o){vt(o instanceof Error?o.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>vt(null),4e3)}finally{ua(!1)}},[Ie,Gt,ne,l,i]),Ra=a.useRef(!0),ei=a.useRef(n);ei.current=n,a.useEffect(()=>(Ra.current=!0,()=>{Ra.current=!1}),[]);const th=a.useCallback(t=>{Fm.getState().enqueue(t,n??null,x||"/",o=>{if(Ie&&Ra.current&&ei.current===n)Gt(o);else return yd(o,n)})},[n,x,Ie,Gt]),rh=a.useCallback(async t=>{const c=(await Wa("/tmp",[t])).files[0]?.path;if(!c)throw new Error("截图上传未返回文件路径");Ie&&Ra.current&&ei.current===n?Gt(c):await yd(c,n)},[Ie,Gt,n]),$r=a.useCallback((t,o)=>{if(!t)return;const c=t.includes(`
|
|
1660
1660
|
`)?`
|
|
1661
|
-
`:void 0;
|
|
1662
|
-
`)||t.endsWith(" ")?t:`${t} `,o,c)},[
|
|
1663
|
-
`)},[
|
|
1664
|
-
`),y=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let v=!1;const k=Z=>{v||(v=!0,window.removeEventListener("termdock-insert-reference-ack",S),window.clearTimeout(
|
|
1665
|
-
`)},[wc,
|
|
1666
|
-
`):[];if(!r||t.length===0){Tn(null);return}const o=new AbortController;let c=!1,y=0,v=0;Tn(null);const k=async()=>{let S=0;for(;!c&&!o.signal.aborted;){let ae=null;try{Tn(null),await ym(t,me=>{const{applicableEvents:Ee,unavailableReason:Xe}=Pp(me);Ee.length>0&&Gl(Ee);for(const G of Ee){if(G.type!=="rescan-required")continue;const X=J.getState();if(!X.directoryCache.has(G.path))continue;vn.current.get(G.path)?.abort();const Oe=new AbortController;vn.current.set(G.path,Oe);const st=`file-watch-rescan:${G.path}`;Ct(st),wm(G.path,Oe.signal,X.showHiddenFiles,"watch_rescan",st,X.fileSortModes[G.path]??"name").then(Be=>{vn.current.get(G.path)===Oe&&Kl(G.path,Be.entries)}).catch(Be=>{fr(Be)||Tn(Be instanceof Error?Be.message:"File refresh unavailable")}).finally(()=>{vn.current.get(G.path)===Oe&&vn.current.delete(G.path)})}Xe&&Tn(Xe)},o.signal),ae=new Error("File watch stream ended")}catch(me){ae=me}if(c||o.signal.aborted||fr(ae))return;Tn(ae instanceof Error?ae.message:"File watching unavailable");const Z=zd[Math.min(S,zd.length-1)];S+=1,await new Promise(me=>{v=window.setTimeout(me,Z)})}};return y=window.setTimeout(()=>{c||k()},Mi),()=>{c=!0,window.clearTimeout(y),window.clearTimeout(v),o.abort();for(const S of vn.current.values())S.abort();vn.current.clear()}},[Gl,r,Kl,si]),a.useEffect(()=>{if(!x||Go.current!==x)return;if(Ko.current===x){Ko.current=null;return}const t=qd();Ds(Hu,{...t,[x]:{selectedRepoRoots:ea,repoTargetBranches:Zt,repoBaseBranches:Et,previewEntries:Qr,selectedPreviewKey:be&&jr?Ye:null,selectedPreviewFileKey:be&&jr?Eo:null,previewDetailOpen:!!(be&&jr),previewScrollTops:ss,previewMobileSlideIndex:1,repoIncludeUncommitted:sn,updatedAt:Date.now()}},Ng)},[jr,sn,be,Qr,ss,Et,Zt,ea,x,Eo,Ye]);const ht=a.useMemo(()=>iu(je.values()),[je]),ct=a.useMemo(()=>{const t=new Map;for(const o of le)t.set(o.root,o);return t},[le]),ys=a.useMemo(()=>{const t=new Map;for(const o of le)o.deferred||t.set(o.root,o.files.length);return t},[le]),Ma=a.useCallback(t=>{if(t){if(!t.deferred){hs.current.delete(t.root);return}ys.has(t.root)||hs.current.has(t.root)||(hs.current.add(t.root),It(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(o=>{o||hs.current.delete(t.root)}))}},[It,ys]),rr=a.useMemo(()=>ce?Ce.find(t=>t.root===ce)??null:null,[ce,Ce]),Kt=a.useMemo(()=>ot?Array.from(je.values()).find(t=>t.path===ot||t.absolutePath===ot)??null:null,[je,ot]),Ft=a.useMemo(()=>{const t=new Map;for(const o of le)o.available&&o.context?.available&&t.set(o.root,o);return t.size===0&&R?.available&&R.root&&t.set(R.root,{id:R.root,root:R.root,relativeRoot:".",name:nt,depth:0,nested:!1,available:!0,files:Array.from(je.values()).filter(o=>gt(o,x)===R.root),context:R}),Array.from(t.values()).sort((o,c)=>o.root===x?-1:c.root===x?1:(o.relativeRoot||o.name).localeCompare(c.relativeRoot||c.name)).map(o=>{const c=o.relativeRoot==="."?nt:o.relativeRoot||o.name||kt(o.root),y=ou(o.files),v=o.files.length;return{value:o.root,label:c,meta:[o.context?.branch,v>0?i("rightSidebar.repoChangedCount",{count:v}):null,y>0?i("rightSidebar.repoStagedCount",{count:y}):null].filter(Boolean).join(" · ")}})},[je,R,le,nt,x,i]),we=a.useMemo(()=>ce&&Ft.some(t=>t.value===ce)?ce:Kt?.repoRoot&&Ft.some(t=>t.value===Kt.repoRoot)?Kt.repoRoot:Ft.length===1||Ft.length>1?Ft[0].value:null,[ce,Ft,Kt?.repoRoot]),kc=we?ct.get(we)??null:null,fe=kc?.context?.available?kc.context:we===R?.root?R:null,Je=Ft.length>0&&!we,Sc=a.useMemo(()=>Je?[]:we?Array.from(je.values()).filter(t=>gt(t,x)===we):Array.from(je.values()),[we,je,Je,x]),yn=a.useMemo(()=>iu(Sc),[Sc]),ai=!!(fe?.available&&fe.root&&we&&fe.root===we),lh=we?Ft.find(t=>t.value===we)?.label??kt(we):i("rightSidebar.gitRepositoryPlaceholder"),jc=ai?fe?.branch??"HEAD":Je?i("rightSidebar.selectRepositoryForGitActions"):cn?i("rightSidebar.gitActionRunning"):"HEAD",Vn=!!(fe?.available&&fe.root===we&&fe.status);a.useEffect(()=>{jl.current={count:Tt.length,loading:Js,loadingMore:Qs,hasMore:jo}},[Tt.length,jo,Js,Qs]),a.useEffect(()=>{Ur.current+=1,or.current?.abort(),Ct("right-sidebar-recent-commits"),or.current=null,nn(""),ar([]),is(!1),ls(!1),En(null),$n(!1)},[we]);const ws=a.useCallback(async(t={})=>{if(!x||!we||Je)return;const o=t.reset??!1,c=jl.current,y=o?0:c.count;if(!o&&(c.loading||c.loadingMore||!c.hasMore))return;const v=Ur.current+1;Ur.current=v,or.current?.abort(),Ct("right-sidebar-recent-commits");const k=new AbortController;or.current=k,o?is(!0):ls(!0),En(null);try{const S=await mm({cwd:x,repoRoot:we,limit:_g,skip:y,query:os.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Ur.current!==v)return;if(!S.available){En(S.error??"Recent commits are unavailable"),o&&ar([]),$n(!1);return}qe(ae=>o?S.commitSyncStatus??{}:{...ae,...S.commitSyncStatus}),ar(ae=>o?S.commits:[...ae,...S.commits]),$n(S.hasMore)}catch(S){if(Ur.current!==v||fr(S))return;En(S instanceof Error?S.message:"Failed to load recent commits"),o&&ar([]),$n(!1)}finally{or.current===k&&(or.current=null),Ur.current===v&&(is(!1),ls(!1))}},[we,os,Je,x]);a.useEffect(()=>{tn&&ws({reset:!0})},[os,ws,tn,fe?.ahead,fe?.behind,fe?.upstream]);const ch=a.useCallback(t=>{const o=t.currentTarget;o.scrollTop+o.clientHeight<o.scrollHeight-48||ws({reset:!1})},[ws]);a.useEffect(()=>{!we||!R?.available||!lt||!ir||Vn||cn||Je||Yo(we)},[we,R?.available,Vn,cn,lt,ir,Yo,Je]),a.useEffect(()=>{!r||!Rt&&!lt||!x||cr()},[Rt,lt,r,cr,x]),a.useEffect(()=>{!r||!lt||!ir||!cs||!x||wa(null)},[cs,lt,ir,r,wa,x]);const dh=a.useMemo(()=>{if(!ce)return 0;const t=Ce.findIndex(o=>o.root===ce);return t>=0?t+1:0},[ce,Ce]),Rc=a.useCallback(t=>{if(!t)return null;const o=Array.from(je.values()).filter(c=>gt(c,x)===t).sort((c,y)=>c.path.localeCompare(y.path))[0];return o?wt(o):null},[je,x]),wn=Ce.length>1,Ea=a.useMemo(()=>[{root:null,label:i("rightSidebar.allRepositories"),count:je.size,branch:null,deferred:!1},...Ce.map(t=>({root:t.root,label:t.label,count:t.deferred?ys.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!ys.has(t.root)}))],[je.size,Ce,ys,i]),Cc=Ea[dh]??Ea[0],$a=!!ce,Nc=a.useMemo(()=>Yu(Ce,le),[Ce,le]);a.useEffect(()=>{qo.current===x&&ce&&!Nc.has(ce)&&Pe(null),Nn(t=>t.filter(o=>Ce.some(c=>c.root===o)))},[ce,Ce,Nc,x,Pe]),a.useEffect(()=>{ce&&Ma(ct.get(ce))},[ce,Ma,ct]);const uh=a.useMemo(()=>{const t=new Set;fe?.branch&&t.add(fe.branch);for(const o of fe?.branches??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0}))},[fe?.branch,fe?.branches,i]),Mc=a.useMemo(()=>{const t=new Set;fe?.upstreamRemote&&t.add(fe.upstreamRemote);for(const o of fe?.remotes??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===fe?.upstreamRemote?i("rightSidebar.pushUpstreamBadge"):void 0}))},[fe?.remotes,fe?.upstreamRemote,i]),Ec=Mc.length>1,fh=a.useMemo(()=>{const t=[],o=new Set,c=(v,k)=>{!v||o.has(v)||(o.add(v),t.push({value:v,label:v,meta:k}))};c(fe?.upstreamBranch,fe?.upstreamBranch?i("rightSidebar.pushUpstreamBadge"):void 0),c(fe?.branch,fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0);for(const v of fe?.branches??[])c(v,v===fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");const y=fe?.upstreamRemote;for(const v of fe?.remoteBranches??[]){const k=v.indexOf("/"),S=k>=0?v.slice(0,k):null,ae=k>=0?v.slice(k+1):v;(!y||S===y)&&c(ae,"remote")}return t},[fe?.branch,fe?.branches,fe?.remoteBranches,fe?.upstreamBranch,fe?.upstreamRemote,i]),Vt=a.useMemo(()=>Ft.map(t=>{const o=ct.get(t.value);return{root:t.value,label:t.label,branch:o?.context?.branch??null}}),[Ft,ct]);a.useEffect(()=>{Vt.length!==0&&(ta(t=>{let o=!1;const c={...t},y=new Set(Vt.map(v=>v.root));for(const v of Object.keys(c))y.has(v)||(delete c[v],o=!0);for(const v of Vt)!c[v.root]&&v.branch&&(c[v.root]=v.branch,o=!0);return o?c:t}),ra(t=>{let o=!1;const c={...t},y=new Set(Vt.map(v=>v.root));for(const v of Object.keys(c))y.has(v)||(delete c[v],o=!0);for(const v of Vt){const k=ct.get(v.root)?.context;if(c[v.root]&&Xu(c[v.root],k?.branch)&&(delete c[v.root],o=!0),c[v.root])continue;const S=Jd(k);S&&(c[v.root]=S,o=!0)}return o?c:t}))},[Vt,ct]);const La=a.useMemo(()=>{const t=new Set(Vt.map(o=>o.root));return ea.filter(o=>t.has(o))},[ea,Vt]),Pa=La.length===0,ur=a.useMemo(()=>Pa?Vt:Vt.filter(t=>La.includes(t.root)),[Vt,La,Pa]),ks=a.useMemo(()=>ur.filter(t=>!!Et[t.root]?.trim()),[Et,ur]),Vr=a.useCallback((t,o)=>{const c=ct.get(t)?.context?.branch;return!!(c&&o&&o.replace(/^refs\/heads\//,"")===c)},[ct]),$c=a.useMemo(()=>ur.filter(t=>!Et[t.root]?.trim()),[Et,ur]),Lc=a.useCallback(async t=>{if(!t||Wo.current.has(t))return;const o=ct.get(t)?.context;if((o?.branches?.length??0)>0||(o?.remoteBranches?.length??0)>0||o?.upstream)return;const c=x;Wo.current.add(t),Nl(y=>new Set(y).add(t));try{const y=await fd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!y.available||!Re(c))return;Me(v=>v.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...y},error:void 0}:k)),ta(v=>v[t]||!y.branch?v:{...v,[t]:y.branch}),ra(v=>{if(v[t])return v;const k=Jd(y);return k?{...v,[t]:k}:v})}catch(y){fr(y)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,y)}finally{Wo.current.delete(t),Nl(y=>{const v=new Set(y);return v.delete(t),v})}},[ct,Re,x]);a.useEffect(()=>{if(Ro)for(const t of ur)Lc(t.root)},[Ro,ur,Lc]),a.useEffect(()=>{!ai||!fe||(ia(fe.branch||(fe.branches?.[0]??"")),la(fe.upstreamRemote||(fe.remotes?.includes("origin")?"origin":fe.remotes?.[0]??"")),ca(fe.upstreamBranch||fe.branch||(fe.branches?.[0]??"")))},[fe,ai]);const Pc=a.useMemo(()=>{if(Je)return{text:i("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Vn||cn)return{text:i("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!fe?.upstream)return{text:i("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=fe.ahead??0,o=fe.behind??0;return t>0&&o>0?{text:i("rightSidebar.pushDivergedCount",{ahead:t,behind:o}),className:"bg-destructive/10 text-destructive"}:t>0?{text:i("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:o>0?{text:i("rightSidebar.pushBehindCount",{count:o}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:i("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[fe?.ahead,fe?.behind,fe?.upstream,Vn,cn,Je,i]),hh=a.useCallback(t=>{if(t&&!ne){const o=t.currentTarget.getBoundingClientRect();Ae({x:Math.min(o.left,window.innerWidth-352),y:Math.min(o.bottom+6,window.innerHeight-64)})}else Ae(null);I?.()},[ne,I]),oi=a.useCallback(()=>{Ae(null),_?.()},[_]);function Ac(){if(!wn)return null;const t=Cc?.label??i("rightSidebar.allRepositories"),o=Cc?.count??je.size,c=kt(t)||t;return e.jsxs("button",{type:"button",onClick:hh,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 ${w?"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":w,title:t,children:[e.jsx(Pr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:c}),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(Us,{size:12,className:"shrink-0"})]})}function mh(){if(!w||!wn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,o=typeof window>"u"?768:window.innerHeight,c=Math.max(12,Math.min(et?.x??t-368,t-352)),y=Math.max(12,Math.min(et?.y??80,o-420)),v=ne?void 0:{left:c,top:y},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${ne?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:oi,children:e.jsxs("div",{className:ne?"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:v,onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:ne?"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:ne?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:i("rightSidebar.repositories")}),!ne&&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:Ea.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${je.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:je.size})]})]}),e.jsx("button",{type:"button",onClick:oi,className:ne?"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":i("rightSidebar.close"),children:e.jsx(Yt,{size:ne?16:14})})]}),e.jsx("div",{className:ne?"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:Ea.map(S=>{const ae=(S.root??null)===ce,Z=kt(S.label)||S.label;return e.jsxs("button",{type:"button",onClick:()=>{Zc(S.root),oi()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${ne?"px-3 py-2":"px-2 py-1.5"} ${ae?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:S.label,role:"option","aria-selected":ae,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${ae?"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 ${ae?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(Pr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${ne?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Z}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:S.root===null?i("rightSidebar.allRepositories"):S.label})]}),S.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:S.branch}),S.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:i("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${S.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:S.count})]},S.root??"all")})})]})});return Du(k,ne,document.body)}function ph(){return mh()}function Tc(t){const o=gt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),y=lo(c,o??x);return{key:wt(t),path:t.path,absolutePath:c,displayName:y.name,displayDir:y.dir,oldPath:t.oldPath,status:t.status,title:c}}function Ic(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:i("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function Aa(t,o){const c=kn(t,x),y=`path:${c}`,v=ke===y,k=rt===y,S=v||k;return e.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),Gt(c,y)},...Zo(ja(c),y),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${S?"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"} ${S?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:o,children:e.jsx("span",{className:"whitespace-nowrap",children:i(k?"rightSidebar.copied":v?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Dc(t){const o=gt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),y=Hh(t),v=Fi(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(zb,{actions:y,running:Ue,completed:Ln?.path===v?Ln:null}),Aa(c,i("rightSidebar.insertThisFile"))]})}function Fc(t,o){const c=o.root??x;if(!c)return null;const y=kn(t,c);return Aa(y,i("fileTree.insertRefTitle"))}function Ss(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":i("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Vc("unified"),"aria-pressed":Ut==="unified",title:i("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ut==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Vc("split"),"aria-pressed":Ut==="split",title:i("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ut==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.split")})]})}function _c(){return js.map(t=>{const o=ou(t.files.map(([,k])=>k)),c=el({activeGitRepoRoot:ce,groupCount:js.length,label:t.label,rootName:nt}),y=!!(c&&t.root&&xr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:y,files:t.files.map(([,k])=>Tc(k)),header:c?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${y?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Ah(t.root),"aria-expanded":!y,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:y?e.jsx(Ga,{size:13}):e.jsx(Us,{size:13})}),e.jsx(Pr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),o>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:o})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),Ua("stage-all",t.root,t.label)},disabled:!!Ue,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:i("rightSidebar.stageAll"),children:i("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),Ua("stash-all",t.root,t.label)},disabled:!!Ue,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:i("rightSidebar.stashAll"),children:i("rightSidebar.stashAll")})]})]}):null}})}function Bc(){return je.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:i("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ia.map(([,t])=>{const o=gt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path);return{key:wt(t),path:t.path,absolutePath:c,status:t.status,repoRoot:o,displayName:lo(c,o).name,displayDir:lo(c,o).dir,auditRecords:Mt}})}function Oc(t){const o=Array.from(je.values()).find(v=>wt(v)===t.key),c=o?gt(o,x):null,y=vp(Mt,c,o?.path??t.path);return e.jsx(Yi,{changeStatus:t.status,auditStatus:y,renderChangeBadge:v=>e.jsx(Fs,{status:v})})}const Ta=a.useCallback(t=>{if(ne)return null;const o=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(o.length===0)return null;const y=t.getBoundingClientRect().top+48;let v=null,k=Number.POSITIVE_INFINITY;for(const ae of o){const Z=ae.getBoundingClientRect();if(Z.bottom<y)continue;const me=Math.abs(Z.top-y);me<k&&(v=ae,k=me)}const S=v?.dataset.diffSelectionPath??v?.dataset.diffStreamItem??null;return S?(xa.current===S&&J.getState().selectedFilePath===S||(xa.current=S,it(S)),S):null},[ne,it]),gh=!!(!Ue&&we&&!Je&&(fe?.upstream||dn.trim()&&un.trim())),bh=!!(!Ue&&we&&!Je&&(fe?.upstream||dn.trim()&&un.trim())),xh=!!(!Ue&&we&&!Je&&An.trim()&&An.trim()!==fe?.branch),qt=a.useMemo(()=>{const t=_e.trim().toLowerCase(),o=Array.from(je.entries()).filter(([,c])=>!ce||gt(c,x)===ce).sort(([c],[y])=>c.localeCompare(y));return t?o.filter(([c,y])=>`${c} ${y.path} ${y.status} ${y.repoRelativeRoot??""} ${y.repoName??""}`.toLowerCase().includes(t)):o},[ce,je,_e,x]);a.useEffect(()=>{no("selected_file_state",{selectedFilePath:ot,selectedChangedFilePath:Kt?.path??null,selectedChangedFileAbsolutePath:Kt?.absolutePath??null,selectedChangedFileRepoRoot:Kt?.repoRoot??null,rootPath:x,activeGitRepoRoot:ce,rightTab:Bo,effectiveRightTab:dr,diffPaneActive:Rt,changedFiles:je.size,filteredChangedFiles:qt.length,gitBundleLoading:zr,gitBundleLastLoadedAt:Fn})},[ce,je.size,Rt,dr,qt.length,Fn,zr,Bo,x,Kt?.absolutePath,Kt?.path,Kt?.repoRoot,ot]);const js=a.useMemo(()=>{const t=new Map;for(const o of qt){const[,c]=o,y=gt(c,x),v=Ub(c)||nt,k=y??v,S=y?ct.get(y):void 0,ae=t.get(k)??{root:y,label:v,branch:S?.context?.branch,files:[]};ae.files.push(o),t.set(k,ae)}return Array.from(t.values()).sort((o,c)=>o.label===nt?-1:c.label===nt?1:o.label.localeCompare(c.label))},[qt,ct,nt,x]),Ia=a.useMemo(()=>{const t=[],o=new Map;for(const c of qt)o.set(wt(c[1]),c);for(const c of js){if(!!(c.root&&el({activeGitRepoRoot:ce,groupCount:js.length,label:c.label,rootName:nt})&&xr.has(c.root)))continue;if(wr!=="tree"){t.push(...c.files);continue}const v=c.files.map(([,k])=>Tc(k));for(const k of Vm(v)){const S=o.get(k.key);S&&t.push(S)}}return t},[ce,xr,wr,js,qt,nt]);a.useEffect(()=>{if(!Rt||Ia.length===0||ne)return;const t=[],o=()=>{const c=document.querySelector(".termdock-diff-stream-scroller");if(c&&Ta(c))return;const y=document.querySelector("[data-diff-stream-item]"),v=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;if(v){xa.current=v,it(v);return}const k=Ia[0]?.[1];if(!k)return;const S=wt(k);xa.current=S,it(S)};for(const c of[80,240,600,1200])t.push(window.setTimeout(o,c));return()=>t.forEach(c=>window.clearTimeout(c))},[Rt,ne,Ia,it,Ta]);const ii=a.useMemo(()=>{const t=S=>`'${S.replace(/'/g,"'\\''")}'`,o=tr.length>0?gn:le.filter(S=>S.files.length>0),c=o.length>0?o:x?[{root:x,relativeRoot:".",name:nt}]:[],y=c.length>0?c.map(S=>`- ${S.relativeRoot==="."?".":S.relativeRoot} (${S.root})`).join(`
|
|
1661
|
+
`:void 0;Gn(t.endsWith(`
|
|
1662
|
+
`)||t.endsWith(" ")?t:`${t} `,o,c)},[Gn]),fc=a.useRef($r);fc.current=$r;const ti=a.useRef(!0);a.useEffect(()=>(ti.current=!0,()=>{ti.current=!1}),[]);const ri=a.useRef(new Set),hc=a.useCallback((t,o,c)=>{if(ri.current.has(o))return;const y=wd.getState().activeSessionId;ri.current.add(o),bp(t,o,c,{insert:$r,upload:async(v,k)=>(await Wa("/tmp",[v],k)).files[0]?.path,isCurrent:()=>ti.current&&fc.current===$r&&y===wd.getState().activeSessionId}).finally(()=>ri.current.delete(o))},[$r]),Lr=a.useCallback((t,o,c)=>{o&&Gn(o.endsWith(" ")?o:`${o} `,c??`context:${t}`,`
|
|
1663
|
+
`)},[Gn]),mc=a.useCallback(t=>{const o=Bp(ve,t);if(!o)return;const c=t&&ve.trim().includes(`
|
|
1664
|
+
`),y=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let v=!1;const k=Z=>{v||(v=!0,window.removeEventListener("termdock-insert-reference-ack",S),window.clearTimeout(se),Z?(br(!1),Ke(""),H&&Bt(!0)):(br(!0),Bt(!1)))},S=Z=>{const me=Z.detail;me?.nonce===y&&k(me.ok===!0)},se=window.setTimeout(()=>k(!1),1500);window.addEventListener("termdock-insert-reference-ack",S),br(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:o,focus:!0,paste:c,nonce:y}}))},[H,ve]),st=a.useMemo(()=>x?kt(x):i("rightSidebar.workspace"),[x,i]),nh=a.useMemo(()=>kt(ge)||st,[ge,st]),Ca=a.useMemo(()=>Ti(ge),[ge]),Na=a.useMemo(()=>x?Ul[x]??[]:[],[Ul,x]),bn=a.useMemo(()=>new Set(Na.map(t=>t.path)),[Na]),vs=!!(ge&&bn.has(ge)),ni=!!(x&&ge&&ge!==x),sh=!!(x&&Tn&&Tn!==x),Dt=ge?`path:${ge}`:null,pc="context:change-audit",ah=a.useCallback(()=>{Ca&&Ht(Ca)},[Ca,Ht]),gc=a.useCallback(()=>{Wl()},[Wl]),oh=a.useCallback(()=>{ge&&(ma(ge,!0),Vl())},[Vl,ge,ma]),ih=a.useCallback(()=>{!ge||!ni||(vs?un(ge):In(ge,"directory"))},[ni,ge,vs,In,un]),bc=a.useCallback(t=>{Ht(t),K("")},[Ht]),xc=a.useCallback(t=>{ge&&(ie(Cg(ge,t)),W(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ge,W]),vc=a.useCallback(t=>{!x||t===x||(bn.has(t)?un(t):In(t,"directory"))},[In,bn,x,un]),yc=a.useCallback(t=>{!x||!t||(bn.has(t)?un(t):In(t,"file"))},[In,bn,x,un]),wc=J(t=>t.expandedPaths),si=a.useMemo(()=>{const t=new Set;if(zn&&ge){t.add(ge);const o=`${ge.replace(/\/+$/,"")}/`;for(const c of wc)c.startsWith(o)&&t.add(c)}if(zn&&x&&ot){const o=ot.startsWith("/")?ot:`${x}/${ot}`,c=Ti(o);c&&t.add(c)}return $p(t).join(`
|
|
1665
|
+
`)},[wc,zn,ge,x,ot]),xn=a.useRef(new Map);a.useEffect(()=>{const t=si?si.split(`
|
|
1666
|
+
`):[];if(!r||t.length===0){An(null);return}const o=new AbortController;let c=!1,y=0,v=0;An(null);const k=async()=>{let S=0;for(;!c&&!o.signal.aborted;){let se=null;try{An(null),await ym(t,me=>{const{applicableEvents:$e,unavailableReason:Je}=Pp(me);$e.length>0&&Gl($e);for(const G of $e){if(G.type!=="rescan-required")continue;const Y=J.getState();if(!Y.directoryCache.has(G.path))continue;xn.current.get(G.path)?.abort();const Me=new AbortController;xn.current.set(G.path,Me);const He=`file-watch-rescan:${G.path}`;Ct(He),wm(G.path,Me.signal,Y.showHiddenFiles,"watch_rescan",He,Y.fileSortModes[G.path]??"name").then(Oe=>{xn.current.get(G.path)===Me&&Kl(G.path,Oe.entries)}).catch(Oe=>{fr(Oe)||An(Oe instanceof Error?Oe.message:"File refresh unavailable")}).finally(()=>{xn.current.get(G.path)===Me&&xn.current.delete(G.path)})}Je&&An(Je)},o.signal),se=new Error("File watch stream ended")}catch(me){se=me}if(c||o.signal.aborted||fr(se))return;An(se instanceof Error?se.message:"File watching unavailable");const Z=zd[Math.min(S,zd.length-1)];S+=1,await new Promise(me=>{v=window.setTimeout(me,Z)})}};return y=window.setTimeout(()=>{c||k()},Mi),()=>{c=!0,window.clearTimeout(y),window.clearTimeout(v),o.abort();for(const S of xn.current.values())S.abort();xn.current.clear()}},[Gl,r,Kl,si]),a.useEffect(()=>{if(!x||Go.current!==x)return;if(Ko.current===x){Ko.current=null;return}const t=qd();Ds(Hu,{...t,[x]:{selectedRepoRoots:ea,repoTargetBranches:Zt,repoBaseBranches:Et,previewEntries:Jr,selectedPreviewKey:be&&jr?Xe:null,selectedPreviewFileKey:be&&jr?Eo:null,previewDetailOpen:!!(be&&jr),previewScrollTops:ss,previewMobileSlideIndex:1,repoIncludeUncommitted:nn,updatedAt:Date.now()}},Ng)},[jr,nn,be,Jr,ss,Et,Zt,ea,x,Eo,Xe]);const ht=a.useMemo(()=>iu(Re.values()),[Re]),ct=a.useMemo(()=>{const t=new Map;for(const o of le)t.set(o.root,o);return t},[le]),ys=a.useMemo(()=>{const t=new Map;for(const o of le)o.deferred||t.set(o.root,o.files.length);return t},[le]),Ma=a.useCallback(t=>{if(t){if(!t.deferred){hs.current.delete(t.root);return}ys.has(t.root)||hs.current.has(t.root)||(hs.current.add(t.root),It(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(o=>{o||hs.current.delete(t.root)}))}},[It,ys]),rr=a.useMemo(()=>ce?Ne.find(t=>t.root===ce)??null:null,[ce,Ne]),Kt=a.useMemo(()=>ot?Array.from(Re.values()).find(t=>t.path===ot||t.absolutePath===ot)??null:null,[Re,ot]),Ft=a.useMemo(()=>{const t=new Map;for(const o of le)o.available&&o.context?.available&&t.set(o.root,o);return t.size===0&&R?.available&&R.root&&t.set(R.root,{id:R.root,root:R.root,relativeRoot:".",name:st,depth:0,nested:!1,available:!0,files:Array.from(Re.values()).filter(o=>gt(o,x)===R.root),context:R}),Array.from(t.values()).sort((o,c)=>o.root===x?-1:c.root===x?1:(o.relativeRoot||o.name).localeCompare(c.relativeRoot||c.name)).map(o=>{const c=o.relativeRoot==="."?st:o.relativeRoot||o.name||kt(o.root),y=ou(o.files),v=o.files.length;return{value:o.root,label:c,meta:[o.context?.branch,v>0?i("rightSidebar.repoChangedCount",{count:v}):null,y>0?i("rightSidebar.repoStagedCount",{count:y}):null].filter(Boolean).join(" · ")}})},[Re,R,le,st,x,i]),we=a.useMemo(()=>ce&&Ft.some(t=>t.value===ce)?ce:Kt?.repoRoot&&Ft.some(t=>t.value===Kt.repoRoot)?Kt.repoRoot:Ft.length===1||Ft.length>1?Ft[0].value:null,[ce,Ft,Kt?.repoRoot]),kc=we?ct.get(we)??null:null,fe=kc?.context?.available?kc.context:we===R?.root?R:null,Qe=Ft.length>0&&!we,Sc=a.useMemo(()=>Qe?[]:we?Array.from(Re.values()).filter(t=>gt(t,x)===we):Array.from(Re.values()),[we,Re,Qe,x]),vn=a.useMemo(()=>iu(Sc),[Sc]),ai=!!(fe?.available&&fe.root&&we&&fe.root===we),lh=we?Ft.find(t=>t.value===we)?.label??kt(we):i("rightSidebar.gitRepositoryPlaceholder"),jc=ai?fe?.branch??"HEAD":Qe?i("rightSidebar.selectRepositoryForGitActions"):ln?i("rightSidebar.gitActionRunning"):"HEAD",Kn=!!(fe?.available&&fe.root===we&&fe.status);a.useEffect(()=>{jl.current={count:Tt.length,loading:Js,loadingMore:Qs,hasMore:jo}},[Tt.length,jo,Js,Qs]),a.useEffect(()=>{Ur.current+=1,or.current?.abort(),Ct("right-sidebar-recent-commits"),or.current=null,rn(""),ar([]),is(!1),ls(!1),Mn(null),En(!1)},[we]);const ws=a.useCallback(async(t={})=>{if(!x||!we||Qe)return;const o=t.reset??!1,c=jl.current,y=o?0:c.count;if(!o&&(c.loading||c.loadingMore||!c.hasMore))return;const v=Ur.current+1;Ur.current=v,or.current?.abort(),Ct("right-sidebar-recent-commits");const k=new AbortController;or.current=k,o?is(!0):ls(!0),Mn(null);try{const S=await mm({cwd:x,repoRoot:we,limit:_g,skip:y,query:os.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Ur.current!==v)return;if(!S.available){Mn(S.error??"Recent commits are unavailable"),o&&ar([]),En(!1);return}Ye(se=>o?S.commitSyncStatus??{}:{...se,...S.commitSyncStatus}),ar(se=>o?S.commits:[...se,...S.commits]),En(S.hasMore)}catch(S){if(Ur.current!==v||fr(S))return;Mn(S instanceof Error?S.message:"Failed to load recent commits"),o&&ar([]),En(!1)}finally{or.current===k&&(or.current=null),Ur.current===v&&(is(!1),ls(!1))}},[we,os,Qe,x]);a.useEffect(()=>{en&&ws({reset:!0})},[os,ws,en,fe?.ahead,fe?.behind,fe?.upstream]);const ch=a.useCallback(t=>{const o=t.currentTarget;o.scrollTop+o.clientHeight<o.scrollHeight-48||ws({reset:!1})},[ws]);a.useEffect(()=>{!we||!R?.available||!lt||!ir||Kn||ln||Qe||Yo(we)},[we,R?.available,Kn,ln,lt,ir,Yo,Qe]),a.useEffect(()=>{!r||!Rt&&!lt||!x||cr()},[Rt,lt,r,cr,x]),a.useEffect(()=>{!r||!lt||!ir||!cs||!x||wa(null)},[cs,lt,ir,r,wa,x]);const dh=a.useMemo(()=>{if(!ce)return 0;const t=Ne.findIndex(o=>o.root===ce);return t>=0?t+1:0},[ce,Ne]),Rc=a.useCallback(t=>{if(!t)return null;const o=Array.from(Re.values()).filter(c=>gt(c,x)===t).sort((c,y)=>c.path.localeCompare(y.path))[0];return o?wt(o):null},[Re,x]),yn=Ne.length>1,Ea=a.useMemo(()=>[{root:null,label:i("rightSidebar.allRepositories"),count:Re.size,branch:null,deferred:!1},...Ne.map(t=>({root:t.root,label:t.label,count:t.deferred?ys.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!ys.has(t.root)}))],[Re.size,Ne,ys,i]),Cc=Ea[dh]??Ea[0],$a=!!ce,Nc=a.useMemo(()=>Yu(Ne,le),[Ne,le]);a.useEffect(()=>{qo.current===x&&ce&&!Nc.has(ce)&&Ae(null),Cn(t=>t.filter(o=>Ne.some(c=>c.root===o)))},[ce,Ne,Nc,x,Ae]),a.useEffect(()=>{ce&&Ma(ct.get(ce))},[ce,Ma,ct]);const uh=a.useMemo(()=>{const t=new Set;fe?.branch&&t.add(fe.branch);for(const o of fe?.branches??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0}))},[fe?.branch,fe?.branches,i]),Mc=a.useMemo(()=>{const t=new Set;fe?.upstreamRemote&&t.add(fe.upstreamRemote);for(const o of fe?.remotes??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===fe?.upstreamRemote?i("rightSidebar.pushUpstreamBadge"):void 0}))},[fe?.remotes,fe?.upstreamRemote,i]),Ec=Mc.length>1,fh=a.useMemo(()=>{const t=[],o=new Set,c=(v,k)=>{!v||o.has(v)||(o.add(v),t.push({value:v,label:v,meta:k}))};c(fe?.upstreamBranch,fe?.upstreamBranch?i("rightSidebar.pushUpstreamBadge"):void 0),c(fe?.branch,fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0);for(const v of fe?.branches??[])c(v,v===fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");const y=fe?.upstreamRemote;for(const v of fe?.remoteBranches??[]){const k=v.indexOf("/"),S=k>=0?v.slice(0,k):null,se=k>=0?v.slice(k+1):v;(!y||S===y)&&c(se,"remote")}return t},[fe?.branch,fe?.branches,fe?.remoteBranches,fe?.upstreamBranch,fe?.upstreamRemote,i]),Vt=a.useMemo(()=>Ft.map(t=>{const o=ct.get(t.value);return{root:t.value,label:t.label,branch:o?.context?.branch??null}}),[Ft,ct]);a.useEffect(()=>{Vt.length!==0&&(ta(t=>{let o=!1;const c={...t},y=new Set(Vt.map(v=>v.root));for(const v of Object.keys(c))y.has(v)||(delete c[v],o=!0);for(const v of Vt)!c[v.root]&&v.branch&&(c[v.root]=v.branch,o=!0);return o?c:t}),ra(t=>{let o=!1;const c={...t},y=new Set(Vt.map(v=>v.root));for(const v of Object.keys(c))y.has(v)||(delete c[v],o=!0);for(const v of Vt){const k=ct.get(v.root)?.context;if(c[v.root]&&Xu(c[v.root],k?.branch)&&(delete c[v.root],o=!0),c[v.root])continue;const S=Jd(k);S&&(c[v.root]=S,o=!0)}return o?c:t}))},[Vt,ct]);const La=a.useMemo(()=>{const t=new Set(Vt.map(o=>o.root));return ea.filter(o=>t.has(o))},[ea,Vt]),Pa=La.length===0,ur=a.useMemo(()=>Pa?Vt:Vt.filter(t=>La.includes(t.root)),[Vt,La,Pa]),ks=a.useMemo(()=>ur.filter(t=>!!Et[t.root]?.trim()),[Et,ur]),Vn=a.useCallback((t,o)=>{const c=ct.get(t)?.context?.branch;return!!(c&&o&&o.replace(/^refs\/heads\//,"")===c)},[ct]),$c=a.useMemo(()=>ur.filter(t=>!Et[t.root]?.trim()),[Et,ur]),Lc=a.useCallback(async t=>{if(!t||Wo.current.has(t))return;const o=ct.get(t)?.context;if((o?.branches?.length??0)>0||(o?.remoteBranches?.length??0)>0||o?.upstream)return;const c=x;Wo.current.add(t),Nl(y=>new Set(y).add(t));try{const y=await fd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!y.available||!Ce(c))return;Ee(v=>v.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...y},error:void 0}:k)),ta(v=>v[t]||!y.branch?v:{...v,[t]:y.branch}),ra(v=>{if(v[t])return v;const k=Jd(y);return k?{...v,[t]:k}:v})}catch(y){fr(y)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,y)}finally{Wo.current.delete(t),Nl(y=>{const v=new Set(y);return v.delete(t),v})}},[ct,Ce,x]);a.useEffect(()=>{if(Ro)for(const t of ur)Lc(t.root)},[Ro,ur,Lc]),a.useEffect(()=>{!ai||!fe||(ia(fe.branch||(fe.branches?.[0]??"")),la(fe.upstreamRemote||(fe.remotes?.includes("origin")?"origin":fe.remotes?.[0]??"")),ca(fe.upstreamBranch||fe.branch||(fe.branches?.[0]??"")))},[fe,ai]);const Pc=a.useMemo(()=>{if(Qe)return{text:i("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Kn||ln)return{text:i("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!fe?.upstream)return{text:i("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=fe.ahead??0,o=fe.behind??0;return t>0&&o>0?{text:i("rightSidebar.pushDivergedCount",{ahead:t,behind:o}),className:"bg-destructive/10 text-destructive"}:t>0?{text:i("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:o>0?{text:i("rightSidebar.pushBehindCount",{count:o}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:i("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[fe?.ahead,fe?.behind,fe?.upstream,Kn,ln,Qe,i]),hh=a.useCallback(t=>{if(t&&!ne){const o=t.currentTarget.getBoundingClientRect();Te({x:Math.min(o.left,window.innerWidth-352),y:Math.min(o.bottom+6,window.innerHeight-64)})}else Te(null);I?.()},[ne,I]),oi=a.useCallback(()=>{Te(null),_?.()},[_]);function Ac(){if(!yn)return null;const t=Cc?.label??i("rightSidebar.allRepositories"),o=Cc?.count??Re.size,c=kt(t)||t;return e.jsxs("button",{type:"button",onClick:hh,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 ${w?"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":w,title:t,children:[e.jsx(Pr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:c}),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(Us,{size:12,className:"shrink-0"})]})}function mh(){if(!w||!yn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,o=typeof window>"u"?768:window.innerHeight,c=Math.max(12,Math.min(tt?.x??t-368,t-352)),y=Math.max(12,Math.min(tt?.y??80,o-420)),v=ne?void 0:{left:c,top:y},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${ne?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:oi,children:e.jsxs("div",{className:ne?"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:v,onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:ne?"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:ne?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:i("rightSidebar.repositories")}),!ne&&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:Ea.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Re.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Re.size})]})]}),e.jsx("button",{type:"button",onClick:oi,className:ne?"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":i("rightSidebar.close"),children:e.jsx(Yt,{size:ne?16:14})})]}),e.jsx("div",{className:ne?"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:Ea.map(S=>{const se=(S.root??null)===ce,Z=kt(S.label)||S.label;return e.jsxs("button",{type:"button",onClick:()=>{Zc(S.root),oi()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${ne?"px-3 py-2":"px-2 py-1.5"} ${se?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:S.label,role:"option","aria-selected":se,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${se?"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 ${se?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(Pr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${ne?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Z}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:S.root===null?i("rightSidebar.allRepositories"):S.label})]}),S.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:S.branch}),S.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:i("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${S.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:S.count})]},S.root??"all")})})]})});return Du(k,ne,document.body)}function ph(){return mh()}function Tc(t){const o=gt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),y=lo(c,o??x);return{key:wt(t),path:t.path,absolutePath:c,displayName:y.name,displayDir:y.dir,oldPath:t.oldPath,status:t.status,title:c}}function Ic(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:i("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function Aa(t,o){const c=wn(t,x),y=`path:${c}`,v=ke===y,k=nt===y,S=v||k;return e.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),Gt(c,y)},...Zo(ja(c),y),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${S?"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"} ${S?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:o,children:e.jsx("span",{className:"whitespace-nowrap",children:i(k?"rightSidebar.copied":v?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Dc(t){const o=gt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),y=Hh(t),v=Fi(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(zb,{actions:y,running:Ue,completed:$n?.path===v?$n:null}),Aa(c,i("rightSidebar.insertThisFile"))]})}function Fc(t,o){const c=o.root??x;if(!c)return null;const y=wn(t,c);return Aa(y,i("fileTree.insertRefTitle"))}function Ss(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":i("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Vc("unified"),"aria-pressed":Ut==="unified",title:i("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ut==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Vc("split"),"aria-pressed":Ut==="split",title:i("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ut==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.split")})]})}function _c(){return js.map(t=>{const o=ou(t.files.map(([,k])=>k)),c=el({activeGitRepoRoot:ce,groupCount:js.length,label:t.label,rootName:st}),y=!!(c&&t.root&&xr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:y,files:t.files.map(([,k])=>Tc(k)),header:c?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${y?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Ah(t.root),"aria-expanded":!y,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:y?e.jsx(Ga,{size:13}):e.jsx(Us,{size:13})}),e.jsx(Pr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),o>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:o})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),Ua("stage-all",t.root,t.label)},disabled:!!Ue,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:i("rightSidebar.stageAll"),children:i("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),Ua("stash-all",t.root,t.label)},disabled:!!Ue,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:i("rightSidebar.stashAll"),children:i("rightSidebar.stashAll")})]})]}):null}})}function Bc(){return Re.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:i("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ia.map(([,t])=>{const o=gt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path);return{key:wt(t),path:t.path,absolutePath:c,status:t.status,repoRoot:o,displayName:lo(c,o).name,displayDir:lo(c,o).dir,auditRecords:Mt}})}function Oc(t){const o=Array.from(Re.values()).find(v=>wt(v)===t.key),c=o?gt(o,x):null,y=vp(Mt,c,o?.path??t.path);return e.jsx(Yi,{changeStatus:t.status,auditStatus:y,renderChangeBadge:v=>e.jsx(Fs,{status:v})})}const Ta=a.useCallback(t=>{if(ne)return null;const o=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(o.length===0)return null;const y=t.getBoundingClientRect().top+48;let v=null,k=Number.POSITIVE_INFINITY;for(const se of o){const Z=se.getBoundingClientRect();if(Z.bottom<y)continue;const me=Math.abs(Z.top-y);me<k&&(v=se,k=me)}const S=v?.dataset.diffSelectionPath??v?.dataset.diffStreamItem??null;return S?(xa.current===S&&J.getState().selectedFilePath===S||(xa.current=S,it(S)),S):null},[ne,it]),gh=!!(!Ue&&we&&!Qe&&(fe?.upstream||cn.trim()&&dn.trim())),bh=!!(!Ue&&we&&!Qe&&(fe?.upstream||cn.trim()&&dn.trim())),xh=!!(!Ue&&we&&!Qe&&Pn.trim()&&Pn.trim()!==fe?.branch),qt=a.useMemo(()=>{const t=Be.trim().toLowerCase(),o=Array.from(Re.entries()).filter(([,c])=>!ce||gt(c,x)===ce).sort(([c],[y])=>c.localeCompare(y));return t?o.filter(([c,y])=>`${c} ${y.path} ${y.status} ${y.repoRelativeRoot??""} ${y.repoName??""}`.toLowerCase().includes(t)):o},[ce,Re,Be,x]);a.useEffect(()=>{no("selected_file_state",{selectedFilePath:ot,selectedChangedFilePath:Kt?.path??null,selectedChangedFileAbsolutePath:Kt?.absolutePath??null,selectedChangedFileRepoRoot:Kt?.repoRoot??null,rootPath:x,activeGitRepoRoot:ce,rightTab:Bo,effectiveRightTab:dr,diffPaneActive:Rt,changedFiles:Re.size,filteredChangedFiles:qt.length,gitBundleLoading:zr,gitBundleLastLoadedAt:Dn})},[ce,Re.size,Rt,dr,qt.length,Dn,zr,Bo,x,Kt?.absolutePath,Kt?.path,Kt?.repoRoot,ot]);const js=a.useMemo(()=>{const t=new Map;for(const o of qt){const[,c]=o,y=gt(c,x),v=Ub(c)||st,k=y??v,S=y?ct.get(y):void 0,se=t.get(k)??{root:y,label:v,branch:S?.context?.branch,files:[]};se.files.push(o),t.set(k,se)}return Array.from(t.values()).sort((o,c)=>o.label===st?-1:c.label===st?1:o.label.localeCompare(c.label))},[qt,ct,st,x]),Ia=a.useMemo(()=>{const t=[],o=new Map;for(const c of qt)o.set(wt(c[1]),c);for(const c of js){if(!!(c.root&&el({activeGitRepoRoot:ce,groupCount:js.length,label:c.label,rootName:st})&&xr.has(c.root)))continue;if(wr!=="tree"){t.push(...c.files);continue}const v=c.files.map(([,k])=>Tc(k));for(const k of Vm(v)){const S=o.get(k.key);S&&t.push(S)}}return t},[ce,xr,wr,js,qt,st]);a.useEffect(()=>{if(!Rt||Ia.length===0||ne)return;const t=[],o=()=>{const c=document.querySelector(".termdock-diff-stream-scroller");if(c&&Ta(c))return;const y=document.querySelector("[data-diff-stream-item]"),v=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;if(v){xa.current=v,it(v);return}const k=Ia[0]?.[1];if(!k)return;const S=wt(k);xa.current=S,it(S)};for(const c of[80,240,600,1200])t.push(window.setTimeout(o,c));return()=>t.forEach(c=>window.clearTimeout(c))},[Rt,ne,Ia,it,Ta]);const ii=a.useMemo(()=>{const t=S=>`'${S.replace(/'/g,"'\\''")}'`,o=tr.length>0?pn:le.filter(S=>S.files.length>0),c=o.length>0?o:x?[{root:x,relativeRoot:".",name:st}]:[],y=c.length>0?c.map(S=>`- ${S.relativeRoot==="."?".":S.relativeRoot} (${S.root})`).join(`
|
|
1667
1667
|
`):`- ${x?".":""}`,v=c.length>0?c.map(S=>` td audit-export ${t(S.root)}`).join(`
|
|
1668
1668
|
`):" td audit-export",k=c.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${x??""}`,"目标仓库:",y,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",v,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",k,'10. 少量 hunk 或临时补单条时使用:printf "%s\\n" "这里写该 hunk 的改动意义" | td audit-explain <hunkId> <对应仓库绝对路径>',"11. 注入成功后清理本次 payload:rm -f ~/.termdock/change-audit/payload*.json","","payload.walkthrough 示例字段:","{",' "title": "一句话标题",',' "summary": "整批改动的目的和结果",',' "highlights": [{ "what": "改了什么", "effect": "用户或系统得到什么", "tag": "体验" }],',' "nodes": [{ "id": "n1", "title": "节点标题", "kind": "ui", "business": "零上下文业务解释", "anchor": { "repoRoot": "<repoRoot>", "filePath": "<filePath>", "hunkIndex": 0, "hunkFingerprint": "<fingerprint>", "sectionIndex": 0, "sectionFingerprint": "<sectionFingerprint>" } }],',' "edges": [{ "from": "n1", "to": "n2", "label": "调用/传递/消费", "desc": "这条关系的业务含义" }],',' "risks": [{ "title": "真实风险或口径疑问", "anchor": { "filePath": "<filePath>" } }],',' "checks": ["可执行验证动作"]',"}","","写作标准:","- summary:一句话概括该 hunk 在整批改动中的职责。","- explanation:自包含说明业务链路、该 hunk 的作用、解决的问题、与其它 hunk 的关系。","- walkthrough.highlights 必须大白话,不要堆文件名/函数名;只看 highlights 应该知道这次改动干嘛。","- walkthrough.nodes 优先对应方法、关键业务步骤或关键 section;每个有 anchor 的节点必须能跳回真实 diff。","- 面向不了解本轮对话的 AI 编写,补足必要上下文。","- 输出高信息量结论;避免铺垫、套话、流程复述、泛泛风险、逐行翻译 diff。","","完成条件:汇报每个目标仓库已注入的 hunk 数和总数。"].join(`
|
|
1669
|
-
`)},[tr.length,
|
|
1670
|
-
`);dt("insert_change_audit_prompt",{rootPath:x,activeGitRepoRoots:tr,mode:t,hasAuditListCommand:o.includes("td audit-list"),promptLength:o.length}),Lr(i("rightSidebar.insertChangeAuditPrompt"),o,`${pc}:${t}`),cr(),d||l()},[ce,ii,_r.length,tr,Lr,cr,l,d,x,
|
|
1671
|
-
`))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(y+=1),k.startsWith("-")&&(v+=1));return{filePath:o.filePath,oldPath:o.oldPath,newPath:o.newPath,hunkHeader:o.hunkHeader,hunkIndex:o.hunkIndex??0,fingerprint:o.fingerprint,additions:y,deletions:v,diff:c}};return be?(be.hunks??[]).map(o=>{const c=be.comparisonRepos&&be.comparisonRepos.length>1?[...be.comparisonRepos].sort((v,k)=>k.label.length-v.label.length).find(v=>o.filePath.startsWith(`${v.label}/`)):void 0,y=Jt.find(v=>v.repoRoot===be.repoRoot&&v.baseRef===be.baseRef&&(v.branchName??null)===(be.currentBranch??null)&&v.filePath===o.filePath&&v.hunkHeader===o.hunkHeader&&(v.hunkIndex??0)===o.hunkIndex&&v.fingerprint===o.fingerprint)??null;return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex}`,repoRoot:c?.repoRoot??be.repoRoot,repositoryPath:c?o.filePath.slice(c.label.length+1):o.filePath,hunk:o.previewRevert&&!
|
|
1672
|
-
`):`- ${x?".":""}`,y=o.length>0?o.map(v=>{const k=Zt[v.root]||v.branch||"",S=Et[v.root]||"",
|
|
1669
|
+
`)},[tr.length,pn,le,st,x]),vh=a.useCallback((t="generate")=>{if(yn&&_r.length===0&&!ce){Xr(!0);return}const o=t==="generate"?ii:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",ii].join(`
|
|
1670
|
+
`);dt("insert_change_audit_prompt",{rootPath:x,activeGitRepoRoots:tr,mode:t,hasAuditListCommand:o.includes("td audit-list"),promptLength:o.length}),Lr(i("rightSidebar.insertChangeAuditPrompt"),o,`${pc}:${t}`),cr(),d||l()},[ce,ii,_r.length,tr,Lr,cr,l,d,x,yn,i]),Da=a.useCallback(async t=>{try{await md({ids:[t]}),Yr(o=>o.filter(c=>c.id!==t))}catch{cr()}},[cr]),yh=a.useCallback(async()=>{if(Mt.length===0)return;const t=Mt.map(o=>o.id);try{await md({ids:t}),Yr(o=>o.filter(c=>!t.includes(c.id))),Fr(null)}catch(o){const c=o instanceof Error?o.message:"Failed to clear change audit explanations";Fr(i("rightSidebar.changeAuditClearFailed",{message:c})),cr()}},[Mt,cr,i]),wh=a.useCallback(async t=>{if(t.records.length===0)return;const o=t.records.map(c=>c.id);try{await pm({ids:o}),Br(c=>c.filter(y=>!o.includes(y.id))),Xe===t.key&&(sn(null),nr(!1))}catch(c){vt(i("rightSidebar.branchAuditClearFailed",{message:c instanceof Error?c.message:"Failed to clear branch explanation"})),wa(null)}},[wa,Xe,i]),kh=a.useCallback(t=>{Cn(o=>t===null?(Xr(!1),[]):o.includes(t)?o.filter(c=>c!==t):[...o,t])},[]),Sh=a.useCallback(t=>{No(o=>t===null?(Co(!1),[]):o.includes(t)?o.filter(c=>c!==t):[...o,t])},[]),li=a.useMemo(()=>{if(!ir)return[];const t=o=>{const c=o.diff??"";let y=0,v=0;for(const k of c.split(`
|
|
1671
|
+
`))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(y+=1),k.startsWith("-")&&(v+=1));return{filePath:o.filePath,oldPath:o.oldPath,newPath:o.newPath,hunkHeader:o.hunkHeader,hunkIndex:o.hunkIndex??0,fingerprint:o.fingerprint,additions:y,deletions:v,diff:c}};return be?(be.hunks??[]).map(o=>{const c=be.comparisonRepos&&be.comparisonRepos.length>1?[...be.comparisonRepos].sort((v,k)=>k.label.length-v.label.length).find(v=>o.filePath.startsWith(`${v.label}/`)):void 0,y=Jt.find(v=>v.repoRoot===be.repoRoot&&v.baseRef===be.baseRef&&(v.branchName??null)===(be.currentBranch??null)&&v.filePath===o.filePath&&v.hunkHeader===o.hunkHeader&&(v.hunkIndex??0)===o.hunkIndex&&v.fingerprint===o.fingerprint)??null;return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex}`,repoRoot:c?.repoRoot??be.repoRoot,repositoryPath:c?o.filePath.slice(c.label.length+1):o.filePath,hunk:o.previewRevert&&!Vn(o.previewRevert.cwd,o.previewRevert.comparisonBranch)?{...o,previewRevert:void 0}:o,current:y,stale:null}}):Xe?Jt.filter(o=>Yd(o)===Xe).map(o=>{const c=t(o);return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex??0}`,hunk:c,current:o,stale:null}}):[]},[be,Jt,Vn,ir,Xe]),ci=Jt.length>0,qn=a.useMemo(()=>{if(!ir)return[];const t=new Map;for(const o of Jt){const c=o.repoRoot,y=ct.get(c),v=y?.relativeRoot==="."?st:y?.relativeRoot||y?.name||kt(c),k=Yd(o),S=t.get(k)??{key:k,repoRoot:c,repoLabel:v,baseRef:o.baseRef,branchName:o.branchName??null,headRef:o.headRef??null,diffFingerprint:o.diffFingerprint??null,records:[],latestInjectedAt:0};S.records.push(o),S.latestInjectedAt=Math.max(S.latestInjectedAt,o.injectedAt??0),t.set(k,S)}return Array.from(t.values()).sort((o,c)=>c.latestInjectedAt-o.latestInjectedAt)},[Jt,ct,ir,st]),di=a.useMemo(()=>Xe?qn.find(t=>t.key===Xe)??null:null,[qn,Xe]),Rs=be?{repoRoot:be.repoRoot??"",repoLabel:be.repoRoot?ct.get(be.repoRoot)?.relativeRoot==="."?st:ct.get(be.repoRoot)?.relativeRoot||ct.get(be.repoRoot)?.name||kt(be.repoRoot):st,baseRef:be.baseRef??be.baseBranch??"",branchName:be.currentBranch??null,headRef:be.headRef??null,diffFingerprint:be.diffFingerprint??null}:di,jh=a.useMemo(()=>(qe?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,repoRoot:qe?.repoRoot,hunk:t,current:null,stale:null})),[qe?.hunks,qe?.repoRoot]),Rh=a.useMemo(()=>{if(be)return[];const t=di;return t?rs.filter(o=>o.repoRoot===t.repoRoot&&o.baseRef===t.baseRef&&(o.branchName??null)===t.branchName&&(!t.diffFingerprint||o.diffFingerprint===t.diffFingerprint)):[]},[be,rs,di]),Ch=a.useCallback(t=>{const o=li.find(c=>c.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${c.hunk.filePath}`===t.filePath:!1));o&&(an(o.key),window.setTimeout(()=>kn(t),90),window.setTimeout(()=>kn(t),320),window.setTimeout(()=>kn(t),760))},[li]),ui=a.useMemo(()=>{const t=v=>`'${v.replace(/'/g,"'\\''")}'`,o=ks,c=o.length>0?o.map(v=>`- ${v.label} (${v.root}),目标分支:${Zt[v.root]||v.branch||"(current branch)"},基线分支:${Et[v.root]||"(not set)"},包含本地未提交更改:${Vn(v.root,Zt[v.root]||v.branch)&&(nn[v.root]??!0)?"是":"否"}`).join(`
|
|
1672
|
+
`):`- ${x?".":""}`,y=o.length>0?o.map(v=>{const k=Zt[v.root]||v.branch||"",S=Et[v.root]||"",se=v.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(v.root)} switch ${t(k)}`:` # ${v.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(S)} ${t(v.root)} > ~/.termdock/branch-audit/branch-audit-export-${se}.json`].join(`
|
|
1673
1673
|
`)}).join(`
|
|
1674
1674
|
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${x??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",c,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",y,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:x??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(`
|
|
1675
|
-
`)},[
|
|
1676
|
-
`);Lr(i("rightSidebar.branchAuditShort"),o,`context:branch-audit-scope:${t}`),d||l()},[ui,Lr,l,d,i]),fi=a.useCallback(async(t={})=>{const o=t.refresh===!0,c=o&&be?.comparisonRepos?be.comparisonRepos:ks.map(S=>{const
|
|
1677
|
-
`),files:S.flatMap((G,
|
|
1678
|
-
`),truncated:S.some(G=>G.truncated)};if(Z.comparisonRepos=c.map((G,X)=>({...G,head:G.head??S[X].currentBranch??null,includeUncommitted:S[X].includeUncommitted===!0})),Z.canIncludeUncommitted=S.every(G=>G.canIncludeUncommitted===!0),Z.includeUncommitted=S.some(G=>G.includeUncommitted===!0),Mo(G=>({...G,...Object.fromEntries(Z.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!o&&(Z.hunks??[]).length===0){Fe(i("rightSidebar.branchAuditDiffEmpty"));return}const me=Date.now(),Ee=(o?Ye:null)??["preview",Z.repoRoot??x,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??me].join("\0"),Xe=c.length===1?c[0].label:`${c.length} repos`;Qt(Z),Zr(G=>[{key:Ee,diff:Z,repoLabel:Xe,createdAt:me},...G.filter(X=>X.key!==Ee)].slice(0,8)),o||A(G=>G[Ee]===void 0?G:{...G,[Ee]:0}),an(Ee),on(G=>{const X=Z.hunks?.[0],Ne=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return o&&G&&(Z.hunks??[]).some(Oe=>Oe.filePath===G.split("\0")[0])?G:Ne}),nr(!0)}catch(S){if(!k()||fr(S))return;Fe(S instanceof Error?S.message:"Failed to load branch diff")}finally{k()&&De(!1)}},[Vr,sn,be,Ye,ks,Et,Zt,Re,x,i]),Mh=a.useCallback(t=>{++z.current,De(!1),Qt(t.diff),Fe(null),an(t.key),on(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),nr(!0)},[]),Eh=a.useCallback(t=>{Zr(o=>o.filter(c=>c.key!==t)),A(o=>{if(!(t in o))return o;const c={...o};return delete c[t],c}),Ye===t&&(an(null),Qt(null),nr(!1))},[Ye]),$h=a.useCallback(t=>{++z.current,De(!1);const o=qn.find(c=>c.key===t);o&&(Qt(null),Fe(null),an(t),on(o.records[0]?.filePath??null),nr(!0))},[qn]),Lh=a.useCallback(async t=>{if(!x||!we)return;const[o]=t.split(/\s+/);if(o){sr(o),en(null),ft(null);try{const c=await gm({cwd:x,repoRoot:we,commit:o,requestSlotId:"right-sidebar-commit-diff"});if(!c.available){en(c.error??"Commit diff is unavailable");return}ft(c);const y=c.hunks?.[0];Zs(y?`${y.filePath}\0${y.hunkHeader}\0${y.hunkIndex}`:null)}catch(c){en(c instanceof Error?c.message:"Failed to load commit diff")}finally{sr(null)}}},[we,x]),Ph=a.useCallback(t=>{if(!be||!Ye)return;const o=Math.max(0,Math.round(t));A(c=>Math.abs((c[Ye]??0)-o)<24?c:{...c,[Ye]:o})},[be,Ye]);a.useEffect(()=>{!be||!Ye||Zr(t=>t.map(o=>o.key===Ye&&o.diff!==be?{...o,diff:be}:o))},[be,Ye]);const Uc=!!be;a.useEffect(()=>{!ne||!jr||!Uc||gs(1)},[jr,Uc,ne,gs]);const Hc=a.useCallback(t=>{t&&Gf(o=>qm(o,t))},[]),zc=fa.key===ot?fa.key:null,Fa=a.useCallback(t=>{const o=J.getState(),c=ex();no("select_diff_file",{interactionId:c,path:t,previousSelectedFilePath:o.selectedFilePath,rootPath:o.rootPath,activeGitRepoRoot:ce,changedFiles:o.changedFiles.size,gitBundleLoading:o.gitBundleLoading,gitBundleLastLoadedAt:o.gitBundleLastLoadedAt,rightTab:o.rightTab}),it(t),er("diff"),ne&&t&&gs(1),Hc(t),queueMicrotask(()=>{const y=J.getState();no("select_diff_file_after",{interactionId:c,requestedPath:t,selectedFilePath:y.selectedFilePath,rootPath:y.rootPath,rightTab:y.rightTab,changedFiles:y.changedFiles.size,activeGitRepoRoot:ce})})},[ce,ne,Hc,it,er,gs]),Wc=a.useCallback(t=>{const o=Array.from(je.values()).find(c=>{const y=gt(c,x),v=wt(c);return c.path===t.filePath||v===t.filePath||c.absolutePath===t.filePath||(y?`${y}/${c.path}`===t.filePath:!1)||t.repoRoot&&y===t.repoRoot&&c.path===t.filePath});if(o){Fa(wt(o)),window.setTimeout(()=>Sn(t),90),window.setTimeout(()=>Sn(t),320),window.setTimeout(()=>Sn(t),760);return}Sn(t)},[je,x,Fa]),Gc=a.useCallback(({slideToDetail:t,fullscreen:o,toggleFullscreen:c}={})=>es.length>0?e.jsx(yu,{walkthroughs:es,repoRoot:ce,fullscreen:o,onToggleFullscreen:c,onNavigate:y=>{ne&&window.requestAnimationFrame(()=>t?.()),Wc(y)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(zs,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),i("rightSidebar.changeWalkthroughEmpty")]}),[ce,es,Wc,ne,i]),Ah=a.useCallback(t=>{t&&vr(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),Ei(Ri,c),c})},[]),Kc=a.useCallback(t=>{yr(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),Ei(Bd,c),c})},[]),_a=a.useCallback(t=>{qs(t),Lt(_u,t)},[]);a.useEffect(()=>{$a||wr!=="ai"||_a("tree")},[wr,_a,$a]);const Ba=a.useCallback(()=>{Zn(t=>{const o=!t;return Lt(Bu,o),o})},[]),Vc=a.useCallback(t=>{Ys(t),Lt(Ou,t)},[]),{whitespace:qc,context:Yc}=Xm(),Xc=a.useMemo(()=>({algorithm:"histogram",whitespace:qc,context:Yc}),[qc,Yc]),Jc=a.useCallback(t=>{V(t),Lt(Uu,t)},[]),Oa=a.useCallback(async(t,o,c,y)=>{let v=t;for(;v.ok&&v.status==="running";)await new Promise(S=>window.setTimeout(S,1500)),v=await gd({jobId:v.jobId,cwd:o.cwd,action:o.action});if(!v.ok)throw new Error("Git action status is unavailable");if(v.status==="error")throw new Error(v.error||v.message||"Git action failed");const k={action:o.action,path:y,label:c};return us(k),window.setTimeout(()=>us(S=>S?.action===k.action&&S.path===k.path?null:S),1400),v},[]),yt=a.useCallback(async(t,o,c)=>{const y=x;x&&lr.current.delete(x),vt(null),us(null),ds({action:t.action,path:c});try{const v=await bm({...t,includeNested:$s(x)}),k=await Oa(v,t,o,c);if(!Re(y))return!1;const S=x?await yi(x,void 0,{includeNested:$s(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ps(x)}).catch(()=>k.bundle):k.bundle;return Re(y)?(S&&Hn(S,{reloadDiff:!0,cacheOnly:!0}),ln(null),!0):!1}catch(v){return us(null),vt(i("rightSidebar.gitActionFailed",{message:v instanceof Error?v.message:"Unknown error"})),!1}finally{Re(y)&&ds(null)}},[Hn,Re,x,i,Oa]),Qc=a.useCallback(async t=>{const o=x;await bd({...t,includeNested:$s(x)}),Re(o)&&It(x??void 0,{refresh:!0,background:!0})},[Re,It,x]),Th=a.useCallback(async t=>{const o=be,c=z.current,y=o?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!o||!y||!t.comparisonBase)throw new Error(i("diffViewer.hunkActionUnavailable"));Se(k=>k+1),Fe(null);try{await bd(t)}catch(k){throw Se(S=>S-1),k}if(c!==z.current||!Re(x)){Se(k=>k-1);return}const v=k=>{Qt(S=>{if(!S||c!==z.current)return S;const ae=S.hunks??[],Z=k===void 0?ae.filter(Ee=>!(Ee.previewRevert?.cwd===t.cwd&&Ee.previewRevert.patch===t.patch)):[...ae.filter(Ee=>Ee.filePath!==y.filePath),...k];return{...S,hunks:Z}})};v(),pd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(c!==z.current||!Re(x))return;if(!k.available||k.truncated)throw new Error(k.error??i("diffViewer.hunkActionUnavailable"));const S=t.path.slice(t.cwd.length+1),ae=y.filePath.slice(0,y.filePath.length-S.length);v((k.hunks??[]).map(Z=>({...Z,filePath:`${ae}${Z.filePath}`,oldPath:Z.oldPath?`${ae}${Z.oldPath}`:Z.oldPath,newPath:Z.newPath?`${ae}${Z.newPath}`:Z.newPath})))}).catch(k=>{c===z.current&&Re(x)&&!fr(k)&&Fe(`${i("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>Se(k=>k-1))},[be,Re,x,i]),Ua=a.useCallback((t,o,c)=>{if(o){if(t==="stage-all"){yt({action:"stage-all",cwd:o},i("rightSidebar.stageAll"),`repo:${o}`);return}ln({kind:"stash-all",repoRoot:o,repoLabel:c})}},[yt,i]),Zc=a.useCallback(t=>{Pe(t),ia(""),la(""),ca(""),it(Rc(t)),lt||er("diff"),t&&Ma(ct.get(t))},[Ma,Rc,lt,ct,it,Pe,er]),ed=a.useCallback(t=>{const o=new Set([...Wt.current.keys(),...mn.current,...lr.current]);for(const c of o)c!==t&&(zt.current.delete(c),Wt.current.get(c)?.abort(),Wt.current.delete(c),Ct(`right-sidebar-git-untracked:${c}`),mn.current.delete(c),lr.current.delete(c))},[]),Ih=a.useCallback(async t=>{const o=x;if(!o||(await J.getState().setNestedGitScanRoot(o,t),!Re(o)))return;if(t){await It(o,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}ed(o),ia(""),la(""),ca(""),No(y=>y.filter(v=>v===o));const c=Kt;c&>(c,o)!==o&&it(null),await It(o,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[ed,Re,It,x,it,Kt]),Dh=a.useCallback(async()=>{if(!we||Je){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=An.trim();!t||t===fe?.branch||await yt({action:"switch-branch",cwd:we,branch:t},i("rightSidebar.switchBranch"))},[fe?.branch,we,Je,yt,An,i]),td=a.useCallback(async()=>{if(!we||Je){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=oa.trim();if(!t)return;await yt({action:"commit",cwd:we,message:t},i("rightSidebar.commitChanges"))&&Tl("")},[we,oa,Je,yt,i]),Fh=a.useCallback(async()=>{if(!we||Je){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),o=un.trim();await yt({action:"push",cwd:we,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pushChanges"))},[we,un,dn,Je,yt,i]),_h=a.useCallback(async()=>{if(!we||Je){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),o=un.trim();await yt({action:"pull",cwd:we,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pullChanges"))},[we,un,dn,Je,yt,i]);a.useEffect(()=>{if(!lt||!we||Ue)return;let t=!1;const o={push:i("rightSidebar.pushChanges"),pull:i("rightSidebar.pullChanges"),commit:i("rightSidebar.commitChanges"),"switch-branch":i("rightSidebar.switchBranch"),"stage-all":i("rightSidebar.stageAll"),"stash-all":i("rightSidebar.stashAll")};return(async()=>{for(const c of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const y=await gd({cwd:we,action:c}).catch(()=>null);if(!y?.ok||y.status!=="running")continue;const v={action:c,cwd:we},k=o[c]??c;ds({action:c});try{const S=await Oa(y,v,k);if(t||!Re(x))return;const ae=x?await yi(x,void 0,{includeNested:$s(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ps(x)}).catch(()=>S.bundle):S.bundle;ae&&Hn(ae,{reloadDiff:!0,cacheOnly:!0})}catch(S){t||vt(i("rightSidebar.gitActionFailed",{message:S instanceof Error?S.message:"Unknown error"}))}finally{t||ds(null)}return}})(),()=>{t=!0}},[we,Hn,lt,Re,x,Ue,i,Oa]);const hi=Ln?.action==="commit",mi=Ln?.action==="switch-branch",pi=Ln?.action==="pull",gi=Ln?.action==="push",Ha=lt||zf,bi=Pa?i("rightSidebar.changeAuditScopeAll"):ur.length===1?ur[0].label:`${ur.length} repos`,Bh=ur.length>0,rd=ks.length>0,Oh=x?e.jsx(nu,{open:Ro,onOpenChange:Co,showScopePicker:!0,selectedAll:Pa,repos:Vt,selectedRoots:La,onToggleRepo:Sh,onGenerate:()=>Nh(ci?"regenerate":"generate"),disabled:!Bh,generateDisabled:!rd,inserted:ke?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:i(ci?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.branchAuditGenerateTitle"),ariaLabel:i("rightSidebar.branchAuditShort"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:bi,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i(ci?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{fi()},secondaryDisabled:!rd||Ze,secondaryLabel:i("rightSidebar.branchAuditViewDiff"),secondaryTitle:i("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Ze,loading:Cl.size>0,statusTitle:Cl.size>0?i("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:$c.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:i("rightSidebar.missingBaseReposSkipped",{repositories:$c.map(t=>t.label).join(O==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const o=ct.get(t.root),c=Vr(t.root,Zt[t.root]||o?.context?.branch),y=[],v=new Set,k=(me,Ee)=>{!me||v.has(me)||(v.add(me),y.push({value:me,label:me,meta:Ee}))};k(Zt[t.root]||o?.context?.branch,i("rightSidebar.pushCurrentBranchBadge"));for(const me of o?.context?.branches??[])k(me,me===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):i("rightSidebar.localBranch"));for(const me of o?.context?.remoteBranches??[])k(me,i("rightSidebar.remoteBranch"));const S=[],ae=new Set,Z=(me,Ee)=>{!me||ae.has(me)||(ae.add(me),S.push({value:me,label:me,meta:Ee}))};Z(Et[t.root],Et[t.root]?i("rightSidebar.pushUpstreamBadge"):void 0),Z(o?.context?.upstream,o?.context?.upstream?i("rightSidebar.pushUpstreamBadge"):void 0);for(const me of o?.context?.remoteBranches??[])Z(me,"remote");for(const me of o?.context?.branches??[])Z(me,me===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(Xn,{label:i("rightSidebar.currentBranchLabel"),value:Zt[t.root]||o?.context?.branch||"",options:y,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),onChange:me=>{ta(Ee=>({...Ee,[t.root]:me}))}}),e.jsx(Xn,{label:i("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:S,placeholder:i("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:i("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:i("rightSidebar.branchAuditBaseEmpty"),onChange:me=>{ra(Ee=>({...Ee,[t.root]:me}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:i("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:i(c?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:c&&(sn[t.root]??!0),disabled:!c,onChange:me=>Mo(Ee=>({...Ee,[t.root]:me.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,nd=As(Mt.reduce((t,o)=>Math.max(t,o.injectedAt??0),0),O),Uh=x?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Rl(t=>{const o=!t;return Lt(Ci,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":cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(zs,{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:i("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:bi})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${cs?"rotate-90":""}`,children:e.jsx(Ga,{size:13})})]}),cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[i("rightSidebar.changeAuditScopeLabel"),": ",bi]}),Oh]}),Ke&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ke}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Qr.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ye===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Mh(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:i("rightSidebar.branchAuditViewDiff")})]}),As(t.createdAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:As(t.createdAt,O)})]}),e.jsx("button",{type:"button",onClick:()=>Eh(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:i("common.delete"),"aria-label":i("common.delete"),children:e.jsx(ao,{size:12})})]},t.key)),qn.length>0?qn.slice(0,Math.max(0,8-Qr.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ye===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>$h(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),As(t.latestInjectedAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:i("rightSidebar.branchAuditGeneratedAt",{time:As(t.latestInjectedAt,O)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{wh(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:i("rightSidebar.branchAuditClearTitle"),"aria-label":i("rightSidebar.branchAuditClearTitle"),children:e.jsx(ao,{size:12})})]},t.key)):Qr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:i("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,sd=ir&&x&&Vn?e.jsxs("div",{className:Ha?"overflow-visible":"overflow-hidden",children:[Uh,e.jsxs("button",{type:"button",onClick:()=>{lt||Wf(t=>{const o=!t;return o&&we&&!Vn&&!cn&&Yo(we),o})},"aria-expanded":Ha,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${lt?"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(Pr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:i("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${yn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[cn&&e.jsx(Nt,{size:10,className:"animate-spin"}),yn.staged>0?i("rightSidebar.stagedCount",{count:yn.staged}):i("rightSidebar.noStagedChangesShort")]}),!lt&&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 ${Ha?"rotate-90":""}`,children:e.jsx(Ga,{size:13})})]})]}),Ha&&e.jsxs("div",{className:"space-y-0",children:[Ft.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:lh})]})}),e.jsx(Xn,{label:i("rightSidebar.gitRepositoryLabel"),value:we??"",options:Ft,placeholder:i("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:i("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:i("rightSidebar.gitRepositoryEmpty"),disabled:!!Ue,onChange:t=>{Zc(t||null)}}),Je&&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:i("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:An!==jc?jc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Dh()},disabled:!xh,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${mi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Ue?.action==="switch-branch"||mi?"opacity-0":"",children:i("rightSidebar.switchBranch")}),Ue?.action==="switch-branch"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),mi&&Ue?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(Xn,{label:i("rightSidebar.currentBranchLabel"),value:An,options:uh,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),disabled:!!Ue,onChange:ia})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Je?i("rightSidebar.selectRepositoryForGitActions"):yn.staged>0?i("rightSidebar.commitReadyHint",{count:yn.staged}):i("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{td()},disabled:!!Ue||Je||yn.staged===0||!oa.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${hi?"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:Je?i("rightSidebar.selectRepositoryForGitActions"):yn.staged===0?i("rightSidebar.commitNeedsStaged"):i("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Ue?.action==="commit"||hi?"opacity-0":"",children:i("rightSidebar.commitChanges")}),Ue?.action==="commit"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),hi&&Ue?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:oa,onChange:t=>Tl(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),td())},placeholder:i("rightSidebar.commitMessagePlaceholder"),disabled:!!Ue,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Or(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":tn,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:i("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Js&&e.jsx(Nt,{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 ${tn?"rotate-90":""}`,children:e.jsx(Ga,{size:13})})]})]}),tn&&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(Jn,{size:12,className:"shrink-0"}),e.jsx("input",{value:rn,onChange:t=>nn(t.target.value),placeholder:i("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}),rn&&e.jsx("button",{type:"button",onClick:()=>nn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(Yt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:ch,children:[Tt.length>0?Tt.map(t=>{const[o,...c]=t.split(/\s+/),y=c.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Lh(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:y,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:o}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:y,children:y}),Q[o]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${Q[o]==="ahead"?"bg-accent/10 text-accent":Q[o]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:i(Q[o]==="ahead"?"rightSidebar.commitAhead":Q[o]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Mn===o&&e.jsx(Nt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Js?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:i("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:i("rightSidebar.recentCommitsEmpty")}),Qs&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(Nt,{size:12,className:"animate-spin"})}),jo&&!Qs&&Tt.length>0&&e.jsx("button",{type:"button",onClick:()=>{ws({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:i("rightSidebar.recentCommitsLoadMore")})]})]}),as&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:as}),Sl&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Sl})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{_h()},disabled:!gh,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${pi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Ue?.action==="pull"||pi?"opacity-0":"",children:i("rightSidebar.pullChanges")}),Ue?.action==="pull"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),pi&&Ue?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Fh()},disabled:!bh,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${gi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Ue?.action==="push"||gi?"opacity-0":"",children:i("rightSidebar.pushChanges")}),Ue?.action==="push"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),gi&&Ue?.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] ${Pc.className}`,title:fe?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:Pc.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:fe?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${Ec?"grid-cols-2":"grid-cols-1"}`,children:[Ec&&e.jsx(Xn,{label:i("rightSidebar.pushRemoteLabel"),value:dn,options:Mc,placeholder:i("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:i("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:i("rightSidebar.pushNoRemotes"),disabled:!!Ue,onChange:la}),e.jsx(Xn,{label:i("rightSidebar.pushBranchLabel"),value:un,options:fh,placeholder:i("rightSidebar.pushBranchPlaceholder",{branch:fe?.branch??"HEAD"}),searchPlaceholder:i("rightSidebar.pushBranchSearchPlaceholder"),emptyText:i("rightSidebar.pushNoBranches"),disabled:!!Ue,onChange:ca})]})]})]})]}):null,Hh=a.useCallback(t=>{const o=gt(t,x);if(!o)return[];const c=Fi(t),y=[];return t.canStage&&y.push({key:"stage-file",label:i("rightSidebar.stageFile"),onClick:()=>{yt({action:"stage-file",cwd:o,paths:[t.path]},i("rightSidebar.stageFile"),c)}}),t.canUnstage&&y.push({key:"unstage-file",label:i("rightSidebar.unstageFile"),onClick:()=>{yt({action:"unstage-file",cwd:o,paths:[t.path]},i("rightSidebar.unstageFile"),c)}}),t.canStash&&y.push({key:"stash-file",label:i("rightSidebar.stashFile"),onClick:()=>{yt({action:"stash-file",cwd:o,paths:[t.path]},i("rightSidebar.stashFile"),c)}}),t.canRestoreWorktree&&y.push({key:"restore-worktree-file",label:i("rightSidebar.restoreFile"),destructive:!0,onClick:()=>ln({kind:"restore",file:t,phrase:""})}),y},[x,yt,i]),zh=a.useCallback(()=>{if(m){j?.();return}Cr(0),Mr.current?.slideTo(0),Rr(!1),bt(null)},[j,m]),ad=a.useCallback(t=>{if(K(""),Ht(t),it(null),bt(null),te(null),ne){m&&j?.(),Cr(0),Mr.current?.slideTo(0),Rr(!1);return}},[ne,j,m,it,Ht]);a.useEffect(()=>{const t=o=>{const c=o.detail,y=c?.path;if(typeof y!="string"||!y.startsWith("/"))return;K(""),bt(null),Pt(null);const v=!!(x&&(y===x||y.startsWith(`${x}/`)));if(c.kind==="file"){const k=Ti(y);bs(y),typeof c.line=="number"&&Number.isSafeInteger(c.line)&&c.line>0&&Pt(c.line),Ht(v?null:k),te(S=>({path:y,nonce:(S?.nonce??0)+1}));return}it(null),v?(Ht(null),te(k=>({path:y,nonce:(k?.nonce??0)+1}))):(te(null),Ht(y)),ne&&(m&&j?.(),Cr(0),Mr.current?.slideTo(0),Rr(!1))};return window.addEventListener(kd,t),()=>window.removeEventListener(kd,t)},[bs,ne,j,m,x,it,Ht]),a.useEffect(()=>{r||(Ot(!1),gr(!1))},[r]),a.useEffect(()=>{if(!mr&&!pr)return;const t=o=>{o instanceof globalThis.KeyboardEvent&&o.key!=="Escape"||o instanceof globalThis.MouseEvent&&o.target instanceof Node&&(jn.current?.contains(o.target)||Rn.current?.contains(o.target))||(Ot(!1),gr(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[pr,mr]);const od=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:ah,disabled:!Ca,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":i("rightSidebar.parentFolder"),title:i("rightSidebar.parentFolder"),children:e.jsx(pu,{size:14})}),e.jsx("button",{type:"button",onClick:gc,disabled:!x||In===x,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":i("rightSidebar.backToProjectRoot"),title:i("rightSidebar.backToProjectRoot"),children:e.jsx(Sd,{size:14})}),e.jsx("button",{type:"button",onClick:oh,disabled:!ge,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":i("rightSidebar.refreshFiles"),title:Il?i("rightSidebar.fileWatchUnavailable",{message:Il}):i("rightSidebar.refreshFiles"),children:e.jsx(Hi,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:ge??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:nh}),ga==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:i("fileTree.sortedByModified"),"aria-label":i("fileTree.sortedByModified"),children:e.jsx(jd,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>ge&&Gt(ge,Dt??void 0),disabled:!ge,...ge&&Dt?Zo(ja(ge),Dt):{},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 ${Dt&&(ke===Dt||rt===Dt)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":i(Dt&&rt===Dt?"rightSidebar.copied":Dt&&ke===Dt?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:i("rightSidebar.insertCurrentFolder"),children:Dt&&(ke===Dt||rt===Dt)?e.jsx(Ui,{size:13}):e.jsx(uo,{size:13})}),e.jsxs("div",{ref:Rn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Ot(!1),gr(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${pr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":pr,"aria-haspopup":"menu","aria-label":i("sidebar.moreActions"),title:i("sidebar.moreActions"),children:e.jsx(co,{size:14})}),pr&&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:()=>{gr(!1),ih()},disabled:!ni,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${vs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[vs?e.jsx(ki,{size:14}):e.jsx(Ka,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(vs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{gr(!1),Kf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Oo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Oo?e.jsx(ep,{size:14}):e.jsx(Vi,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(Oo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!ge,onClick:()=>{ge&&(gr(!1),Vf(ge,ga==="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:[ga==="modified"?e.jsx(_m,{size:14}):e.jsx(jd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(ga==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),x&&(Na.length>0||sh)&&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:i("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:gc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${ge===x?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:x,children:[e.jsx(Sd,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:nt})]}),Na.map(t=>{const o=t.path,c=t.kind==="file",y=c?ot===o:ge===o;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${y?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o,children:[e.jsxs("button",{type:"button",onClick:()=>c?bs(o):Ht(o),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[c?e.jsx(qi,{size:10,className:"shrink-0"}):e.jsx(Ka,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:kt(o)})]}),e.jsx("button",{type:"button",onClick:()=>fn(o),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":i("rightSidebar.unpinFolder",{name:kt(o)}),title:i("rightSidebar.unpinFolder",{name:kt(o)}),children:e.jsx(Yt,{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"})]}),xi=a.useMemo(()=>{if(Pn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,o=Math.max(0,Math.floor((To-Pn)/1e3)),c=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[y,v]=o<60?[-o,"second"]:o<3600?[-Math.floor(o/60),"minute"]:o<86400?[-Math.floor(o/3600),"hour"]:[-Math.floor(o/86400),"day"];return c.format(y,v)},[To,Pn]),Wh=x&&!zn?e.jsx("button",{type:"button",onClick:()=>{Ih(!Uo)},"aria-pressed":Uo,title:i("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${Uo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:i("rightSidebar.multiRepoScan")}):null,id=x?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[xi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:i("rightSidebar.gitLastUpdated",{time:xi}),children:xi}):null,e.jsx("button",{type:"button",onClick:()=>{ps()},disabled:zr,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":i("rightSidebar.refreshGit"),title:i("rightSidebar.refreshGit"),children:e.jsx(Hi,{size:13,className:zr?"animate-spin":""})})]}):null,Gh=nc?i("rightSidebar.changeAuditScopeAll"):gn.length===1?gn[0].relativeRoot==="."?nt:gn[0].relativeRoot||gn[0].name:`${gn.length} repos`,Kh=x?e.jsxs("div",{className:"inline-flex min-h-9 shrink-0 items-center",children:[e.jsx(nu,{open:ts,onOpenChange:Jr,showScopePicker:wn,selectedAll:nc,repos:qf,selectedRoots:tr,onToggleRepo:kh,onGenerate:()=>vh(),disabled:!x,inserted:ke===pc,buttonLabel:i("rightSidebar.changeAuditShort"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:i("rightSidebar.insertChangeAuditPrompt"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:Gh,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i("rightSidebar.changeAuditShort"),loading:Dr,error:!!Sr,statusTitle:Sr??(Dr?i("rightSidebar.changeAuditLoading"):Mt.length>0?`${i("rightSidebar.changeAuditLoaded",{count:Mt.length})}${nd?` · ${i("rightSidebar.changeAuditLoadedAt",{time:nd})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{yh()},disabled:Dr||Mt.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 ${Mt.length>0?"":"invisible"}`,title:i("rightSidebar.clearChangeAuditTitle"),"aria-label":i("rightSidebar.clearChangeAudit"),children:e.jsx(ao,{size:12})})]}):null,Cs=rr??(R?.available&&x&&je.size>0&&le.length<=1?{root:x,label:nt}:null),ld=e.jsxs(e.Fragment,{children:[Cs&&e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Ua("stage-all",Cs.root,Cs.label),disabled:!!Ue,className:"flex-1 rounded-md bg-accent/10 px-2 py-1 text-[11px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",children:i("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>Ua("stash-all",Cs.root,Cs.label),disabled:!!Ue,className:"flex-1 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground hover:bg-surface disabled:opacity-50",children:i("rightSidebar.stashAll")})]}),Wh,Kh]}),za=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[R?.available&&R.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:R.branch,children:[e.jsx(Pr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:R.branch})]}),ht.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[ht.modified,"M"]}),ht.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",ht.added]}),ht.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",ht.deleted]}),ht.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[ht.renamed,"R"]}),ht.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[ht.copied,"C"]}),ht.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[ht.untracked,"U"]}),ht.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[ht.conflicted,"!"]}),ht.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[ht.other,"?"]}),ht.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:i("rightSidebar.stagedCountShort",{count:ht.staged})})]});return e.jsxs(Bm,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h,children:[Zo.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Jf?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:x??void 0,children:nt}),(!ne||Lo)&&R?.available&&R.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:R.branch,children:[e.jsx(Pr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:R.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!xe;W(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):K("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${xe?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i("rightSidebar.toggleSearch"),title:i("common.search"),children:e.jsx(Jn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Te,onClick:()=>{He(t=>!t),Bt(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Te?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i("rightSidebar.toggleContextDraft"),title:i("rightSidebar.contextDraftTitle"),children:[e.jsx(Om,{size:14}),!Te&&ve.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:Bl,type:"file",multiple:!0,className:"hidden",onChange:t=>{const o=t.target.files;!o||o.length===0||(xs(Array.from(o)),t.target.value="")}}),e.jsx("input",{ref:Ol,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const o=t.target.files?.[0];t.target.value="",o&&eh(o)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${h?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:h?e.jsx(ki,{size:14}):e.jsx(Ka,{size:14})}),e.jsxs("div",{ref:jn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{gr(!1),Ot(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${mr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":mr,"aria-haspopup":"menu","aria-label":i("sidebar.moreActions"),title:i("sidebar.moreActions"),children:e.jsx(co,{size:15})}),mr&&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:"menuitemcheckbox","aria-checked":Hr,onClick:()=>Zf(!Hr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(xd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:i("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Hr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Hr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Bl.current?.click()},disabled:da,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:[da?e.jsx(Nt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(dp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Ol.current?.click()},disabled:da,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:[da?e.jsx(Nt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(sp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${h?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[h?e.jsx(ki,{size:14}):e.jsx(Ka,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),h&&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":i("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:i("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",i("rightSidebar.layoutModeAuto")],["narrow",i("rightSidebar.layoutModeNarrow")],["wide",i("rightSidebar.layoutModeWide")]].map(([t,o])=>{const c=Y===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":c,onClick:()=>{P(t),Ot(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${c?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:o},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":i("rightSidebar.close"),children:e.jsx(Yt,{size:14})})]}),xe&&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(Jn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:C,onChange:t=>K(t.target.value),placeholder:i(F==="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 ${ne?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Jc("name"),"aria-pressed":F==="name",className:`rounded-full px-2 transition active:scale-95 ${ne?"py-1":"py-0.5"} ${F==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:i("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Jc("content"),"aria-pressed":F==="content",className:`rounded-full px-2 transition active:scale-95 ${ne?"py-1":"py-0.5"} ${F==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:i("rightSidebar.searchModeContent")})]}),C&&e.jsx("button",{type:"button",onClick:()=>K(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(Yt,{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(Um,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:i("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:re,onChange:t=>ie(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:i("rightSidebar.searchScopePlaceholder"),"aria-label":i("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),re!=="."&&e.jsx("button",{type:"button",onClick:()=>ie("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.resetSearchScope"),children:e.jsx(Yt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>N(t=>!t),"aria-expanded":Ie,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${Ie||fs.length>0||q||$e||Le?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:i("rightSidebar.searchOptions"),"aria-label":i("rightSidebar.searchOptions"),children:[e.jsx(Hm,{size:13}),fs.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:fs.length})]})]}),Ie&&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:i("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:ye,onChange:t=>pe(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:i("rightSidebar.searchExcludePlaceholder"),"aria-label":i("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),ye&&e.jsx("button",{type:"button",onClick:()=>pe(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":i("rightSidebar.clearSearchExclude"),children:e.jsx(Yt,{size:11})})]}),F==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":i("rightSidebar.contentSearchOptions"),children:[[q,()=>he(t=>!t),Qm,i("rightSidebar.matchCase")],[$e,()=>Qe(t=>!t),fp,i("rightSidebar.matchWholeWord")],[Le,()=>at(t=>!t),op,i("rightSidebar.useRegex")]].map(([t,o,c,y])=>e.jsxs("button",{type:"button",onClick:o,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(c,{size:12}),y]},y))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(zn?2:3)+(Hr?1:0)}, minmax(0, 1fr))`},children:[!zn&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>er("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Pr,{size:12}),i("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:()=>er("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Nu,{size:12}),i("rightSidebar.tabChanges"),je.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:je.size}):null]})]}),e.jsxs("button",{type:"button",onClick:()=>er("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Km,{size:12}),i("rightSidebar.tabFiles")]}),Hr&&e.jsxs("button",{type:"button",onClick:()=>er("android"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xd,{size:12}),i("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),Pl&&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:Pl})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(to,{active:lt,mounted:ir,fallback:e.jsx(Ai,{slow:!1}),children:Ve?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Ld,{items:jh,diffViewType:Do,inlineMode:Xt,viewControls:h?Ss():void 0,renderPathReference:(t,o)=>Aa(kn(t,Ve.repoRoot??x),i(o==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:_f,onSelect:Zs,emptyText:i("rightSidebar.noChanges"),mobile:ne,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i("rightSidebar.recentCommitsTitle"),headerMeta:`${Ve.headRef??""}${Ve.commits?.[0]?` · ${Ve.commits[0]}`:""}`,onClose:()=>{ft(null),Zs(null)},closeLabel:i("common.back"),wrap:At,onToggleWrap:Ba,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:ne?"stacked":"split",onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:rt,onClearAuditRecord:Da})}):jr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Ld,{items:li,diffViewType:Do,inlineMode:Xt,viewControls:h?Ss():void 0,renderPathReference:(t,o)=>{const c=be?.comparisonRepos,y=c&&c.length>1?[...c].sort((k,S)=>S.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,v=y?t===y.label?y.repoRoot:kn(t.slice(y.label.length+1),y.repoRoot):kn(t,Rs?.repoRoot||x);return Aa(v,i(o==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Eo,onSelect:on,emptyText:i(be?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:ne,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i(be?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Rs?`${Rs.repoLabel} · ${Rs.branchName??"HEAD"} → ${Rs.baseRef}`:void 0,onClose:()=>{++z.current,De(!1),nr(!1),Qt(null)},closeLabel:i("common.back"),wrap:At,onToggleWrap:Ba,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:ne?"stacked":"split",onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:rt,onClearAuditRecord:Da,localOptions:be?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??be.includeUncommitted??!1,disabled:!Vr(t.repoRoot,t.head),onChange:o=>{fi({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:o})}})),onHunkGitAction:be?.includeUncommitted?Th:void 0,error:Ke,actionsBusy:ue>0,onRefresh:()=>{fi({refresh:!0})},refreshing:Ze,refreshLabel:i("rightSidebar.branchAuditRefreshDiff"),refreshTitle:i("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Rh,onWalkthroughNavigate:Ch,initialDetailScrollTop:be&&Ye?ss[Ye]:void 0,onDetailScrollPositionChange:Ph,externalSwiperRef:ne?ya:void 0,onMobileSlideChange:ne?$o:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:sd?e.jsx("div",{className:"px-3",children:sd}):zr?e.jsx(Ai,{slow:ql}):hn?e.jsx(ro,{message:hn,onRetry:()=>{ps()}}):lu(R)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):R?.available===!1?e.jsx(ro,{message:R.error??i("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ps()}}):x?e.jsx(Ai,{slow:ql}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(to,{active:Wn,children:ne?e.jsxs(bu,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Mr.current=t,t.slideTo(Ml,0)},onSlideChange:t=>{if(Cr(t.activeIndex),ms.current===t.activeIndex){ms.current=null;return}t.activeIndex===0&&(Rr(!1),bt(null),j?.())},children:[e.jsx(zi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:_n,onScroll:ac,onDragOver:ka,onDragEnter:ka,onDragLeave:lc,onDrop:cc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[Dl&&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:i("rightSidebar.dropToUpload")})}),!C.trim()&&od,e.jsx(Rd,{rootPath:ge??"",onFileSelect:bs,onPathReference:Gt,getReferenceText:ja,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:rt,onDirectoryRoot:bc,onSearchFromDirectory:xc,onDirectoryPinToggle:vc,onFilePinToggle:yc,pinnedPaths:xn,selectedFilePath:ot,query:_e,searchRootPath:Ql,searchOptions:Zl,searchMode:F,onContentMatchSelect:oc,onDirectoryDropFiles:(t,o)=>xs(o,t),revealDirectory:de,canOpenInFileBrowser:Fl,onOpenInFileBrowser:ic})]})}),e.jsx(zi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(cl,{filePath:Wn&&(Bf||Ml===1)?ot:null,onInsertReference:Gt,onInsertText:$r,onInsertFeature:$r,onReviewReference:hc,onReferenceCopied:Er,onClose:zh,onDirectoryLinkOpen:ad,isMobile:!0,lineRange:Cn,onLineRangeChange:bt,insertedReferenceKey:ke,copiedReferenceKey:rt,scrollToLine:We,onScrollToLineHandled:()=>Pt(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:E,onOpenMarkdownOutline:$,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:_n,onScroll:ac,onDragOver:ka,onDragEnter:ka,onDragLeave:lc,onDrop:cc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Fo},children:[Dl&&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:i("rightSidebar.dropToUpload")})}),!C.trim()&&od,e.jsx(Rd,{rootPath:ge??"",onFileSelect:bs,onPathReference:Gt,getReferenceText:ja,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:rt,onDirectoryRoot:bc,onSearchFromDirectory:xc,onDirectoryPinToggle:vc,onFilePinToggle:yc,pinnedPaths:xn,selectedFilePath:ot,query:_e,searchRootPath:Ql,searchOptions:Zl,searchMode:F,onContentMatchSelect:oc,onDirectoryDropFiles:(t,o)=>xs(o,t),revealDirectory:de,canOpenInFileBrowser:Fl,onOpenInFileBrowser:ic})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":i("rightSidebar.resizeFileTree"),title:i("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:Yf,onPointerMove:Xf,onPointerUp:sc,onPointerCancel:sc,onDoubleClick:()=>{_o(Zi),Lt(Ts,Zi)},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(cl,{filePath:Wn?ot:null,onInsertReference:Gt,onInsertText:$r,onInsertFeature:$r,onReviewReference:hc,onReferenceCopied:Er,onDirectoryLinkOpen:ad,isMobile:!1,lineRange:Cn,onLineRangeChange:bt,insertedReferenceKey:ke,copiedReferenceKey:rt,scrollToLine:We,onScrollToLineHandled:()=>Pt(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:E,onOpenMarkdownOutline:$,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p})})]})}),e.jsx(to,{active:Rt,mounted:Of||Rt,children:()=>Xo?e.jsx(zm,{}):ne?e.jsx(Wi,{mobile:!0,backLabel:i("rightSidebar.backToChangeList"),externalSwiperRef:ya,onMobileSlideChange:$o,groups:qt.length>0?_c():[],mode:wr,onModeChange:_a,selectedKey:ot,scrollToKey:zc,scrollToKeyNonce:fa.nonce,compact:!1,collapsedDirectoryKeys:Vs,onToggleDirectory:Kc,onSelectFile:t=>{const o=Array.from(je.values()).find(c=>wt(c)===t.key);o&&Fa(wt(o))},renderLeading:Oc,renderTrailing:t=>{const o=Array.from(je.values()).find(c=>wt(c)===t.key);return o?Dc(o):null},renderDirectoryTrailing:Fc,renderSubtitle:t=>{const o=Array.from(je.values()).find(c=>wt(c)===t.key);return o?Ic(o):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>x&&e.jsxs("div",{className:"px-0 py-0",children:[za&&e.jsx("div",{className:"mb-2",children:za}),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:i("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[qt.length,"/",je.size]})]}),e.jsxs(Ed,{actions:ld,children:[Ac(),t,h&&Ss(),id]},x),rr&&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:rr.label}),rr.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:rr.branch})]}),!rr&&wn&&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(Pr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:$a?(t=>Gc(t)):void 0,emptyContent:Xo?null:hn&&je.size===0?e.jsx(ro,{message:hn,onRetry:()=>{ps()}}):je.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):qt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:i("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>gs(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:i("rightSidebar.backToChangeList"),children:[e.jsx(Os,{size:14}),i("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[h&&Ss(),e.jsxs("button",{type:"button",onClick:Ba,"aria-pressed":At,title:i("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 ${At?"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:i(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Bc(),activePane:Rt,wrap:At,diffViewType:Do,inlineMode:Xt,diffOptions:Xc,reloadKey:Xs,renderStreamBadge:t=>e.jsx(Fs,{status:t}),onHunkGitAction:Qc,onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:rt,onClearAuditRecord:Da,onDetailScroll:Ta}):e.jsx(Wi,{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:i("rightSidebar.backToChangeList"),groups:qt.length>0?_c():[],mode:wr,onModeChange:_a,selectedKey:ot,scrollToKey:zc,scrollToKeyNonce:fa.nonce,compact:!0,collapsedDirectoryKeys:Vs,onToggleDirectory:Kc,onSelectFile:t=>{const o=Array.from(je.values()).find(c=>wt(c)===t.key);o&&Fa(wt(o))},renderLeading:Oc,renderTrailing:t=>{const o=Array.from(je.values()).find(c=>wt(c)===t.key);return o?Dc(o):null},renderDirectoryTrailing:Fc,renderSubtitle:t=>{const o=Array.from(je.values()).find(c=>wt(c)===t.key);return o?Ic(o):null},aiContent:$a?(t=>Gc(t)):void 0,emptyContent:Xo?null:hn&&je.size===0?e.jsx(ro,{message:hn,onRetry:()=>{ps()}}):je.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):qt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:i("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>x&&e.jsxs("div",{className:"px-0 py-0",children:[za&&e.jsx("div",{className:"mb-2",children:za}),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:i("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[qt.length,"/",je.size]})})]}),e.jsxs(Ed,{actions:ld,children:[Ac(),t,Ss(),e.jsxs("button",{type:"button",onClick:Ba,"aria-pressed":At,title:i("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${At?"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:i(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),id]},x),rr&&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:rr.label}),rr.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:rr.branch})]}),!rr&&wn&&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(Pr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i("rightSidebar.selectRepositoryForDiff")})]})]}),files:Bc(),activePane:Rt,wrap:At,diffViewType:Ut,inlineMode:Xt,diffOptions:Xc,reloadKey:Xs,renderStreamBadge:t=>e.jsx(Fs,{status:t}),onHunkGitAction:Qc,onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:rt,onClearAuditRecord:Da,onDetailScroll:Ta})}),e.jsx(to,{active:Gn,mounted:Ao&&Hr,children:Uf?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:i("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{vi.getState().setDock(wi,null),so({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:i("android.splitClose")})]}):e.jsx(Wm,{sessionId:n??null,onInsertPrompt:t=>Lr("android-deps",t),onInsertFile:rh,onRecordingComplete:th})})]}),r&&Te&&e.jsx(Fp,{value:ve,collapsed:_t,autoCollapseAfterSend:H,focusRequest:pt,insertError:Tr?i("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{br(!1),Ge(t)},onCollapsedChange:Bt,onAutoCollapseAfterSendChange:se,onDisable:()=>He(!1),onClear:()=>Ge(""),onInsert:()=>mc(!1),onInsertAndSend:()=>mc(!0),labels:{title:i("rightSidebar.contextDraftTitle"),hint:i("rightSidebar.contextDraftHint"),placeholder:i("rightSidebar.contextDraftPlaceholder"),collapse:i("rightSidebar.contextDraftCollapse"),expand:i("rightSidebar.contextDraftExpand"),disable:i("rightSidebar.contextDraftDisable"),clear:i("rightSidebar.contextDraftClear"),insert:i("rightSidebar.contextDraftInsert"),insertAndSend:i("rightSidebar.contextDraftInsertAndSend"),inserted:i("rightSidebar.contextDraftInserted"),sent:i("rightSidebar.contextDraftSent"),send:i("rightSidebar.contextDraftSend"),appended:i("rightSidebar.contextDraftAppended"),resize:i("rightSidebar.contextDraftResize"),autoCollapseAfterSend:i("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>i("rightSidebar.contextDraftCharacterCount",{count:t})}}),ph(),xt&&typeof document<"u"&&Yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>ln(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:xt.kind==="restore"?i("rightSidebar.confirmRestoreTitle"):i("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:xt.kind==="restore"?i("rightSidebar.confirmRestoreDescription",{path:mu(xt.file.absolutePath,x)}):i("rightSidebar.confirmStashAllDescription")}),xt.kind==="restore"&&e.jsx("input",{value:xt.phrase,onChange:t=>ln({...xt,phrase:t.target.value}),placeholder:i("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:()=>ln(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:i("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Ue||xt.kind==="restore"&&xt.phrase.trim()!==i("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(xt.kind==="restore"){const t=gt(xt.file,x);if(!t)return;yt({action:"restore-worktree-file",cwd:t,paths:[xt.file.path],confirm:{acknowledged:!0,phrase:xt.phrase}},i("rightSidebar.restoreFile"),Fi(xt.file))}else{const t=xt.repoRoot??x;if(!t)return;yt({action:"stash-all",cwd:t},i("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${xt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:i(Ue?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const px=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:cl,MarkdownImageLightbox:Rf,MarkdownPreview:Cf,RightSidebar:nx,__testParseMarkdownListBlock:yb,buildMarkdownPreviewBlocks:Lb,buildMarkdownPreviewRenderResult:yl,collectKnownGitRepoRoots:Yu,computeMarkdownImageDisplayBox:lf,getMarkdownHeadingOutline:jf,getMarkdownHeadingPathAtLine:Sf,getNextMarkdownPreviewLineRange:Fb,isSvgImageSrc:wo,mountRightSidebarRepoPickerOverlay:Du,replaceGitRepositorySnapshot:Pf,resolveMarkdownLocalLinkTarget:ml,resolveRightSidebarDiffViewType:Vu,shouldCloseMarkdownImageLightboxDrag:yf,showsGitRepoGroupHeader:el},Symbol.toStringTag,{value:"Module"}));export{Vi as E,px as R,ep as a,pp as c,mx as m};
|
|
1675
|
+
`)},[nn,Vn,ks,Et,Zt,x]),Nh=a.useCallback((t="generate")=>{const o=t==="generate"?ui:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",ui].join(`
|
|
1676
|
+
`);Lr(i("rightSidebar.branchAuditShort"),o,`context:branch-audit-scope:${t}`),d||l()},[ui,Lr,l,d,i]),fi=a.useCallback(async(t={})=>{const o=t.refresh===!0,c=o&&be?.comparisonRepos?be.comparisonRepos:ks.map(S=>{const se=(Zt[S.root]||S.branch||"").trim();return{repoRoot:S.root,label:S.label,base:Et[S.root]?.trim()??"",head:se||null,includeUncommitted:nn[S.root]??!0}});if(!x||c.length===0)return;const y=++z.current,v=x,k=()=>Ce(v)&&y===z.current;Fe(!0),_e(null),o||(Qt(null),ft(null));try{const S=await Promise.all(c.map(async G=>{if(!G.base)throw new Error(i("rightSidebar.branchAuditMissingBase",{repo:G.label}));return pd({cwd:x,repoRoot:G.repoRoot,base:G.base,head:G.head,includeUncommitted:t.repoRoot===G.repoRoot?t.includeUncommitted??!1:G.includeUncommitted??be?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${G.repoRoot}`})}));if(!k())return;const se=S.find(G=>!G.available);if(se){_e(se.error??"Branch diff is unavailable");return}const Z=S.length===1?S[0]:{available:!0,workspaceRoot:x,repoRoot:x,baseRef:S.map(G=>G.baseRef??G.baseBranch).filter(Boolean).join(", "),currentBranch:S.map(G=>G.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:S.map(G=>G.headRef).filter(Boolean).join(", "),diffFingerprint:S.map(G=>G.diffFingerprint).filter(Boolean).join("+"),stat:S.map(G=>G.stat).filter(Boolean).join(`
|
|
1677
|
+
`),files:S.flatMap((G,Y)=>{const je=c[Y];return(G.files??[]).map(Me=>`${je?.label??G.repoRoot??"repo"}/${Me}`)}),hunks:S.flatMap((G,Y)=>{const Me=c[Y]?.label??G.repoRoot??"repo";return(G.hunks??[]).map(He=>({...He,filePath:`${Me}/${He.filePath}`,oldPath:He.oldPath?`${Me}/${He.oldPath}`:He.oldPath,newPath:He.newPath?`${Me}/${He.newPath}`:He.newPath}))}),commits:S.flatMap(G=>G.commits??[]),commitCount:S.reduce((G,Y)=>G+(Y.commitCount??Y.commits?.length??0),0),diff:S.map(G=>G.diff).filter(Boolean).join(`
|
|
1678
|
+
`),truncated:S.some(G=>G.truncated)};if(Z.comparisonRepos=c.map((G,Y)=>({...G,head:G.head??S[Y].currentBranch??null,includeUncommitted:S[Y].includeUncommitted===!0,canIncludeUncommitted:S[Y].canIncludeUncommitted})),Z.canIncludeUncommitted=S.every(G=>G.canIncludeUncommitted===!0),Z.includeUncommitted=S.some(G=>G.includeUncommitted===!0),Mo(G=>({...G,...Object.fromEntries(Z.comparisonRepos.map(Y=>[Y.repoRoot,Y.includeUncommitted??!1]))})),!o&&(Z.hunks??[]).length===0){_e(i("rightSidebar.branchAuditDiffEmpty"));return}const me=Date.now(),$e=(o?Xe:null)??["preview",Z.repoRoot??x,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??me].join("\0"),Je=c.length===1?c[0].label:`${c.length} repos`;Qt(Z),Qr(G=>[{key:$e,diff:Z,repoLabel:Je,createdAt:me},...G.filter(Y=>Y.key!==$e)].slice(0,8)),o||A(G=>G[$e]===void 0?G:{...G,[$e]:0}),sn($e),an(G=>{const Y=Z.hunks?.[0],je=Y?`${Y.filePath}\0${Y.hunkHeader}\0${Y.hunkIndex}`:null;return o&&G&&(Z.hunks??[]).some(Me=>Me.filePath===G.split("\0")[0])?G:je}),nr(!0)}catch(S){if(!k()||fr(S))return;_e(S instanceof Error?S.message:"Failed to load branch diff")}finally{k()&&Fe(!1)}},[nn,be,Xe,ks,Et,Zt,Ce,x,i]),Mh=a.useCallback(t=>{++z.current,Fe(!1),Qt(t.diff),_e(null),sn(t.key),an(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),nr(!0)},[]),Eh=a.useCallback(t=>{Qr(o=>o.filter(c=>c.key!==t)),A(o=>{if(!(t in o))return o;const c={...o};return delete c[t],c}),Xe===t&&(sn(null),Qt(null),nr(!1))},[Xe]),$h=a.useCallback(t=>{++z.current,Fe(!1);const o=qn.find(c=>c.key===t);o&&(Qt(null),_e(null),sn(t),an(o.records[0]?.filePath??null),nr(!0))},[qn]),Lh=a.useCallback(async t=>{if(!x||!we)return;const[o]=t.split(/\s+/);if(o){sr(o),Zr(null),ft(null);try{const c=await gm({cwd:x,repoRoot:we,commit:o,requestSlotId:"right-sidebar-commit-diff"});if(!c.available){Zr(c.error??"Commit diff is unavailable");return}ft(c);const y=c.hunks?.[0];Zs(y?`${y.filePath}\0${y.hunkHeader}\0${y.hunkIndex}`:null)}catch(c){Zr(c instanceof Error?c.message:"Failed to load commit diff")}finally{sr(null)}}},[we,x]),Ph=a.useCallback(t=>{if(!be||!Xe)return;const o=Math.max(0,Math.round(t));A(c=>Math.abs((c[Xe]??0)-o)<24?c:{...c,[Xe]:o})},[be,Xe]);a.useEffect(()=>{!be||!Xe||Qr(t=>t.map(o=>o.key===Xe&&o.diff!==be?{...o,diff:be}:o))},[be,Xe]);const Uc=!!be;a.useEffect(()=>{!ne||!jr||!Uc||gs(1)},[jr,Uc,ne,gs]);const Hc=a.useCallback(t=>{t&&Gf(o=>qm(o,t))},[]),zc=fa.key===ot?fa.key:null,Fa=a.useCallback(t=>{const o=J.getState(),c=ex();no("select_diff_file",{interactionId:c,path:t,previousSelectedFilePath:o.selectedFilePath,rootPath:o.rootPath,activeGitRepoRoot:ce,changedFiles:o.changedFiles.size,gitBundleLoading:o.gitBundleLoading,gitBundleLastLoadedAt:o.gitBundleLastLoadedAt,rightTab:o.rightTab}),it(t),er("diff"),ne&&t&&gs(1),Hc(t),queueMicrotask(()=>{const y=J.getState();no("select_diff_file_after",{interactionId:c,requestedPath:t,selectedFilePath:y.selectedFilePath,rootPath:y.rootPath,rightTab:y.rightTab,changedFiles:y.changedFiles.size,activeGitRepoRoot:ce})})},[ce,ne,Hc,it,er,gs]),Wc=a.useCallback(t=>{const o=Array.from(Re.values()).find(c=>{const y=gt(c,x),v=wt(c);return c.path===t.filePath||v===t.filePath||c.absolutePath===t.filePath||(y?`${y}/${c.path}`===t.filePath:!1)||t.repoRoot&&y===t.repoRoot&&c.path===t.filePath});if(o){Fa(wt(o)),window.setTimeout(()=>kn(t),90),window.setTimeout(()=>kn(t),320),window.setTimeout(()=>kn(t),760);return}kn(t)},[Re,x,Fa]),Gc=a.useCallback(({slideToDetail:t,fullscreen:o,toggleFullscreen:c}={})=>es.length>0?e.jsx(yu,{walkthroughs:es,repoRoot:ce,fullscreen:o,onToggleFullscreen:c,onNavigate:y=>{ne&&window.requestAnimationFrame(()=>t?.()),Wc(y)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(zs,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),i("rightSidebar.changeWalkthroughEmpty")]}),[ce,es,Wc,ne,i]),Ah=a.useCallback(t=>{t&&vr(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),Ei(Ri,c),c})},[]),Kc=a.useCallback(t=>{yr(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),Ei(Bd,c),c})},[]),_a=a.useCallback(t=>{qs(t),Lt(_u,t)},[]);a.useEffect(()=>{$a||wr!=="ai"||_a("tree")},[wr,_a,$a]);const Ba=a.useCallback(()=>{Zn(t=>{const o=!t;return Lt(Bu,o),o})},[]),Vc=a.useCallback(t=>{Ys(t),Lt(Ou,t)},[]),{whitespace:qc,context:Yc}=Xm(),Xc=a.useMemo(()=>({algorithm:"histogram",whitespace:qc,context:Yc}),[qc,Yc]),Jc=a.useCallback(t=>{V(t),Lt(Uu,t)},[]),Oa=a.useCallback(async(t,o,c,y)=>{let v=t;for(;v.ok&&v.status==="running";)await new Promise(S=>window.setTimeout(S,1500)),v=await gd({jobId:v.jobId,cwd:o.cwd,action:o.action});if(!v.ok)throw new Error("Git action status is unavailable");if(v.status==="error")throw new Error(v.error||v.message||"Git action failed");const k={action:o.action,path:y,label:c};return us(k),window.setTimeout(()=>us(S=>S?.action===k.action&&S.path===k.path?null:S),1400),v},[]),yt=a.useCallback(async(t,o,c)=>{const y=x;x&&lr.current.delete(x),vt(null),us(null),ds({action:t.action,path:c});try{const v=await bm({...t,includeNested:$s(x)}),k=await Oa(v,t,o,c);if(!Ce(y))return!1;const S=x?await yi(x,void 0,{includeNested:$s(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ps(x)}).catch(()=>k.bundle):k.bundle;return Ce(y)?(S&&Un(S,{reloadDiff:!0,cacheOnly:!0}),on(null),!0):!1}catch(v){return us(null),vt(i("rightSidebar.gitActionFailed",{message:v instanceof Error?v.message:"Unknown error"})),!1}finally{Ce(y)&&ds(null)}},[Un,Ce,x,i,Oa]),Qc=a.useCallback(async t=>{const o=x;await bd({...t,includeNested:$s(x)}),Ce(o)&&It(x??void 0,{refresh:!0,background:!0})},[Ce,It,x]),Th=a.useCallback(async t=>{const o=be,c=z.current,y=o?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!o||!y||!t.comparisonBase)throw new Error(i("diffViewer.hunkActionUnavailable"));Se(k=>k+1),_e(null);try{await bd(t)}catch(k){throw Se(S=>S-1),k}if(c!==z.current||!Ce(x)){Se(k=>k-1);return}const v=k=>{Qt(S=>{if(!S||c!==z.current)return S;const se=S.hunks??[],Z=k===void 0?se.filter($e=>!($e.previewRevert?.cwd===t.cwd&&$e.previewRevert.patch===t.patch)):[...se.filter($e=>$e.filePath!==y.filePath),...k];return{...S,hunks:Z}})};v(),pd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(c!==z.current||!Ce(x))return;if(!k.available||k.truncated)throw new Error(k.error??i("diffViewer.hunkActionUnavailable"));const S=t.path.slice(t.cwd.length+1),se=y.filePath.slice(0,y.filePath.length-S.length);v((k.hunks??[]).map(Z=>({...Z,filePath:`${se}${Z.filePath}`,oldPath:Z.oldPath?`${se}${Z.oldPath}`:Z.oldPath,newPath:Z.newPath?`${se}${Z.newPath}`:Z.newPath})))}).catch(k=>{c===z.current&&Ce(x)&&!fr(k)&&_e(`${i("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>Se(k=>k-1))},[be,Ce,x,i]),Ua=a.useCallback((t,o,c)=>{if(o){if(t==="stage-all"){yt({action:"stage-all",cwd:o},i("rightSidebar.stageAll"),`repo:${o}`);return}on({kind:"stash-all",repoRoot:o,repoLabel:c})}},[yt,i]),Zc=a.useCallback(t=>{Ae(t),ia(""),la(""),ca(""),it(Rc(t)),lt||er("diff"),t&&Ma(ct.get(t))},[Ma,Rc,lt,ct,it,Ae,er]),ed=a.useCallback(t=>{const o=new Set([...Wt.current.keys(),...hn.current,...lr.current]);for(const c of o)c!==t&&(zt.current.delete(c),Wt.current.get(c)?.abort(),Wt.current.delete(c),Ct(`right-sidebar-git-untracked:${c}`),hn.current.delete(c),lr.current.delete(c))},[]),Ih=a.useCallback(async t=>{const o=x;if(!o||(await J.getState().setNestedGitScanRoot(o,t),!Ce(o)))return;if(t){await It(o,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}ed(o),ia(""),la(""),ca(""),No(y=>y.filter(v=>v===o));const c=Kt;c&>(c,o)!==o&&it(null),await It(o,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[ed,Ce,It,x,it,Kt]),Dh=a.useCallback(async()=>{if(!we||Qe){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=Pn.trim();!t||t===fe?.branch||await yt({action:"switch-branch",cwd:we,branch:t},i("rightSidebar.switchBranch"))},[fe?.branch,we,Qe,yt,Pn,i]),td=a.useCallback(async()=>{if(!we||Qe){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=oa.trim();if(!t)return;await yt({action:"commit",cwd:we,message:t},i("rightSidebar.commitChanges"))&&Tl("")},[we,oa,Qe,yt,i]),Fh=a.useCallback(async()=>{if(!we||Qe){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=cn.trim(),o=dn.trim();await yt({action:"push",cwd:we,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pushChanges"))},[we,dn,cn,Qe,yt,i]),_h=a.useCallback(async()=>{if(!we||Qe){vt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=cn.trim(),o=dn.trim();await yt({action:"pull",cwd:we,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pullChanges"))},[we,dn,cn,Qe,yt,i]);a.useEffect(()=>{if(!lt||!we||Ue)return;let t=!1;const o={push:i("rightSidebar.pushChanges"),pull:i("rightSidebar.pullChanges"),commit:i("rightSidebar.commitChanges"),"switch-branch":i("rightSidebar.switchBranch"),"stage-all":i("rightSidebar.stageAll"),"stash-all":i("rightSidebar.stashAll")};return(async()=>{for(const c of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const y=await gd({cwd:we,action:c}).catch(()=>null);if(!y?.ok||y.status!=="running")continue;const v={action:c,cwd:we},k=o[c]??c;ds({action:c});try{const S=await Oa(y,v,k);if(t||!Ce(x))return;const se=x?await yi(x,void 0,{includeNested:$s(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ps(x)}).catch(()=>S.bundle):S.bundle;se&&Un(se,{reloadDiff:!0,cacheOnly:!0})}catch(S){t||vt(i("rightSidebar.gitActionFailed",{message:S instanceof Error?S.message:"Unknown error"}))}finally{t||ds(null)}return}})(),()=>{t=!0}},[we,Un,lt,Ce,x,Ue,i,Oa]);const hi=$n?.action==="commit",mi=$n?.action==="switch-branch",pi=$n?.action==="pull",gi=$n?.action==="push",Ha=lt||zf,bi=Pa?i("rightSidebar.changeAuditScopeAll"):ur.length===1?ur[0].label:`${ur.length} repos`,Bh=ur.length>0,rd=ks.length>0,Oh=x?e.jsx(nu,{open:Ro,onOpenChange:Co,showScopePicker:!0,selectedAll:Pa,repos:Vt,selectedRoots:La,onToggleRepo:Sh,onGenerate:()=>Nh(ci?"regenerate":"generate"),disabled:!Bh,generateDisabled:!rd,inserted:ke?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:i(ci?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.branchAuditGenerateTitle"),ariaLabel:i("rightSidebar.branchAuditShort"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:bi,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i(ci?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{fi()},secondaryDisabled:!rd||et,secondaryLabel:i("rightSidebar.branchAuditViewDiff"),secondaryTitle:i("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:et,loading:Cl.size>0,statusTitle:Cl.size>0?i("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:$c.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:i("rightSidebar.missingBaseReposSkipped",{repositories:$c.map(t=>t.label).join(O==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const o=ct.get(t.root),c=Vn(t.root,Zt[t.root]||o?.context?.branch),y=[],v=new Set,k=(me,$e)=>{!me||v.has(me)||(v.add(me),y.push({value:me,label:me,meta:$e}))};k(Zt[t.root]||o?.context?.branch,i("rightSidebar.pushCurrentBranchBadge"));for(const me of o?.context?.branches??[])k(me,me===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):i("rightSidebar.localBranch"));for(const me of o?.context?.remoteBranches??[])k(me,i("rightSidebar.remoteBranch"));const S=[],se=new Set,Z=(me,$e)=>{!me||se.has(me)||(se.add(me),S.push({value:me,label:me,meta:$e}))};Z(Et[t.root],Et[t.root]?i("rightSidebar.pushUpstreamBadge"):void 0),Z(o?.context?.upstream,o?.context?.upstream?i("rightSidebar.pushUpstreamBadge"):void 0);for(const me of o?.context?.remoteBranches??[])Z(me,"remote");for(const me of o?.context?.branches??[])Z(me,me===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(Xn,{label:i("rightSidebar.currentBranchLabel"),value:Zt[t.root]||o?.context?.branch||"",options:y,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),onChange:me=>{ta($e=>({...$e,[t.root]:me}))}}),e.jsx(Xn,{label:i("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:S,placeholder:i("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:i("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:i("rightSidebar.branchAuditBaseEmpty"),onChange:me=>{ra($e=>({...$e,[t.root]:me}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:i("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:i(c?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:c&&(nn[t.root]??!0),disabled:!c,onChange:me=>Mo($e=>({...$e,[t.root]:me.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,nd=As(Mt.reduce((t,o)=>Math.max(t,o.injectedAt??0),0),O),Uh=x?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Rl(t=>{const o=!t;return Lt(Ci,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":cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(zs,{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:i("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:bi})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${cs?"rotate-90":""}`,children:e.jsx(Ga,{size:13})})]}),cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[i("rightSidebar.changeAuditScopeLabel"),": ",bi]}),Oh]}),Ve&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ve}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Jr.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Xe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Mh(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:i("rightSidebar.branchAuditViewDiff")})]}),As(t.createdAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:As(t.createdAt,O)})]}),e.jsx("button",{type:"button",onClick:()=>Eh(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:i("common.delete"),"aria-label":i("common.delete"),children:e.jsx(ao,{size:12})})]},t.key)),qn.length>0?qn.slice(0,Math.max(0,8-Jr.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Xe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>$h(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),As(t.latestInjectedAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:i("rightSidebar.branchAuditGeneratedAt",{time:As(t.latestInjectedAt,O)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{wh(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:i("rightSidebar.branchAuditClearTitle"),"aria-label":i("rightSidebar.branchAuditClearTitle"),children:e.jsx(ao,{size:12})})]},t.key)):Jr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:i("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,sd=ir&&x&&Kn?e.jsxs("div",{className:Ha?"overflow-visible":"overflow-hidden",children:[Uh,e.jsxs("button",{type:"button",onClick:()=>{lt||Wf(t=>{const o=!t;return o&&we&&!Kn&&!ln&&Yo(we),o})},"aria-expanded":Ha,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${lt?"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(Pr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:i("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${vn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[ln&&e.jsx(Nt,{size:10,className:"animate-spin"}),vn.staged>0?i("rightSidebar.stagedCount",{count:vn.staged}):i("rightSidebar.noStagedChangesShort")]}),!lt&&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 ${Ha?"rotate-90":""}`,children:e.jsx(Ga,{size:13})})]})]}),Ha&&e.jsxs("div",{className:"space-y-0",children:[Ft.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:lh})]})}),e.jsx(Xn,{label:i("rightSidebar.gitRepositoryLabel"),value:we??"",options:Ft,placeholder:i("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:i("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:i("rightSidebar.gitRepositoryEmpty"),disabled:!!Ue,onChange:t=>{Zc(t||null)}}),Qe&&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:i("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:Pn!==jc?jc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Dh()},disabled:!xh,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${mi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Ue?.action==="switch-branch"||mi?"opacity-0":"",children:i("rightSidebar.switchBranch")}),Ue?.action==="switch-branch"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),mi&&Ue?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(Xn,{label:i("rightSidebar.currentBranchLabel"),value:Pn,options:uh,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),disabled:!!Ue,onChange:ia})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Qe?i("rightSidebar.selectRepositoryForGitActions"):vn.staged>0?i("rightSidebar.commitReadyHint",{count:vn.staged}):i("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{td()},disabled:!!Ue||Qe||vn.staged===0||!oa.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${hi?"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:Qe?i("rightSidebar.selectRepositoryForGitActions"):vn.staged===0?i("rightSidebar.commitNeedsStaged"):i("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Ue?.action==="commit"||hi?"opacity-0":"",children:i("rightSidebar.commitChanges")}),Ue?.action==="commit"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),hi&&Ue?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:oa,onChange:t=>Tl(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),td())},placeholder:i("rightSidebar.commitMessagePlaceholder"),disabled:!!Ue,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Or(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":en,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:i("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Js&&e.jsx(Nt,{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 ${en?"rotate-90":""}`,children:e.jsx(Ga,{size:13})})]})]}),en&&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(Jn,{size:12,className:"shrink-0"}),e.jsx("input",{value:tn,onChange:t=>rn(t.target.value),placeholder:i("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}),tn&&e.jsx("button",{type:"button",onClick:()=>rn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(Yt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:ch,children:[Tt.length>0?Tt.map(t=>{const[o,...c]=t.split(/\s+/),y=c.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Lh(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:y,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:o}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:y,children:y}),Q[o]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${Q[o]==="ahead"?"bg-accent/10 text-accent":Q[o]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:i(Q[o]==="ahead"?"rightSidebar.commitAhead":Q[o]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Nn===o&&e.jsx(Nt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Js?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:i("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:i("rightSidebar.recentCommitsEmpty")}),Qs&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(Nt,{size:12,className:"animate-spin"})}),jo&&!Qs&&Tt.length>0&&e.jsx("button",{type:"button",onClick:()=>{ws({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:i("rightSidebar.recentCommitsLoadMore")})]})]}),as&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:as}),Sl&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Sl})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{_h()},disabled:!gh,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${pi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Ue?.action==="pull"||pi?"opacity-0":"",children:i("rightSidebar.pullChanges")}),Ue?.action==="pull"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),pi&&Ue?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Fh()},disabled:!bh,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${gi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Ue?.action==="push"||gi?"opacity-0":"",children:i("rightSidebar.pushChanges")}),Ue?.action==="push"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),gi&&Ue?.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] ${Pc.className}`,title:fe?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:Pc.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:fe?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${Ec?"grid-cols-2":"grid-cols-1"}`,children:[Ec&&e.jsx(Xn,{label:i("rightSidebar.pushRemoteLabel"),value:cn,options:Mc,placeholder:i("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:i("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:i("rightSidebar.pushNoRemotes"),disabled:!!Ue,onChange:la}),e.jsx(Xn,{label:i("rightSidebar.pushBranchLabel"),value:dn,options:fh,placeholder:i("rightSidebar.pushBranchPlaceholder",{branch:fe?.branch??"HEAD"}),searchPlaceholder:i("rightSidebar.pushBranchSearchPlaceholder"),emptyText:i("rightSidebar.pushNoBranches"),disabled:!!Ue,onChange:ca})]})]})]})]}):null,Hh=a.useCallback(t=>{const o=gt(t,x);if(!o)return[];const c=Fi(t),y=[];return t.canStage&&y.push({key:"stage-file",label:i("rightSidebar.stageFile"),onClick:()=>{yt({action:"stage-file",cwd:o,paths:[t.path]},i("rightSidebar.stageFile"),c)}}),t.canUnstage&&y.push({key:"unstage-file",label:i("rightSidebar.unstageFile"),onClick:()=>{yt({action:"unstage-file",cwd:o,paths:[t.path]},i("rightSidebar.unstageFile"),c)}}),t.canStash&&y.push({key:"stash-file",label:i("rightSidebar.stashFile"),onClick:()=>{yt({action:"stash-file",cwd:o,paths:[t.path]},i("rightSidebar.stashFile"),c)}}),t.canRestoreWorktree&&y.push({key:"restore-worktree-file",label:i("rightSidebar.restoreFile"),destructive:!0,onClick:()=>on({kind:"restore",file:t,phrase:""})}),y},[x,yt,i]),zh=a.useCallback(()=>{if(m){j?.();return}Cr(0),Mr.current?.slideTo(0),Rr(!1),bt(null)},[j,m]),ad=a.useCallback(t=>{if(K(""),Ht(t),it(null),bt(null),te(null),ne){m&&j?.(),Cr(0),Mr.current?.slideTo(0),Rr(!1);return}},[ne,j,m,it,Ht]);a.useEffect(()=>{const t=o=>{const c=o.detail,y=c?.path;if(typeof y!="string"||!y.startsWith("/"))return;K(""),bt(null),Pt(null);const v=!!(x&&(y===x||y.startsWith(`${x}/`)));if(c.kind==="file"){const k=Ti(y);bs(y),typeof c.line=="number"&&Number.isSafeInteger(c.line)&&c.line>0&&Pt(c.line),Ht(v?null:k),te(S=>({path:y,nonce:(S?.nonce??0)+1}));return}it(null),v?(Ht(null),te(k=>({path:y,nonce:(k?.nonce??0)+1}))):(te(null),Ht(y)),ne&&(m&&j?.(),Cr(0),Mr.current?.slideTo(0),Rr(!1))};return window.addEventListener(kd,t),()=>window.removeEventListener(kd,t)},[bs,ne,j,m,x,it,Ht]),a.useEffect(()=>{r||(Ot(!1),gr(!1))},[r]),a.useEffect(()=>{if(!mr&&!pr)return;const t=o=>{o instanceof globalThis.KeyboardEvent&&o.key!=="Escape"||o instanceof globalThis.MouseEvent&&o.target instanceof Node&&(Sn.current?.contains(o.target)||jn.current?.contains(o.target))||(Ot(!1),gr(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[pr,mr]);const od=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:ah,disabled:!Ca,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":i("rightSidebar.parentFolder"),title:i("rightSidebar.parentFolder"),children:e.jsx(pu,{size:14})}),e.jsx("button",{type:"button",onClick:gc,disabled:!x||Tn===x,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":i("rightSidebar.backToProjectRoot"),title:i("rightSidebar.backToProjectRoot"),children:e.jsx(Sd,{size:14})}),e.jsx("button",{type:"button",onClick:oh,disabled:!ge,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":i("rightSidebar.refreshFiles"),title:Il?i("rightSidebar.fileWatchUnavailable",{message:Il}):i("rightSidebar.refreshFiles"),children:e.jsx(Hi,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:ge??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:nh}),ga==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:i("fileTree.sortedByModified"),"aria-label":i("fileTree.sortedByModified"),children:e.jsx(jd,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>ge&&Gt(ge,Dt??void 0),disabled:!ge,...ge&&Dt?Zo(ja(ge),Dt):{},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 ${Dt&&(ke===Dt||nt===Dt)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":i(Dt&&nt===Dt?"rightSidebar.copied":Dt&&ke===Dt?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:i("rightSidebar.insertCurrentFolder"),children:Dt&&(ke===Dt||nt===Dt)?e.jsx(Ui,{size:13}):e.jsx(uo,{size:13})}),e.jsxs("div",{ref:jn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Ot(!1),gr(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${pr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":pr,"aria-haspopup":"menu","aria-label":i("sidebar.moreActions"),title:i("sidebar.moreActions"),children:e.jsx(co,{size:14})}),pr&&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:()=>{gr(!1),ih()},disabled:!ni,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${vs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[vs?e.jsx(ki,{size:14}):e.jsx(Ka,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(vs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{gr(!1),Kf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Oo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Oo?e.jsx(ep,{size:14}):e.jsx(Vi,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(Oo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!ge,onClick:()=>{ge&&(gr(!1),Vf(ge,ga==="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:[ga==="modified"?e.jsx(_m,{size:14}):e.jsx(jd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(ga==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),x&&(Na.length>0||sh)&&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:i("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:gc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${ge===x?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:x,children:[e.jsx(Sd,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:st})]}),Na.map(t=>{const o=t.path,c=t.kind==="file",y=c?ot===o:ge===o;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${y?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o,children:[e.jsxs("button",{type:"button",onClick:()=>c?bs(o):Ht(o),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[c?e.jsx(qi,{size:10,className:"shrink-0"}):e.jsx(Ka,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:kt(o)})]}),e.jsx("button",{type:"button",onClick:()=>un(o),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":i("rightSidebar.unpinFolder",{name:kt(o)}),title:i("rightSidebar.unpinFolder",{name:kt(o)}),children:e.jsx(Yt,{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"})]}),xi=a.useMemo(()=>{if(Ln===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,o=Math.max(0,Math.floor((To-Ln)/1e3)),c=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[y,v]=o<60?[-o,"second"]:o<3600?[-Math.floor(o/60),"minute"]:o<86400?[-Math.floor(o/3600),"hour"]:[-Math.floor(o/86400),"day"];return c.format(y,v)},[To,Ln]),Wh=x&&!Hn?e.jsx("button",{type:"button",onClick:()=>{Ih(!Uo)},"aria-pressed":Uo,title:i("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${Uo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:i("rightSidebar.multiRepoScan")}):null,id=x?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[xi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:i("rightSidebar.gitLastUpdated",{time:xi}),children:xi}):null,e.jsx("button",{type:"button",onClick:()=>{ps()},disabled:zr,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":i("rightSidebar.refreshGit"),title:i("rightSidebar.refreshGit"),children:e.jsx(Hi,{size:13,className:zr?"animate-spin":""})})]}):null,Gh=nc?i("rightSidebar.changeAuditScopeAll"):pn.length===1?pn[0].relativeRoot==="."?st:pn[0].relativeRoot||pn[0].name:`${pn.length} repos`,Kh=x?e.jsxs("div",{className:"inline-flex min-h-9 shrink-0 items-center",children:[e.jsx(nu,{open:ts,onOpenChange:Xr,showScopePicker:yn,selectedAll:nc,repos:qf,selectedRoots:tr,onToggleRepo:kh,onGenerate:()=>vh(),disabled:!x,inserted:ke===pc,buttonLabel:i("rightSidebar.changeAuditShort"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:i("rightSidebar.insertChangeAuditPrompt"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:Gh,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i("rightSidebar.changeAuditShort"),loading:Dr,error:!!Sr,statusTitle:Sr??(Dr?i("rightSidebar.changeAuditLoading"):Mt.length>0?`${i("rightSidebar.changeAuditLoaded",{count:Mt.length})}${nd?` · ${i("rightSidebar.changeAuditLoadedAt",{time:nd})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{yh()},disabled:Dr||Mt.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 ${Mt.length>0?"":"invisible"}`,title:i("rightSidebar.clearChangeAuditTitle"),"aria-label":i("rightSidebar.clearChangeAudit"),children:e.jsx(ao,{size:12})})]}):null,Cs=rr??(R?.available&&x&&Re.size>0&&le.length<=1?{root:x,label:st}:null),ld=e.jsxs(e.Fragment,{children:[Cs&&e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Ua("stage-all",Cs.root,Cs.label),disabled:!!Ue,className:"flex-1 rounded-md bg-accent/10 px-2 py-1 text-[11px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",children:i("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>Ua("stash-all",Cs.root,Cs.label),disabled:!!Ue,className:"flex-1 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground hover:bg-surface disabled:opacity-50",children:i("rightSidebar.stashAll")})]}),Wh,Kh]}),za=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[R?.available&&R.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:R.branch,children:[e.jsx(Pr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:R.branch})]}),ht.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[ht.modified,"M"]}),ht.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",ht.added]}),ht.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",ht.deleted]}),ht.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[ht.renamed,"R"]}),ht.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[ht.copied,"C"]}),ht.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[ht.untracked,"U"]}),ht.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[ht.conflicted,"!"]}),ht.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[ht.other,"?"]}),ht.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:i("rightSidebar.stagedCountShort",{count:ht.staged})})]});return e.jsxs(Bm,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h,children:[Zo.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Jf?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:x??void 0,children:st}),(!ne||Lo)&&R?.available&&R.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:R.branch,children:[e.jsx(Pr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:R.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!xe;W(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):K("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${xe?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i("rightSidebar.toggleSearch"),title:i("common.search"),children:e.jsx(Jn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Ie,onClick:()=>{ze(t=>!t),Bt(!1)},className:`relative 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":i("rightSidebar.toggleContextDraft"),title:i("rightSidebar.contextDraftTitle"),children:[e.jsx(Om,{size:14}),!Ie&&ve.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:Bl,type:"file",multiple:!0,className:"hidden",onChange:t=>{const o=t.target.files;!o||o.length===0||(xs(Array.from(o)),t.target.value="")}}),e.jsx("input",{ref:Ol,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const o=t.target.files?.[0];t.target.value="",o&&eh(o)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${h?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:h?e.jsx(ki,{size:14}):e.jsx(Ka,{size:14})}),e.jsxs("div",{ref:Sn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{gr(!1),Ot(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${mr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":mr,"aria-haspopup":"menu","aria-label":i("sidebar.moreActions"),title:i("sidebar.moreActions"),children:e.jsx(co,{size:15})}),mr&&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:"menuitemcheckbox","aria-checked":Hr,onClick:()=>Zf(!Hr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(xd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:i("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Hr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Hr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Bl.current?.click()},disabled:da,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:[da?e.jsx(Nt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(dp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Ol.current?.click()},disabled:da,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:[da?e.jsx(Nt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(sp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${h?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[h?e.jsx(ki,{size:14}):e.jsx(Ka,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),h&&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":i("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:i("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",i("rightSidebar.layoutModeAuto")],["narrow",i("rightSidebar.layoutModeNarrow")],["wide",i("rightSidebar.layoutModeWide")]].map(([t,o])=>{const c=X===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":c,onClick:()=>{P(t),Ot(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${c?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:o},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":i("rightSidebar.close"),children:e.jsx(Yt,{size:14})})]}),xe&&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(Jn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:C,onChange:t=>K(t.target.value),placeholder:i(F==="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 ${ne?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Jc("name"),"aria-pressed":F==="name",className:`rounded-full px-2 transition active:scale-95 ${ne?"py-1":"py-0.5"} ${F==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:i("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Jc("content"),"aria-pressed":F==="content",className:`rounded-full px-2 transition active:scale-95 ${ne?"py-1":"py-0.5"} ${F==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:i("rightSidebar.searchModeContent")})]}),C&&e.jsx("button",{type:"button",onClick:()=>K(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(Yt,{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(Um,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:i("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:re,onChange:t=>ie(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:i("rightSidebar.searchScopePlaceholder"),"aria-label":i("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),re!=="."&&e.jsx("button",{type:"button",onClick:()=>ie("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.resetSearchScope"),children:e.jsx(Yt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>N(t=>!t),"aria-expanded":De,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${De||fs.length>0||q||Le||Pe?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:i("rightSidebar.searchOptions"),"aria-label":i("rightSidebar.searchOptions"),children:[e.jsx(Hm,{size:13}),fs.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:fs.length})]})]}),De&&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:i("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:ye,onChange:t=>pe(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:i("rightSidebar.searchExcludePlaceholder"),"aria-label":i("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),ye&&e.jsx("button",{type:"button",onClick:()=>pe(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":i("rightSidebar.clearSearchExclude"),children:e.jsx(Yt,{size:11})})]}),F==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":i("rightSidebar.contentSearchOptions"),children:[[q,()=>he(t=>!t),Qm,i("rightSidebar.matchCase")],[Le,()=>Ze(t=>!t),fp,i("rightSidebar.matchWholeWord")],[Pe,()=>at(t=>!t),op,i("rightSidebar.useRegex")]].map(([t,o,c,y])=>e.jsxs("button",{type:"button",onClick:o,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(c,{size:12}),y]},y))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(Hn?2:3)+(Hr?1:0)}, minmax(0, 1fr))`},children:[!Hn&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>er("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Pr,{size:12}),i("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:()=>er("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Nu,{size:12}),i("rightSidebar.tabChanges"),Re.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Re.size}):null]})]}),e.jsxs("button",{type:"button",onClick:()=>er("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Km,{size:12}),i("rightSidebar.tabFiles")]}),Hr&&e.jsxs("button",{type:"button",onClick:()=>er("android"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${dr==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xd,{size:12}),i("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),Pl&&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:Pl})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(to,{active:lt,mounted:ir,fallback:e.jsx(Ai,{slow:!1}),children:qe?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Ld,{items:jh,diffViewType:Do,inlineMode:Xt,viewControls:h?Ss():void 0,renderPathReference:(t,o)=>Aa(wn(t,qe.repoRoot??x),i(o==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:_f,onSelect:Zs,emptyText:i("rightSidebar.noChanges"),mobile:ne,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i("rightSidebar.recentCommitsTitle"),headerMeta:`${qe.headRef??""}${qe.commits?.[0]?` · ${qe.commits[0]}`:""}`,onClose:()=>{ft(null),Zs(null)},closeLabel:i("common.back"),wrap:At,onToggleWrap:Ba,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:ne?"stacked":"split",onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:nt,onClearAuditRecord:Da})}):jr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Ld,{items:li,diffViewType:Do,inlineMode:Xt,viewControls:h?Ss():void 0,renderPathReference:(t,o)=>{const c=be?.comparisonRepos,y=c&&c.length>1?[...c].sort((k,S)=>S.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,v=y?t===y.label?y.repoRoot:wn(t.slice(y.label.length+1),y.repoRoot):wn(t,Rs?.repoRoot||x);return Aa(v,i(o==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Eo,onSelect:an,emptyText:i(be?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:ne,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i(be?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Rs?`${Rs.repoLabel} · ${Rs.branchName??"HEAD"} → ${Rs.baseRef}`:void 0,onClose:()=>{++z.current,Fe(!1),nr(!1),Qt(null)},closeLabel:i("common.back"),wrap:At,onToggleWrap:Ba,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:ne?"stacked":"split",onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:nt,onClearAuditRecord:Da,localOptions:be?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??be.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??Vn(t.repoRoot,t.head)),onChange:o=>{fi({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:o})}})),onHunkGitAction:be?.includeUncommitted?Th:void 0,error:Ve,actionsBusy:ue>0,onRefresh:()=>{fi({refresh:!0})},refreshing:et,refreshLabel:i("rightSidebar.branchAuditRefreshDiff"),refreshTitle:i("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Rh,onWalkthroughNavigate:Ch,initialDetailScrollTop:be&&Xe?ss[Xe]:void 0,onDetailScrollPositionChange:Ph,externalSwiperRef:ne?ya:void 0,onMobileSlideChange:ne?$o:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:sd?e.jsx("div",{className:"px-3",children:sd}):zr?e.jsx(Ai,{slow:ql}):fn?e.jsx(ro,{message:fn,onRetry:()=>{ps()}}):lu(R)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):R?.available===!1?e.jsx(ro,{message:R.error??i("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ps()}}):x?e.jsx(Ai,{slow:ql}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(to,{active:zn,children:ne?e.jsxs(bu,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Mr.current=t,t.slideTo(Ml,0)},onSlideChange:t=>{if(Cr(t.activeIndex),ms.current===t.activeIndex){ms.current=null;return}t.activeIndex===0&&(Rr(!1),bt(null),j?.())},children:[e.jsx(zi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Fn,onScroll:ac,onDragOver:ka,onDragEnter:ka,onDragLeave:lc,onDrop:cc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[Dl&&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:i("rightSidebar.dropToUpload")})}),!C.trim()&&od,e.jsx(Rd,{rootPath:ge??"",onFileSelect:bs,onPathReference:Gt,getReferenceText:ja,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:nt,onDirectoryRoot:bc,onSearchFromDirectory:xc,onDirectoryPinToggle:vc,onFilePinToggle:yc,pinnedPaths:bn,selectedFilePath:ot,query:Be,searchRootPath:Ql,searchOptions:Zl,searchMode:F,onContentMatchSelect:oc,onDirectoryDropFiles:(t,o)=>xs(o,t),revealDirectory:de,canOpenInFileBrowser:Fl,onOpenInFileBrowser:ic})]})}),e.jsx(zi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(cl,{filePath:zn&&(Bf||Ml===1)?ot:null,onInsertReference:Gt,onInsertText:$r,onInsertFeature:$r,onReviewReference:hc,onReferenceCopied:Er,onClose:zh,onDirectoryLinkOpen:ad,isMobile:!0,lineRange:Rn,onLineRangeChange:bt,insertedReferenceKey:ke,copiedReferenceKey:nt,scrollToLine:Ge,onScrollToLineHandled:()=>Pt(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:E,onOpenMarkdownOutline:$,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Fn,onScroll:ac,onDragOver:ka,onDragEnter:ka,onDragLeave:lc,onDrop:cc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Fo},children:[Dl&&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:i("rightSidebar.dropToUpload")})}),!C.trim()&&od,e.jsx(Rd,{rootPath:ge??"",onFileSelect:bs,onPathReference:Gt,getReferenceText:ja,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:nt,onDirectoryRoot:bc,onSearchFromDirectory:xc,onDirectoryPinToggle:vc,onFilePinToggle:yc,pinnedPaths:bn,selectedFilePath:ot,query:Be,searchRootPath:Ql,searchOptions:Zl,searchMode:F,onContentMatchSelect:oc,onDirectoryDropFiles:(t,o)=>xs(o,t),revealDirectory:de,canOpenInFileBrowser:Fl,onOpenInFileBrowser:ic})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":i("rightSidebar.resizeFileTree"),title:i("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:Yf,onPointerMove:Xf,onPointerUp:sc,onPointerCancel:sc,onDoubleClick:()=>{_o(Zi),Lt(Ts,Zi)},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(cl,{filePath:zn?ot:null,onInsertReference:Gt,onInsertText:$r,onInsertFeature:$r,onReviewReference:hc,onReferenceCopied:Er,onDirectoryLinkOpen:ad,isMobile:!1,lineRange:Rn,onLineRangeChange:bt,insertedReferenceKey:ke,copiedReferenceKey:nt,scrollToLine:Ge,onScrollToLineHandled:()=>Pt(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:E,onOpenMarkdownOutline:$,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p})})]})}),e.jsx(to,{active:Rt,mounted:Of||Rt,children:()=>Xo?e.jsx(zm,{}):ne?e.jsx(Wi,{mobile:!0,backLabel:i("rightSidebar.backToChangeList"),externalSwiperRef:ya,onMobileSlideChange:$o,groups:qt.length>0?_c():[],mode:wr,onModeChange:_a,selectedKey:ot,scrollToKey:zc,scrollToKeyNonce:fa.nonce,compact:!1,collapsedDirectoryKeys:Vs,onToggleDirectory:Kc,onSelectFile:t=>{const o=Array.from(Re.values()).find(c=>wt(c)===t.key);o&&Fa(wt(o))},renderLeading:Oc,renderTrailing:t=>{const o=Array.from(Re.values()).find(c=>wt(c)===t.key);return o?Dc(o):null},renderDirectoryTrailing:Fc,renderSubtitle:t=>{const o=Array.from(Re.values()).find(c=>wt(c)===t.key);return o?Ic(o):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>x&&e.jsxs("div",{className:"px-0 py-0",children:[za&&e.jsx("div",{className:"mb-2",children:za}),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:i("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[qt.length,"/",Re.size]})]}),e.jsxs(Ed,{actions:ld,children:[Ac(),t,h&&Ss(),id]},x),rr&&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:rr.label}),rr.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:rr.branch})]}),!rr&&yn&&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(Pr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:$a?(t=>Gc(t)):void 0,emptyContent:Xo?null:fn&&Re.size===0?e.jsx(ro,{message:fn,onRetry:()=>{ps()}}):Re.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):qt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:i("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>gs(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:i("rightSidebar.backToChangeList"),children:[e.jsx(Os,{size:14}),i("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[h&&Ss(),e.jsxs("button",{type:"button",onClick:Ba,"aria-pressed":At,title:i("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 ${At?"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:i(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Bc(),activePane:Rt,wrap:At,diffViewType:Do,inlineMode:Xt,diffOptions:Xc,reloadKey:Xs,renderStreamBadge:t=>e.jsx(Fs,{status:t}),onHunkGitAction:Qc,onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:nt,onClearAuditRecord:Da,onDetailScroll:Ta}):e.jsx(Wi,{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:i("rightSidebar.backToChangeList"),groups:qt.length>0?_c():[],mode:wr,onModeChange:_a,selectedKey:ot,scrollToKey:zc,scrollToKeyNonce:fa.nonce,compact:!0,collapsedDirectoryKeys:Vs,onToggleDirectory:Kc,onSelectFile:t=>{const o=Array.from(Re.values()).find(c=>wt(c)===t.key);o&&Fa(wt(o))},renderLeading:Oc,renderTrailing:t=>{const o=Array.from(Re.values()).find(c=>wt(c)===t.key);return o?Dc(o):null},renderDirectoryTrailing:Fc,renderSubtitle:t=>{const o=Array.from(Re.values()).find(c=>wt(c)===t.key);return o?Ic(o):null},aiContent:$a?(t=>Gc(t)):void 0,emptyContent:Xo?null:fn&&Re.size===0?e.jsx(ro,{message:fn,onRetry:()=>{ps()}}):Re.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):qt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:i("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>x&&e.jsxs("div",{className:"px-0 py-0",children:[za&&e.jsx("div",{className:"mb-2",children:za}),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:i("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[qt.length,"/",Re.size]})})]}),e.jsxs(Ed,{actions:ld,children:[Ac(),t,Ss(),e.jsxs("button",{type:"button",onClick:Ba,"aria-pressed":At,title:i("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${At?"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:i(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),id]},x),rr&&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:rr.label}),rr.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:rr.branch})]}),!rr&&yn&&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(Pr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i("rightSidebar.selectRepositoryForDiff")})]})]}),files:Bc(),activePane:Rt,wrap:At,diffViewType:Ut,inlineMode:Xt,diffOptions:Xc,reloadKey:Xs,renderStreamBadge:t=>e.jsx(Fs,{status:t}),onHunkGitAction:Qc,onInsertDiffReference:Lr,onReferenceCopied:Er,insertedReferenceKey:ke,copiedReferenceKey:nt,onClearAuditRecord:Da,onDetailScroll:Ta})}),e.jsx(to,{active:Wn,mounted:Ao&&Hr,children:Uf?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:i("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{vi.getState().setDock(wi,null),so({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:i("android.splitClose")})]}):e.jsx(Wm,{sessionId:n??null,onInsertPrompt:t=>Lr("android-deps",t),onInsertFile:rh,onRecordingComplete:th})})]}),r&&Ie&&e.jsx(Fp,{value:ve,collapsed:_t,autoCollapseAfterSend:H,focusRequest:pt,insertError:Tr?i("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{br(!1),Ke(t)},onCollapsedChange:Bt,onAutoCollapseAfterSendChange:ae,onDisable:()=>ze(!1),onClear:()=>Ke(""),onInsert:()=>mc(!1),onInsertAndSend:()=>mc(!0),labels:{title:i("rightSidebar.contextDraftTitle"),hint:i("rightSidebar.contextDraftHint"),placeholder:i("rightSidebar.contextDraftPlaceholder"),collapse:i("rightSidebar.contextDraftCollapse"),expand:i("rightSidebar.contextDraftExpand"),disable:i("rightSidebar.contextDraftDisable"),clear:i("rightSidebar.contextDraftClear"),insert:i("rightSidebar.contextDraftInsert"),insertAndSend:i("rightSidebar.contextDraftInsertAndSend"),inserted:i("rightSidebar.contextDraftInserted"),sent:i("rightSidebar.contextDraftSent"),send:i("rightSidebar.contextDraftSend"),appended:i("rightSidebar.contextDraftAppended"),resize:i("rightSidebar.contextDraftResize"),autoCollapseAfterSend:i("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>i("rightSidebar.contextDraftCharacterCount",{count:t})}}),ph(),xt&&typeof document<"u"&&qr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>on(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:xt.kind==="restore"?i("rightSidebar.confirmRestoreTitle"):i("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:xt.kind==="restore"?i("rightSidebar.confirmRestoreDescription",{path:mu(xt.file.absolutePath,x)}):i("rightSidebar.confirmStashAllDescription")}),xt.kind==="restore"&&e.jsx("input",{value:xt.phrase,onChange:t=>on({...xt,phrase:t.target.value}),placeholder:i("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:()=>on(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:i("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Ue||xt.kind==="restore"&&xt.phrase.trim()!==i("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(xt.kind==="restore"){const t=gt(xt.file,x);if(!t)return;yt({action:"restore-worktree-file",cwd:t,paths:[xt.file.path],confirm:{acknowledged:!0,phrase:xt.phrase}},i("rightSidebar.restoreFile"),Fi(xt.file))}else{const t=xt.repoRoot??x;if(!t)return;yt({action:"stash-all",cwd:t},i("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${xt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:i(Ue?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const px=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:cl,MarkdownImageLightbox:Rf,MarkdownPreview:Cf,RightSidebar:nx,__testParseMarkdownListBlock:yb,buildMarkdownPreviewBlocks:Lb,buildMarkdownPreviewRenderResult:yl,collectKnownGitRepoRoots:Yu,computeMarkdownImageDisplayBox:lf,getMarkdownHeadingOutline:jf,getMarkdownHeadingPathAtLine:Sf,getNextMarkdownPreviewLineRange:Fb,isSvgImageSrc:wo,mountRightSidebarRepoPickerOverlay:Du,replaceGitRepositorySnapshot:Pf,resolveMarkdownLocalLinkTarget:ml,resolveRightSidebarDiffViewType:Vu,shouldCloseMarkdownImageLightboxDrag:yf,showsGitRepoGroupHeader:el},Symbol.toStringTag,{value:"Module"}));export{Vi as E,px as R,ep as a,pp as c,mx as m};
|