termdock 1.4.337 → 1.4.338
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-DhHRFEY2.js → App-CXkkfKD5.js} +56 -56
- package/dist/client/assets/App-CXkkfKD5.js.br +0 -0
- package/dist/client/assets/App-CXkkfKD5.js.gz +0 -0
- package/dist/client/assets/{ArchitecturePanel-DeMEq2Yq.js → ArchitecturePanel-DN-6DCxW.js} +2 -2
- package/dist/client/assets/ArchitecturePanel-DN-6DCxW.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-DN-6DCxW.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-DG4TnQvn.js → ChangeWalkthroughPanel-BPts_ir_.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-BPts_ir_.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-BPts_ir_.js.gz +0 -0
- package/dist/client/assets/{CollaborationMainWorkspace-D_yEJJy_.js → CollaborationMainWorkspace-DGpvCpho.js} +1 -1
- package/dist/client/assets/CollaborationMainWorkspace-DGpvCpho.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DGpvCpho.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-BT-YwIEZ.js +2 -0
- package/dist/client/assets/{ComputerControlView-DGoBNNRA.js → ComputerControlView-3S0HonKc.js} +3 -3
- package/dist/client/assets/ComputerControlView-3S0HonKc.js.br +0 -0
- package/dist/client/assets/ComputerControlView-3S0HonKc.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-CiCwopwo.js → DagPlayground--XjArBtQ.js} +1 -1
- package/dist/client/assets/DagPlayground--XjArBtQ.js.br +0 -0
- package/dist/client/assets/DagPlayground--XjArBtQ.js.gz +0 -0
- package/dist/client/assets/{DiffLab-C8ItelM8.js → DiffLab-kaxzJTd5.js} +1 -1
- package/dist/client/assets/DiffLab-kaxzJTd5.js.br +0 -0
- package/dist/client/assets/DiffLab-kaxzJTd5.js.gz +0 -0
- package/dist/client/assets/{DiffReview-riYMjjAA.js → DiffReview-CXJ6sNbW.js} +1 -1
- package/dist/client/assets/DiffReview-CXJ6sNbW.js.br +0 -0
- package/dist/client/assets/DiffReview-CXJ6sNbW.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-CXlrQWLJ.js → DiffReviewLab-6C3YRheR.js} +1 -1
- package/dist/client/assets/DiffReviewLab-6C3YRheR.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-6C3YRheR.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-BxcK2w41.js → DiffViewer-CeQiMH5R.js} +21 -21
- package/dist/client/assets/DiffViewer-CeQiMH5R.js.br +0 -0
- package/dist/client/assets/DiffViewer-CeQiMH5R.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-HzxWwmh4.js → ModelPreview-D7H8wUeV.js} +14 -14
- package/dist/client/assets/ModelPreview-D7H8wUeV.js.br +0 -0
- package/dist/client/assets/ModelPreview-D7H8wUeV.js.gz +0 -0
- package/dist/client/assets/RightSidebar-ce9i1SOF.js +1677 -0
- package/dist/client/assets/RightSidebar-ce9i1SOF.js.br +0 -0
- package/dist/client/assets/RightSidebar-ce9i1SOF.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-BUDaRwTy.js → abnfDiagram-VCTEODGH-CKkrXeo0.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-CKkrXeo0.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CKkrXeo0.js.gz +0 -0
- package/dist/client/assets/{app-D2M53LZx.js → app-Dg_ED-QO.js} +3 -3
- package/dist/client/assets/app-Dg_ED-QO.js.br +0 -0
- package/dist/client/assets/app-Dg_ED-QO.js.gz +0 -0
- package/dist/client/assets/{arc-DO-aRhWz.js → arc-Dxf-FIYZ.js} +1 -1
- package/dist/client/assets/arc-Dxf-FIYZ.js.br +0 -0
- package/dist/client/assets/arc-Dxf-FIYZ.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-CMImzZR-.js → architectureDiagram-5GKGNRK7-CGQj9SLG.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CGQj9SLG.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CGQj9SLG.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-DPC_EssA.js → blockDiagram-I7D4REHJ-CL5aAr4d.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-CL5aAr4d.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CL5aAr4d.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-DJazaM0T.js → c4Diagram-7LVT6UL2-C8Wmae8R.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-C8Wmae8R.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-C8Wmae8R.js.gz +0 -0
- package/dist/client/assets/channel-OQcdyixZ.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-BxDoppAq.js → chunk-2Q5K7J3B-CTrZpKdR.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DFunSKh5.js → chunk-5VM5RSS4-BD_r4eYS.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-bLBUcK9l.js → chunk-F27PBJKO-CXMD2934.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-CXMD2934.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-CXMD2934.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-CQzRDG_F.js → chunk-IMKFNOWR-BvCSOrCO.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-BvCSOrCO.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-BvCSOrCO.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-oYEx3lo8.js → chunk-JWPE2WC7-DbsYJ5y7.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-DiElQN3B.js → chunk-POPQ4Y6H-B-iz2Px-.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-Cf1eK48Z.js → chunk-SVP7TREG-DJHziRBt.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-DJHziRBt.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-DJHziRBt.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-CAsKSnF3.js → chunk-TICWLB2K-BVHRHcKL.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-BVHRHcKL.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-BVHRHcKL.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-CnELf36-.js → chunk-XXDRQBXY-Bc_IsYPC.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-lDa2ikip.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-lDa2ikip.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-BjkkSzWB.js → cose-bilkent-JH36ORCC-mx371eJz.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-mx371eJz.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-mx371eJz.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-DL9YtN7p.js → cynefin-OW5HDTMX-CwvWqWZW.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-CwvWqWZW.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CwvWqWZW.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-vSIBJhoT.js → cynefinDiagram-5FMLGOSQ-DfZeBPbV.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DfZeBPbV.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DfZeBPbV.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-CJ8Milln.js → dagre-GXQ25YYZ-Dg1Si0Y9.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-Dg1Si0Y9.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-Dg1Si0Y9.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-Ci6Vle0S.js → diagram-S7CK7UJ4-BlUd5wom.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-BlUd5wom.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BlUd5wom.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-Cf1bxglx.js → diagram-UQ7AKVKN-DHfqYQTv.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-DHfqYQTv.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DHfqYQTv.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-MPVKDZTF.js → diagram-VSXAHHWV-D891qXNM.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-D891qXNM.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-D891qXNM.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-C9VznNFM.js → diagram-VX7I27RA-BmrG8uW7.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-BmrG8uW7.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-BmrG8uW7.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-D3Z39FXB.js → diagram-Z3DM3KII-vaoN6Nwt.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-vaoN6Nwt.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-vaoN6Nwt.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-CB6iYj5F.js → ebnfDiagram-PWID7BFC-DVP1DfM_.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DVP1DfM_.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DVP1DfM_.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-BbywGzIs.js → erDiagram-RLTQ6QDP-B5Ltd1Ls.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-B5Ltd1Ls.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-B5Ltd1Ls.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-BIhsRkKW.js → flowDiagram-HODETNUW-DSuB_TT2.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-DSuB_TT2.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-DSuB_TT2.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-0ov1Ht5f.js → ganttDiagram-EL5Y4UJY-CNduC1yg.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CNduC1yg.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CNduC1yg.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-DPFs4a-w.js → gestureArbiter-BbwCtljt.js} +1 -1
- package/dist/client/assets/gestureArbiter-BbwCtljt.js.br +0 -0
- package/dist/client/assets/gestureArbiter-BbwCtljt.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-DPmWc8PK.js → gitGraphDiagram-WWUBYQGX-Bi4rIOuP.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Bi4rIOuP.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Bi4rIOuP.js.gz +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-CiGxOtMe.js → infoDiagram-27XIBGKW-BCHsBNvL.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-CVQw2h65.js → ishikawaDiagram-5VMMS53U-CuLPfxyA.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CuLPfxyA.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CuLPfxyA.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-CWyQl9rp.js → journeyDiagram-3NMN7TZE-CAkxVGsT.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CAkxVGsT.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CAkxVGsT.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-QYWm-bRz.js → kanban-definition-UXKFOSKX-CYs8cggw.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-CYs8cggw.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-CYs8cggw.js.gz +0 -0
- package/dist/client/assets/{layout-wWwHCqP-.js → layout-D2bo_IZk.js} +1 -1
- package/dist/client/assets/{layout-wWwHCqP-.js.br → layout-D2bo_IZk.js.br} +0 -0
- package/dist/client/assets/layout-D2bo_IZk.js.gz +0 -0
- package/dist/client/assets/{linear-CxAeiA5o.js → linear-BaJeXari.js} +1 -1
- package/dist/client/assets/linear-BaJeXari.js.br +0 -0
- package/dist/client/assets/linear-BaJeXari.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-Dy-VIGNi.js → mermaid.core-BcUHOzZA.js} +5 -5
- package/dist/client/assets/mermaid.core-BcUHOzZA.js.br +0 -0
- package/dist/client/assets/mermaid.core-BcUHOzZA.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-CaOlKAQP.js → mindmap-definition-YA3MSWOX-o7kR2MMC.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-o7kR2MMC.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-o7kR2MMC.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-DADiddYD.js → passwordBootstrap-BQcjYxfm.js} +1 -1
- package/dist/client/assets/passwordBootstrap-BQcjYxfm.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-BQcjYxfm.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-DbMiTSC0.js → pegDiagram-XKGWAZYB-DHihjPBu.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-DHihjPBu.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DHihjPBu.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-DHsbRsqO.js → pieDiagram-E7YTZNPT-Cj5YyMJX.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-Cj5YyMJX.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-Cj5YyMJX.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-ivXNY01m.js → quadrantDiagram-AXDQQJYC-DFw7I0gh.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DFw7I0gh.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DFw7I0gh.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-B6XiBJ2p.js → railroadDiagram-O6MQD6OU-CGa7eUEA.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CGa7eUEA.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CGa7eUEA.js.gz +0 -0
- package/dist/client/assets/{rdpSession-tZqbe3lc.js → rdpSession-DlDYKZ_-.js} +1 -1
- package/dist/client/assets/rdpSession-DlDYKZ_-.js.br +0 -0
- package/dist/client/assets/rdpSession-DlDYKZ_-.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-l-iC26Y4.js → referenceLongPress-BuqW1wcx.js} +1 -1
- package/dist/client/assets/referenceLongPress-BuqW1wcx.js.br +0 -0
- package/dist/client/assets/referenceLongPress-BuqW1wcx.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-BVuulzR5.js → requirementDiagram-BXWQKSXE-BA0xYpod.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BA0xYpod.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BA0xYpod.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-DCiS6hhT.js → sankeyDiagram-P5KCCOFB-CCwnq_gV.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CCwnq_gV.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CCwnq_gV.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-vobocfD-.js → sequenceDiagram-WJ2MYXX4-DlNNXqV0.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DlNNXqV0.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DlNNXqV0.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-DY_P3bTc.js → sizeCapture-INFHLROL-C29vtgEf.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-C29vtgEf.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-C29vtgEf.js.gz +0 -0
- package/dist/client/assets/{sparkles-iFcvD4yM.js → sparkles-C3PtqDej.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-g9dDzGJR.js → stateDiagram-D77RDMKH-D3w8RERh.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-D3w8RERh.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-D3w8RERh.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DFqwYCZO.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-CC39tzCY.js → swimlanes-42K2YHIH-DU6OaKnw.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-DU6OaKnw.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-DU6OaKnw.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-C89KlnBg.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-Bf-Np1KC.js → timeline-definition-24CTP7MA-CYYMLE5-.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-CYYMLE5-.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CYYMLE5-.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-BeIpvW9N.js → triangle-alert-CqCR0Enc.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-BA9Lil5m.js → vennDiagram-4TSXK5OY-CO33abms.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-CO33abms.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CO33abms.js.gz +0 -0
- package/dist/client/assets/{videoCompression-ESn5rZIR.js → videoCompression-CftmPlZi.js} +1 -1
- package/dist/client/assets/videoCompression-CftmPlZi.js.br +0 -0
- package/dist/client/assets/videoCompression-CftmPlZi.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-BCDzPgJu.js → wardleyDiagram-VM6X3IG4-BFOOIY9t.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFOOIY9t.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFOOIY9t.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-CXvxPVbT.js → xychartDiagram-S5SC5T6Z-CnlV8THF.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CnlV8THF.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CnlV8THF.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-DhHRFEY2.js.br +0 -0
- package/dist/client/assets/App-DhHRFEY2.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-DeMEq2Yq.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-DeMEq2Yq.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DG4TnQvn.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DG4TnQvn.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-D_yEJJy_.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-D_yEJJy_.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-BtFTzMVY.js +0 -2
- package/dist/client/assets/ComputerControlView-DGoBNNRA.js.br +0 -0
- package/dist/client/assets/ComputerControlView-DGoBNNRA.js.gz +0 -0
- package/dist/client/assets/DagPlayground-CiCwopwo.js.br +0 -0
- package/dist/client/assets/DagPlayground-CiCwopwo.js.gz +0 -0
- package/dist/client/assets/DiffLab-C8ItelM8.js.br +0 -0
- package/dist/client/assets/DiffLab-C8ItelM8.js.gz +0 -0
- package/dist/client/assets/DiffReview-riYMjjAA.js.br +0 -0
- package/dist/client/assets/DiffReview-riYMjjAA.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-CXlrQWLJ.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-CXlrQWLJ.js.gz +0 -0
- package/dist/client/assets/DiffViewer-BxcK2w41.js.br +0 -0
- package/dist/client/assets/DiffViewer-BxcK2w41.js.gz +0 -0
- package/dist/client/assets/ModelPreview-HzxWwmh4.js.br +0 -0
- package/dist/client/assets/ModelPreview-HzxWwmh4.js.gz +0 -0
- package/dist/client/assets/RightSidebar-ChmJQUxz.js +0 -1677
- package/dist/client/assets/RightSidebar-ChmJQUxz.js.br +0 -0
- package/dist/client/assets/RightSidebar-ChmJQUxz.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-BUDaRwTy.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-BUDaRwTy.js.gz +0 -0
- package/dist/client/assets/app-D2M53LZx.js.br +0 -0
- package/dist/client/assets/app-D2M53LZx.js.gz +0 -0
- package/dist/client/assets/arc-DO-aRhWz.js.br +0 -0
- package/dist/client/assets/arc-DO-aRhWz.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CMImzZR-.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CMImzZR-.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-DPC_EssA.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-DPC_EssA.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DJazaM0T.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DJazaM0T.js.gz +0 -0
- package/dist/client/assets/channel-BKGmfJ01.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-bLBUcK9l.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-bLBUcK9l.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-CQzRDG_F.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-CQzRDG_F.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-Cf1eK48Z.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-Cf1eK48Z.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-CAsKSnF3.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-CAsKSnF3.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-M1OSgOBU.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-M1OSgOBU.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-BjkkSzWB.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-BjkkSzWB.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-DL9YtN7p.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-DL9YtN7p.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-vSIBJhoT.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-vSIBJhoT.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-CJ8Milln.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-CJ8Milln.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Ci6Vle0S.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Ci6Vle0S.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-Cf1bxglx.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-Cf1bxglx.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-MPVKDZTF.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-MPVKDZTF.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C9VznNFM.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C9VznNFM.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-D3Z39FXB.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-D3Z39FXB.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CB6iYj5F.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CB6iYj5F.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-BbywGzIs.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-BbywGzIs.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BIhsRkKW.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BIhsRkKW.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-0ov1Ht5f.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-0ov1Ht5f.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-DPFs4a-w.js.br +0 -0
- package/dist/client/assets/gestureArbiter-DPFs4a-w.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DPmWc8PK.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DPmWc8PK.js.gz +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CVQw2h65.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CVQw2h65.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CWyQl9rp.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CWyQl9rp.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-QYWm-bRz.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-QYWm-bRz.js.gz +0 -0
- package/dist/client/assets/layout-wWwHCqP-.js.gz +0 -0
- package/dist/client/assets/linear-CxAeiA5o.js.br +0 -0
- package/dist/client/assets/linear-CxAeiA5o.js.gz +0 -0
- package/dist/client/assets/mermaid.core-Dy-VIGNi.js.br +0 -0
- package/dist/client/assets/mermaid.core-Dy-VIGNi.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-CaOlKAQP.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-CaOlKAQP.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-DADiddYD.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-DADiddYD.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DbMiTSC0.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DbMiTSC0.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DHsbRsqO.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DHsbRsqO.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-ivXNY01m.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-ivXNY01m.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-B6XiBJ2p.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-B6XiBJ2p.js.gz +0 -0
- package/dist/client/assets/rdpSession-tZqbe3lc.js.br +0 -0
- package/dist/client/assets/rdpSession-tZqbe3lc.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-l-iC26Y4.js.br +0 -0
- package/dist/client/assets/referenceLongPress-l-iC26Y4.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BVuulzR5.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BVuulzR5.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DCiS6hhT.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DCiS6hhT.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-vobocfD-.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-vobocfD-.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DY_P3bTc.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DY_P3bTc.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-g9dDzGJR.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-g9dDzGJR.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-Bxp20Ww7.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-CC39tzCY.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-CC39tzCY.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-bz2A714u.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-Bf-Np1KC.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-Bf-Np1KC.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-BA9Lil5m.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-BA9Lil5m.js.gz +0 -0
- package/dist/client/assets/videoCompression-ESn5rZIR.js.br +0 -0
- package/dist/client/assets/videoCompression-ESn5rZIR.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BCDzPgJu.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BCDzPgJu.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CXvxPVbT.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CXvxPVbT.js.gz +0 -0
|
@@ -0,0 +1,1677 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BcUHOzZA.js","assets/app-Dg_ED-QO.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CLjn9_01.css","assets/purify.es-4eNOHKSq.js","assets/ModelPreview-D7H8wUeV.js","assets/App-CXkkfKD5.js","assets/gestureArbiter-BbwCtljt.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-CqCR0Enc.js","assets/referenceLongPress-BuqW1wcx.js","assets/DiffReview-CXJ6sNbW.js","assets/sparkles-C3PtqDej.js","assets/DiffViewer-CeQiMH5R.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-BPts_ir_.js","assets/ArchitecturePanel-DN-6DCxW.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-3S0HonKc.js","assets/katex-55ZPZeOF.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ah as Br,df as ht,bA as e,h as $o,cv as zd,ar as Ju,_ as Ln,bI as Qu,L as ut,e as hs,X as Lt,dl as V,dt as At,bV as gt,a as ca,b3 as Zu,C as Po,d as da,db as ra,dc as bl,U as Wd,c_ as Km,cA as qm,bl as Vm,O as Vs,aA as Ym,bs as Xm,bu as Bl,bv as Jm,bw as ef,bt as Ys,aQ as Qm,E as Zm,k as ep,bp as tp,bX as rp,bZ as np,b_ as sp,bg as ap,bY as Gd,N as jt,g as op,j as qi,I as ip,b as lp,dd as Vi,bf as Kd,aK as qd,aG as cp,aU as Yi,aV as Vd,du as aa,ax as Xs,aW as dp,bN as up,cX as Yd,aN as fp,d9 as hp,cq as mp,dm as Qr,aZ as pp,a2 as Xd,a1 as gp,aH as Jd,aM as bp,aS as Qd,cs as xp,z as Zd,l as eu,r as tu,J as tf,av as rf,ci as vp,dr as yp,n as wp}from"./app-Dg_ED-QO.js";import{b as a,r as wr}from"./dnd-BCFAPC0L.js";import{i as Ol,F as kp,O as nf,y as Sp,s as ru,Q as nu,W as jo,m as jp,aj as sf,Z as Rp,x as Np,I as Cp,t as Ep,M as Mp,R as Ro,a6 as af,a7 as $p,S as ms,n as of,g as Pp,ap as lf,A as Xi,am as Ap,aa as Ji,ak as Pn,a8 as Lp,a9 as su,an as Tp,ac as au,r as ou,k as iu,E as Qi,B as ho,h as Ip,T as Dp,z as Fp,N as lu,Y as _p,q as Bp,U as Op,o as cu,C as Up,c as Hp,G as zp,f as Wp}from"./App-CXkkfKD5.js";import{F as xl,a as du,S as uu,b as cf,c as vl}from"./gestureArbiter-BbwCtljt.js";import{D as yl,C as oa,L as df,f as Gp,n as Kp}from"./DiffReview-CXJ6sNbW.js";import{T as qp,L as Ao,M as uf,G as xr}from"./triangle-alert-CqCR0Enc.js";import{S as ua}from"./sparkles-C3PtqDej.js";import{C as ff,M as hf}from"./ChangeWalkthroughPanel-BPts_ir_.js";import{r as mf,s as pf,l as gf,a as fu,h as wl,u as Vp,g as kl,b as bf}from"./DiffViewer-CeQiMH5R.js";import{u as xf,G as vf}from"./referenceLongPress-BuqW1wcx.js";const Yp=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Xp=Br("case-sensitive",Yp);const Jp=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Qp=Br("eye-off",Jp);const Zp=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Sl=Br("eye",Zp);const eg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],jl=Br("file-text",eg);const tg=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],rg=Br("funnel",tg);const ng=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],sg=Br("image-plus",ng);const ag=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],og=Br("regex",ag);const ig=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],lg=Br("scan",ig);const cg=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],dg=Br("whole-word",cg),ug=100,fg=5e5,hg=1e4,hu=16384,mg=32,pg=1e5;class cs extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class gg{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>pg)throw new cs("complexity");if(performance.now()-this.startedAt>=ug)throw new cs("timeout")}validateLines(n){if(n.length>hg)throw new cs("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>fg||l.length>hu)throw new cs("size")}validateInline(n){if(this.check(),n.length>hu)throw new cs("size")}nested(n){if(this.check(),this.depth>=mg)throw new cs("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const mu=new RegExp(`(\\\\\\([^)]*\\\\\\)|\\$[^$\\n]+\\$|<br\\s*\\/?>|<\\s*img\\b[^>]*>|<\\s*video\\b[^>]*>[\\s\\S]*?<\\/video\\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\\b[\\s\\S]*?<\\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\\[[^\\]]*\\]\\((?:<[^>]+>|(?:[^\\s()]|\\([^()\\s]*\\))+)(?:\\s+(?:"[^"]*"|'[^']*'|\\([^)]*\\)))?\\)|!?\\[[^\\]]+\\]\\[[^\\]]*\\]|!?\\[[^\\]]+\\]|\\[\\^[^\\]]+\\]|~~[^~]+~~|\\*\\*[^*]+\\*\\*|(?<![\\p{L}\\p{N}_])__[^_]+__(?![\\p{L}\\p{N}_])|\\*[^*\\s][^*]*\\*|(?<![\\p{L}\\p{N}_])_[^_\\s][^_]*_(?![\\p{L}\\p{N}_])|<https?:\\/\\/[^>\\s]+>|<[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+>|https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+|[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+)`,"iyu");function bg(r,n,s){let l=n;for(;r[l]==="`";)l+=1;const d=l-n;let c=l;for(;c<r.length;){s.check();const m=r.indexOf("`",c);if(m<0)return null;for(c=m;r[c]==="`";)c+=1;if(c-m===d)return c}return null}function*xg(r,n){n.validateInline(r);const s=new RegExp(mu.source,mu.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=bg(r,l,n);if(c!==null)yield{index:l,token:r.slice(l,c)},l=c;else for(;r[l]==="`";)l+=1;continue}s.lastIndex=l;const d=s.exec(r);n.check(),d?(yield{index:l,token:d[0]},l=s.lastIndex):l+=(r.codePointAt(l)??0)>65535?2:1}}function pu({children:r,actions:n}){const{t:s}=ht(),[l,d]=a.useState(!1),c=a.useId(),m=a.useRef(null),g=a.useRef(null),f=()=>{d(!1),m.current?.focus({preventScroll:!0})};return a.useLayoutEffect(()=>{if(!l)return;const p=m.current,x=g.current;if(!p||!x)return;const h=window.visualViewport,b=()=>{const S=p.getBoundingClientRect(),T=(h?.offsetLeft??0)+8,D=(h?.offsetTop??0)+8,F=Math.max(0,(h?.width??window.innerWidth)-16),$=D+(h?.height??window.innerHeight)-16,C=Math.min(240,F),A=Math.max(0,S.top-D-6),O=Math.max(0,$-S.bottom-6),q=x.scrollHeight>O&&A>O;Object.assign(x.style,{width:`${C}px`,left:`${Math.max(T,Math.min(S.right-C,T+F-C))}px`,top:`${q?S.top-6:S.bottom+6}px`,maxHeight:`${q?A:O}px`,transform:q?"translateY(-100%)":"none"})};b();const E=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return E?.observe(p),E?.observe(x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),h?.addEventListener("resize",b),h?.addEventListener("scroll",b),()=>{E?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),h?.removeEventListener("resize",b),h?.removeEventListener("scroll",b)}},[l]),a.useEffect(()=>{if(!l)return;g.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const p=x=>{x.target instanceof Node&&!m.current?.contains(x.target)&&!g.current?.contains(x.target)&&d(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[l]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:m,type:"button","aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?c:void 0,onClick:()=>d(p=>!p),onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),d(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${l?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx($o,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&wr.createPortal(e.jsx("div",{ref:g,id:c,hidden:!l,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":s("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:p=>{if(!p.currentTarget.contains(p.target))return;const x=[...p.currentTarget.querySelectorAll("button:not(:disabled)")],h=x.indexOf(document.activeElement);let b;if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),f();return}if(p.key==="Tab"){f();return}if(p.key==="ArrowDown")b=(h+1)%x.length;else if(p.key==="ArrowUp")b=(h-1+x.length)%x.length;else if(p.key==="Home")b=0;else if(p.key==="End")b=x.length-1;else return;p.preventDefault(),x[b]?.focus({preventScroll:!0})},children:n(f)}),document.body)]})}const Zi="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",ds=a.memo(function({active:n,mounted:s=!0,fallback:l=null,children:d}){const c=a.useRef(null);return a.useLayoutEffect(()=>{const m=c.current;if(!m||n)return;const g=new Map,f=h=>{g.has(h)||(g.set(h,h.inert),h.inert=!0)},p=h=>{h instanceof HTMLElement&&h.matches(Zi)&&f(h),h.querySelectorAll(Zi).forEach(f)};p(m);const x=new MutationObserver(h=>{for(const b of h)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Zi)&&f(b.target):b.addedNodes.forEach(E=>{E instanceof Element&&p(E)})});return x.observe(m,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{x.disconnect();for(const[h,b]of g)h.inert=b}},[n,s]),e.jsx("div",{ref:c,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:n?void 0:{clipPath:"inset(100%)"},"aria-hidden":!n,children:s?typeof d=="function"?d():d:l})},(r,n)=>!r.active&&!n.active&&r.mounted===n.mounted);async function vg(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function yg({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!r||!n||s||d.current===n)return;const m=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(m)},[r,n,s,l,d,c])}async function wg(r){if(r.kind==="mermaid"){await zd(new Blob([r.svg],{type:"image/svg+xml"}),"mermaid.svg");return}const n=new URL(r.src,window.location.href);if(n.origin===window.location.origin&&n.pathname==="/api/terminal/fs/blob"){const c=n.searchParams.get("path");if(!c)throw new Error("Missing image path");await Ju(c);return}const s=await fetch(r.src);if(!s.ok)throw new Error(`HTTP ${s.status}`);const l=await s.blob(),d=decodeURIComponent(n.pathname.split("/").pop()||"")||`image.${{"image/svg+xml":"svg","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[l.type]||"png"}`;await zd(l,d)}let mo=null,gu=!1;function kg(){return mo||(mo=Ln(()=>import("./mermaid.core-BcUHOzZA.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw mo=null,r})),mo}function Sg(r){gu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),gu=!0)}function jg({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:d}=ht(),[c,m]=a.useState(""),[g,f]=a.useState(0),[p,x]=a.useState(null),[h,b]=a.useState(!1),[E,S]=a.useState(!1),T=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const C=new AbortController;return x(null),b(!1),Qu(T,C.signal,!0,"pick_git_ignore_exception").then(A=>{C.signal.aborted||x({directory:c,entries:A.entries,truncated:!!A.truncated})}).catch(()=>{C.signal.aborted||b(!0)}),()=>C.abort()},[T,c,g]);const D=C=>{x(null),b(!1),m(C)},F=p?.directory===c,$=C=>{if(C.length>200){S(!0);return}S(!1),l(C)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":d("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(Ol,{size:14})}),e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(""),"aria-label":d("rightSidebar.backToProjectRoot"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(xl,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:T,children:c||"./"})]}),e.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":d("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!F&&!h,children:[h?e.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[e.jsx("p",{role:"alert",className:"text-destructive",children:d("rightSidebar.gitIgnoreExceptionsLoadFailed")}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{b(!1),f(C=>C+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:d("common.retry")})]}):F?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(C=>{const A=c?`${c}/${C.name}`:C.name,O=A+(C.type==="directory"?"/":""),q=n.includes(O)||n.includes(A),j=n.some(_=>_.endsWith("/")&&A.startsWith(_)),o=C.type==="directory"?xl:kp;return e.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[e.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:q||j,disabled:s||j,onChange:()=>$(q?n.filter(_=>_!==O&&_!==A):[...n,O]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),e.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",title:C.name,children:C.name})]}),C.type==="directory"&&e.jsx("button",{type:"button",disabled:s,onClick:()=>D(A),"aria-label":d("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:C.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:e.jsx(hs,{size:15})})]},C.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ut,{size:18})}),F&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:d("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>$([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:d("rightSidebar.gitIgnoreExceptionsClear")})]}),n.length>0&&e.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:n.map(C=>e.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:C,children:C}),e.jsx("button",{type:"button",disabled:s,onClick:()=>$(n.filter(A=>A!==C)),"aria-label":d("rightSidebar.gitIgnoreExceptionsRemove",{path:C}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:13})})]},C))}),E&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function Rg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:d}){const{t:c}=ht(),m=a.useId(),g=a.useRef(null),f=a.useRef(null),p=a.useRef(null),x=a.useRef(null),h=a.useRef(!1),[b,E]=a.useState(!1),[S,T]=a.useState([]),[D,F]=a.useState(!1),[$,C]=a.useState(null),A=V(I=>I.setGitIgnoreExceptions),O=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,x.current=null},q=()=>{O(),!(n||D||!r)&&(T([...V.getState().gitIgnoreExceptions[r]??[]]),C(null),E(!0))},j=()=>{D||E(!1)},o=I=>{O(),h.current=!1,!(I.button!==0||!I.isPrimary||n)&&(I.currentTarget.setPointerCapture(I.pointerId),x.current={x:I.clientX,y:I.clientY},p.current=setTimeout(()=>{h.current=!0,q()},450))};a.useEffect(()=>(E(!1),O(),O),[r]),a.useEffect(()=>{if(b)return f.current?.focus(),()=>g.current?.focus()},[b]);const _=c(s?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",disabled:n||D,"aria-pressed":s,"aria-label":_,"aria-description":c("rightSidebar.gitIgnoreConfigureHint"),title:`${_} · ${c("rightSidebar.gitIgnoreConfigureHint")}`,onClick:I=>{if(h.current&&I.detail!==0){h.current=!1,I.preventDefault();return}d()},onContextMenu:I=>{I.preventDefault(),h.current=!0,b||q()},onPointerDown:o,onPointerMove:I=>{const Y=x.current;Y&&Math.hypot(I.clientX-Y.x,I.clientY-Y.y)>10&&O()},onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${s?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:l?e.jsx(ut,{size:14}):e.jsx(rg,{size:14})}),b&&wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:j,children:e.jsxs("form",{ref:f,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:I=>I.stopPropagation(),onKeyDown:I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),j()),I.key==="Tab"){const Y=Array.from(f.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!Y.length){I.preventDefault(),f.current?.focus();return}const H=Y[0],U=Y[Y.length-1];I.shiftKey&&document.activeElement===H&&(I.preventDefault(),U?.focus()),document.activeElement===f.current?(I.preventDefault(),(I.shiftKey?U:H)?.focus()):!I.shiftKey&&document.activeElement===U&&(I.preventDefault(),H?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||D)){if(S.length>200){C(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}F(!0),C(null),A(r,S).then(()=>E(!1)).catch(()=>C(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>F(!1))}},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:`${m}-title`,className:"text-sm font-medium",children:c("rightSidebar.gitIgnoreExceptionsTitle")}),e.jsx("button",{type:"button",disabled:D,onClick:j,"aria-label":c("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:16})})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),e.jsx("p",{id:`${m}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:c("rightSidebar.gitIgnoreExceptionsHint")}),e.jsx("p",{className:"text-xs font-medium",children:c("rightSidebar.gitIgnoreExceptionsPaths")}),r&&e.jsx(jg,{rootPath:r,paths:S,onChange:T,disabled:D}),$&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:$}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:D,onClick:j,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:c("common.cancel")}),e.jsxs("button",{type:"submit",disabled:D,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[D&&e.jsx(ut,{size:13}),c("common.save")]})]})]})}),document.body)]})}function Ng(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,d=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!d)return Promise.resolve(null);const c=r instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),m=document.createElement("canvas");m.width=Math.max(1,Math.round(l*c)),m.height=Math.max(1,Math.round(d*c));const g=m.getContext("2d");if(!g)return Promise.resolve(null);const f=getComputedStyle(document.documentElement);if(g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,m.height),g.drawImage(r,0,0,m.width,m.height),s){const p=Math.max(10,Math.min(16,m.width/35));g.font=`${p}px sans-serif`;const x=[];let h="";for(const b of s.split(" "))h&&g.measureText(`${h} ${b}`).width>m.width-20?(x.push(h),h=b):h=h?`${h} ${b}`:b;h&&x.push(h),g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,x.length*(p+4)+12),g.fillStyle=f.getPropertyValue("--foreground").trim()||"black",x.forEach((b,E)=>g.fillText(b,10,8+p+E*(p+4)))}if(n){const p=n.xPercent*m.width/100,x=n.yPercent*m.height/100,h=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),b=h*1.6;g.strokeStyle=f.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,h/3),g.beginPath(),g.arc(p,x,h,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(p-b,x),g.lineTo(p+b,x),g.moveTo(p,x-b),g.lineTo(p,x+b),g.stroke()}return new Promise(p=>m.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function Cg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
+
`)}function L0(r,n,s){const l=n*Math.PI/360,d=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(r,1e-6)/Math.sin(d)*1.15}async function Eg(r,n,s,l){if(!s?.snapshot)return l.isCurrent()?await l.insert(r,n):!1;const d=new Date().toISOString(),c=new AbortController;let m,g;try{g=await Promise.race([(async()=>{const f=await s.snapshot;if(!(!f||c.signal.aborted||!l.isCurrent()))return l.upload(new File([f],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(f=>{m=setTimeout(()=>{c.abort(),f(void 0)},3e3)})])}catch{}finally{clearTimeout(m),c.abort()}return l.isCurrent()?await l.insert(g?Cg(r,"",d,g):r,n):!1}function Mg(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function bu(r,n){return`${r??""}\0${n}`}function $g(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=bu(n,s);let d=0,c=0;for(const m of r){const g=[m.filePath,m.newPath,m.oldPath].filter(p=>typeof p=="string"&&p.length>0);(g.some(p=>bu(m.repoRoot,p)===l)||g.some(p=>Mg(p,s)))&&(d+=1)}return{explained:d,stale:c}}function Pg({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(qp,{size:10}):e.jsx(ua,{size:10})})}function Rl({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(Pg,{status:n})]})}const yf="termdock:right-sidebar:diff-change-list-mode:v1";function Ag(r){return r==="list"||r==="tree"}function Lg(){return gt(yf,Ag)??"tree"}function Tg(r){for(const n of r){const s=n.hunk;if(s.oldPath&&s.newPath&&s.oldPath!==s.newPath)return"renamed";if(s.oldPath===null&&s.newPath)return"added";if(s.oldPath&&s.newPath===null)return"deleted"}return"modified"}function Ig(r){const n=new Map;for(const l of r){const d=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(l),d.additions+=l.hunk.additions,d.deletions+=l.hunk.deletions,l.current&&(d.explained+=1),l.stale&&(d.stale+=1),n.set(l.hunk.filePath,d)}const s=Array.from(n.values()).sort((l,d)=>l.filePath.localeCompare(d.filePath));for(const l of s)l.changeType=Tg(l.items);return s}function Dg(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 Fg(r,n){const s=r.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],d=new Set;for(const[c,m]of s.entries()){const g=m.split(`
|
|
4
|
+
`),f=g.findIndex(h=>h.startsWith("@@ "));if(f<0){l.push(...g);continue}c===0&&l.push(...g.slice(0,f));const p=n[c];let x=f;for(;x>=0&&x<g.length;){const h=g.findIndex((F,$)=>$>x&&F.startsWith("@@ ")),b=h>=0?h:g.length,E=g.slice(x,b),S=E[0]??"",T=p?S===p:!0,D=S||p||E.join(`
|
|
5
|
+
`);T&&!d.has(D)&&(l.push(...E),d.add(D)),x=h}}return l.join(`
|
|
6
|
+
`)}function _g({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Fg(s.items.map(f=>f.hunk.diff||f.current?.diff||f.stale?.diff||""),s.items.map(f=>f.hunk.hunkHeader)),d=s.items.map(f=>f.current??f.stale).filter(f=>!!f).map(f=>({id:f.id,repoRoot:f.repoRoot,filePath:f.filePath,oldPath:f.oldPath,newPath:f.newPath,hunkHeader:f.hunkHeader,hunkIndex:f.hunkIndex,fingerprint:f.fingerprint,diff:f.diff,explanation:f.explanation,summary:f.summary,workspaceRoot:f.workspaceRoot,generatedBy:f.generatedBy,injectedAt:f.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,m=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"",g=s.items[0]?.repoRoot??d[0]?.repoRoot??null;return{key:s.key,path:s.filePath,oldPath:s.items[0]?.hunk.oldPath??void 0,absolutePath:g?`${g}/${s.items[0]?.repositoryPath??s.filePath}`:s.filePath,status:s.changeType,repoRoot:g,displayName:c,displayDir:m,diffOverride:l,oldSourceRef:s.items[0]?.current?.headRef?`${s.items[0].current.baseRef}...${s.items[0].current.headRef}`:s.items[0]?.stale?.headRef?`${s.items[0].stale.baseRef}...${s.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(s.items.flatMap(f=>f.hunk.previewRevert?[[f.hunk.hunkHeader,f.hunk.previewRevert]]:[])),auditRecords:d,onInsertDiffReference:n}})}function Bg(r,n,s){const l=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=r.getBoundingClientRect().top+48;let m=null,g=Number.POSITIVE_INFINITY;for(const p of l){const x=p.getBoundingClientRect();if(x.bottom<c)continue;const h=Math.abs(x.top-c);h<g&&(m=p,g=h)}const f=m?.dataset.diffSelectionPath??m?.dataset.diffStreamItem??null;return!f||f===n||s(f),f}function xu({items:r,selectedKey:n,onSelect:s,emptyText:l,mobile:d=!1,backLabel:c="Back",headerTitle:m,headerMeta:g,onClose:f,closeLabel:p="Back",wrap:x=!0,diffViewType:h,inlineMode:b,viewControls:E,onToggleWrap:S,wrapTitle:T,wrapOnLabel:D="Wrap on",wrapOffLabel:F="Wrap off",desktopLayout:$="split",onInsertDiffReference:C,onReferenceCopied:A,renderPathReference:O,insertedReferenceKey:q,copiedReferenceKey:j,onClearAuditRecord:o,onRefresh:_,localOptions:I,onHunkGitAction:Y,error:H,refreshing:U,actionsBusy:R,refreshLabel:z,refreshTitle:Z,walkthroughs:P=[],onWalkthroughNavigate:G,initialDetailScrollTop:J,onDetailScrollPositionChange:ie,scrollToKey:pe,scrollToKeyNonce:Se,externalSwiperRef:ke,onMobileSlideChange:Me}){const{t:Q}=ht(),ge=a.useMemo(()=>Ig(r),[r]),ue=a.useMemo(()=>new Map(ge.map(te=>[te.key,te])),[ge]),[_e,Ue]=a.useState(()=>Lg()),[W,we]=a.useState(()=>new Set),[ye,He]=a.useState({key:null,nonce:0}),Ke=ge.find(te=>te.explained>0||te.stale>0)?.key??ge[0]?.key??null,M=n&&ge.some(te=>te.key===n)?n:Ke,he=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ge.map(Dg)}],[ge]),fe=a.useMemo(()=>_g({groups:ge,onInsertDiffReference:C}),[ge,C]),Ne=a.useRef(Ke),$e=a.useRef(s);Ne.current=Ke,$e.current=s,a.useEffect(()=>{!n&&Ne.current&&$e.current(Ne.current)},[n]);const rt=S?e.jsxs("button",{type:"button",onClick:S,"aria-pressed":x,title:T,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${x?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:x?D:F})]}):null,ce=I?.map(te=>e.jsxs("label",{title:te.disabled?Q("rightSidebar.includeUncommittedCurrentBranchOnly"):te.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:te.checked,disabled:U||R||te.disabled&&!te.checked,onChange:je=>te.onChange(je.target.checked),className:"accent-primary"}),e.jsxs("span",{children:[te.label," · ",Q("rightSidebar.includeUncommitted"),te.disabled&&e.jsx("span",{className:"block text-[10px]",children:Q("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},te.key)),Te=H?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:H}):null,qe=_?e.jsxs("button",{type:"button",onClick:_,disabled:U||R,title:Z??z,"aria-label":Z??z,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx(nf,{size:12,className:U?"animate-spin":""}),z&&e.jsx("span",{children:z})]}):null,Ie=te=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[m&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:m}),g&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:g})]}),f&&e.jsxs("button",{type:"button",onClick:f,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[e.jsx(ca,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[te,ce,qe,E,rt,Te]})]});if(r.length===0){const te=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!m&&!f?te:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ie(null),te]})}const De=S||_?({slideToList:te})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:te,children:[e.jsx(ca,{size:14}),c]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[ce,qe,E,S&&e.jsxs("button",{type:"button",onClick:S,"aria-pressed":x,title:T,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${x?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:x?D:F})]})]}),Te]}):void 0;return e.jsx(yl,{mobile:d,preserveScrollOnUpdate:!!I?.length,desktopLayout:$,backLabel:c,groups:he,selectedKey:M,mode:_e,onModeChange:te=>{Ue(te),te!=="ai"&&At(yf,te)},compact:d,collapsedDirectoryKeys:W,onToggleDirectory:te=>{we(je=>{const nt=new Set(je);return nt.has(te)?nt.delete(te):nt.add(te),nt})},onSelectFile:te=>{s(te.key),He(je=>({key:te.key,nonce:je.nonce+1}))},renderLeading:te=>{const je=ue.get(te.key);return e.jsx(Rl,{changeStatus:te.status,auditStatus:je,renderChangeBadge:nt=>e.jsx(oa,{status:nt})})},renderTrailing:te=>{const je=ue.get(te.key);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[je&&e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",je.additions," -",je.deletions]}),O?.(te.path,"file")]})},renderDirectoryTrailing:te=>O?.(te,"directory"),renderListHeader:Ie,aiContent:({slideToDetail:te,fullscreen:je,toggleFullscreen:nt})=>P.length>0&&G?e.jsx(ff,{walkthroughs:P,repoRoot:P[0]?.repoRoot,fullscreen:je,onToggleFullscreen:nt,onNavigate:Rt=>{d&&window.requestAnimationFrame(te),G(Rt)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:Q("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:De,externalSwiperRef:ke,onMobileSlideChange:Me,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:J,scrollToKey:pe??ye.key,scrollToKeyNonce:pe==null?ye.nonce:Se,onDetailScroll:te=>{Bg(te,M,s),ie?.(te.scrollTop)},files:fe,activePane:!0,wrap:x,diffViewType:h,inlineMode:b,renderStreamBadge:(te,je)=>{const nt=ue.get(je.key);return e.jsx(Rl,{changeStatus:te,auditStatus:nt,renderChangeBadge:Rt=>e.jsx(oa,{status:Rt})})},onInsertDiffReference:C,onReferenceCopied:A,insertedReferenceKey:q,copiedReferenceKey:j,onClearAuditRecord:o,onHunkGitAction:U?void 0:Y,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function Og(r){return r.replace(/\/+$/,"")||"/"}function Ug(r){return[...new Set(Array.from(r,Og))].sort((n,s)=>n.localeCompare(s))}function Hg(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function zg(r){let n=null;return{applicableEvents:r.filter(l=>{const d=l.type==="rescan-required"&&!Hg(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const Wg=1400,Gg=1200,wf=44,Kg=.7;function el(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Nl(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function qg(r){try{const n=window.localStorage.getItem(Nl(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=wf?s:null}catch{return null}}function vu(r,n){try{n===null?window.localStorage.removeItem(Nl(r)):window.localStorage.setItem(Nl(r),String(n))}catch{}}function po(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Vg({value:r,collapsed:n,labels:s,focusRequest:l,insertError:d,autoCollapseAfterSend:c,onChange:m,onCollapsedChange:g,onAutoCollapseAfterSendChange:f,onDisable:p,onClear:x,onInsert:h,onInsertAndSend:b}){const[E,S]=a.useState(null),[T,D]=a.useState(!1),F=a.useRef(!1),$=a.useRef(!0),[C,A]=a.useState(!1),[O,q]=a.useState(()=>qg(el())),j=a.useRef(O),o=a.useRef(null),_=a.useRef(null),I=a.useRef(r),Y=a.useRef(null),H=a.useRef(null),U=!!r.trim(),R=r.trim().split(`
|
|
7
|
+
`)[0]??"",z=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>($.current=!0,()=>{$.current=!1,o.current!==null&&window.clearTimeout(o.current),_.current!==null&&window.clearTimeout(_.current)}),[]),a.useEffect(()=>{let W=!1;const we=el();return Zu().then(ye=>{if(W)return;const He=ye.contextDraftHeight?.[we]??null;vu(we,He),j.current=He,q(He)}).catch(()=>{}),()=>{W=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const W=Y.current;if(!W)return;po()||W.focus(),W.setSelectionRange(W.value.length,W.value.length),W.scrollTop=W.scrollHeight}},[l]),a.useEffect(()=>{const W=I.current;I.current=r,!(!n||r.length<=W.length)&&(A(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{_.current=null,A(!1)},Gg))},[r,n]),a.useEffect(()=>{if(n)return;const W=Y.current;W&&(W.style.height=O!==null?`${O}px`:"")},[r,n,O]),a.useEffect(()=>{if(n)return;const W=Y.current;!W||document.activeElement===W||(W.scrollTop=W.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||po())return;const W=Y.current;!W||document.activeElement===W||(W.focus(),W.setSelectionRange(W.value.length,W.value.length))},[n]);const Z=a.useRef(null);a.useLayoutEffect(()=>{if(!po())return;const W=window.visualViewport;if(!W)return;const we=()=>{const ye=Z.current;if(!ye)return;if(W.height>=window.innerHeight*.75){ye.style.transform="";return}const He=ye.getBoundingClientRect(),Ke=Math.round(W.height-He.bottom);ye.style.transform=Ke!==0?`translateY(${Ke}px)`:""};return we(),W.addEventListener("resize",we),W.addEventListener("scroll",we),()=>{W.removeEventListener("resize",we),W.removeEventListener("scroll",we),Z.current&&(Z.current.style.transform="")}},[n]);const P=W=>{S(W),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,S(null)},Wg)},G=W=>{g(!1),po()&&window.requestAnimationFrame(()=>{const we=Y.current;if(!we)return;we.focus();const ye=we.value.length;we.setSelectionRange(ye,ye),window.requestAnimationFrame(()=>{we.setSelectionRange(ye,ye)})})},J=async(W,we)=>{if(!(!U||F.current)){F.current=!0,D(!0),S(null);try{await(W==="sent"?b(we):h(we))&&$.current&&P(W)}catch{}finally{F.current=!1,$.current&&D(!1)}}},ie=W=>{J("inserted",W.currentTarget)},pe=W=>{J("sent",W.currentTarget)},Se=W=>{if(W.key==="Escape"){W.preventDefault(),g(!0);return}W.nativeEvent.isComposing||W.keyCode===229||W.key!=="Enter"||!W.metaKey&&!W.ctrlKey||(W.preventDefault(),pe(W))},ke=W=>{W.preventDefault()},Me=W=>{W.preventDefault();const we=Y.current;we&&(H.current={startY:W.clientY,startHeight:we.getBoundingClientRect().height},W.currentTarget.setPointerCapture?.(W.pointerId))},Q=W=>{const we=H.current;if(!we)return;const ye=window.visualViewport?.height??window.innerHeight,He=Math.round(Math.min(Math.max(we.startHeight+(we.startY-W.clientY),wf),ye*Kg));j.current=He,q(He)},ge=W=>{const we=el();vu(we,W),ra({contextDraftHeight:{[we]:W}}).catch(()=>{})},ue=()=>{H.current&&(H.current=null,j.current!==null&&ge(j.current))},_e=()=>{j.current=null,q(null),ge(null)},Ue=r.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(r.length)});return n?e.jsx("section",{ref:Z,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:e.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[e.jsxs("button",{type:"button",onClick:()=>G(),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!1,"aria-label":s.expand,title:s.expand,children:[e.jsx(Sp,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:`truncate text-[11px] ${d?"text-destructive":C?"text-primary":U?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(C?s.appended:U?R:s.title)})]}),Ue,e.jsx("button",{type:"button",onClick:pe,disabled:!U||T,"aria-busy":T,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${U?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:T?e.jsx(ru,{size:12,className:"animate-spin"}):E==="sent"?e.jsx(Po,{size:12}):e.jsx(nu,{size:12})})]})}):e.jsxs("section",{ref:Z,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[e.jsx("div",{className:"group absolute left-1/2 top-0 z-10 flex h-3 w-16 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize touch-none items-center justify-center",onPointerDown:Me,onPointerMove:Q,onPointerUp:ue,onPointerCancel:ue,onDoubleClick:_e,title:s.resize,"aria-hidden":"true",children:e.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),e.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[e.jsxs("button",{type:"button",onPointerDown:ke,onClick:()=>g(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[e.jsx(da,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:s.title}),Ue]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:ke,onClick:()=>f(!c),className:"inline-flex h-6 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-surface/70 hover:text-foreground","aria-label":s.autoCollapseAfterSend,title:s.autoCollapseAfterSend,children:e.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${c?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${c?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:ke,onClick:p,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:e.jsx(Lt,{size:11})})]}),e.jsx("div",{className:"px-2 pb-2",children:e.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[e.jsx("textarea",{ref:Y,value:r,onChange:W=>m(W.target.value),onKeyDown:Se,placeholder:s.title,rows:1,className:"block min-h-11 w-full resize-none bg-transparent px-2.5 py-2 font-mono text-[12px] leading-relaxed text-foreground placeholder:text-muted-foreground/30 focus:outline-none",autoCapitalize:"sentences",spellCheck:!0,"data-context-draft-input":!0}),e.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[e.jsx("button",{type:"button",onPointerDown:ke,onClick:x,disabled:!U,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(jo,{size:11})}),d?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:d}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:ke,onClick:ie,disabled:!U||T,"aria-busy":T,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[e.jsx(jp,{size:11}),e.jsx("span",{children:T?s.pending??s.insert:E==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:ke,onClick:pe,disabled:!U||T,"aria-busy":T,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${z}`,children:[T?e.jsx(ru,{size:11,className:"animate-spin"}):E==="sent"?e.jsx(Po,{size:11}):e.jsx(nu,{size:11}),e.jsx("span",{children:E==="sent"?s.sent:s.send})]})]})]})})]})}function Yg(r,n){const s=n.trim();if(!s)return r;if(!r.trim())return s;const l=r.endsWith(`
|
|
8
|
+
|
|
9
|
+
`)?"":r.endsWith(`
|
|
10
|
+
`)?`
|
|
11
|
+
`:`
|
|
12
|
+
|
|
13
|
+
`;return`${r}${l}${s}`}function Xg(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}function Jg(r,n){return{text:Xg(r,n),options:{paste:/[\r\n]/.test(r),submitAfterPaste:n}}}function Qg(r){const[n,s]=a.useState(null),l=a.useRef(null),d=a.useRef(null),c=a.useRef(!0),m=a.useRef(r);m.current=r,a.useEffect(()=>(c.current=!0,()=>{c.current=!1,l.current?.controller.abort()}),[]);const g=a.useCallback(async b=>{if(l.current)return!1;l.current=b,d.current=b;const E=S=>{b.task={...b.task,...S},c.current&&l.current===b&&s(b.task)};E({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const S=await bl(b.task.directory,b.task.retryFiles,b.controller.signal);if(E({uploaded:[...b.task.uploaded,...S.files]}),m.current(b.task.directory),S.files.length!==b.task.retryFiles.length){const T=new Set(S.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw E({retryFiles:S.results?b.task.retryFiles.filter((D,F)=>!T.has(F)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}E({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){E({status:"inserting"});const S=b.task.uploaded[0]?.path;if(!S||!b.isCurrent?.()||!await b.insert(S)||!b.isCurrent?.()||b.controller.signal.aborted)return E({status:"error",error:"reference"}),!1}return E({status:"done"}),!0}catch(S){if(S instanceof Wd&&S.result?.files.length){const T=new Set(S.result.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);E({uploaded:[...b.task.uploaded,...S.result.files],retryFiles:S.result.results?b.task.retryFiles.filter((D,F)=>!T.has(F)):[]}),m.current(b.task.directory)}return E({status:b.controller.signal.aborted?"canceled":"error",error:S instanceof Wd&&S.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":S instanceof Error?S.message:String(S)}),!1}finally{l.current===b&&(l.current=null)}},[]),f=a.useCallback((b,E,S,T)=>E.length?g({task:{kind:S?"image":"files",directory:b,files:E,retryFiles:E,uploaded:[],status:"uploading"},controller:new AbortController,insert:S,isCurrent:T}):Promise.resolve(!1),[g]),p=a.useCallback(()=>{const b=d.current;if(!b||l.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const E={...b,controller:new AbortController,task:{...b.task}};return g(E)},[g]),x=a.useCallback(()=>{const b=l.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),h=a.useCallback(()=>{l.current||(d.current=null,s(null))},[]);return{task:n,start:f,retry:p,cancel:x,dismiss:h,busy:n?.status==="uploading"||n?.status==="inserting"}}function Zg({task:r,labels:n,onCancel:s,onRetry:l,onDismiss:d}){const c=r.status==="uploading"||r.status==="inserting",m=r.error==="reference"?n.referenceRejected:r.error==="UPLOAD_LIMIT"?n.limit:r.status==="error"?`${n.failed}: ${r.error??""}`:n[r.status],g=r.status==="error"&&(r.kind==="image"&&r.uploaded.length>0||r.retryFiles.length>0&&r.retryFiles.length<=50);return e.jsxs("section",{className:"shrink-0 border-t border-border/20 bg-surface/80 px-3 py-2 text-xs","data-sidebar-upload-status":!0,"aria-busy":c,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`min-w-0 flex-1 break-words ${r.status==="error"?"text-destructive":"text-foreground"}`,role:r.status==="error"?"alert":"status",children:m}),r.status==="uploading"&&e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:s,children:n.cancel}),g&&e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:l,children:n.retry}),!c&&e.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-muted-foreground hover:bg-surface-2",onClick:d,"aria-label":n.dismiss,children:"×"})]}),e.jsx("div",{className:"mt-1 truncate text-muted-foreground",title:r.directory,children:r.directory}),e.jsxs("details",{className:"mt-1 min-w-0 text-muted-foreground",children:[e.jsxs("summary",{className:"cursor-pointer truncate",children:[n.files," · ",r.files[0]?.name]}),e.jsxs("ul",{className:"mt-1 max-h-24 overflow-y-auto font-mono text-[10px]",children:[r.files.map((f,p)=>e.jsx("li",{className:"break-all",children:f.name},`${p}:${f.name}`)),r.uploaded.map(f=>e.jsx("li",{className:"break-all text-foreground",children:f.path},f.path))]})]})]})}function eb(r){const n=a.useRef(r),s=a.useRef(0);(n.current.text!==r.text||n.current.sessionId!==r.sessionId||n.current.active!==r.active)&&(s.current+=1),n.current=r;const l=a.useRef(!0),d=a.useRef(!1);return a.useEffect(()=>(l.current=!0,()=>{l.current=!1,s.current+=1}),[]),a.useCallback(async(c,m)=>{if(d.current||!n.current.active)return!1;const g=n.current,f=s.current,{text:p,options:x}=Jg(g.text,c);if(!p)return!1;d.current=!0;try{const h=await sf(p,g.sessionId,()=>l.current&&n.current.active&&n.current.sessionId===g.sessionId,m,x),b=l.current&&f===s.current;return b&&(h?n.current.onAccepted():n.current.onRejected()),h&&b}finally{d.current=!1}},[])}const yu={status:"idle",error:null,result:null};function tb(r,n=!0){const[s,l]=a.useState(yu),d=a.useRef(null);a.useEffect(()=>Km(g=>{const f=d.current;!f||f.targetPeerId===g?.targetPeerId||(d.current=null,f.controller.abort(new DOMException("Download target changed","AbortError")),l({status:"canceled",error:null,result:"canceled"}))}),[]),a.useLayoutEffect(()=>(l(yu),()=>{const g=d.current;d.current=null,g?.controller.abort()}),[r,n]);const c=a.useCallback(()=>{const g=d.current;g&&(d.current=null,g.controller.abort(),l({status:"canceled",error:null,result:"canceled"}))},[]),m=a.useCallback(async()=>{if(!n||!r||d.current)return;const g=new AbortController,f=qm()?.targetPeerId;d.current={controller:g,targetPeerId:f},l({status:"pending",error:null,result:null});try{const p=await Ju(r,g.signal);if(d.current?.controller!==g)return;d.current=null;const x=g.signal.aborted?"canceled":p;l({status:x,error:null,result:x})}catch(p){if(d.current?.controller!==g)return;d.current=null,g.signal.aborted?l({status:"canceled",error:null,result:"canceled"}):l({status:"error",error:p instanceof Error?p.message:String(p),result:null})}},[r,n]);return{...s,start:m,cancel:c}}const Cl="termdock:right-sidebar:html-view-mode-by-file:v1";function rb(r){return r==="preview"||r==="source"}function kf(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(rb)}function Sf(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function wu(r,n){const s=Sf(r,n);return s?gt(Cl,kf)?.[s]??"source":"source"}function nb(r,n,s){const l=Sf(r,n);if(!l)return;const d=gt(Cl,kf)??{};At(Cl,{...d,[l]:s})}function jf(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const sb=1500,ku=256*1024*1024;async function ab(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",d=s.body?.getReader();if(!d){const g=await s.blob();if(g.size>ku)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(g)}const c=[];let m=0;try{for(;;){const{done:g,value:f}=await d.read();if(g)break;if(m+=f.byteLength,m>ku)throw new Error("Media too large for encrypted fallback");c.push(f)}}catch(g){throw await d.cancel().catch(()=>{}),g}return URL.createObjectURL(new Blob(c,{type:l}))}function Ho(r,n){const s=jf(r),[l,d]=a.useState(()=>!!navigator.serviceWorker?.controller),[c,m]=a.useState(void 0),g=a.useRef(n);return g.current=n,a.useEffect(()=>{if(!s||l)return;const f=navigator.serviceWorker,p=()=>d(!!f?.controller);return f?.addEventListener("controllerchange",p),p(),()=>f?.removeEventListener("controllerchange",p)},[s,l]),a.useEffect(()=>{if(!s||l){m(void 0);return}let f=!1,p;const x=new AbortController,h=window.setTimeout(()=>{ab(r,x.signal).then(b=>{if(f){URL.revokeObjectURL(b);return}p=b,m(b)}).catch(()=>{f||x.signal.aborted||g.current?.()})},sb);return()=>{f=!0,window.clearTimeout(h),x.abort(),p&&URL.revokeObjectURL(p)}},[s,l,r]),!s||l?r:c}function tl(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),d=n%60,c=String(l).padStart(2,"0"),m=String(d).padStart(2,"0");return s>0?`${s}:${c}:${m}`:`${c}:${m}`}function ob(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const Zr=2,ib=8,lb=60,go=5,Su=.05,cb=900;function db(r){return!Number.isFinite(r)||r<=0?Zr:Math.min(ib,Zr+Math.floor(r/lb))}const ub=350,fb=6,hb=90;function mb({url:r,onLoadError:n}){const s=Ho(r,n),{t:l}=ht(),d=a.useRef(null),c=a.useRef(null),m=a.useRef(null),g=a.useRef(null),f=a.useRef(!1),p=a.useRef(null),x=a.useRef(null),h=a.useRef(0),b=a.useRef(!1),E=a.useRef(!1),S=a.useRef(!1),T=a.useRef(null),D=a.useRef(null),F=a.useRef(!1),$=a.useRef(1),C=a.useRef(!1),[A,O]=a.useState(0),[q,j]=a.useState(0),[o,_]=a.useState(!1),[I,Y]=a.useState(!1),[H,U]=a.useState(null),[R,z]=a.useState(!1),[Z,P]=a.useState(0),[G,J]=a.useState(!1),[ie,pe]=a.useState({width:0,height:0}),[Se,ke]=a.useState(Zr),[Me,Q]=a.useState(1),[ge,ue]=a.useState(null),_e=a.useRef(Zr),Ue=a.useRef(null),W=a.useCallback(()=>{T.current!==null&&(clearTimeout(T.current),T.current=null)},[]),we=a.useCallback(()=>{W();const B=D.current;if(D.current=null,!F.current)return!1;const ae=m.current;if(ae&&(ae.playbackRate=$.current,B))try{ae.releasePointerCapture?.(B.id)}catch{}return F.current=!1,_e.current=Zr,z(!1),!0},[W]);a.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),x.current!==null&&clearTimeout(x.current),Ue.current!==null&&clearTimeout(Ue.current),W();const B=m.current;B&&F.current&&(B.playbackRate=$.current)},[W]),a.useEffect(()=>{const B=c.current;if(!B||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(([Ce])=>{Ce&&pe({width:Ce.contentRect.width,height:Ce.contentRect.height})});return ae.observe(B),()=>ae.disconnect()},[]),a.useEffect(()=>{const B=()=>J(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",B),()=>document.removeEventListener("fullscreenchange",B)},[]);const ye=a.useCallback((B,ae=!1)=>{const Ce=m.current;if(!Ce)return!1;const et=Number.isFinite(Ce.duration)?Ce.duration:B,xt=Math.min(Math.max(B,0),et);if(j(xt),Math.abs(Ce.currentTime-xt)<1/120)return!1;const kr=Ce.fastSeek;return ae&&typeof kr=="function"?kr.call(Ce,xt):Ce.currentTime=xt,!0},[]),He=a.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const B=m.current;if(!B||!b.current||E.current||B.seeking)return;const ae=S.current;S.current=!1,E.current=ye(h.current,!ae)}))},[ye]),Ke=a.useCallback(B=>{const ae=g.current,Ce=m.current;if(!ae||!Ce)return;const et=ae.getBoundingClientRect(),xt=ob(B,et,Ce.duration);h.current=xt,U(xt),S.current=!1,He(),x.current!==null&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,S.current=!0,He()},hb)},[He]),M=a.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),x.current!==null&&(clearTimeout(x.current),x.current=null),S.current=!1,E.current=!1,ye(h.current)},[ye]),he=a.useCallback(B=>{const ae=m.current;if(!(!ae||!Number.isFinite(ae.duration)||ae.duration<=0)){f.current=!ae.paused,ae.pause(),b.current=!0,Y(!0);try{B.currentTarget.setPointerCapture(B.pointerId)}catch{}Ke(B.clientX)}},[Ke]),fe=a.useCallback(()=>{b.current=!1,M(),Y(!1),U(null);const B=m.current;B&&f.current&&!B.ended&&B.play().catch(()=>{}),f.current=!1},[M]),Ne=a.useCallback(()=>{const B=m.current;if(B){if(C.current){C.current=!1;return}B.paused?B.play().catch(()=>{}):B.pause()}},[]),$e=a.useCallback(B=>{const ae=m.current;if(!ae)return;const Ce=Math.min(1,Math.max(0,Math.round((ae.volume+B)*100)/100));ae.volume=Ce,Ce>0&&(ae.muted=!1),Q(Ce),ue(Ce),Ue.current!==null&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>{Ue.current=null,ue(null)},cb)},[]),rt=a.useCallback(B=>{const ae=m.current;if(ae){if(B.key==="ArrowLeft"){B.preventDefault(),ye(ae.currentTime-(B.shiftKey?go*2:go));return}if(B.key==="ArrowRight"){B.preventDefault(),ye(ae.currentTime+(B.shiftKey?go*2:go));return}if(B.key==="ArrowUp"){B.preventDefault(),$e(Su);return}if(B.key==="ArrowDown"){B.preventDefault(),$e(-Su);return}(B.key===" "||B.key==="Spacebar"||B.key==="k"||B.key==="K")&&(B.preventDefault(),ae.paused?ae.play().catch(()=>{}):ae.pause())}},[ye,$e]),ce=a.useCallback(B=>{const ae=m.current;!ae||ae.paused||B.button!==0||(W(),D.current={id:B.pointerId,x:B.clientX,y:B.clientY},T.current=setTimeout(()=>{T.current=null;const Ce=D.current;if($.current=ae.playbackRate,ae.playbackRate=Zr,_e.current=Zr,ke(Zr),F.current=!0,z(!0),Ce)try{ae.setPointerCapture?.(Ce.id)}catch{}},ub))},[W]),Te=a.useCallback(B=>{const ae=D.current;if(!ae||ae.id!==B.pointerId)return;if(!F.current){Math.hypot(B.clientX-ae.x,B.clientY-ae.y)>fb&&(W(),D.current=null);return}const Ce=db(B.clientX-ae.x);if(Ce===_e.current)return;_e.current=Ce,ke(Ce);const et=m.current;et&&(et.playbackRate=Ce)},[W]),qe=a.useCallback(()=>{we()&&(C.current=!0)},[we]);a.useEffect(()=>(window.addEventListener("pointerup",qe),window.addEventListener("pointercancel",qe),window.addEventListener("blur",qe),()=>{window.removeEventListener("pointerup",qe),window.removeEventListener("pointercancel",qe),window.removeEventListener("blur",qe)}),[qe]);const Ie=a.useCallback(async()=>{const B=d.current,ae=m.current;if(!(!B||!ae))try{document.fullscreenElement===B?await document.exitFullscreen():B.requestFullscreen?await B.requestFullscreen():ae.webkitEnterFullscreen?.()}catch{ae.webkitEnterFullscreen?.()}},[]),De=a.useCallback(()=>P(B=>(B+90)%360),[]),te=a.useCallback(B=>{const ae=m.current;if(!ae||!Number.isFinite(ae.duration))return;const Ce=B.shiftKey?10:5;let et=null;B.key==="ArrowLeft"?et=ae.currentTime-Ce:B.key==="ArrowRight"?et=ae.currentTime+Ce:B.key==="Home"?et=0:B.key==="End"&&(et=ae.duration),et!==null&&(B.preventDefault(),ye(et))},[ye]),je=I&&H!==null?H:q,nt=A>0?Math.min(1,Math.max(0,je/A)):0,lr=(Z===90||Z===270)&&ie.width>0&&ie.height>0?{width:`${ie.height}px`,height:`${ie.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:d,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":Z,children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:m,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${R?` ${du}`:""}`,style:{...lr,transform:`translate(-50%, -50%) rotate(${Z}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...R?{[uu]:""}:{},onClick:Ne,onKeyDown:rt,onVolumeChange:B=>Q(B.currentTarget.volume),onPointerDown:ce,onPointerMove:Te,onPointerUp:qe,onPointerCancel:qe,onContextMenu:B=>{F.current&&B.preventDefault()},onPlay:()=>_(!0),onPause:()=>_(!1),onTimeUpdate:B=>j(B.currentTarget.currentTime),onSeeked:B=>{const ae=B.currentTarget;if(j(ae.currentTime),E.current=!1,!b.current)return;const Ce=ae.requestVideoFrameCallback;typeof Ce=="function"?Ce.call(ae,()=>{b.current&&He()}):requestAnimationFrame(()=>{b.current&&He()})},onLoadedMetadata:B=>O(Number.isFinite(B.currentTarget.duration)?B.currentTarget.duration:0),onDurationChange:B=>O(Number.isFinite(B.currentTarget.duration)?B.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),R&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(Se)})}),ge!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(Rp,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Me*100)})]}),I&&H!==null&&e.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${nt*100}%`},"data-testid":"file-preview-video-scrub-time",children:tl(H)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${du}`,[uu]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Ne,"aria-label":l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:o?e.jsx(Np,{size:14}):e.jsx(Cp,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(A),"aria-valuenow":Math.floor(je),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:he,onPointerMove:B=>{I&&Ke(B.clientX)},onPointerUp:fe,onPointerCancel:fe,onKeyDown:te,children:[e.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),e.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${nt*100}%`}}),e.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${nt*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[tl(je)," / ",tl(A)]}),e.jsx("button",{type:"button",onClick:De,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(nf,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Ie()},"aria-label":l(G?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(G?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:G?e.jsx(Ep,{size:14}):e.jsx(Mp,{size:14})})]})})]})}function pb(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function zo({anchor:r,children:n,disabled:s=!1,onClick:l,title:d}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l(c.currentTarget)},title:d,style:pb(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(Ao,{size:11}),n]})}function gb(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const d=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(d)||d<=0)return null;const c=l.width*d,m=l.height*d,g=s.left+(s.width-c)/2,f=s.top+(s.height-m)/2,p=r-g,x=n-f;if(p<0||x<0||p>c||x>m)return null;const h=p/c*100,b=x/m*100;return{x:l.x+l.width*h/100,y:l.y+l.height*b/100,xPercent:h,yPercent:b}}function bb(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function xb(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const d of Array.from(l.attributes)){const c=d.name.toLowerCase(),m=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&m&&!m.startsWith("#"))&&l.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function vb(r,n,s){let l=null;for(const d of Array.from(r.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const m=Number(d.getAttribute("x")),g=Number(d.getAttribute("y"));if(!Number.isFinite(m)||!Number.isFinite(g))continue;const f=Math.hypot(m-n,g-s);(!l||f<l.distance)&&(l={text:c,distance:f})}return l?.text.slice(0,120)}function Rf({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=a.useRef(null),c=a.useRef(null),[m,g]=a.useState(null),[f,p]=a.useState(null),[x,h]=a.useState(1),[b,E]=a.useState(!1),[S,T]=a.useState(null),D=a.useRef(new Map),F=a.useRef(null),$=a.useRef(!1),C=a.useRef(null),A=a.useRef(x);A.current=x,a.useEffect(()=>{const P=new AbortController;return g(null),p(null),T(null),h(1),fetch(r,{signal:P.signal}).then(G=>G.text()).then(G=>g(xb(G))).catch(G=>{P.signal.aborted||p(G instanceof Error?G.message:"SVG preview failed")}),()=>P.abort()},[r]),a.useEffect(()=>{if(!b)return;const P=G=>{G.key==="Escape"&&E(!1)};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[b]),a.useLayoutEffect(()=>{const P=c.current,G=P?.querySelector("[data-svg-document] > svg");if(!P||!G)return;let J;try{J=G.getBBox()}catch{return}if(!J.width||!J.height)return;const ie=Math.max(2,Math.min(J.width,J.height)*.025);G.setAttribute("viewBox",`${J.x-ie} ${J.y-ie} ${J.width+2*ie} ${J.height+2*ie}`),G.style.width=`${x*100}%`,G.style.height=`${x*100}%`,G.style.minWidth=`${x*100}%`,G.style.minHeight=`${x*100}%`,G.style.display="block"},[m,x]);const O=a.useMemo(()=>S?bb(n,s,S):null,[n,S,s]),q=P=>{if($.current){$.current=!1;return}const G=c.current,J=G?.querySelector("[data-svg-document] > svg"),ie=d.current;if(!G||!J||!ie)return;const pe=J.viewBox.baseVal,Se=gb(P.clientX,P.clientY,J.getBoundingClientRect(),pe);if(!Se)return;const ke=ie.getBoundingClientRect();T({...Se,nearestText:vb(J,Se.x,Se.y),stageX:P.clientX-ke.left,stageY:P.clientY-ke.top,stageXPercent:(P.clientX-ke.left)/ke.width*100,stageYPercent:(P.clientY-ke.top)/ke.height*100})},j=P=>Math.max(1,Math.min(12,P)),o=(P,G)=>{const J=j(G),ie=P.querySelector("[data-svg-document] > svg");if(!ie)return J;const pe=`${J*100}%`;return ie.style.width=pe,ie.style.height=pe,ie.style.minWidth=pe,ie.style.minHeight=pe,A.current=J,J},_=(P,G,J,ie)=>{const pe=A.current,Se=P.getBoundingClientRect(),ke=J-Se.left,Me=ie-Se.top,Q=(P.scrollLeft+ke)/pe,ge=(P.scrollTop+Me)/pe,ue=o(P,G);return P.scrollLeft=Q*ue-ke,P.scrollTop=ge*ue-Me,ue},I=()=>{const P=Array.from(D.current.values());return P.length>=2?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0},Y=P=>{if(P.pointerType==="mouse"&&P.button!==0)return;const G=c.current;G&&(D.current.set(P.pointerId,{x:P.clientX,y:P.clientY}),G.setPointerCapture?.(P.pointerId),D.current.size>=2?(F.current={kind:"pinch",startX:P.clientX,startY:P.clientY,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startDistance:I(),startZoom:A.current,moved:!1},$.current=!0):A.current>1&&(F.current={kind:"pan",startX:P.clientX,startY:P.clientY,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startZoom:A.current,moved:!1}))},H=P=>{if(!D.current.has(P.pointerId))return;D.current.set(P.pointerId,{x:P.clientX,y:P.clientY});const G=c.current,J=F.current;if(!(!G||!J)){if(D.current.size>=2&&J.kind==="pinch"){const ie=I();if(!J.startDistance||!ie)return;const pe=j(J.startZoom*ie/J.startDistance);if(Math.abs(pe-A.current)<.01)return;const Se=Array.from(D.current.values()),ke=(Se[0].x+Se[1].x)/2,Me=(Se[0].y+Se[1].y)/2;J.moved=!0,$.current=!0,_(G,pe,ke,Me),P.preventDefault();return}if(J.kind==="pan"&&D.current.size===1){const ie=P.clientX-J.startX,pe=P.clientY-J.startY;if(!J.moved&&Math.hypot(ie,pe)<6)return;J.moved=!0,$.current=!0,G.scrollLeft=J.startScrollLeft-ie,G.scrollTop=J.startScrollTop-pe,P.preventDefault()}}},U=P=>{const G=c.current,J=F.current,ie=D.current.size===1&&!J?.moved;D.current.delete(P.pointerId);try{G?.releasePointerCapture?.(P.pointerId)}catch{}if(D.current.size===1&&J?.kind==="pinch"){const ke=Array.from(D.current.values())[0];F.current=G?{kind:"pan",startX:ke.x,startY:ke.y,startScrollLeft:G.scrollLeft,startScrollTop:G.scrollTop,startZoom:A.current,moved:!1}:null;return}if(D.current.size>0||(F.current=null,J?.kind==="pinch"&&h(A.current),!ie||$.current))return;const pe=Date.now(),Se=C.current;Se&&pe-Se.time<350&&Math.hypot(P.clientX-Se.x,P.clientY-Se.y)<24?(C.current=null,$.current=!0,h(ke=>ke>1?1:2.5)):C.current={time:pe,x:P.clientX,y:P.clientY}},R=P=>{if(!P.ctrlKey&&!P.metaKey)return;const G=c.current;if(!G)return;P.preventDefault();const J=_(G,A.current*Math.exp(-P.deltaY*.01),P.clientX,P.clientY);h(J)},z=()=>{h(1),A.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},Z=e.jsxs("div",{className:b?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:q,onDoubleClick:P=>{P.preventDefault(),h(G=>G>1?1:2.5)},onPointerDown:Y,onPointerMove:H,onPointerUp:U,onPointerCancel:U,onWheel:R,onScroll:()=>T(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:f?e.jsx("div",{className:"p-4 text-sm text-destructive",children:f}):m?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:m}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),S&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:S.stageX,top:S.stageY}}),S&&O&&e.jsx(zo,{anchor:{xPercent:S.stageXPercent,yPercent:S.stageYPercent},title:"引用 SVG 标注",onClick:async P=>{await l?.(O,`svg:${S.x.toFixed(2)}:${S.y.toFixed(2)}`,void 0,P)!==!1&&T(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[x>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:P=>{P.stopPropagation(),z()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(lg,{size:14})}),e.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:P=>{P.stopPropagation(),E(G=>!G)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:b?e.jsx(hf,{size:14}):e.jsx(uf,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:S?`SVG (${S.x.toFixed(2)}, ${S.y.toFixed(2)}) · ${S.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return b?wr.createPortal(Z,document.body):Z}function No(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function yb(r,n,s,l){const d=[`电子标注: ${r}`,`视图: ${No(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(d.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&d.push(`显示层: ${l.layer}`),l.nearest)){const c=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");d.push(`最近对象: ${l.nearest.label}${c?`(${c})`:""}`)}return`"${d.join(" / ")}"`}function wb({blobUrl:r,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:m,interactive3d:g}){const{t:f}=ht(),p=a.useRef(null),x=a.useRef(null),h=a.useRef(null),[b,E]=a.useState(null),[S,T]=a.useState(!1);a.useEffect(()=>(h.current?.abort(),E(null),T(!1),()=>h.current?.abort()),[r,s]);const D=a.useMemo(()=>b?yb(n,s,b,b.inspection):null,[n,b,s]),F=C=>{const A=p.current,O=x.current;if(!A||!O||!O.naturalWidth||!O.naturalHeight)return;const q=A.getBoundingClientRect(),j=O.getBoundingClientRect(),o=Math.min(j.width/O.naturalWidth,j.height/O.naturalHeight),_=O.naturalWidth*o,I=O.naturalHeight*o,Y=j.left+(j.width-_)/2,H=j.top+(j.height-I)/2,U=C.clientX-Y,R=C.clientY-H;if(U<0||R<0||U>_||R>I)return;const z={xPercent:Math.max(0,Math.min(100,U/_*100)),yPercent:Math.max(0,Math.min(100,R/I*100)),stageXPercent:(C.clientX-q.left)/q.width*100,stageYPercent:(C.clientY-q.top)/q.height*100,inspecting:l&&s!=="pcb-3d"};if(E(z),h.current?.abort(),!z.inspecting)return;const Z=new AbortController;h.current=Z,Vm(n,s,z.xPercent,z.yPercent,Z.signal).then(P=>E(G=>G===z?{...G,inspection:P,inspecting:!1}:G)).catch(()=>{Z.signal.aborted||E(P=>P===z?{...P,inspection:{available:!1},inspecting:!1}:P)})},$=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:$.map(C=>e.jsx("button",{type:"button",onClick:()=>d(C),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${C===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:No(C)},C))}),e.jsx("button",{type:"button",onClick:m,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:f("rightSidebar.edaRefresh"),"aria-label":f("rightSidebar.edaRefresh"),children:e.jsx(Ro,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:p,role:"button",tabIndex:0,onClick:F,onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),E({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:f("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:x,src:r,alt:`${n} ${No(s)}`,onLoad:()=>T(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${S?"opacity-100":"opacity-0"}`}),b&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${b.stageXPercent}%`,top:`${b.stageYPercent}%`}}),b&&D&&e.jsx(zo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:f("rightSidebar.edaInsertAnnotation"),onClick:async C=>{await c?.(D,`eda:${s}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:x.current?Ng(x.current,b):Promise.resolve(null)},C)!==!1&&E(null)},children:f("rightSidebar.edaInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:b?b.inspecting?f("rightSidebar.edaInspecting"):b.inspection?.available?f("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??f("rightSidebar.edaNoNearbyObject")}):f("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):f("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Rf,{blobUrl:r,filePath:n,viewLabel:No(s),onInsertAnnotation:c})})]})}function kb(r){const n=[];let s=[],l="",d=!1;for(let c=0;c<r.length;c+=1){const m=r[c];d?m==='"'&&r[c+1]==='"'?(l+='"',c+=1):m==='"'?d=!1:l+=m:m==='"'?d=!0:m===","?(s.push(l),l=""):m===`
|
|
14
|
+
`?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=m}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function Sb(r,n,s,l,d){const c=n[d]||`第${d+1}列`,m=s[d]??"",g=n.map((f,p)=>`${f||`第${p+1}列`}=${s[p]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${l+1} / 列: ${c} / 值: ${m} / 记录: ${g}"`}function jb({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=ht(),d=a.useMemo(()=>kb(r),[r]),c=d[0]??[],m=d.slice(1),g=a.useRef(null),[f,p]=a.useState(null),x=f?m[f.row]:null,h=f&&x?Sb(n,c,x,f.row+1,f.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:g,className:"relative min-h-0 flex-1",children:[e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),c.map((b,E)=>e.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:b||l("rightSidebar.csvUnnamedColumn",{index:E+1})},`${b}:${E}`))]})}),e.jsx("tbody",{children:m.map((b,E)=>e.jsxs("tr",{className:"hover:bg-surface-2",children:[e.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:E+1}),c.map((S,T)=>{const D=f?.row===E&&f.column===T;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${D?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:F=>{const $=g.current?.getBoundingClientRect(),C=F.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const A=F.clientX||C.left+C.width/2,O=F.clientY||C.top+C.height/2;p({row:E,column:T,xPercent:(A-$.left)/$.width*100,yPercent:(O-$.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:b[T]||" "})},`cell:${E}:${T}`)})]},`row:${E}`))})]})}),f&&h&&e.jsx(zo,{anchor:{xPercent:f.xPercent,yPercent:f.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:async b=>{await s?.(h,`csv:${n}:${f.row+1}:${f.column+1}`,void 0,b)!==!1&&p(null)},children:l("rightSidebar.csvInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:f&&x?l("rightSidebar.csvSelectedCell",{row:f.row+1,column:c[f.column]||f.column+1}):l("rightSidebar.csvPickHint",{rows:m.length,columns:c.length})})})]})}function us(r,n){let s=r;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function Rb(r,n){const s=JSON.parse(r),l=us(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(us(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(us(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:us(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=us(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(g=>g&&typeof g=="object"&&g.name==="Default"):void 0,m=us(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(d)?d.length:0)},{label:"默认间距",value:c?.clearance!==void 0?`${c.clearance} mm`:"未设置"},{label:"默认线宽",value:c?.track_width!==void 0?`${c.track_width} mm`:"未设置"},{label:"默认过孔",value:c?.via_diameter!==void 0?`${c.via_diameter} / ${c.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(m)?m.length:0)}]}function Nb(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function Cb({content:r,filePath:n,localState:s,onInsertAnnotation:l}){const{t:d}=ht(),c=a.useRef(null),[m,g]=a.useState(null),f=a.useMemo(()=>{try{return{items:Rb(r,s),error:null}}catch(x){return{items:[],error:x instanceof Error?x.message:String(x)}}},[r,s]),p=m===null?null:f.items[m.index];return f.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:d("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[e.jsx("div",{className:"divide-y divide-border/15",children:f.items.map((x,h)=>e.jsxs("button",{type:"button",onClick:b=>{const E=c.current?.getBoundingClientRect(),S=b.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const T=b.clientX||S.left+S.width/2,D=b.clientY||S.top+S.height/2;g({index:h,xPercent:(T-E.left)/E.width*100,yPercent:(D-E.top)/E.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${m?.index===h?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:x.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:x.value})]},x.label))}),e.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:d("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),p&&m&&e.jsx(zo,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:async x=>{await l?.(Nb(n,p),`kicad-project:${n}:${p.label}`,void 0,x)!==!1&&g(null)},children:d("rightSidebar.kicadInsertSetting")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:p?`${p.label}: ${p.value}`:d("rightSidebar.kicadProjectPickHint")})})]})}const Eb=`/** ES Module Shims Wasm @version 2.8.4 */
|
|
15
|
+
(function () {
|
|
16
|
+
|
|
17
|
+
const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
18
|
+
|
|
19
|
+
let invalidate;
|
|
20
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
21
|
+
const initHotReload = (topLevelLoad, importShim) => {
|
|
22
|
+
let _importHook = importHook,
|
|
23
|
+
_resolveHook = resolveHook,
|
|
24
|
+
_metaHook = metaHook;
|
|
25
|
+
|
|
26
|
+
let defaultResolve;
|
|
27
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
28
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
29
|
+
const originalParent = stripVersion(parent);
|
|
30
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
31
|
+
const hotState = getHotState(url);
|
|
32
|
+
const parents = hotState.p;
|
|
33
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
34
|
+
return toVersioned(url, hotState);
|
|
35
|
+
};
|
|
36
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
37
|
+
const hotState = getHotState(url);
|
|
38
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
39
|
+
hotState.t = sourceType;
|
|
40
|
+
};
|
|
41
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
42
|
+
|
|
43
|
+
const Hot = class Hot {
|
|
44
|
+
constructor(url) {
|
|
45
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
46
|
+
}
|
|
47
|
+
accept(deps, cb) {
|
|
48
|
+
if (typeof deps === 'function') {
|
|
49
|
+
cb = deps;
|
|
50
|
+
deps = null;
|
|
51
|
+
}
|
|
52
|
+
const hotState = getHotState(this.url);
|
|
53
|
+
if (!hotState.A) return;
|
|
54
|
+
(hotState.a = hotState.a || []).push([
|
|
55
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
56
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
57
|
+
: null,
|
|
58
|
+
cb
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
dispose(cb) {
|
|
62
|
+
getHotState(this.url).u = cb;
|
|
63
|
+
}
|
|
64
|
+
invalidate() {
|
|
65
|
+
const hotState = getHotState(this.url);
|
|
66
|
+
hotState.a = hotState.A = null;
|
|
67
|
+
const seen = [this.url];
|
|
68
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const versionedRegEx = /\\?v=\\d+$/;
|
|
73
|
+
const stripVersion = url => {
|
|
74
|
+
const versionMatch = url.match(versionedRegEx);
|
|
75
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const toVersioned = (url, hotState) => {
|
|
79
|
+
const { v } = hotState;
|
|
80
|
+
return url + (v ? '?v=' + v : '');
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
let hotRegistry = {},
|
|
84
|
+
curInvalidationRoots = new Set(),
|
|
85
|
+
curInvalidationInterval;
|
|
86
|
+
const getHotState = url =>
|
|
87
|
+
hotRegistry[url] ||
|
|
88
|
+
(hotRegistry[url] = {
|
|
89
|
+
// version
|
|
90
|
+
v: 0,
|
|
91
|
+
// accept list ([deps, cb] pairs)
|
|
92
|
+
a: null,
|
|
93
|
+
// accepting acceptors
|
|
94
|
+
A: true,
|
|
95
|
+
// unload callback
|
|
96
|
+
u: null,
|
|
97
|
+
// entry point or inline script source
|
|
98
|
+
e: false,
|
|
99
|
+
// hot data
|
|
100
|
+
d: {},
|
|
101
|
+
// parents
|
|
102
|
+
p: [],
|
|
103
|
+
// source type
|
|
104
|
+
t: undefined
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
108
|
+
const hotState = hotRegistry[url];
|
|
109
|
+
if (!hotState || seen.includes(url)) return false;
|
|
110
|
+
seen.push(url);
|
|
111
|
+
hotState.A = false;
|
|
112
|
+
if (
|
|
113
|
+
fromUrl &&
|
|
114
|
+
hotState.a &&
|
|
115
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
116
|
+
) {
|
|
117
|
+
curInvalidationRoots.add(fromUrl);
|
|
118
|
+
} else {
|
|
119
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
120
|
+
hotState.v++;
|
|
121
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
122
|
+
}
|
|
123
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleInvalidations = () => {
|
|
128
|
+
curInvalidationInterval = null;
|
|
129
|
+
const earlyRoots = new Set();
|
|
130
|
+
for (const root of curInvalidationRoots) {
|
|
131
|
+
const hotState = hotRegistry[root];
|
|
132
|
+
topLevelLoad(
|
|
133
|
+
toVersioned(root, hotState),
|
|
134
|
+
baseUrl,
|
|
135
|
+
defaultFetchOpts,
|
|
136
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
137
|
+
false,
|
|
138
|
+
undefined,
|
|
139
|
+
hotState.t
|
|
140
|
+
).then(m => {
|
|
141
|
+
if (hotState.a) {
|
|
142
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
143
|
+
// unload should be the latest unload handler from the just loaded module
|
|
144
|
+
if (hotState.u) {
|
|
145
|
+
hotState.u(hotState.d);
|
|
146
|
+
hotState.u = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
hotState.p.forEach(p => {
|
|
150
|
+
const hotState = hotRegistry[p];
|
|
151
|
+
if (hotState && hotState.a)
|
|
152
|
+
hotState.a.forEach(
|
|
153
|
+
async ([d, c]) =>
|
|
154
|
+
d &&
|
|
155
|
+
!earlyRoots.has(c) &&
|
|
156
|
+
(typeof d === 'string' ?
|
|
157
|
+
d === root && c(m)
|
|
158
|
+
: c(await Promise.all(d.map(d => (earlyRoots.add(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
}, throwError);
|
|
162
|
+
}
|
|
163
|
+
curInvalidationRoots = new Set();
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
setHooks(
|
|
167
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
168
|
+
_resolveHook ?
|
|
169
|
+
(id, parent, defaultResolve) =>
|
|
170
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
171
|
+
: hotResolveHook,
|
|
172
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const hasDocument = typeof document !== 'undefined';
|
|
177
|
+
|
|
178
|
+
const noop = () => {};
|
|
179
|
+
|
|
180
|
+
const chain = (a, b) =>
|
|
181
|
+
function () {
|
|
182
|
+
a.apply(this, arguments);
|
|
183
|
+
b.apply(this, arguments);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const dynamicImport = (u, _errUrl) => import(u);
|
|
187
|
+
|
|
188
|
+
const defineValue = (obj, prop, value) =>
|
|
189
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
190
|
+
|
|
191
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
192
|
+
|
|
193
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
194
|
+
Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
|
|
195
|
+
|
|
196
|
+
const version = "2.8.4";
|
|
197
|
+
|
|
198
|
+
const r$1 = esmsInitOptions.version;
|
|
199
|
+
if (self_.importShim || (r$1 && r$1 !== version)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// shim mode is determined on initialization, no late shim mode
|
|
204
|
+
const shimMode =
|
|
205
|
+
esmsInitOptions.shimMode ||
|
|
206
|
+
(hasDocument ?
|
|
207
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
208
|
+
.length > 0
|
|
209
|
+
// Without a document, shim mode is always true as we cannot polyfill
|
|
210
|
+
: true);
|
|
211
|
+
|
|
212
|
+
let importHook,
|
|
213
|
+
resolveHook,
|
|
214
|
+
fetchHook = fetch,
|
|
215
|
+
sourceHook,
|
|
216
|
+
metaHook,
|
|
217
|
+
tsTransform =
|
|
218
|
+
esmsInitOptions.tsTransform ||
|
|
219
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\\.\\w+)?\\.js$/, '-typescript.js')) ||
|
|
220
|
+
'./es-module-shims-typescript.js';
|
|
221
|
+
|
|
222
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
223
|
+
|
|
224
|
+
const globalHook = name => (typeof name === 'string' ? self_[name] : name);
|
|
225
|
+
|
|
226
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
227
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
228
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
229
|
+
if (esmsInitOptions.source) sourceHook = globalHook(esmsInitOptions.source);
|
|
230
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
231
|
+
|
|
232
|
+
const hasCustomizationHooks = importHook || resolveHook || fetchHook !== fetch || sourceHook || metaHook;
|
|
233
|
+
|
|
234
|
+
const {
|
|
235
|
+
noLoadEventRetriggers,
|
|
236
|
+
enforceIntegrity,
|
|
237
|
+
hotReload,
|
|
238
|
+
hotReloadInterval = 100,
|
|
239
|
+
nativePassthrough = !hasCustomizationHooks && !hotReload
|
|
240
|
+
} = esmsInitOptions;
|
|
241
|
+
|
|
242
|
+
const setHooks = (importHook_, resolveHook_, metaHook_) => (
|
|
243
|
+
(importHook = importHook_),
|
|
244
|
+
(resolveHook = resolveHook_),
|
|
245
|
+
(metaHook = metaHook_)
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
249
|
+
|
|
250
|
+
let nonce = esmsInitOptions.nonce;
|
|
251
|
+
if (!nonce && hasDocument) {
|
|
252
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
253
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
257
|
+
|
|
258
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
259
|
+
const disable = Array.isArray(esmsInitOptions.polyfillDisable) ? esmsInitOptions.polyfillDisable : [];
|
|
260
|
+
|
|
261
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
262
|
+
const wasmInstancePhaseEnabled =
|
|
263
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
|
|
264
|
+
const wasmSourcePhaseEnabled =
|
|
265
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
|
|
266
|
+
const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
|
|
267
|
+
const cssModulesEnabled = !disable.includes('css-modules');
|
|
268
|
+
const jsonModulesEnabled = !disable.includes('json-modules');
|
|
269
|
+
|
|
270
|
+
const onpolyfill =
|
|
271
|
+
esmsInitOptions.onpolyfill ?
|
|
272
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
273
|
+
: () => {
|
|
274
|
+
console.log(\`%c^^ Module error above is polyfilled and can be ignored ^^\`, 'font-weight:900;color:#391');
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const baseUrl =
|
|
278
|
+
hasDocument ? document.baseURI
|
|
279
|
+
: typeof location !== 'undefined' ?
|
|
280
|
+
\`\${location.protocol}//\${location.host}\${
|
|
281
|
+
location.pathname.includes('/') ?
|
|
282
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
283
|
+
: location.pathname
|
|
284
|
+
}\`
|
|
285
|
+
: 'about:blank';
|
|
286
|
+
|
|
287
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
288
|
+
let { skip } = esmsInitOptions;
|
|
289
|
+
if (Array.isArray(skip)) {
|
|
290
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
291
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
292
|
+
} else if (typeof skip === 'string') {
|
|
293
|
+
const r = new RegExp(skip);
|
|
294
|
+
skip = s => r.test(s);
|
|
295
|
+
} else if (skip instanceof RegExp) {
|
|
296
|
+
skip = s => skip.test(s);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
300
|
+
|
|
301
|
+
const throwError = err => {
|
|
302
|
+
(self_.reportError || dispatchError)(err);
|
|
303
|
+
onerror(err);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const fromParent = parent => (parent ? \` imported from \${parent}\` : '');
|
|
307
|
+
|
|
308
|
+
const backslashRegEx = /\\\\/g;
|
|
309
|
+
|
|
310
|
+
const asURL = url => {
|
|
311
|
+
try {
|
|
312
|
+
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
313
|
+
} catch (_) {}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const resolveUrl = (relUrl, parentUrl) =>
|
|
317
|
+
resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
|
|
318
|
+
|
|
319
|
+
const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
|
|
320
|
+
const hIdx = parentUrl.indexOf('#'),
|
|
321
|
+
qIdx = parentUrl.indexOf('?');
|
|
322
|
+
if (hIdx + qIdx > -2)
|
|
323
|
+
parentUrl = parentUrl.slice(
|
|
324
|
+
0,
|
|
325
|
+
hIdx === -1 ? qIdx
|
|
326
|
+
: qIdx === -1 || qIdx > hIdx ? hIdx
|
|
327
|
+
: qIdx
|
|
328
|
+
);
|
|
329
|
+
if (relUrl.indexOf('\\\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
|
|
330
|
+
// protocol-relative
|
|
331
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
332
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
333
|
+
}
|
|
334
|
+
// relative-url
|
|
335
|
+
else if (
|
|
336
|
+
(relUrl[0] === '.' &&
|
|
337
|
+
(relUrl[1] === '/' ||
|
|
338
|
+
(relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
|
|
339
|
+
(relUrl.length === 1 && (relUrl += '/')))) ||
|
|
340
|
+
relUrl[0] === '/'
|
|
341
|
+
) {
|
|
342
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
343
|
+
if (parentProtocol === 'blob:') {
|
|
344
|
+
throw new TypeError(
|
|
345
|
+
\`Failed to resolve module specifier "\${relUrl}". Invalid relative url or base scheme isn't hierarchical.\`
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
349
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
|
350
|
+
// throw new Error('Cannot resolve');
|
|
351
|
+
// read pathname from parent URL
|
|
352
|
+
// pathname taken to be part after leading "/"
|
|
353
|
+
let pathname;
|
|
354
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
355
|
+
// resolving to a :// so we need to read out the auth and host
|
|
356
|
+
if (parentProtocol !== 'file:') {
|
|
357
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
358
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
359
|
+
} else {
|
|
360
|
+
pathname = parentUrl.slice(8);
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
// resolving to :/ so pathname is the /... part
|
|
364
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
368
|
+
|
|
369
|
+
// join together and split for removal of .. and . segments
|
|
370
|
+
// looping the string instead of anything fancy for perf reasons
|
|
371
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
372
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
373
|
+
|
|
374
|
+
const output = [];
|
|
375
|
+
let segmentIndex = -1;
|
|
376
|
+
for (let i = 0; i < segmented.length; i++) {
|
|
377
|
+
// busy reading a segment - only terminate on '/'
|
|
378
|
+
if (segmentIndex !== -1) {
|
|
379
|
+
if (segmented[i] === '/') {
|
|
380
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
|
381
|
+
segmentIndex = -1;
|
|
382
|
+
}
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
// new segment - check if it is relative
|
|
386
|
+
else if (segmented[i] === '.') {
|
|
387
|
+
// ../ segment
|
|
388
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
389
|
+
output.pop();
|
|
390
|
+
i += 2;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
// ./ segment
|
|
394
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
395
|
+
i += 1;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
// it is the start of a new segment
|
|
400
|
+
while (segmented[i] === '/') i++;
|
|
401
|
+
segmentIndex = i;
|
|
402
|
+
}
|
|
403
|
+
// finish reading out the last segment
|
|
404
|
+
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
405
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
410
|
+
const outMap = {
|
|
411
|
+
imports: { ...parentMap.imports },
|
|
412
|
+
scopes: { ...parentMap.scopes },
|
|
413
|
+
integrity: { ...parentMap.integrity }
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
417
|
+
|
|
418
|
+
if (json.scopes)
|
|
419
|
+
for (let s in json.scopes) {
|
|
420
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
|
421
|
+
resolveAndComposePackages(
|
|
422
|
+
json.scopes[s],
|
|
423
|
+
outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
|
|
424
|
+
baseUrl,
|
|
425
|
+
parentMap
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
430
|
+
|
|
431
|
+
return outMap;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
const getMatch = (path, matchObj) => {
|
|
435
|
+
if (matchObj[path]) return path;
|
|
436
|
+
let sepIndex = path.length;
|
|
437
|
+
do {
|
|
438
|
+
const segment = path.slice(0, sepIndex + 1);
|
|
439
|
+
if (segment in matchObj) return segment;
|
|
440
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const applyPackages = (id, packages) => {
|
|
444
|
+
const pkgName = getMatch(id, packages);
|
|
445
|
+
if (pkgName) {
|
|
446
|
+
const pkg = packages[pkgName];
|
|
447
|
+
if (pkg === null) return;
|
|
448
|
+
return pkg + id.slice(pkgName.length);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
|
|
453
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
454
|
+
while (scopeUrl) {
|
|
455
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
456
|
+
if (packageResolution) return packageResolution;
|
|
457
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
458
|
+
}
|
|
459
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
|
|
463
|
+
for (let p in packages) {
|
|
464
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
465
|
+
if (
|
|
466
|
+
(!shimMode || !mapOverrides) &&
|
|
467
|
+
outPackages[resolvedLhs] &&
|
|
468
|
+
outPackages[resolvedLhs] !== packages[resolvedLhs]
|
|
469
|
+
) {
|
|
470
|
+
console.warn(
|
|
471
|
+
\`es-module-shims: Rejected map override "\${resolvedLhs}" from \${outPackages[resolvedLhs]} to \${packages[resolvedLhs]}.\`
|
|
472
|
+
);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
let target = packages[p];
|
|
476
|
+
if (typeof target !== 'string') continue;
|
|
477
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
478
|
+
if (mapped) {
|
|
479
|
+
outPackages[resolvedLhs] = mapped;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
console.warn(\`es-module-shims: Mapping "\${p}" -> "\${packages[p]}" does not resolve\`);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
|
|
487
|
+
for (let p in integrity) {
|
|
488
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
489
|
+
if (
|
|
490
|
+
(!shimMode || !mapOverrides) &&
|
|
491
|
+
outIntegrity[resolvedLhs] &&
|
|
492
|
+
outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
|
|
493
|
+
) {
|
|
494
|
+
console.warn(
|
|
495
|
+
\`es-module-shims: Rejected map integrity override "\${resolvedLhs}" from \${outIntegrity[resolvedLhs]} to \${integrity[resolvedLhs]}.\`
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
outIntegrity[resolvedLhs] = integrity[p];
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
let policy;
|
|
503
|
+
if (
|
|
504
|
+
typeof self !== 'undefined' &&
|
|
505
|
+
(typeof self.trustedTypes !== 'undefined' || typeof self.TrustedTypes !== 'undefined')
|
|
506
|
+
) {
|
|
507
|
+
try {
|
|
508
|
+
policy = (self.trustedTypes || self.TrustedTypes).createPolicy('es-module-shims', {
|
|
509
|
+
createHTML: html => html,
|
|
510
|
+
createScript: script => script
|
|
511
|
+
});
|
|
512
|
+
} catch {}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function maybeTrustedInnerHTML(html) {
|
|
516
|
+
return policy ? policy.createHTML(html) : html;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function maybeTrustedScript(script) {
|
|
520
|
+
return policy ? policy.createScript(script) : script;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
524
|
+
let supportsJsonType = false;
|
|
525
|
+
let supportsCssType = false;
|
|
526
|
+
|
|
527
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
528
|
+
|
|
529
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
530
|
+
let supportsWasmInstancePhase = false;
|
|
531
|
+
let supportsWasmSourcePhase = false;
|
|
532
|
+
let supportsMultipleImportMaps = false;
|
|
533
|
+
|
|
534
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
535
|
+
|
|
536
|
+
let featureDetectionPromise = (async function () {
|
|
537
|
+
// In shim mode, feature detection results are unused — skip the iframe overhead
|
|
538
|
+
if (shimMode) return;
|
|
539
|
+
if (!hasDocument)
|
|
540
|
+
return Promise.all([
|
|
541
|
+
import(createBlob(\`import"\${createBlob('{}', 'text/json')}"with{type:"json"}\`)).then(
|
|
542
|
+
() => (
|
|
543
|
+
(supportsJsonType = true),
|
|
544
|
+
import(createBlob(\`import"\${createBlob('', 'text/css')}"with{type:"css"}\`)).then(
|
|
545
|
+
() => (supportsCssType = true),
|
|
546
|
+
noop
|
|
547
|
+
)
|
|
548
|
+
),
|
|
549
|
+
noop
|
|
550
|
+
),
|
|
551
|
+
wasmInstancePhaseEnabled &&
|
|
552
|
+
import(createBlob(\`import"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
|
|
553
|
+
() => (supportsWasmInstancePhase = true),
|
|
554
|
+
noop
|
|
555
|
+
),
|
|
556
|
+
wasmSourcePhaseEnabled &&
|
|
557
|
+
import(createBlob(\`import source x from"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
|
|
558
|
+
() => (supportsWasmSourcePhase = true),
|
|
559
|
+
noop
|
|
560
|
+
)
|
|
561
|
+
]);
|
|
562
|
+
|
|
563
|
+
const msgTag = \`s\${version}\`;
|
|
564
|
+
return new Promise(resolve => {
|
|
565
|
+
const iframe = document.createElement('iframe');
|
|
566
|
+
iframe.style.display = 'none';
|
|
567
|
+
iframe.setAttribute('nonce', nonce);
|
|
568
|
+
function cb({ data }) {
|
|
569
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
|
|
570
|
+
if (!isFeatureDetectionMessage) return;
|
|
571
|
+
[
|
|
572
|
+
,
|
|
573
|
+
supportsImportMaps,
|
|
574
|
+
supportsMultipleImportMaps,
|
|
575
|
+
supportsJsonType,
|
|
576
|
+
supportsCssType,
|
|
577
|
+
supportsWasmSourcePhase,
|
|
578
|
+
supportsWasmInstancePhase
|
|
579
|
+
] = data;
|
|
580
|
+
resolve();
|
|
581
|
+
document.head.removeChild(iframe);
|
|
582
|
+
window.removeEventListener('message', cb, false);
|
|
583
|
+
}
|
|
584
|
+
window.addEventListener('message', cb, false);
|
|
585
|
+
// Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
|
|
586
|
+
const importMapTest = \`<script nonce=\${nonce || ''}>\${
|
|
587
|
+
policy ? 't=(window.trustedTypes||window.TrustedTypes).createPolicy("es-module-shims",{createScript:s=>s});' : ''
|
|
588
|
+
}b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"\${nonce}",text:\${
|
|
589
|
+
policy ? 't.createScript(innerText)' : 'innerText'
|
|
590
|
+
}}));i(\\\`{"imports":{"x":"\\\${b('')}"}}\\\`);i(\\\`{"imports":{"y":"\\\${b('')}"}}\\\`);cm=\${
|
|
591
|
+
supportsImportMaps && jsonModulesEnabled ? \`c(b(\\\`import"\\\${b('{}','text/json')}"with{type:"json"}\\\`))\` : 'false'
|
|
592
|
+
};sp=\${
|
|
593
|
+
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
594
|
+
\`c(b(\\\`import source x from "\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\`
|
|
595
|
+
: 'false'
|
|
596
|
+
};Promise.all([\${supportsImportMaps ? 'true' : "c('x')"},\${supportsImportMaps ? "c('y')" : false},cm,\${
|
|
597
|
+
supportsImportMaps && cssModulesEnabled ?
|
|
598
|
+
\`cm.then(s=>s?c(b(\\\`import"\\\${b('','text/css')\\}"with{type:"css"}\\\`)):false)\`
|
|
599
|
+
: 'false'
|
|
600
|
+
},sp,\${
|
|
601
|
+
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
602
|
+
\`\${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\\\`import"\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\${wasmSourcePhaseEnabled ? ':false)' : ''}\`
|
|
603
|
+
: 'false'
|
|
604
|
+
}]).then(a=>parent.postMessage(['\${msgTag}'].concat(a),'*'))<\${''}/script>\`;
|
|
605
|
+
|
|
606
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
607
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
608
|
+
let readyForOnload = false,
|
|
609
|
+
onloadCalledWhileNotReady = false;
|
|
610
|
+
function doOnload() {
|
|
611
|
+
if (!readyForOnload) {
|
|
612
|
+
onloadCalledWhileNotReady = true;
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
616
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
617
|
+
const doc = iframe.contentDocument;
|
|
618
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
619
|
+
const s = doc.createElement('script');
|
|
620
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
621
|
+
s.innerText = maybeTrustedScript(importMapTest.slice(15 + (nonce ? nonce.length : 0), -9));
|
|
622
|
+
doc.head.appendChild(s);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
iframe.onload = doOnload;
|
|
627
|
+
// WeChat browser requires append before setting srcdoc
|
|
628
|
+
document.head.appendChild(iframe);
|
|
629
|
+
|
|
630
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
631
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
632
|
+
// document.write gives usability warnings
|
|
633
|
+
readyForOnload = true;
|
|
634
|
+
if ('srcdoc' in iframe) iframe.srcdoc = maybeTrustedInnerHTML(importMapTest);
|
|
635
|
+
else iframe.contentDocument.write(importMapTest);
|
|
636
|
+
// retrigger onload for Safari only if necessary
|
|
637
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
638
|
+
});
|
|
639
|
+
})();
|
|
640
|
+
|
|
641
|
+
/* es-module-lexer (minimal) 2.3.1 */
|
|
642
|
+
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="etaourceeferromsyncunctionlassvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallelsxportport";let c$1,t,n;function parse(k,l="@"){c$1=k,t=l;const u=2*c$1.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,108)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),c=new e.Uint8Array(r),t=new e.Uint16Array(r),n=1040;function b(e){e=e|0;var a=0,r=0,c=0,t=0,n=0,b=0,k=0,o=0,w=0,g=0,p=0,y=0,m=0,O=0,T=0;y=s[398]|0;a=f[71]|0;f[68]=a;k=a;p=a;o=y;g=0;e:while(1){r=f[72]|0;t=o<<16>>16==y<<16>>16;c=g&e;b=a;while(1){n=b+2|0;if(b>>>0>=r>>>0){a=0;w=100;break e}a=s[n>>1]|0;if(!(M(a)|0)){if(t){switch(a<<16>>16){case 125:case 93:case 41:case 59:case 44:{w=100;break e}default:{}}if(c?se(a)|0:0){w=100;break e}}if(!(se(a)|0))break}b=n;}f[71]=n;a:do{switch(a<<16>>16){case 101:{if((o<<16>>16==0?Q(n)|0:0)?(S(b+4|0,214,10)|0)==0:0){u();w=89;}else w=89;break}case 105:{if(((s[b+4>>1]|0)==109?Q(n)|0:0)?(S(b+6|0,224,8)|0)==0:0){l();w=89;}else w=89;break}case 99:{if((((s[b+4>>1]|0)==108?Q(n)|0:0)?(S(b+6|0,70,6)|0)==0:0)?L(s[b+12>>1]|0)|0:0){i[800]=1;w=89;}else w=89;break}case 40:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=1;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 91:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=8;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 93:if(!(o<<16>>16)){ee();break a}else {s[398]=o+-1<<16>>16;w=89;break a}case 44:{r=s[397]|0;if((!(o<<16>>16==0|r<<16>>16==0)?(f[(f[69]|0)+((o&65535)+-1<<3)>>2]|0)==5:0)?(m=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0,(f[m+4>>2]|0)==0):0){f[m+4>>2]=p+2;f[71]=b+4;v(1)|0;w=f[71]|0;f[m+16>>2]=w;f[71]=w+-2;w=89;}else w=89;break}case 41:{if(!(o<<16>>16)){ee();break a}w=o+-1<<16>>16;s[398]=w;r=s[397]|0;if(r<<16>>16!=0?(f[(f[69]|0)+((w&65535)<<3)>>2]|0)==5:0){c=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0;if(!(f[c+4>>2]|0))f[c+4>>2]=p+2;f[c+12>>2]=b+4;s[397]=r+-1<<16>>16;w=89;}else w=89;break}case 123:{w=f[62]|0;do{if((s[p>>1]|0)==41&(w|0)!=0?(f[w+12>>2]|0)==(p+2|0):0){r=f[63]|0;f[62]=r;if(!r){f[58]=0;break}else {f[r+32>>2]=0;break}}}while(0);b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=(i[800]|0)==0?2:6;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;i[800]=0;w=89;break}case 125:{if(!(o<<16>>16)){ee();break a}k=f[69]|0;w=o+-1<<16>>16;s[398]=w;if((f[k+((w&65535)<<3)>>2]|0)==4){d();w=89;}else w=89;break}case 34:case 39:{A(a);w=89;break}case 47:switch(s[b+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{c=s[p>>1]|0;r:do{if(!($(c)|0)){if(!(c<<16>>16==41?K(f[(f[69]|0)+((o&65535)<<3)+4>>2]|0)|0:0))w=62;}else switch(c<<16>>16){case 46:if(((s[p+-2>>1]|0)+-48&65535)<10){w=62;break r}else break r;case 43:if((s[p+-2>>1]|0)==43){w=62;break r}else break r;case 45:if((s[p+-2>>1]|0)==45){w=62;break r}else break r;default:break r}}while(0);r:do{if((w|0)==62){w=0;if(o<<16>>16!=0?(O=f[69]|0,T=(o&65535)+-1|0,c<<16>>16==102?(f[O+(T<<3)>>2]|0)==1:0):0){if(((s[p+-2>>1]|0)==111?C(p+-4|0)|0:0)?B(f[O+(T<<3)+4>>2]|0,178,3)|0:0)break}else w=67;if((w|0)==67?(0,c<<16>>16==125):0){t=f[69]|0;r=o&65535;if(U(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(h(p)|0)){switch(c<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}w=f[64]|0;if((w|0?p>>>0>=(f[w>>2]|0)>>>0:0)?p>>>0<=(f[w+4>>2]|0)>>>0:0){I();i[799]=0;w=89;break a}t=f[3]|0;r=p;do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;c=s[r>>1]|0;}while(!(D(c)|0));if(M(c)|0){do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;}while(M(s[r>>1]|0)|0);if(q(r)|0){I();i[799]=0;w=89;break a}}i[799]=1;w=89;break a}}}while(0);I();i[799]=0;w=89;break a}}case 96:{b=f[69]|0;w=o&65535;f[b+(w<<3)+4>>2]=k;s[398]=o+1<<16>>16;f[b+(w<<3)>>2]=3;d();w=89;break}default:w=89;}}while(0);if((w|0)==89){w=0;f[68]=f[71];}if(i[798]|0){a=0;break}r=f[68]|0;a:do{if((r|0)==(p|0))if(g&((s[398]|0)==y<<16>>16&e)){a=s[f[71]>>1]|0;if(se(a)|0)break e;else a=1;}else a=g;else {if(a<<16>>16==47){a=(i[799]|0)==0;break}if(G(a)|0)a=1;else {switch(a<<16>>16){case 96:case 34:case 39:case 41:case 93:case 125:{a=1;break a}default:{}}a=0;}}}while(0);k=r;p=r;o=s[398]|0;g=a;a=f[71]|0;}if((w|0)==100)f[71]=n;return a|0}function k(){var e=0,a=0,r=0,c=0,t=0,b=0,k=0,o=0,w=0;w=n;n=n+10240|0;s[397]=0;s[398]=0;f[68]=f[2];i[799]=0;f[67]=0;i[798]=0;f[69]=w+2048;f[70]=w;i[800]=0;r=(f[3]|0)+-2|0;f[71]=r;e=r+(f[65]<<1)|0;f[72]=e;e:while(1){a=r+2|0;f[71]=a;if(r>>>0>=e>>>0){c=85;break}e=s[a>>1]|0;a:do{switch(e<<16>>16){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[398]|0)==0?Q(a)|0:0)?(S(r+4|0,214,10)|0)==0:0){u();c=84;}else c=84;break}case 105:{if(((s[r+4>>1]|0)==109?Q(a)|0:0)?(S(r+6|0,224,8)|0)==0:0){l();c=84;}else c=84;break}case 99:{if((((s[r+4>>1]|0)==108?Q(a)|0:0)?(S(r+6|0,70,6)|0)==0:0)?L(s[r+12>>1]|0)|0:0){i[800]=1;c=84;}else c=84;break}case 40:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=1;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 91:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=8;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 93:{e=s[398]|0;if(!(e<<16>>16)){c=21;break e}s[398]=e+-1<<16>>16;c=84;break}case 44:{e=s[397]|0;if(((e<<16>>16!=0?(t=s[398]|0,t<<16>>16!=0):0)?(f[(f[69]|0)+((t&65535)+-1<<3)>>2]|0)==5:0)?(b=f[(f[70]|0)+((e&65535)+-1<<2)>>2]|0,(f[b+4>>2]|0)==0):0){f[b+4>>2]=(f[68]|0)+2;f[71]=r+4;v(1)|0;c=f[71]|0;f[b+16>>2]=c;f[71]=c+-2;c=84;}else c=84;break}case 41:{e=s[398]|0;if(!(e<<16>>16)){c=29;break e}s[398]=e+-1<<16>>16;a=s[397]|0;if(a<<16>>16!=0?(f[(f[69]|0)+((e+-1&65535)<<3)>>2]|0)==5:0){e=f[(f[70]|0)+((a&65535)+-1<<2)>>2]|0;if(!(f[e+4>>2]|0))f[e+4>>2]=(f[68]|0)+2;f[e+12>>2]=r+4;s[397]=a+-1<<16>>16;c=84;}else c=84;break}case 123:{e=f[68]|0;c=f[62]|0;do{if((s[e>>1]|0)==41&(c|0)!=0?(f[c+12>>2]|0)==(e+2|0):0){a=f[63]|0;f[62]=a;if(!a){f[58]=0;break}else {f[a+32>>2]=0;break}}}while(0);r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=(i[800]|0)==0?2:6;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=e;i[800]=0;c=84;break}case 125:{e=s[398]|0;if(!(e<<16>>16)){c=42;break e}c=f[69]|0;s[398]=e+-1<<16>>16;if((f[c+((e+-1&65535)<<3)>>2]|0)==4){d();c=84;}else c=84;break}case 34:case 39:{A(e);c=84;break}case 47:switch(s[r+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{e=f[68]|0;a=s[e>>1]|0;r:do{if(!($(a)|0))if(a<<16>>16==41){r=s[398]|0;if(!(K(f[(f[69]|0)+((r&65535)<<3)+4>>2]|0)|0))c=57;}else c=56;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){c=56;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){c=56;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){c=56;break r}else break r;default:break r}}while(0);if((c|0)==56){r=s[398]|0;c=57;}r:do{if((c|0)==57){c=0;if(r<<16>>16!=0?(k=f[69]|0,o=(r&65535)+-1|0,a<<16>>16==102?(f[k+(o<<3)>>2]|0)==1:0):0){if(((s[e+-2>>1]|0)==111?C(e+-4|0)|0:0)?B(f[k+(o<<3)+4>>2]|0,178,3)|0:0)break}else c=62;if((c|0)==62?(0,a<<16>>16==125):0){c=f[69]|0;r=r&65535;if(U(f[c+(r<<3)+4>>2]|0)|0)break;if((f[c+(r<<3)>>2]|0)==6)break}if(!(h(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}c=f[64]|0;if((c|0?e>>>0>=(f[c>>2]|0)>>>0:0)?e>>>0<=(f[c+4>>2]|0)>>>0:0){I();i[799]=0;c=84;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;a=s[e>>1]|0;}while(!(D(a)|0));if(M(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;}while(M(s[e>>1]|0)|0);if(q(e)|0){I();i[799]=0;c=84;break a}}i[799]=1;c=84;break a}}}while(0);I();i[799]=0;c=84;break a}}case 96:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)+4>>2]=f[68];s[398]=c+1<<16>>16;f[r+((c&65535)<<3)>>2]=3;d();c=84;break}default:c=84;}}while(0);if((c|0)==84){c=0;f[68]=f[71];}r=f[71]|0;e=f[72]|0;}if((c|0)==21){ee();e=0;}else if((c|0)==29){ee();e=0;}else if((c|0)==42){ee();e=0;}else if((c|0)==85)e=(i[798]|0)==0?(s[397]|s[398])<<16>>16==0:0;n=w;return e|0}function l(){var e=0,a=0,r=0,c=0,t=0,n=0;n=f[71]|0;f[71]=n+12;e=v(1)|0;r=f[71]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&r>>>0>(n+12|0)>>>0)){if(!(e<<16>>16==100&r>>>0>(n+10|0)>>>0)){r=0;t=28;break}if(S(r+2|0,32,8)|0){a=r;e=100;r=0;t=60;break}if(!(L(s[r+10>>1]|0)|0)){a=r;e=100;r=0;t=60;break}f[71]=r+10;e=v(1)|0;if(e<<16>>16==42){e=42;c=2;t=62;break}f[71]=r;r=0;t=28;break}if((S(r+2|0,22,10)|0)==0?L(s[r+12>>1]|0)|0:0){f[71]=r+12;e=v(1)|0;a=f[71]|0;if((a|0)!=(r+12|0)){if(e<<16>>16!=102){r=1;t=28;break}if(S(a+2|0,40,6)|0){e=102;r=1;t=60;break}if(!(D(s[a+8>>1]|0)|0)){e=102;r=1;t=60;break}}f[71]=r;r=0;t=28;}else {a=r;e=115;r=0;t=60;}}else {f[71]=r+2;switch((v(1)|0)<<16>>16){case 109:{e=f[71]|0;if(S(e+2|0,16,6)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;g(n,n,e+8|0,2);break e}case 115:{e=f[71]|0;if(S(e+2|0,22,10)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+12;e=v(1)|0;r=1;t=28;break e}case 100:{e=f[71]|0;if(S(e+2|0,32,8)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+10;e=v(1)|0;r=2;t=28;break e}default:break e}}}while(0);e:do{if((t|0)==28){if(e<<16>>16==40){a=f[69]|0;c=s[398]|0;f[a+((c&65535)<<3)>>2]=5;e=f[71]|0;s[398]=c+1<<16>>16;f[a+((c&65535)<<3)+4>>2]=e;if((s[f[68]>>1]|0)==46)break;f[71]=e+2;a=v(1)|0;g(n,f[71]|0,0,e);if(!r)e=f[62]|0;else {e=f[62]|0;f[e+28>>2]=(r|0)==1?5:7;}c=f[70]|0;n=s[397]|0;s[397]=n+1<<16>>16;f[c+((n&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{A(39);break}case 34:{A(34);break}case 96:{if(!(y()|0))t=37;break}default:t=37;}if((t|0)==37){f[71]=(f[71]|0)+-2;break}e=(f[71]|0)+2|0;f[71]=e;switch((v(1)|0)<<16>>16){case 44:{f[71]=(f[71]|0)+2;v(1)|0;c=f[62]|0;f[c+4>>2]=e;n=f[71]|0;f[c+16>>2]=n;i[c+24>>0]=1;f[71]=n+-2;break e}case 41:{s[398]=(s[398]|0)+-1<<16>>16;n=f[62]|0;f[n+4>>2]=e;f[n+12>>2]=(f[71]|0)+2;i[n+24>>0]=1;s[397]=(s[397]|0)+-1<<16>>16;break e}default:{f[71]=(f[71]|0)+-2;break e}}}if(!((r|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{c=r;t=62;break e}default:{}}a=f[71]|0;t=60;break}e=f[71]|0;if(s[398]|0){f[71]=e+-2;break}while(1){if(e>>>0>=(f[72]|0)>>>0)break;e=v(1)|0;if(!(ae(e)|0)){if(e<<16>>16==125){t=50;break}}else A(e);e=(f[71]|0)+2|0;f[71]=e;}if((t|0)==50)f[71]=(f[71]|0)+2;c=(v(1)|0)<<16>>16==102;e=f[71]|0;if(c?S(e+2|0,40,6)|0:0){ee();break}f[71]=e+8;e=v(1)|0;if(ae(e)|0){w(n,e,0);break}else {ee();break}}}while(0);if((t|0)==60)if((a|0)==(n+12|0))f[71]=n+10;else {c=r;t=62;}do{if((t|0)==62){if(!((e<<16>>16==42|(c|0)!=2)&(s[398]|0)==0)){f[71]=(f[71]|0)+-2;break}e=f[72]|0;a=f[71]|0;while(1){if(a>>>0>=e>>>0){t=69;break}r=s[a>>1]|0;if(ae(r)|0){t=67;break}t=a+2|0;f[71]=t;a=t;}if((t|0)==67){w(n,r,c);break}else if((t|0)==69){ee();break}}}while(0);return}function u(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0,k=0,l=0,u=0;k=f[71]|0;l=f[64]|0;f[71]=k+12;a=v(1)|0;e=f[71]|0;if(!((e|0)==(k+12|0)?!(O(a)|0):0))u=3;e:do{if((u|0)==3){a:do{switch(a<<16>>16){case 123:{f[71]=e+2;e=v(1)|0;r=f[71]|0;while(1){if(ae(e)|0){A(e);e=(f[71]|0)+2|0;f[71]=e;}else {H(e)|0;e=f[71]|0;}v(1)|0;e=p(r,e)|0;if(e<<16>>16==44){f[71]=(f[71]|0)+2;e=v(1)|0;}a=r;r=f[71]|0;if(e<<16>>16==125){u=15;break}if((r|0)==(a|0)){u=12;break}if(r>>>0>(f[72]|0)>>>0){u=14;break}}if((u|0)==12){ee();break e}else if((u|0)==14){ee();break e}else if((u|0)==15){f[71]=r+2;u=49;break a}break}case 42:{f[71]=e+2;v(1)|0;u=f[71]|0;p(u,u)|0;u=49;break}case 100:{f[71]=e+14;switch((v(1)|0)<<16>>16){case 97:{a=f[71]|0;if((S(a+2|0,46,8)|0)==0?M(s[a+10>>1]|0)|0:0){f[71]=a+10;v(0)|0;u=21;}break}case 102:{u=21;break}case 99:{a=f[71]|0;if(((S(a+2|0,68,8)|0)==0?(l=s[a+10>>1]|0,L(l)|0|l<<16>>16==123):0)?(f[71]=a+10,r=v(1)|0,r<<16>>16!=123):0){n=r;u=30;}break}default:{}}r:do{if((u|0)==21?(i=f[71]|0,(S(i+2|0,54,14)|0)==0):0){a=s[i+16>>1]|0;if(!(L(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[71]=i+16;a=v(1)|0;if(a<<16>>16==42){f[71]=(f[71]|0)+2;a=v(1)|0;}if(a<<16>>16!=40){n=a;u=30;}}}while(0);if((u|0)==30?(c=f[71]|0,H(n)|0,t=f[71]|0,t>>>0>c>>>0):0){E(e,e+14|0,c,t);f[71]=(f[71]|0)+-2;break e}E(e,e+14|0,0,0);f[71]=e+12;break e}case 97:{f[71]=e+10;v(0)|0;e=f[71]|0;u=34;break}case 102:{u=34;break}case 99:{if((S(e+2|0,68,8)|0)==0?D(s[e+10>>1]|0)|0:0){f[71]=e+10;u=v(1)|0;l=f[71]|0;H(u)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break e}f[71]=e+4;e=e+4|0;u=41;break}case 108:case 118:{u=41;break}default:break e}}while(0);if((u|0)==34){f[71]=e+16;e=v(1)|0;if(e<<16>>16==42){f[71]=(f[71]|0)+2;e=v(1)|0;}l=f[71]|0;H(e)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break}else if((u|0)==41){f[71]=e+6;while(1){a=v(1)|0;e=f[71]|0;if(e>>>0>(f[72]|0)>>>0)break;a=P(a)|0;if((f[71]|0)==(e|0))break;if(a<<16>>16==61)a=b(1)|0;e=f[71]|0;if(a<<16>>16!=44)break;f[71]=e+2;}f[71]=e+-2;break}else if((u|0)==49){u=(v(1)|0)<<16>>16==102;e=f[71]|0;if(u?(S(e+2|0,40,6)|0)==0:0){f[71]=e+8;w(k,v(1)|0,0);e=(l|0)==0?236:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[71]=e+-2;break}}}while(0);return}function o(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0;e=f[71]|0;c=(s[e>>1]|0)==123;f[71]=e+2;e=v(1)|0;t=c?125:93;e:while(1){if((t|0)==(e&65535|0))break;i=f[71]|0;if(i>>>0>(f[72]|0)>>>0)break;if((e<<16>>16==46?(s[i+2>>1]|0)==46:0)?(s[i+4>>1]|0)==46:0){f[71]=i+6;e=P(v(1)|0)|0;}else n=9;a:do{if((n|0)==9){n=0;do{if(c){do{if(e<<16>>16==91){b(0)|0;f[71]=(f[71]|0)+2;a=i;}else {if(ae(e)|0){A(e);f[71]=(f[71]|0)+2;a=i;break}if((e+-48&65535)>=10){H(e)|0;a=f[71]|0;break}e=i;r:while(1){r=e+2|0;a=s[r>>1]|0;i:do{if((a+-48&65535)>=10){switch(a<<16>>16){case 67:case 68:case 70:case 97:case 65:case 99:case 100:case 102:case 46:case 66:case 69:case 79:case 88:case 95:case 98:case 101:case 110:case 111:case 120:break i;case 43:case 45:break;default:break r}switch(s[e>>1]|0){case 69:case 101:break;default:break r}}}while(0);e=r;}f[71]=r;a=i;}}while(0);e=v(1)|0;if(e<<16>>16==58){f[71]=(f[71]|0)+2;e=P(v(1)|0)|0;break}if(a>>>0>i>>>0)E(i,a,i,a);}else if(e<<16>>16==44){f[71]=i+2;e=v(1)|0;break a}else {e=P(e)|0;break}}while(0);if(e<<16>>16==61)e=b(0)|0;if(e<<16>>16!=44)break e;f[71]=(f[71]|0)+2;e=v(1)|0;}}while(0)}return}function h(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=B(e+-4|0,76,2)|0;break e}case 108:{e=B(e+-4|0,80,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=z(e+-6|0,101)|0;break e}case 97:{e=z(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=B(e+-4|0,86,4)|0;break e}case 117:{e=B(e+-4|0,94,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=B(e+-8|0,106,6)|0;break e}case 112:{e=B(e+-8|0,118,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=B(e+-2|0,122,4)|0;break}case 110:{if(z(e+-2|0,105)|0)e=1;else e=B(e+-2|0,130,5)|0;break}case 111:{e=z(e+-2|0,100)|0;break}case 114:{e=B(e+-2|0,140,7)|0;break}case 116:{e=B(e+-2|0,154,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=z(e+-4|0,110)|0;break e}case 111:{e=B(e+-4|0,162,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function w(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,c=0;i=(f[71]|0)+2|0;switch(a<<16>>16){case 39:{A(39);c=5;break}case 34:{A(34);c=5;break}default:ee();}do{if((c|0)==5){g(e,i,f[71]|0,1);if((r|0)>0)f[(f[62]|0)+28>>2]=(r|0)==1?4:6;f[71]=(f[71]|0)+2;c=(v(0)|0)<<16>>16==119;a=f[71]|0;if(((c?(s[a+2>>1]|0)==105:0)?(s[a+4>>1]|0)==116:0)?(s[a+6>>1]|0)==104:0){f[71]=a+8;if((v(1)|0)<<16>>16!=123){f[71]=a;break}r=f[71]|0;i=r;e:while(1){f[71]=i+2;i=v(1)|0;switch(i<<16>>16){case 39:{A(39);f[71]=(f[71]|0)+2;i=v(1)|0;break}case 34:{A(34);f[71]=(f[71]|0)+2;i=v(1)|0;break}default:i=H(i)|0;}if(i<<16>>16!=58){c=20;break}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 39:{A(39);break}case 34:{A(34);break}default:{c=24;break e}}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 125:{c=28;break e}case 44:break;default:{c=26;break e}}i=(f[71]|0)+2|0;f[71]=i;}if((c|0)==20){f[71]=a;break}else if((c|0)==24){f[71]=a;break}else if((c|0)==26){f[71]=a;break}else if((c|0)==28){c=f[62]|0;f[c+16>>2]=r;f[c+12>>2]=(f[71]|0)+2;break}}f[71]=a+-2;}}while(0);return}function d(){var e=0,a=0,r=0;a=f[72]|0;r=f[71]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[71]=e;a=f[69]|0;r=s[398]|0;f[a+((r&65535)<<3)>>2]=4;s[398]=r+1<<16>>16;f[a+((r&65535)<<3)+4>>2]=e;}else if((a|0)==7){f[71]=e;a=f[69]|0;r=(s[398]|0)+-1<<16>>16;s[398]=r;if((f[a+((r&65535)<<3)>>2]|0)!=3)ee();}else if((a|0)==10){f[71]=e;ee();}return}function v(e){e=e|0;var a=0,r=0,i=0;r=f[71]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(L(a)|0)break;else break e;else if(M(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{F();break a}case 42:{x(e);break a}default:{a=47;break e}}}while(0);i=f[71]|0;r=i+2|0;f[71]=r;}while(i>>>0<(f[72]|0)>>>0);return a|0}function A(e){e=e|0;var a=0,r=0,i=0,c=0;c=f[72]|0;a=f[71]|0;while(1){i=a+2|0;if(a>>>0>=c>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(se(r)|0){a=9;break}else a=i;}if((a|0)==9){f[71]=i;ee();}else if((a|0)==10)f[71]=i;return}function C(e){e=e|0;var a=0,r=0;a=s[e>>1]|0;if(L(a)|0)r=3;else switch(a<<16>>16){case 41:case 125:case 93:{r=3;break}default:e=0;}e:do{if((r|0)==3){r=f[3]|0;while(1){if(e>>>0<=r>>>0)break;e=e+-2|0;if(!(L(a)|0))break;a=s[e>>1]|0;}switch(a<<16>>16){case 41:case 125:case 93:{e=1;break e}default:{}}e=(O(a)|0)^1;}}while(0);return e|0}function g(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var c=0,t=0;t=f[66]|0;f[66]=t+36;c=f[62]|0;f[((c|0)==0?232:c+32|0)>>2]=t;f[63]=c;f[62]=t;f[t+8>>2]=e;if(2==(s|0)){e=3;c=r;}else {e=1==(s|0)?1:2;c=1==(s|0)?r+2|0:0;}f[t+12>>2]=c;f[t+28>>2]=e;f[t>>2]=a;f[t+4>>2]=r;f[t+16>>2]=0;f[t+20>>2]=s;i[t+24>>0]=1==(s|0)&1;f[t+32>>2]=0;return}function p(e,a){e=e|0;a=a|0;var r=0,i=0,c=0,t=0;r=f[71]|0;i=s[r>>1]|0;c=(e|0)==(a|0)?0:e;t=(e|0)==(a|0)?0:a;if(i<<16>>16==97){f[71]=r+4;r=v(1)|0;e=f[71]|0;if(ae(r)|0){A(r);a=(f[71]|0)+2|0;f[71]=a;}else {H(r)|0;a=f[71]|0;}i=v(1)|0;r=f[71]|0;}if((r|0)!=(e|0))E(e,a,c,t);return i|0}function y(){var e=0,a=0,r=0,i=0;i=f[71]|0;r=f[72]|0;a=i;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=7;break}switch(s[e>>1]|0){case 96:{a=8;break e}case 92:{e=a+4|0;break}case 36:{if((s[a+4>>1]|0)==123){a=7;break e}break}default:{}}a=e;}if((a|0)==7){f[71]=i;e=0;}else if((a|0)==8){f[71]=e;e=1;}return e|0}function m(){var e=0,a=0,r=0;r=f[72]|0;a=f[71]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[71]=e;ee();e=0;}else if((a|0)==7){f[71]=e;e=93;}return e|0}function I(){var e=0,a=0;e:while(1){e=f[71]|0;f[71]=e+2;if(e>>>0>=(f[72]|0)>>>0){a=7;break}switch(s[e+2>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{m()|0;break}case 92:{f[71]=e+4;break}default:{}}}if((a|0)==7)ee();return}function U(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=B(e+-2|0,188,4)|0;break}case 121:{e=B(e+-2|0,196,6)|0;break}case 101:{e=B(e+-2|0,208,3)|0;break}default:e=0;}return e|0}function x(e){e=e|0;var a=0,r=0,i=0,c=0,t=0;c=(f[71]|0)+2|0;f[71]=c;r=f[72]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?se(i)|0:0)break;if(i<<16>>16==42?(s[c+4>>1]|0)==47:0){t=8;break}c=a;}if((t|0)==8){f[71]=a;a=c+4|0;}f[71]=a;return}function S(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function O(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function $(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function T(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(O(a)|0)return a<<16>>16!=46|(N(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function j(e){e=e|0;var a=0,r=0;r=n;n=n+16|0;f[r>>2]=0;f[65]=e;a=f[3]|0;s[a+(e<<1)>>1]=0;f[r>>2]=a+(e<<1)+2;f[66]=a+(e<<1)+2;f[58]=0;f[62]=0;f[60]=0;f[59]=0;f[64]=0;f[61]=0;n=r;return a|0}function B(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;s=e+(0-r<<1)+2|0;i=f[3]|0;if(s>>>0>=i>>>0?(S(s,a,r<<1)|0)==0:0)if((s|0)==(i|0))i=1;else i=T(e+(0-r<<1)|0)|0;else i=0;return i|0}function E(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var s=0,c=0;s=f[66]|0;f[66]=s+20;c=f[64]|0;f[((c|0)==0?236:c+16|0)>>2]=s;f[64]=s;f[s>>2]=e;f[s+4>>2]=a;f[s+8>>2]=r;f[s+12>>2]=i;f[s+16>>2]=0;return}function P(e){e=e|0;var a=0;switch(e<<16>>16){case 91:case 123:{o();f[71]=(f[71]|0)+2;break}default:{a=f[71]|0;H(e)|0;e=f[71]|0;if(e>>>0>a>>>0)E(a,e,a,e);}}return v(1)|0}function q(e){e=e|0;switch(s[e>>1]|0){case 107:{e=B(e+-2|0,122,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=B(e+-4|0,94,6)|0;else e=0;break}default:e=0;}return e|0}function z(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=D(s[e+-2>>1]|0)|0;else r=0;return r|0}function D(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(O(e)|0);}}while(0);return e|0}function F(){var e=0,a=0,r=0;e=f[72]|0;r=f[71]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[71]=a;return}function G(e){e=e|0;e:do{if(((e&-33)+-65&65535)<26|(e+-48&65535)<10)e=1;else {switch(e<<16>>16){case 36:case 95:{e=1;break e}default:{}}e=(e&65535)>127;}}while(0);return e|0}function H(e){e=e|0;while(1){if(L(e)|0)break;if(O(e)|0)break;e=(f[71]|0)+2|0;f[71]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(){var e=0;e=f[(f[60]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function K(e){e=e|0;if(!(B(e,168,5)|0)?!(B(e,178,3)|0):0)e=B(e,184,2)|0;else e=1;return e|0}function L(e){e=e|0;switch(e<<16>>16){case 160:case 9:case 10:case 11:case 12:case 13:case 32:{e=1;break}default:e=0;}return e|0}function M(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function N(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function Q(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=T(e+-2|0)|0;return e|0}function R(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function V(){var e=0;e=f[(f[60]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function W(){var e=0;e=f[(f[61]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function X(){var e=0;e=f[(f[60]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Y(){var e=0;e=f[(f[60]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Z(){var e=0;e=f[60]|0;e=f[((e|0)==0?232:e+32|0)>>2]|0;f[60]=e;return (e|0)!=0|0}function _(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+16|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function ee(){i[798]=1;f[67]=(f[71]|0)-(f[3]|0)>>1;f[71]=(f[72]|0)+2;return}function ae(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function re(){return (f[(f[60]|0)+8>>2]|0)-(f[3]|0)>>1|0}function ie(){return (f[(f[61]|0)+4>>2]|0)-(f[3]|0)>>1|0}function se(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function fe(){return (f[f[60]>>2]|0)-(f[3]|0)>>1|0}function ce(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function te(){return c[(f[60]|0)+24>>0]|0|0}function ne(e){e=e|0;f[3]=e;return}function be(){return f[(f[60]|0)+28>>2]|0}function ke(){return f[67]|0}function le(e,a){e=e|0;a=a|0;n=e+a+15&-16;return a}return {su:le,ai:X,e:ke,ee:ie,ele:R,els:W,es:ce,id:J,ie:Y,ip:te,is:fe,it:be,p:k,re:_,ri:Z,sa:j,se:V,ses:ne,ss:re}}("undefined"!=typeof globalThis?globalThis:self,{},a),r=e.su(i-(2<<17),1040);}const h=c$1.length+1;e.ses(r),e.sa(h-1),s(c$1,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),t=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,c$1.charCodeAt(-1===s?a-1:a)));let l=null;w.push({t:n,n:k,s:a,e:r,ss:f,se:t,d:s,a:i,at:l});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=i<0?void 0:v(i,s),c=v(a,r);d.push({s:a,e:r,ls:i,le:s,n:c,ln:f});}return [w,d];function v(e,a){const r=c$1.charCodeAt(e);return 34===r||39===r?b(e+1,r):c$1.slice(e,a)}}function b(e,a){n=e;let r="",i=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&96!==a&&o(),++n);}return r+=c$1.slice(i,n++),r}function k(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\\n";case 114:return "\\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=c$1.charCodeAt(n);let a;123===e?(++n,a=l(c$1.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\\t";case 98:return "\\b";case 118:return "\\v";case 102:return "\\f";case 13:10===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=c$1.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(\`Parse error \${t}:\${c$1.slice(0,n).split("\\n").length}:\${n-c$1.lastIndexOf("\\n",n-1)}\`),{idx:n})}
|
|
643
|
+
|
|
644
|
+
const _resolve = (id, parentUrl = baseUrl) => {
|
|
645
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
646
|
+
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
647
|
+
const composedResolved =
|
|
648
|
+
composedImportMap === firstImportMap ? firstResolved : (
|
|
649
|
+
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
650
|
+
);
|
|
651
|
+
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
652
|
+
// needsShim, shouldShim per load record to set on parent
|
|
653
|
+
let n = false,
|
|
654
|
+
N = false;
|
|
655
|
+
if (!supportsImportMaps) {
|
|
656
|
+
// bare specifier -> needs shim
|
|
657
|
+
if (!urlResolved) n = true;
|
|
658
|
+
// url mapping -> should shim
|
|
659
|
+
else if (urlResolved !== resolved) N = true;
|
|
660
|
+
} else if (!supportsMultipleImportMaps) {
|
|
661
|
+
// bare specifier and not resolved by first import map -> needs shim
|
|
662
|
+
if (!urlResolved && !firstResolved) n = true;
|
|
663
|
+
// resolution doesn't match first import map -> should shim
|
|
664
|
+
if (firstResolved && resolved !== firstResolved) N = true;
|
|
665
|
+
}
|
|
666
|
+
return { r: resolved, n, N };
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
const resolve = (id, parentUrl) => {
|
|
670
|
+
if (!resolveHook) return _resolve(id, parentUrl);
|
|
671
|
+
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
672
|
+
|
|
673
|
+
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// import()
|
|
677
|
+
async function importShim(id, opts, parentUrl) {
|
|
678
|
+
if (typeof opts === 'string') {
|
|
679
|
+
parentUrl = opts;
|
|
680
|
+
opts = undefined;
|
|
681
|
+
}
|
|
682
|
+
await initPromise; // needed for shim check
|
|
683
|
+
if (shimMode || !baselineSupport) {
|
|
684
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
685
|
+
legacyAcceptingImportMaps = false;
|
|
686
|
+
}
|
|
687
|
+
let sourceType = undefined;
|
|
688
|
+
if (typeof opts === 'object') {
|
|
689
|
+
if (opts.lang === 'ts') sourceType = 'ts';
|
|
690
|
+
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
691
|
+
sourceType = opts.with.type;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// import.source()
|
|
698
|
+
// (opts not currently supported as no use cases yet)
|
|
699
|
+
if (shimMode || wasmSourcePhaseEnabled)
|
|
700
|
+
importShim.source = async (id, opts, parentUrl) => {
|
|
701
|
+
if (typeof opts === 'string') {
|
|
702
|
+
parentUrl = opts;
|
|
703
|
+
opts = undefined;
|
|
704
|
+
}
|
|
705
|
+
await initPromise; // needed for shim check
|
|
706
|
+
if (shimMode || !baselineSupport) {
|
|
707
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
708
|
+
legacyAcceptingImportMaps = false;
|
|
709
|
+
}
|
|
710
|
+
await importMapPromise;
|
|
711
|
+
const url = resolve(id, parentUrl || baseUrl).r;
|
|
712
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
713
|
+
await load.f;
|
|
714
|
+
return importShim._s[load.r];
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
718
|
+
if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
|
|
719
|
+
|
|
720
|
+
if (hotReload) {
|
|
721
|
+
initHotReload(topLevelLoad, importShim);
|
|
722
|
+
importShim.hotReload = hotReload$1;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const defaultResolve = (id, parentUrl) => {
|
|
726
|
+
return (
|
|
727
|
+
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
728
|
+
throwUnresolved(id, parentUrl)
|
|
729
|
+
);
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
const throwUnresolved = (id, parentUrl) => {
|
|
733
|
+
throw Error(\`Unable to resolve specifier '\${id}'\${fromParent(parentUrl)}\`);
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
const metaResolve = function (id, parentUrl = this.url) {
|
|
737
|
+
return resolve(id, \`\${parentUrl}\`).r;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
741
|
+
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
742
|
+
importShim.addImportMap = importMapIn => {
|
|
743
|
+
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
744
|
+
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
745
|
+
};
|
|
746
|
+
importShim.version = version;
|
|
747
|
+
|
|
748
|
+
const registry = (importShim._r = {});
|
|
749
|
+
// Wasm caches
|
|
750
|
+
const sourceCache = (importShim._s = {});
|
|
751
|
+
/* const instanceCache = */ importShim._i = new WeakMap();
|
|
752
|
+
|
|
753
|
+
// Ensure this version is the only version
|
|
754
|
+
defineValue(self_, 'importShim', Object.freeze(importShim));
|
|
755
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
756
|
+
if (optionsScript) optionsScript.innerText = maybeTrustedScript(JSON.stringify(shimModeOptions));
|
|
757
|
+
self_.esmsInitOptions = shimModeOptions;
|
|
758
|
+
|
|
759
|
+
const loadAll = async (load, seen) => {
|
|
760
|
+
seen[load.u] = 1;
|
|
761
|
+
await load.L;
|
|
762
|
+
await Promise.all(
|
|
763
|
+
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
764
|
+
if (dep.b || seen[dep.u]) return;
|
|
765
|
+
if (sourcePhase) return dep.f;
|
|
766
|
+
return loadAll(dep, seen);
|
|
767
|
+
})
|
|
768
|
+
);
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
let importMapSrc = false;
|
|
772
|
+
let multipleImportMaps = false;
|
|
773
|
+
let firstImportMap = null;
|
|
774
|
+
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
775
|
+
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
776
|
+
let baselineSupport;
|
|
777
|
+
|
|
778
|
+
const initPromise = featureDetectionPromise.then(() => {
|
|
779
|
+
baselineSupport =
|
|
780
|
+
supportsImportMaps &&
|
|
781
|
+
(!jsonModulesEnabled || supportsJsonType) &&
|
|
782
|
+
(!cssModulesEnabled || supportsCssType) &&
|
|
783
|
+
(!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
|
|
784
|
+
(!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
|
|
785
|
+
!deferPhaseEnabled &&
|
|
786
|
+
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
787
|
+
!importMapSrc &&
|
|
788
|
+
!hasCustomizationHooks;
|
|
789
|
+
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
790
|
+
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
791
|
+
const s = Symbol();
|
|
792
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
793
|
+
class AbstractModuleSource {
|
|
794
|
+
get [Symbol.toStringTag]() {
|
|
795
|
+
if (this[s]) return this[s];
|
|
796
|
+
throw new TypeError('Not an AbstractModuleSource');
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
800
|
+
WebAssembly.Module = Object.setPrototypeOf(
|
|
801
|
+
Object.assign(function Module(...args) {
|
|
802
|
+
return brand(new wasmModule(...args));
|
|
803
|
+
}, wasmModule),
|
|
804
|
+
AbstractModuleSource
|
|
805
|
+
);
|
|
806
|
+
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
807
|
+
WebAssembly.compile = function compile(...args) {
|
|
808
|
+
return wasmCompile(...args).then(brand);
|
|
809
|
+
};
|
|
810
|
+
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
811
|
+
return wasmCompileStreaming(...args).then(brand);
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
if (hasDocument) {
|
|
816
|
+
if (!supportsImportMaps) {
|
|
817
|
+
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
818
|
+
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
819
|
+
}
|
|
820
|
+
if (shimMode || !baselineSupport) {
|
|
821
|
+
attachMutationObserver();
|
|
822
|
+
if (document.readyState === 'complete') {
|
|
823
|
+
readyStateCompleteCheck();
|
|
824
|
+
} else {
|
|
825
|
+
document.addEventListener('readystatechange', readyListener);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
processScriptsAndPreloads();
|
|
829
|
+
}
|
|
830
|
+
return undefined;
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
const attachMutationObserver = () => {
|
|
834
|
+
const observer = new MutationObserver(mutations => {
|
|
835
|
+
for (const mutation of mutations) {
|
|
836
|
+
if (mutation.type !== 'childList') continue;
|
|
837
|
+
for (const node of mutation.addedNodes) {
|
|
838
|
+
if (node.tagName === 'SCRIPT') {
|
|
839
|
+
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
840
|
+
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
841
|
+
} else if (
|
|
842
|
+
node.tagName === 'LINK' &&
|
|
843
|
+
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
844
|
+
!node.ep
|
|
845
|
+
) {
|
|
846
|
+
processPreload(node);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
observer.observe(document, { childList: true });
|
|
852
|
+
observer.observe(document.head, { childList: true });
|
|
853
|
+
processScriptsAndPreloads();
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
let importMapPromise = initPromise;
|
|
857
|
+
let firstPolyfillLoad = true;
|
|
858
|
+
let legacyAcceptingImportMaps = true;
|
|
859
|
+
|
|
860
|
+
async function topLevelLoad(
|
|
861
|
+
url,
|
|
862
|
+
parentUrl,
|
|
863
|
+
fetchOpts,
|
|
864
|
+
source,
|
|
865
|
+
nativelyLoaded,
|
|
866
|
+
lastStaticLoadPromise,
|
|
867
|
+
sourceType
|
|
868
|
+
) {
|
|
869
|
+
await initPromise;
|
|
870
|
+
await importMapPromise;
|
|
871
|
+
url = (await resolve(url, parentUrl)).r;
|
|
872
|
+
|
|
873
|
+
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
874
|
+
// because we can't syntactically pass through to dynamic import with a second argument
|
|
875
|
+
if (sourceType === 'css' || sourceType === 'json') {
|
|
876
|
+
// Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
|
|
877
|
+
source = \`import m from'\${url}'with{type:"\${sourceType}"};export default m;\`;
|
|
878
|
+
url += '?entry';
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
882
|
+
// early analysis opt-out - no need to even fetch if we have feature support
|
|
883
|
+
if (!shimMode && baselineSupport && nativePassthrough && sourceType !== 'ts') {
|
|
884
|
+
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
885
|
+
if (nativelyLoaded) return null;
|
|
886
|
+
await lastStaticLoadPromise;
|
|
887
|
+
return dynamicImport(source ? createBlob(source) : url);
|
|
888
|
+
}
|
|
889
|
+
const load = getOrCreateLoad(url, fetchOpts, undefined, source);
|
|
890
|
+
linkLoad(load, fetchOpts);
|
|
891
|
+
const seen = {};
|
|
892
|
+
await loadAll(load, seen);
|
|
893
|
+
resolveDeps(load, seen);
|
|
894
|
+
await lastStaticLoadPromise;
|
|
895
|
+
if (!shimMode && !load.n) {
|
|
896
|
+
if (nativelyLoaded) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (source) {
|
|
900
|
+
return await dynamicImport(createBlob(source));
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
904
|
+
onpolyfill();
|
|
905
|
+
firstPolyfillLoad = false;
|
|
906
|
+
}
|
|
907
|
+
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
908
|
+
dynamicImport(load.b, load.u)
|
|
909
|
+
: import(load.u));
|
|
910
|
+
// if the top-level load is a shell, run its update function
|
|
911
|
+
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
912
|
+
revokeObjectURLs(Object.keys(seen));
|
|
913
|
+
return module;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
const revokeObjectURLs = registryKeys => {
|
|
917
|
+
let curIdx = 0;
|
|
918
|
+
const handler = self_.requestIdleCallback || self_.requestAnimationFrame || (fn => setTimeout(fn, 0));
|
|
919
|
+
handler(cleanup);
|
|
920
|
+
function cleanup() {
|
|
921
|
+
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
922
|
+
const load = registry[key];
|
|
923
|
+
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
924
|
+
}
|
|
925
|
+
if (curIdx < registryKeys.length) handler(cleanup);
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
const urlJsString = url => \`'\${url.replace(/'/g, "\\\\'")}'\`;
|
|
930
|
+
|
|
931
|
+
let resolvedSource, lastIndex;
|
|
932
|
+
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
933
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
934
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
935
|
+
resolvedSource += \`\${load.S.slice(lastIndex, dynamicImportEnd)}, \${urlJsString(load.r)}\`;
|
|
936
|
+
lastIndex = dynamicImportEnd;
|
|
937
|
+
}
|
|
938
|
+
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
939
|
+
lastIndex = originalIndex;
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
943
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
944
|
+
const commentEnd = load.S.indexOf('\\n', urlStart);
|
|
945
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
946
|
+
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
947
|
+
try {
|
|
948
|
+
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
949
|
+
} catch (e) {}
|
|
950
|
+
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
951
|
+
resolvedSource += sourceUrl;
|
|
952
|
+
lastIndex = urlEnd;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
const resolveDeps = (load, seen) => {
|
|
956
|
+
if (load.b || !seen[load.u]) return;
|
|
957
|
+
seen[load.u] = 0;
|
|
958
|
+
|
|
959
|
+
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
960
|
+
if (!sourcePhase) resolveDeps(dep, seen);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
964
|
+
if (!load.N) load.N = load.d.some(dep => dep.l.N);
|
|
965
|
+
|
|
966
|
+
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
967
|
+
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
968
|
+
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
969
|
+
load.b = load.u;
|
|
970
|
+
load.S = undefined;
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const [imports, exports] = load.a;
|
|
975
|
+
|
|
976
|
+
// "execution"
|
|
977
|
+
let source = load.S,
|
|
978
|
+
depIndex = 0,
|
|
979
|
+
dynamicImportEndStack = [];
|
|
980
|
+
|
|
981
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
|
982
|
+
// and define this blob
|
|
983
|
+
resolvedSource = '';
|
|
984
|
+
lastIndex = 0;
|
|
985
|
+
|
|
986
|
+
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a, at } of imports) {
|
|
987
|
+
// source phase
|
|
988
|
+
if (t === 4) {
|
|
989
|
+
let { l: depLoad } = load.d[depIndex++];
|
|
990
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
991
|
+
resolvedSource += \`\${source.slice(statementStart, start - 1).replace('source', '')}/*\${source.slice(start - 1, end + 1)}*/'\${createBlob(\`export default importShim._s[\${urlJsString(depLoad.r)}]\`)}'\`;
|
|
992
|
+
lastIndex = end + 1;
|
|
993
|
+
}
|
|
994
|
+
// dependency source replacements
|
|
995
|
+
else if (dynamicImportIndex === -1) {
|
|
996
|
+
let keepAssertion = false;
|
|
997
|
+
if (a > 0 && !shimMode) {
|
|
998
|
+
// strip assertions only when unsupported in polyfill mode
|
|
999
|
+
// minimal lexer builds do not provide parsed attributes, so sniff the assertion source directly
|
|
1000
|
+
const assertion = source.slice(a, statementEnd - 1);
|
|
1001
|
+
keepAssertion =
|
|
1002
|
+
nativePassthrough &&
|
|
1003
|
+
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// defer phase stripping
|
|
1007
|
+
if (t === 6) {
|
|
1008
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
1009
|
+
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
1010
|
+
lastIndex = start;
|
|
1011
|
+
}
|
|
1012
|
+
let { l: depLoad } = load.d[depIndex++],
|
|
1013
|
+
blobUrl = depLoad.b,
|
|
1014
|
+
cycleShell = !blobUrl;
|
|
1015
|
+
if (cycleShell) {
|
|
1016
|
+
// circular shell creation
|
|
1017
|
+
if (!(blobUrl = depLoad.s)) {
|
|
1018
|
+
blobUrl = depLoad.s = createBlob(
|
|
1019
|
+
\`export function u$_(m){\${depLoad.a[1]
|
|
1020
|
+
.map(({ s, e }, i) => {
|
|
1021
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
1022
|
+
return \`e$_\${i}=m\${q ? \`[\` : '.'}\${depLoad.S.slice(s, e)}\${q ? \`]\` : ''}\`;
|
|
1023
|
+
})
|
|
1024
|
+
.join(',')}}\${
|
|
1025
|
+
depLoad.a[1].length ? \`let \${depLoad.a[1].map((_, i) => \`e$_\${i}\`).join(',')};\` : ''
|
|
1026
|
+
}export {\${depLoad.a[1]
|
|
1027
|
+
.map(({ s, e }, i) => \`e$_\${i} as \${depLoad.S.slice(s, e)}\`)
|
|
1028
|
+
.join(',')}}\\n//# sourceURL=\${depLoad.r}?cycle\`
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
1034
|
+
resolvedSource += \`/*\${source.slice(start - 1, end + 1)}*/'\${blobUrl}'\`;
|
|
1035
|
+
|
|
1036
|
+
// circular shell execution
|
|
1037
|
+
if (!cycleShell && depLoad.s) {
|
|
1038
|
+
resolvedSource += \`;import*as m$_\${depIndex} from'\${depLoad.b}';import{u$_ as u$_\${depIndex}}from'\${depLoad.s}';u$_\${depIndex}(m$_\${depIndex})\`;
|
|
1039
|
+
depLoad.s = undefined;
|
|
1040
|
+
}
|
|
1041
|
+
lastIndex = keepAssertion ? end + 1 : statementEnd;
|
|
1042
|
+
}
|
|
1043
|
+
// import.meta
|
|
1044
|
+
else if (dynamicImportIndex === -2) {
|
|
1045
|
+
load.m = { url: load.r, resolve: metaResolve };
|
|
1046
|
+
if (metaHook) metaHook(load.m, load.u);
|
|
1047
|
+
pushStringTo(load, start, dynamicImportEndStack);
|
|
1048
|
+
resolvedSource += \`importShim._r[\${urlJsString(load.u)}].m\`;
|
|
1049
|
+
lastIndex = statementEnd;
|
|
1050
|
+
}
|
|
1051
|
+
// dynamic import
|
|
1052
|
+
else {
|
|
1053
|
+
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
1054
|
+
resolvedSource += \`Shim\${t === 5 ? '.source' : ''}(\`;
|
|
1055
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
1056
|
+
lastIndex = start;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
1061
|
+
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
1062
|
+
resolvedSource += \`\\n;import{u$_}from'\${load.s}';try{u$_({\${exports
|
|
1063
|
+
.filter(e => e.ln)
|
|
1064
|
+
.map(({ s, e, ln }) => \`\${source.slice(s, e)}:\${ln}\`)
|
|
1065
|
+
.join(',')}})}catch(_){};\\n\`;
|
|
1066
|
+
|
|
1067
|
+
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
1068
|
+
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
1069
|
+
|
|
1070
|
+
// ignore sourceMap comments before already spliced code
|
|
1071
|
+
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
1072
|
+
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
1073
|
+
|
|
1074
|
+
// sourceURL first / only
|
|
1075
|
+
if (
|
|
1076
|
+
sourceURLCommentStart !== -1 &&
|
|
1077
|
+
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
1078
|
+
) {
|
|
1079
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1080
|
+
}
|
|
1081
|
+
// sourceMappingURL
|
|
1082
|
+
if (sourceMapURLCommentStart !== -1) {
|
|
1083
|
+
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
1084
|
+
// sourceURL last
|
|
1085
|
+
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
1086
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
1090
|
+
|
|
1091
|
+
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
1092
|
+
|
|
1093
|
+
load.b = createBlob(resolvedSource);
|
|
1094
|
+
load.S = resolvedSource = undefined;
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
const sourceURLCommentPrefix = '\\n//# sourceURL=';
|
|
1098
|
+
const sourceMapURLCommentPrefix = '\\n//# sourceMappingURL=';
|
|
1099
|
+
const cssUrlRegEx = /url\\(\\s*(?:(["'])((?:\\\\.|[^\\n\\\\"'])+)\\1|((?:\\\\.|[^\\s,"'()\\\\])+))\\s*\\)/g;
|
|
1100
|
+
|
|
1101
|
+
// restrict in-flight fetches to a pool of 100
|
|
1102
|
+
let p = [];
|
|
1103
|
+
let c = 0;
|
|
1104
|
+
const pushFetchPool = () => {
|
|
1105
|
+
if (++c > 100) return new Promise(r => p.push(r));
|
|
1106
|
+
};
|
|
1107
|
+
const popFetchPool = () => {
|
|
1108
|
+
c--;
|
|
1109
|
+
if (p.length) p.shift()();
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
const doFetch = async (url, fetchOpts, parent) => {
|
|
1113
|
+
if (enforceIntegrity && !fetchOpts.integrity) throw Error(\`No integrity for \${url}\${fromParent(parent)}.\`);
|
|
1114
|
+
let res,
|
|
1115
|
+
poolQueue = pushFetchPool();
|
|
1116
|
+
if (poolQueue) await poolQueue;
|
|
1117
|
+
try {
|
|
1118
|
+
res = await fetchHook(url, fetchOpts);
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
e.message = \`Unable to fetch \${url}\${fromParent(parent)} - see network log for details.\\n\` + e.message;
|
|
1121
|
+
throw e;
|
|
1122
|
+
} finally {
|
|
1123
|
+
popFetchPool();
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (!res.ok) {
|
|
1127
|
+
const error = new TypeError(\`\${res.status} \${res.statusText} \${res.url}\${fromParent(parent)}\`);
|
|
1128
|
+
error.response = res;
|
|
1129
|
+
throw error;
|
|
1130
|
+
}
|
|
1131
|
+
return res;
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
let esmsTsTransform;
|
|
1135
|
+
const initTs = async () => {
|
|
1136
|
+
const m = await import(tsTransform);
|
|
1137
|
+
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
async function defaultSourceHook(url, fetchOpts, parent) {
|
|
1141
|
+
let res = await doFetch(url, fetchOpts, parent),
|
|
1142
|
+
contentType,
|
|
1143
|
+
[, json, type, jsts] =
|
|
1144
|
+
(contentType = res.headers.get('content-type') || '').match(
|
|
1145
|
+
/^(?:[^/;]+\\/(?:[^/+;]+\\+)?(json)|(?:text|application)\\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/
|
|
1146
|
+
) || [];
|
|
1147
|
+
if (!(type = json || (jsts ? jsts[0] + 's' : type || (/\\.m?ts(\\?|#|$)/.test(url) && 'ts')))) {
|
|
1148
|
+
throw Error(
|
|
1149
|
+
\`Unsupported Content-Type "\${contentType}" loading \${url}\${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.\`
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
return {
|
|
1153
|
+
url: res.url,
|
|
1154
|
+
source: await (type > 'v' ? WebAssembly.compileStreaming(res) : res.text()),
|
|
1155
|
+
type
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
const hotPrefix = 'var h=import.meta.hot,';
|
|
1160
|
+
const fetchModule = async (reqUrl, fetchOpts, parent) => {
|
|
1161
|
+
const mapIntegrity = composedImportMap.integrity[reqUrl];
|
|
1162
|
+
fetchOpts = mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts;
|
|
1163
|
+
let {
|
|
1164
|
+
url = reqUrl,
|
|
1165
|
+
source,
|
|
1166
|
+
type
|
|
1167
|
+
} = (await (sourceHook || defaultSourceHook)(reqUrl, fetchOpts, parent, defaultSourceHook)) || {};
|
|
1168
|
+
if (type === 'wasm') {
|
|
1169
|
+
const exports = WebAssembly.Module.exports((sourceCache[url] = source));
|
|
1170
|
+
const imports = WebAssembly.Module.imports(source);
|
|
1171
|
+
const rStr = urlJsString(url);
|
|
1172
|
+
source = \`import*as $_ns from\${rStr};\`;
|
|
1173
|
+
let i = 0,
|
|
1174
|
+
obj = '';
|
|
1175
|
+
for (const { module, kind } of imports) {
|
|
1176
|
+
const specifier = urlJsString(module);
|
|
1177
|
+
source += \`import*as impt\${i} from\${specifier};\\n\`;
|
|
1178
|
+
obj += \`\${specifier}:\${kind === 'global' ? \`importShim._i.get(impt\${i})||impt\${i++}\` : \`impt\${i++}\`},\`;
|
|
1179
|
+
}
|
|
1180
|
+
source += \`\${hotPrefix}i=await WebAssembly.instantiate(importShim._s[\${rStr}],{\${obj}});importShim._i.set($_ns,i);\`;
|
|
1181
|
+
obj = '';
|
|
1182
|
+
for (const { name, kind } of exports) {
|
|
1183
|
+
source += \`export let \${name}=i.exports['\${name}'];\`;
|
|
1184
|
+
if (kind === 'global') source += \`try{\${name}=\${name}.value}catch(_){\${name}=undefined}\`;
|
|
1185
|
+
obj += \`\${name},\`;
|
|
1186
|
+
}
|
|
1187
|
+
source += \`if(h)h.accept(m=>({\${obj}}=m))\`;
|
|
1188
|
+
} else if (type === 'json') {
|
|
1189
|
+
source = \`\${hotPrefix}j=JSON.parse(\${JSON.stringify(source)});export{j as default};if(h)h.accept(m=>j=m.default)\`;
|
|
1190
|
+
} else if (type === 'css') {
|
|
1191
|
+
source = \`\${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(\${JSON.stringify(
|
|
1192
|
+
source.replace(
|
|
1193
|
+
cssUrlRegEx,
|
|
1194
|
+
(_match, quotes = '', relUrl1, relUrl2) => \`url(\${quotes}\${resolveUrl(relUrl1 || relUrl2, url)}\${quotes})\`
|
|
1195
|
+
)
|
|
1196
|
+
)});if(h){h.data.s=s;h.accept(()=>{})}export default s\`;
|
|
1197
|
+
} else if (type === 'ts') {
|
|
1198
|
+
if (!esmsTsTransform) await initTs();
|
|
1199
|
+
const transformed = esmsTsTransform(source, url);
|
|
1200
|
+
// even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
|
|
1201
|
+
// a valid JS MIME here, so we must still polyfill it
|
|
1202
|
+
source = transformed === undefined ? source : transformed;
|
|
1203
|
+
}
|
|
1204
|
+
return { url, source, type };
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1208
|
+
if (source && registry[url]) {
|
|
1209
|
+
let i = 0;
|
|
1210
|
+
while (registry[url + '#' + ++i]);
|
|
1211
|
+
url += '#' + i;
|
|
1212
|
+
}
|
|
1213
|
+
let load = registry[url];
|
|
1214
|
+
if (load) return load;
|
|
1215
|
+
registry[url] = load = {
|
|
1216
|
+
// url
|
|
1217
|
+
u: url,
|
|
1218
|
+
// response url
|
|
1219
|
+
r: source ? url : undefined,
|
|
1220
|
+
// fetchPromise
|
|
1221
|
+
f: undefined,
|
|
1222
|
+
// source
|
|
1223
|
+
S: source,
|
|
1224
|
+
// linkPromise
|
|
1225
|
+
L: undefined,
|
|
1226
|
+
// analysis
|
|
1227
|
+
a: undefined,
|
|
1228
|
+
// deps
|
|
1229
|
+
d: undefined,
|
|
1230
|
+
// blobUrl
|
|
1231
|
+
b: undefined,
|
|
1232
|
+
// shellUrl
|
|
1233
|
+
s: undefined,
|
|
1234
|
+
// needsShim: does it fail execution in the current native loader?
|
|
1235
|
+
n: false,
|
|
1236
|
+
// shouldShim: does it need to be loaded by the polyfill loader?
|
|
1237
|
+
N: false,
|
|
1238
|
+
// type
|
|
1239
|
+
t: null,
|
|
1240
|
+
// meta
|
|
1241
|
+
m: null
|
|
1242
|
+
};
|
|
1243
|
+
load.f = (async () => {
|
|
1244
|
+
if (load.S === undefined) {
|
|
1245
|
+
// preload fetch options override fetch options (race)
|
|
1246
|
+
({ url: load.r, source: load.S, type: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
1247
|
+
if (
|
|
1248
|
+
!load.n &&
|
|
1249
|
+
load.t !== 'js' &&
|
|
1250
|
+
!shimMode &&
|
|
1251
|
+
((load.t === 'css' && !supportsCssType) ||
|
|
1252
|
+
(load.t === 'json' && !supportsJsonType) ||
|
|
1253
|
+
(load.t === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
|
|
1254
|
+
load.t === 'ts')
|
|
1255
|
+
) {
|
|
1256
|
+
load.n = true;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
try {
|
|
1260
|
+
load.a = parse(load.S, load.u);
|
|
1261
|
+
} catch (e) {
|
|
1262
|
+
throwError(e);
|
|
1263
|
+
load.a = [[], [], false];
|
|
1264
|
+
}
|
|
1265
|
+
return load;
|
|
1266
|
+
})();
|
|
1267
|
+
return load;
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
const featErr = feat =>
|
|
1271
|
+
Error(
|
|
1272
|
+
\`\${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["\${feat}"] }<\${''}/script>\`
|
|
1273
|
+
);
|
|
1274
|
+
|
|
1275
|
+
const linkLoad = (load, fetchOpts) => {
|
|
1276
|
+
if (load.L) return;
|
|
1277
|
+
load.L = load.f.then(() => {
|
|
1278
|
+
let childFetchOpts = fetchOpts;
|
|
1279
|
+
load.d = load.a[0]
|
|
1280
|
+
.map(({ n, d, t, a, se }) => {
|
|
1281
|
+
const phaseImport = t >= 4;
|
|
1282
|
+
const sourcePhase = phaseImport && t < 6;
|
|
1283
|
+
if (phaseImport) {
|
|
1284
|
+
if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
|
|
1285
|
+
throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
|
|
1286
|
+
if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
|
|
1287
|
+
}
|
|
1288
|
+
let source = undefined;
|
|
1289
|
+
if (a > 0 && !shimMode && nativePassthrough) {
|
|
1290
|
+
const assertion = load.S.slice(a, se - 1);
|
|
1291
|
+
// no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
|
|
1292
|
+
if (assertion.includes('json')) {
|
|
1293
|
+
if (supportsJsonType) source = '';
|
|
1294
|
+
else load.n = true;
|
|
1295
|
+
} else if (assertion.includes('css')) {
|
|
1296
|
+
if (supportsCssType) source = '';
|
|
1297
|
+
else load.n = true;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
if (d !== -1 || !n) return;
|
|
1301
|
+
const resolved = resolve(n, load.r || load.u);
|
|
1302
|
+
if (resolved.n || hasCustomizationHooks) load.n = true;
|
|
1303
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
1304
|
+
if (d !== -1) return;
|
|
1305
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1306
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1307
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1308
|
+
// assertion case -> inline the CSS / JSON URL directly
|
|
1309
|
+
if (source === '') child.l.b = child.l.u;
|
|
1310
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1311
|
+
// load, sourcePhase
|
|
1312
|
+
return child;
|
|
1313
|
+
})
|
|
1314
|
+
.filter(l => l);
|
|
1315
|
+
});
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
const processScriptsAndPreloads = () => {
|
|
1319
|
+
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1320
|
+
if (!link.ep) processPreload(link);
|
|
1321
|
+
}
|
|
1322
|
+
for (const script of document.querySelectorAll('script[type]')) {
|
|
1323
|
+
if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
|
|
1324
|
+
if (!script.ep) processImportMap(script);
|
|
1325
|
+
} else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
|
|
1326
|
+
legacyAcceptingImportMaps = false;
|
|
1327
|
+
if (!script.ep) processScript(script);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
const getFetchOpts = script => {
|
|
1333
|
+
const fetchOpts = {};
|
|
1334
|
+
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1335
|
+
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
1336
|
+
if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
|
|
1337
|
+
if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
|
|
1338
|
+
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1339
|
+
else fetchOpts.credentials = 'same-origin';
|
|
1340
|
+
return fetchOpts;
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
let lastStaticLoadPromise = Promise.resolve();
|
|
1344
|
+
|
|
1345
|
+
let domContentLoaded = false;
|
|
1346
|
+
let domContentLoadedCnt = 1;
|
|
1347
|
+
const domContentLoadedCheck = m => {
|
|
1348
|
+
if (m === undefined) {
|
|
1349
|
+
if (domContentLoaded) return;
|
|
1350
|
+
domContentLoaded = true;
|
|
1351
|
+
domContentLoadedCnt--;
|
|
1352
|
+
}
|
|
1353
|
+
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1354
|
+
document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1355
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
let loadCnt = 1;
|
|
1359
|
+
const loadCheck = () => {
|
|
1360
|
+
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1361
|
+
window.removeEventListener('load', loadEvent);
|
|
1362
|
+
window.dispatchEvent(new Event('load'));
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
const domContentLoadedEvent = async () => {
|
|
1367
|
+
await initPromise;
|
|
1368
|
+
domContentLoadedCheck();
|
|
1369
|
+
};
|
|
1370
|
+
const loadEvent = async () => {
|
|
1371
|
+
await initPromise;
|
|
1372
|
+
domContentLoadedCheck();
|
|
1373
|
+
loadCheck();
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
1377
|
+
if (hasDocument) {
|
|
1378
|
+
document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1379
|
+
window.addEventListener('load', loadEvent);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
const readyListener = async () => {
|
|
1383
|
+
await initPromise;
|
|
1384
|
+
processScriptsAndPreloads();
|
|
1385
|
+
if (document.readyState === 'complete') {
|
|
1386
|
+
readyStateCompleteCheck();
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
let readyStateCompleteCnt = 1;
|
|
1391
|
+
const readyStateCompleteCheck = () => {
|
|
1392
|
+
if (--readyStateCompleteCnt === 0) {
|
|
1393
|
+
domContentLoadedCheck();
|
|
1394
|
+
if (!noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1395
|
+
document.removeEventListener('readystatechange', readyListener);
|
|
1396
|
+
document.dispatchEvent(new Event('readystatechange'));
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1402
|
+
const epCheck = (script, ready) =>
|
|
1403
|
+
script.ep ||
|
|
1404
|
+
(!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
|
|
1405
|
+
script.getAttribute('noshim') !== null ||
|
|
1406
|
+
!(script.ep = true);
|
|
1407
|
+
|
|
1408
|
+
const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1409
|
+
if (epCheck(script, ready)) return;
|
|
1410
|
+
// we dont currently support external import maps in polyfill mode to match native
|
|
1411
|
+
if (script.src) {
|
|
1412
|
+
if (!shimMode) return;
|
|
1413
|
+
importMapSrc = true;
|
|
1414
|
+
}
|
|
1415
|
+
importMapPromise = importMapPromise
|
|
1416
|
+
.then(async () => {
|
|
1417
|
+
composedImportMap = resolveAndComposeImportMap(
|
|
1418
|
+
script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
|
|
1419
|
+
script.src || baseUrl,
|
|
1420
|
+
composedImportMap
|
|
1421
|
+
);
|
|
1422
|
+
})
|
|
1423
|
+
.catch(e => {
|
|
1424
|
+
if (e instanceof SyntaxError)
|
|
1425
|
+
e = new Error(\`Unable to parse import map \${e.message} in: \${script.src || script.innerHTML}\`);
|
|
1426
|
+
throwError(e);
|
|
1427
|
+
});
|
|
1428
|
+
if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
|
|
1429
|
+
if (!legacyAcceptingImportMaps && !multipleImportMaps) {
|
|
1430
|
+
multipleImportMaps = true;
|
|
1431
|
+
if (!shimMode && baselineSupport && !supportsMultipleImportMaps) {
|
|
1432
|
+
baselineSupport = false;
|
|
1433
|
+
if (hasDocument) attachMutationObserver();
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
legacyAcceptingImportMaps = false;
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
const processScript = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1440
|
+
if (epCheck(script, ready)) return;
|
|
1441
|
+
// does this load block readystate complete
|
|
1442
|
+
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
1443
|
+
// does this load block DOMContentLoaded
|
|
1444
|
+
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
|
1445
|
+
const isLoadScript = loadCnt > 0;
|
|
1446
|
+
if (isLoadScript) loadCnt++;
|
|
1447
|
+
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1448
|
+
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1449
|
+
let loadPromise;
|
|
1450
|
+
const ts = script.lang === 'ts';
|
|
1451
|
+
if (ts && !script.src) {
|
|
1452
|
+
loadPromise = Promise.resolve(esmsTsTransform || initTs())
|
|
1453
|
+
.then(() => {
|
|
1454
|
+
const transformed = esmsTsTransform(script.innerHTML, baseUrl);
|
|
1455
|
+
if (transformed !== undefined) {
|
|
1456
|
+
onpolyfill();
|
|
1457
|
+
firstPolyfillLoad = false;
|
|
1458
|
+
}
|
|
1459
|
+
return topLevelLoad(
|
|
1460
|
+
script.src || baseUrl,
|
|
1461
|
+
baseUrl,
|
|
1462
|
+
getFetchOpts(script),
|
|
1463
|
+
transformed === undefined ? script.innerHTML : transformed,
|
|
1464
|
+
!shimMode && transformed === undefined,
|
|
1465
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1466
|
+
'ts'
|
|
1467
|
+
);
|
|
1468
|
+
})
|
|
1469
|
+
.catch(throwError);
|
|
1470
|
+
} else {
|
|
1471
|
+
loadPromise = topLevelLoad(
|
|
1472
|
+
script.src || baseUrl,
|
|
1473
|
+
baseUrl,
|
|
1474
|
+
getFetchOpts(script),
|
|
1475
|
+
!script.src ? script.innerHTML : undefined,
|
|
1476
|
+
!shimMode,
|
|
1477
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1478
|
+
ts ? 'ts' : undefined
|
|
1479
|
+
).catch(throwError);
|
|
1480
|
+
}
|
|
1481
|
+
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
1482
|
+
if (isBlockingReadyScript && !ts) {
|
|
1483
|
+
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
1484
|
+
}
|
|
1485
|
+
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1486
|
+
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
const fetchCache = {};
|
|
1490
|
+
const processPreload = link => {
|
|
1491
|
+
link.ep = true;
|
|
1492
|
+
initPromise.then(() => {
|
|
1493
|
+
if (baselineSupport && !shimMode) return;
|
|
1494
|
+
if (fetchCache[link.href]) return;
|
|
1495
|
+
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1496
|
+
});
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
})();
|
|
1500
|
+
`,Mb=`/* Runs only in the opaque preview frame. All local reads use its directory capability. */
|
|
1501
|
+
function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
1502
|
+
const external = new Set(externalOrigins);
|
|
1503
|
+
const report = () => parent.postMessage({ type: 'preview-error', capability }, '*');
|
|
1504
|
+
const nativeFetch = window.fetch.bind(window);
|
|
1505
|
+
const nativeWorker = window.Worker;
|
|
1506
|
+
const externalUrl = value => {
|
|
1507
|
+
const url = new URL(value, base);
|
|
1508
|
+
const origin = url.protocol === 'wss:' ? 'https://' + url.host : url.origin;
|
|
1509
|
+
if (!external.has(origin)) throw new Error('Outside preview network scope');
|
|
1510
|
+
return url;
|
|
1511
|
+
};
|
|
1512
|
+
const bridgeFetch = async (input, init = {}) => {
|
|
1513
|
+
const url = new URL(typeof input === 'string' ? input : input.url || String(input), base);
|
|
1514
|
+
const method = String(init.method || (input && input.method) || 'GET').toUpperCase();
|
|
1515
|
+
if (url.protocol === 'blob:' || url.protocol === 'data:') return nativeFetch(input, init);
|
|
1516
|
+
if (url.origin !== new URL(base).origin) {
|
|
1517
|
+
externalUrl(url.href);
|
|
1518
|
+
return nativeFetch(url.href, { ...init, method, credentials: 'omit', referrerPolicy: 'no-referrer' });
|
|
1519
|
+
}
|
|
1520
|
+
if (!['GET', 'HEAD'].includes(method) || !url.pathname.startsWith(new URL(base).pathname)) throw new Error('Outside preview directory');
|
|
1521
|
+
return new Promise((resolve, reject) => {
|
|
1522
|
+
if (init.signal?.aborted) { reject(init.signal.reason); return; }
|
|
1523
|
+
const channel = new MessageChannel();
|
|
1524
|
+
const finish = () => { clearTimeout(timer); channel.port1.close(); init.signal?.removeEventListener('abort', abort); };
|
|
1525
|
+
const abort = () => { finish(); reject(init.signal.reason); };
|
|
1526
|
+
const timer = setTimeout(() => { finish(); report(); reject(new Error('Preview resource timeout')); }, 15000);
|
|
1527
|
+
init.signal?.addEventListener('abort', abort, { once: true });
|
|
1528
|
+
channel.port1.onmessage = event => {
|
|
1529
|
+
finish();
|
|
1530
|
+
if (event.data.error) { reject(new Error(event.data.error)); return; }
|
|
1531
|
+
const response = new Response(method === 'HEAD' ? null : event.data.data, { status: event.data.status, headers: event.data.headers });
|
|
1532
|
+
Object.defineProperty(response, 'url', { value: url.href }); resolve(response);
|
|
1533
|
+
};
|
|
1534
|
+
parent.postMessage({ type: 'preview-fetch', capability, url: url.href, method }, '*', [channel.port2]);
|
|
1535
|
+
});
|
|
1536
|
+
};
|
|
1537
|
+
Object.defineProperty(window, 'fetch', { configurable: false, writable: false, value: bridgeFetch });
|
|
1538
|
+
window.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: bridgeFetch, onerror: report };
|
|
1539
|
+
class PreviewXHR extends EventTarget {
|
|
1540
|
+
readyState = 0; status = 0; statusText = ''; response = null; responseText = ''; responseURL = ''; responseType = ''; timeout = 0;
|
|
1541
|
+
upload = new EventTarget(); withCredentials = false;
|
|
1542
|
+
open(method, url, async = true) {
|
|
1543
|
+
if (!async) throw new Error('Synchronous preview requests are unavailable');
|
|
1544
|
+
this.abort(); this.method = method; this.url = new URL(url, base).href; this.headers = {}; this.readyState = 1; this.emit('readystatechange');
|
|
1545
|
+
}
|
|
1546
|
+
setRequestHeader(name, value) { this.headers[name] = value; }
|
|
1547
|
+
getAllResponseHeaders() { return this.responseHeaders ? [...this.responseHeaders].map(([key, value]) => key + ': ' + value + '\\r\\n').join('') : ''; }
|
|
1548
|
+
getResponseHeader(name) { return this.responseHeaders?.get(name) ?? null; }
|
|
1549
|
+
overrideMimeType(value) { this.mime = value; }
|
|
1550
|
+
emit(type, event = new Event(type)) { this.dispatchEvent(event); this['on' + type]?.call(this, event); }
|
|
1551
|
+
abort() { if (this.controller) { this.controller.abort(); this.controller = null; this.readyState = 0; this.emit('abort'); this.emit('loadend'); } }
|
|
1552
|
+
send(body = null) {
|
|
1553
|
+
const controller = new AbortController(); this.controller = controller;
|
|
1554
|
+
const timer = this.timeout > 0 ? setTimeout(() => { if (this.controller !== controller) return; controller.abort(); this.controller = null; this.emit('timeout'); this.emit('loadend'); }, this.timeout) : null;
|
|
1555
|
+
this.emit('loadstart');
|
|
1556
|
+
bridgeFetch(this.url, { method: this.method, headers: this.headers, body, signal: controller.signal }).then(async response => {
|
|
1557
|
+
this.status = response.status; this.statusText = response.statusText; this.responseURL = response.url; this.responseHeaders = response.headers;
|
|
1558
|
+
this.readyState = 2; this.emit('readystatechange'); this.readyState = 3; this.emit('readystatechange');
|
|
1559
|
+
const bytes = await response.arrayBuffer();
|
|
1560
|
+
if (this.controller !== controller) return;
|
|
1561
|
+
this.responseText = new TextDecoder().decode(bytes);
|
|
1562
|
+
this.response = this.responseType === 'arraybuffer' ? bytes : this.responseType === 'blob' ? new Blob([bytes], { type: this.mime || response.headers.get('content-type') || '' }) : this.responseType === 'json' ? (() => { try { return JSON.parse(this.responseText); } catch { return null; } })() : this.responseType === 'document' ? new DOMParser().parseFromString(this.responseText, 'text/html') : this.responseText;
|
|
1563
|
+
this.readyState = 4; this.emit('readystatechange'); this.emit('progress', new ProgressEvent('progress', { lengthComputable: true, loaded: bytes.byteLength, total: bytes.byteLength })); this.emit('load'); this.emit('loadend'); this.controller = null;
|
|
1564
|
+
}).catch(() => { if (this.controller !== controller) return; this.controller = null; this.status = 0; this.readyState = 4; this.emit('readystatechange'); this.emit('error'); this.emit('loadend'); }).finally(() => clearTimeout(timer));
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
for (const [key, value] of Object.entries({ UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4 })) { PreviewXHR[key] = value; PreviewXHR.prototype[key] = value; }
|
|
1568
|
+
Object.defineProperty(window, 'XMLHttpRequest', { configurable: false, writable: false, value: PreviewXHR });
|
|
1569
|
+
for (const name of ['WebSocket', 'EventSource']) {
|
|
1570
|
+
const Native = window[name];
|
|
1571
|
+
if (Native) Object.defineProperty(window, name, { configurable: false, writable: false, value: class extends Native {
|
|
1572
|
+
constructor(url, options) { super(externalUrl(url).href, name === 'EventSource' ? { withCredentials: false } : options); }
|
|
1573
|
+
} });
|
|
1574
|
+
}
|
|
1575
|
+
// A worker receives the same read-only bridge over a private MessagePort. Its
|
|
1576
|
+
// module graph is loaded by the same shim, including computed dynamic imports.
|
|
1577
|
+
class PreviewWorker extends EventTarget {
|
|
1578
|
+
constructor(url, options = {}) {
|
|
1579
|
+
super();
|
|
1580
|
+
const entry = new URL(url, base).href;
|
|
1581
|
+
const workerSource = \`(\${workerBootstrap.toString()})(\${JSON.stringify(entry)},\${JSON.stringify(options.type || 'classic')},\${JSON.stringify(shimUrl)});\`;
|
|
1582
|
+
this.objectUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));
|
|
1583
|
+
this.worker = new nativeWorker(this.objectUrl, { name: options.name });
|
|
1584
|
+
const channel = new MessageChannel(); this.port = channel.port1;
|
|
1585
|
+
this.port.onmessage = async event => {
|
|
1586
|
+
const { id, url, init } = event.data;
|
|
1587
|
+
try { const response = await bridgeFetch(url, init); const data = await response.arrayBuffer(); this.port.postMessage({ id, status: response.status, headers: [...response.headers], data }, [data]); }
|
|
1588
|
+
catch (error) { this.port.postMessage({ id, error: String(error) }); }
|
|
1589
|
+
};
|
|
1590
|
+
this.worker.postMessage({ previewInit: true, base: entry, importMap: window.importShim?.getImportMap?.() }, [channel.port2]);
|
|
1591
|
+
for (const type of ['message', 'messageerror', 'error']) this.worker.addEventListener(type, event => {
|
|
1592
|
+
const forwarded = type === 'error' ? new ErrorEvent(type, { message: event.message }) : new MessageEvent(type, { data: event.data, ports: event.ports });
|
|
1593
|
+
this.dispatchEvent(forwarded); this['on' + type]?.call(this, forwarded);
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
postMessage(value, transfer) { this.worker.postMessage(value, transfer); }
|
|
1597
|
+
terminate() { this.worker.terminate(); this.port.close(); URL.revokeObjectURL(this.objectUrl); }
|
|
1598
|
+
}
|
|
1599
|
+
function workerBootstrap(entry, type, shim) {
|
|
1600
|
+
const queued = []; let initialized = false, ready = false;
|
|
1601
|
+
const receive = event => {
|
|
1602
|
+
if (!event.data?.previewInit || initialized) { if (!ready) { event.stopImmediatePropagation(); queued.push(event); } return; }
|
|
1603
|
+
initialized = true; event.stopImmediatePropagation();
|
|
1604
|
+
const port = event.ports[0]; const pending = new Map(); let next = 0;
|
|
1605
|
+
port.onmessage = message => { const done = pending.get(message.data.id); if (!done) return; pending.delete(message.data.id); message.data.error ? done.reject(new Error(message.data.error)) : done.resolve(new Response(message.data.data, { status: message.data.status, headers: message.data.headers })); };
|
|
1606
|
+
self.fetch = (url, init = {}) => new Promise((resolve, reject) => { const id = ++next; pending.set(id, { resolve, reject }); port.postMessage({ id, url: new URL(typeof url === 'string' ? url : url.url || String(url), entry).href, init: { method: init.method || 'GET', headers: init.headers } }); });
|
|
1607
|
+
self.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: self.fetch };
|
|
1608
|
+
const nativeImport = self.importScripts.bind(self);
|
|
1609
|
+
nativeImport(shim);
|
|
1610
|
+
if (event.data.importMap) self.importShim.addImportMap(event.data.importMap);
|
|
1611
|
+
const load = type === 'module' ? self.importShim(entry) : self.fetch(entry).then(r => r.text()).then(source => { const blob = URL.createObjectURL(new Blob([source], { type: 'text/javascript' })); nativeImport(blob); URL.revokeObjectURL(blob); });
|
|
1612
|
+
load.then(() => { ready = true; removeEventListener('message', receive); for (const message of queued) dispatchEvent(new MessageEvent('message', { data: message.data, ports: message.ports })); }).catch(error => setTimeout(() => { throw error; }));
|
|
1613
|
+
};
|
|
1614
|
+
addEventListener('message', receive);
|
|
1615
|
+
}
|
|
1616
|
+
Object.defineProperty(window, 'Worker', { configurable: false, writable: false, value: PreviewWorker });
|
|
1617
|
+
const navigate = value => {
|
|
1618
|
+
const url = new URL(value, base);
|
|
1619
|
+
if (url.origin === new URL(base).origin && url.pathname.startsWith(new URL(base).pathname)) parent.postMessage({ type: 'preview-navigate', capability, url: url.href }, '*');
|
|
1620
|
+
else { externalUrl(url.href); parent.postMessage({ type: 'preview-external', capability, url: url.href }, '*'); }
|
|
1621
|
+
};
|
|
1622
|
+
Object.defineProperty(window, 'open', { configurable: false, writable: false, value: value => { navigate(value); return null; } });
|
|
1623
|
+
document.addEventListener('click', event => { const anchor = event.target.closest?.('a,area'); const href = anchor?.getAttribute('href'); if (href && !href.startsWith('#')) { event.preventDefault(); navigate(href); } }, true);
|
|
1624
|
+
document.addEventListener('submit', event => {
|
|
1625
|
+
event.preventDefault(); const form = event.target;
|
|
1626
|
+
const url = new URL(form.getAttribute('action') || base, base);
|
|
1627
|
+
if ((form.getAttribute('method') || 'get').toLowerCase() !== 'get') { report(); return; }
|
|
1628
|
+
for (const [key, value] of new FormData(form)) if (typeof value === 'string') url.searchParams.append(key, value);
|
|
1629
|
+
navigate(url.href);
|
|
1630
|
+
}, true);
|
|
1631
|
+
window.addEventListener('securitypolicyviolation', report);
|
|
1632
|
+
window.addEventListener('error', report, true);
|
|
1633
|
+
window.addEventListener('unhandledrejection', report);
|
|
1634
|
+
}
|
|
1635
|
+
`,bo="/api/terminal/fs/preview/",$b=8*1024*1024,Pb=32*1024*1024,Ab=128,Lb="data:,";function Pt(r){throw new Error(r)}function Tb(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function ju(r,n,s){let l="",d=0;for(const c of r.matchAll(n))l+=r.slice(d,c.index)+await s(c),d=c.index+c[0].length;return l+r.slice(d)}async function Nf(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!Vs(l.pathname)?.startsWith(bo))&&Pt("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,m=[],g=z=>{!m.includes(z)&&m.length<20&&m.push(z)},f=new Set,p=[],x=new Set,h=new Map,b=new Map;let E=0,S=!1;const T=new Set,D=()=>{S=!0;for(const z of[...T])z();f.clear(),p.length=0};async function F(z){z.ok||Pt(`预览资源读取失败(${z.status})`);const Z=z.body?.getReader(),P=[];let G=0;try{if(Z)for(;;){const pe=await Z.read();if(pe.done)break;G+=pe.value.byteLength,E+=pe.value.byteLength,(G>$b||E>Pb)&&Pt("预览资源超出大小限制"),P.push(pe.value)}}catch(pe){throw await Z?.cancel().catch(()=>{}),pe}finally{Z?.releaseLock()}const J=new Uint8Array(G);let ie=0;for(const pe of P)J.set(pe,ie),ie+=pe.length;return{bytes:J,type:z.headers.get("content-type")??"application/octet-stream",status:z.status}}let $=l,C;for(let z=0;z<4;z++){const Z=await n.fetch($.pathname+$.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(Z.status)){C=Z;break}const P=Z.headers.get("location");await Z.body?.cancel(),P||Pt("预览重定向缺少目标");const G=new URL(P,$);(G.origin!==s||!Vs(G.pathname)?.startsWith(bo))&&Pt("预览重定向越出文件范围"),$=G}C||Pt("预览重定向次数过多");const A=Vs($.pathname),O=A.slice(bo.length).split("/");/^[a-f0-9]{32}$/.test(O[0])||Pt("服务未提供有效的预览资源授权");const q=Vs(l.pathname).slice(bo.length).split("/");/^[a-f0-9]{32}$/.test(q[0])&&q.shift(),q.join("/").replace(/\/$/,"")!==O.slice(1).join("/").replace(/\/$/,"")&&Pt("预览重定向改变了文件范围");const j=A.endsWith("/")?A:A.slice(0,A.lastIndexOf("/")+1),o=new URL($.pathname.endsWith("/")?$.pathname:$.pathname.slice(0,$.pathname.lastIndexOf("/")+1),s);function _(z,Z){const P=new URL(z,Z);return P.origin!==s?null:(Vs(P.pathname)?.startsWith(j)||Pt("已阻止预览访问目录之外的资源"),P)}function I(z){const Z=new URL(z,c);(Z.origin!==new URL(c).origin||!Z.pathname.startsWith(new URL(c).pathname))&&Pt("已阻止预览访问服务接口或目录之外的资源");const P=Z.pathname.slice(new URL(c).pathname.length)+Z.search;return _(P,o)??Pt("预览资源无效")}function Y(z){const Z=z.pathname+z.search,P=h.get(Z);if(P)return P;if(S||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(h.size>=Ab)return Promise.reject(new Error("预览资源数量超出限制"));const G=n.fetch(Z,{signal:n.signal,redirect:"manual"}).then(F);return h.set(Z,G),G}function H(z,Z){S&&Pt("预览已关闭");const P=`termdock-resource-${d}-${p.length}`;return p.push({token:P,data:z,type:Z}),f.add(P),P}async function U(z,Z,P,G=new Set){if(!z||z.startsWith("#")||/^data:(?:image|font)\//i.test(z)&&P==="resource")return z;try{const J=_(z,Z);if(!J){const Me=new URL(z,Z);return(Me.protocol!=="https:"||Me.username||Me.password||Me.origin===new URL(c).origin)&&Pt("已阻止不安全的外部资源"),x.add(Me.origin),Me.href}const ie=`${P}:${J.href}`;(G.has(ie)||G.size>=8)&&Pt("预览资源存在循环或过深引用");const pe=b.get(ie);if(pe)return pe;const Se=new Set(G);Se.add(ie);const ke=(async()=>{const Me=await Y(J);return P==="css"?H(await R(new TextDecoder().decode(Me.bytes),J,Se),"text/css"):P==="script"?H(Me.bytes,"text/javascript"):H(Me.bytes,Me.type)})();return b.set(ie,ke),await ke}catch(J){return g(J instanceof Error?J.message:"部分预览资源未能加载"),Lb}}async function R(z,Z,P){return z=await ju(z,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async G=>`@import url("${await U(G[1],Z,"css",P)}")${G[2]};`),ju(z,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async G=>{const J=(G[1]??G[2]??G[3]).trim();return f.has(J)?G[0]:`url("${await U(J,Z,"resource",P)}")`})}try{const z=await F(C),Z=H(Eb,"text/javascript"),P=new DOMParser().parseFromString(new TextDecoder().decode(z.bytes),"text/html");P.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(Q=>Q.remove());for(const Q of P.querySelectorAll("*")){if(Q.removeAttribute("ping"),Q.removeAttribute("srcdoc"),Q.hasAttribute("style")&&Q.setAttribute("style",await R(Q.getAttribute("style"),$,new Set)),Q.tagName==="STYLE"&&(Q.textContent=await R(Q.textContent??"",$,new Set)),Q.tagName==="A"||Q.tagName==="AREA"){const ge=Q.getAttribute("href");try{if(ge&&!ge.startsWith("#")){const ue=_(ge,$);if(ue)Q.setAttribute("href",new URL(ue.pathname.slice(o.pathname.length)+ue.search+ue.hash,c).href);else{const _e=new URL(ge,$);if(_e.protocol!=="https:"){Q.removeAttribute("href");continue}x.add(_e.origin),Q.setAttribute("href",_e.href)}}}catch(ue){Q.removeAttribute("href"),g(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const ge of["data","manifest"])Q.removeAttribute(ge);if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="module"){Q.setAttribute("type","module-shim");const ge=Q.getAttribute("src");if(ge){const ue=_(ge,$);if(ue)Q.setAttribute("src",new URL(ue.pathname.slice(o.pathname.length)+ue.search,c).href);else{const _e=new URL(ge,$);if(_e.protocol!=="https:"){Q.remove();continue}x.add(_e.origin),Q.setAttribute("src",_e.href)}}continue}if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="importmap"){Q.setAttribute("type","importmap-shim");continue}if(Q.tagName==="LINK"){const ge=(Q.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ge)){Q.remove();continue}const ue=Q.getAttribute("href");ue&&Q.setAttribute("href",await U(ue,$,ge==="stylesheet"?"css":"resource"))}if(Q.hasAttribute("src")&&Q.setAttribute("src",await U(Q.getAttribute("src"),$,Q.tagName==="SCRIPT"?"script":"resource")),Q.hasAttribute("poster")&&Q.setAttribute("poster",await U(Q.getAttribute("poster"),$,"resource")),Q.hasAttribute("srcset")){const ge=Q.getAttribute("srcset");/data:/i.test(ge)?(Q.removeAttribute("srcset"),g("混合内嵌图片候选暂不支持安全预览")):Q.setAttribute("srcset",(await Promise.all(ge.split(",").map(async ue=>{const[_e,...Ue]=ue.trim().split(/\s+/);return`${await U(_e,$,"resource")} ${Ue.join(" ")}`}))).join(", "))}Q.setAttribute("referrerpolicy","no-referrer"),Q.removeAttribute("integrity"),Q.removeAttribute("crossorigin")}const G=[...x].join(" "),J=P.createElement("meta");J.httpEquiv="Content-Security-Policy",J.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${G}; style-src 'unsafe-inline' blob: ${G}; img-src blob: data: ${G}; font-src blob: data: ${G}; media-src blob: data: ${G}; connect-src blob: ${G} ${[...x].map(Q=>Q.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ie=P.createElement("base");ie.href=c;const pe=P.createElement("meta");pe.name="referrer",pe.content="no-referrer";const Se=P.createElement("script");Se.textContent=Mb+`
|
|
1636
|
+
installPreviewRuntime(`+[d,c,[...x],Z].map(Tb).join(",")+");";const ke=P.createElement("script");ke.src=Z,P.head.prepend(J,pe,ie,Se,ke);const Me=`<!doctype html>
|
|
1637
|
+
`+P.documentElement.outerHTML;return{html:Me,shellUrl:`/preview-shell.html#${d}`,errors:m,attach(Q,ge){const ue=new Set,_e=W=>{if(W.source!==Q.contentWindow||W.data?.capability!==d)return;if(W.data.type==="preview-ready"){Q.contentWindow?.postMessage({type:"preview-init",capability:d,html:Me,resources:p},"*");return}if(W.data.type==="preview-error"){ge("部分动态内容被安全预览限制");return}if(W.data.type==="preview-navigate"){(async()=>{const ye=I(String(W.data.url)),He=await Nf(ye.pathname+ye.search,n);if(S){He.dispose();return}const Ke=He.attach(Q,ge);T.add(()=>{Ke(),He.dispose()}),Q.src=He.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ye=>ge(ye instanceof Error?ye.message:"无法打开预览页面"));return}if(W.data.type==="preview-external"){try{const ye=new URL(String(W.data.url));ye.protocol==="https:"&&x.has(ye.origin)&&window.open(ye.href,"_blank","noopener,noreferrer")}catch{}return}if(W.data.type!=="preview-fetch"||W.ports.length!==1)return;const we=W.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(W.data.method)){we.postMessage({error:"预览仅允许读取已授权目录资源"}),we.close();return}ue.add(we),(async()=>{const ye=I(String(W.data.url)),He=await Y(ye);if(!ue.has(we)||S)return;const Ke=W.data.method==="HEAD"?new Uint8Array:He.bytes.slice();we.postMessage({status:He.status,headers:{"content-type":He.type},data:Ke.buffer},[Ke.buffer])})().catch(()=>{we.postMessage({error:"预览资源不在授权范围或无法加载"}),ge("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(we),we.close()})};window.addEventListener("message",_e);const Ue=()=>{window.removeEventListener("message",_e);for(const W of ue)W.close();ue.clear(),T.delete(Ue)};return T.add(Ue),Ue},dispose:D}}catch(z){throw D(),z}}const Ib=a.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const m=a.useRef(null),[g,f]=a.useState(null),[p,x]=a.useState(),[h,b]=a.useState("");a.useEffect(()=>{const A=new AbortController;let O;return x(void 0),b(""),(async()=>{const q=await Ym();if(O=await Nf(n,{fetch:(j,o)=>q.fetch(j,o),signal:A.signal}),A.signal.aborted){O.dispose();return}x(O),O.errors.length&&b(O.errors.join(";"))})().catch(q=>{A.signal.aborted||b(q instanceof Error?q.message:"安全预览加载失败")}),()=>{A.abort(),O?.dispose()}},[n]),a.useEffect(()=>{if(!(!p||!g))return p.attach(g,b)},[p,g]);const[E,S]=a.useState(!1),[T,D]=a.useState(!1),F=E||T;a.useEffect(()=>{d?.(F)},[F,d]),a.useEffect(()=>{const A=()=>{S(document.fullscreenElement===m.current)};return document.addEventListener("fullscreenchange",A),()=>document.removeEventListener("fullscreenchange",A)},[]),a.useEffect(()=>{if(!T)return;const A=O=>{O.key==="Escape"&&D(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[T]);const $=a.useCallback(async()=>{const A=m.current;if(A){if(T){D(!1);return}if(document.fullscreenElement===A){await document.exitFullscreen();return}if(A.requestFullscreen&&document.fullscreenEnabled!==!1)try{await A.requestFullscreen();return}catch{}D(!0)}},[T]);a.useImperativeHandle(c,()=>({toggleFullscreen:$}),[$]);const C=e.jsxs("div",{ref:m,"data-html-preview-frame":!0,className:F?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[F&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{$()},"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(hf,{size:15})})]}),h&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:h}),!p&&!h&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:f,src:p?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return T?wr.createPortal(C,document.body):C}),Cf="termdock-file-search-match",El="termdock-file-search-current";function Db(r,n,s){return!!(n&&r?.isConnected&&!s.defaultPrevented&&!r.closest('[inert], [aria-hidden="true"], [hidden]')&&s.target instanceof Node&&r.contains(s.target))}function Fb(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 _b(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Bb(r,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let x=m.nextNode();x;x=m.nextNode()){if(!(x instanceof Text)||!x.data)continue;const h=_b(x);if(!h)continue;c&&c!==h&&(d+=`
|
|
1638
|
+
`);const b=d.length;d+=x.data,l.push({node:x,start:b,end:d.length,group:h}),c=h}const g=d.toLocaleLowerCase(),f=[];let p=0;for(;p<=g.length-s.length;){const x=g.indexOf(s,p);if(x<0)break;const h=x+s.length,b=l.find(S=>S.start<=x&&S.end>x),E=l.find(S=>S.start<h&&S.end>=h);if(b&&E&&b.group===E.group){const S=document.createRange();S.setStart(b.node,x-b.start),S.setEnd(E.node,h-E.start),f.push(S)}p=x+Math.max(s.length,1)}return f}function Ef(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let Lo;function Ru(r){return Lo===r}function xo(r){if(r&&Lo!==r)return;const n=Ef();n?.delete(Cf),n?.delete(El),Lo=void 0}function rl(r,n,s){const l=Ef();if(!l||typeof Highlight>"u")return;Lo=s,l.set(Cf,new Highlight(...r));const d=r[n];d?l.set(El,new Highlight(d)):l.delete(El)}function Nu(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Ob(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Ub(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Hb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Mf(r,n,s){return n?r:wr.createPortal(r,s)}const Ul="termdock:right-sidebar:file-tree-scroll:v1",Hl="termdock:right-sidebar:file-preview-reading-state:v1",na="termdock:right-sidebar:file-tree-width:v1",$f="termdock:right-sidebar:markdown-view-mode:v1",Pf="termdock:right-sidebar:diff-change-list-mode:v1",Af="termdock:right-sidebar:diff-wrap:v1",Lf="termdock:diff-viewer:view-type:v1",Tf="termdock:right-sidebar:file-search-mode:v1",nl="termdock:right-sidebar:collapsed-git-repo-groups:v1",Cu="termdock:right-sidebar:collapsed-diff-directories:v1",sl="termdock:right-sidebar:branch-audit-module-open:v1",If="termdock:right-sidebar:branch-audit-module:v1",zb=150,Eu="termdock:right-sidebar:context-draft-enabled:v1",Mu="termdock:right-sidebar:context-draft-collapsed:v1",$u="termdock:right-sidebar:context-draft-auto-collapse:v1",al="termdock:right-sidebar:context-draft-text:v1",Wb=300,Gb=20,Kb=120,qb=250,Vb=250,Yb=120,Xb=700,ol=600,Jb=6e4;function Js(r){return!!(r&&V.getState().nestedGitScanRoots[r])}const Pu=[2e3,5e3,15e3,3e4],Qb=320,Zb=500,ex=20,tx=12e3,Ml=300,Au=240,rx=560,Df="border-r px-2 py-1.5 sm:px-3 sm:py-2",To="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Ff=`${Df} border-b border-border/15 font-semibold last:border-r-0`,_f=`${Df} border-border/10 align-top text-muted-foreground last:border-r-0`,zl="termdock-file-preview-horizontal-scroll",Lu=a.lazy(()=>Ln(()=>import("./ModelPreview-D7H8wUeV.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),nx=a.lazy(()=>Ln(()=>import("./ArchitecturePanel-DN-6DCxW.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,10,11,12,15,16,6,14,13,17,19])).then(r=>({default:r.ArchitecturePanel}))),sx=a.lazy(()=>Ln(()=>import("./ComputerControlView-3S0HonKc.js").then(r=>r.a),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),Bf=`${zl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Of(r,n,s){return r&&!n?"unified":s}const ax=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function ox(r){return r==="preview"||r==="source"}function ix(r){return r==="list"||r==="tree"||r==="ai"}function Tu(){return gt($f,ox)??"preview"}function lx(){return gt(Pf,ix)??"tree"}function sa(r){return typeof r=="boolean"}function cx(r){return typeof r=="string"}function dx(){return gt(Af,sa)??!0}function ux(r){return r==="unified"||r==="split"}function fx(){return gt(Lf,ux)??"unified"}function hx(r){return r==="name"||r==="content"||r==="regex"}function mx(){return gt(Tf,hx)??"name"}function Uf(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:wt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function px(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function $l(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Hf(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Pl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Iu(r){const n=gt(r,Pl);return n?new Set(n):new Set}function il(r,n){At(r,[...n])}function gx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function bx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Pl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(gx))&&(n.commits===void 0||Pl(n.commits))&&(n.commitCount===void 0||typeof n.commitCount=="number")&&(n.diff===void 0||typeof n.diff=="string")&&(n.truncated===void 0||typeof n.truncated=="boolean")&&(n.error===void 0||typeof n.error=="string")}function xx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&bx(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function vx(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(xx))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Du(){return gt(If,vx)??{}}function Fu(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function _u(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function zf(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||_u(s)===_u(l)}function Bu(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!zf(l,n))??""}function Al(r,n){const s=Math.max(Au,n-320),l=Math.min(rx,s);return Math.min(l,Math.max(Au,r))}function yx(r){return typeof r=="number"&&Number.isFinite(r)}function wx(r){return Al(gt(na,yx)??Ml,r)}function Wf(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Qs(r){return ax.has(Wf(r))}function Gf(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Ll(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Gf(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Kf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const qf=a.createContext(null);function Co(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Vf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Yf(r){return r.replace(/\s+#+\s*$/,"").trim()}function Tl(r,n){const l=Vf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function Ou(r){return Vf(r)||r.trim()}function Io(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Dl(n[2]);return s?{id:Co(n[1]),definition:{href:s.href,title:s.title}}:null}function kx(r){const n=new Map;for(const s of r){const l=Io(s);l&&n.set(l.id,l.definition)}return n}function Xf(r){return r.trim().toLowerCase()}function Jf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Xf(n[1]),text:n[2]}:null}function Sx(r){const n=new Map;let s=null;for(const l of r){const d=Jf(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function Qf(r){const n=new Set;let s=!1;return r.forEach((l,d)=>{if(Jf(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function jx(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const d=r[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Zf(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function ia(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Wl(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,m=d>=0?l.slice(d+1):"",g=c.split("?",1)[0];if(!g)return null;let f,p=null;try{f=decodeURIComponent(g),p=m?decodeURIComponent(m):null}catch{return null}const x=s?ia(s):null;let h;if(f.startsWith("/")){const b=x&&(f===x||f.startsWith(`${x}/`));h=ia(x&&!b?`${x}/${f.slice(1)}`:f)}else{if(!n)return null;h=ia(`${Zf(n)}/${f}`)}return x&&h!==x&&!h.startsWith(`${x}/`)?null:{path:h,fragment:p,directory:/\/$/.test(g)}}function Gl(r,n,s,l,d){const c=r.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!l(c.split(/[?#]/,1)[0]))return null;let m;if(c.startsWith("/")){const g=s&&(c===s||c.startsWith(`${s}/`));m=ia(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=ia(`${Zf(n)}/${c}`)}return d(m)}function Rx(r,n,s){return Gl(r,n,s,Bl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Nx(r,n,s){return Gl(r,n,s,ef,tf)}const Il=128,Cx=360,ll=480;function pa(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function eh(r,n,s,l,d=0){if(!n||!s)return null;let c,m;return d>0?(c=l>0?Math.min(d,l):d,m=s*c/n):pa(r)?(m=Math.min(Math.max(s,Il),Cx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>ll&&(c=c*ll/m,m=ll),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function Ex(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function th(r){const n=Ex(r),s=V(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function Mx({src:r,alt:n,title:s,requestedWidthPx:l}){const d=pa(r),c=th(r),m=Ho(c),g=a.useRef(null),[f,p]=a.useState(!1),[x,h]=a.useState(0),[b,E]=a.useState({status:"loading"}),[S,T]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current;let C=$?.parentElement?.parentElement??$?.parentElement;for(;C;){const j=window.getComputedStyle(C).display;if(j!=="inline"&&j!=="contents")break;C=C.parentElement}if(!C)return;const A=C,O=()=>{const j=window.getComputedStyle(A),o=(parseFloat(j.paddingLeft)||0)+(parseFloat(j.paddingRight)||0);h(Math.max(0,A.clientWidth-o))};if(O(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(O);return q.observe(A),()=>q.disconnect()},[]),a.useEffect(()=>{if(f)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const C=new IntersectionObserver(A=>{A.some(O=>O.isIntersecting)&&(p(!0),C.disconnect())},{rootMargin:"400px"});return C.observe($),()=>C.disconnect()},[f]),a.useEffect(()=>{if(!f)return;const $=new AbortController;let C=null;E({status:"loading"});const A=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return rf(c,{signal:$.signal}).then(async O=>{if(!O.ok)throw new Error(`HTTP ${O.status}`);const q=Number(O.headers.get("X-Image-Width"))||0,j=Number(O.headers.get("X-Image-Height"))||0;return{blob:await O.blob(),width:q,height:j}}).then(({blob:O,width:q,height:j})=>{$.signal.aborted||(C=URL.createObjectURL(O),q>0&&j>0&&T({width:q,height:j}),E({status:"ready",objectUrl:C}))}).catch(()=>{const O=$.signal.reason;$.signal.aborted&&!(O instanceof DOMException&&O.name==="TimeoutError")||E({status:"fallback"})}).finally(()=>{window.clearTimeout(A)}),()=>{window.clearTimeout(A),$.abort(),C&&URL.revokeObjectURL(C)}},[f,c]);const D=eh(r,S?.width??0,S?.height??0,x,l??0),F=D??(l?{width:x>0?Math.min(l,x):l,height:Math.round(l*.75)}:{width:Il*2,height:Il});return e.jsx("div",{ref:g,className:"block max-w-full",style:D?{width:D.width,height:D.height}:void 0,children:b.status==="ready"?e.jsx("img",{src:b.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const C=$.currentTarget;C.naturalWidth>0&&C.naturalHeight>0&&(S?.width!==C.naturalWidth||S?.height!==C.naturalHeight)&&T({width:C.naturalWidth,height:C.naturalHeight})}}):b.status==="fallback"?e.jsx("img",{src:m,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const C=$.currentTarget;C.naturalWidth>0&&C.naturalHeight>0&&(S?.width!==C.naturalWidth||S?.height!==C.naturalHeight)&&T({width:C.naturalWidth,height:C.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:F.width,height:F.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function la(r,n,s,l,d,c){const m=Rx(s,d.markdownFilePath,d.rootPath);if(!m)return c?.fallbackText??``;const g=d.images.length;d.images.push({kind:"image",src:m,alt:n,title:l});const f=e.jsx(Mx,{src:m,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:p=>{p.stopPropagation(),d.onImageOpen?.(g)},children:f},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:f},r)}function cl(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Uu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function Dl(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const rh="",$x=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Px(r){return r.replace($x,(n,s)=>`${rh}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Hu(r){return r.replace(new RegExp(`${rh}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Ax(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const nh={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let vo=null;function sh(){return vo||(vo=Ln(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw vo=null,r})),vo}function ah({html:r}){const{t:n}=ht(),[s,l]=a.useState(null);return a.useEffect(()=>{let d=!1;return l(null),sh().then(c=>{d||l(c.sanitize(r,nh))}).catch(()=>{d||l("")}),()=>{d=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function Lx({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),sh().then(d=>{l||s(d.sanitize(r,nh))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function oh(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let yo=null;function Tx(){return yo||(yo=Promise.all([Ln(()=>import("./katex-DnlPpQZa.js"),[]),Ln(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw yo=null,r})),yo}function fa({tex:r,display:n=!1}){const[s,l]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),c(!1),Tx().then(f=>{g||l(f.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||c(!0)}),()=>{g=!0}},[n,r]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const m=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:m,dangerouslySetInnerHTML:{__html:s}})}function Kl(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function zu(r){const n=Kl(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function Ix(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Kl(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),m=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),g=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:g,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(m)}}function Dx({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=ht(),[c,m]=a.useState(!1),g=Ho(r,()=>m(!0));return g?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||d("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:g,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>m(!0)})}):null}function Fx(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const m=r.slice(0,r.indexOf(">")+1),g=Kl(m).get("href")?.trim()??"",f=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:x,title:h,widthPx:b}=zu(f);if(!p)return null;const E=Gl(p,s.markdownFilePath,s.rootPath,Bl,$=>$);if(!E)return null;const S=g?Wl(g,s.markdownFilePath,s.rootPath):null,D=!!!(S&&S.path===E)&&g?Kf(g):null,F=la(n,x??"",p,h,s,{requestedWidthPx:b,interactive:D?!1:void 0});return D?e.jsx("a",{href:D,target:"_blank",rel:"noreferrer",children:F},n):F}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:m,alt:g,title:f,widthPx:p}=zu(r);return m?la(n,g??"",m,f,s,{fallbackText:r,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:m,fallbackText:g,widthPx:f,controls:p}=Ix(r);if(!m)return null;const x=Nx(m,s.markdownFilePath,s.rootPath);return x?e.jsx(Dx,{url:x,fallbackText:g,widthPx:f,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx(Lx,{html:r},n):null;const d=l[1].toLowerCase(),c=ft(l[2],`${n}-${d}`,!0,s);return d==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:c},n):d==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):d==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function ft(r,n,s=!0,l){return l.budget.nested(()=>_x(r,n,s,l))}function _x(r,n,s=!0,l){l.budget.validateInline(r);const d=Px(r),c=[];let m=0;for(const{index:g,token:f}of xg(d,l.budget)){g>m&&c.push(Hu(d.slice(m,g)));const p=`${n}-${g}`,x=f.startsWith("<")?Fx(f,p,l):null;if(x)c.push(x);else if(f.startsWith("\\(")&&f.endsWith("\\)"))c.push(e.jsx(fa,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))c.push(e.jsx(fa,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const h=f.match(/^`+/)?.[0].length??1;c.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Ax(f.slice(h,-h))},p))}else if(f.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ft(f.slice(2,-2),`${p}-del`,s,l)},p));else if(f.startsWith("**")||f.startsWith("__"))c.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ft(f.slice(2,-2),`${p}-strong`,s,l)},p));else if(f.startsWith("*")||f.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ft(f.slice(1,-1),`${p}-em`,s,l)},p));else if(f.startsWith("![")){const h=f.match(/^!\[([^\]]*)\]\((.*)\)$/),b=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^!\[([^\]]+)\]$/);if(h){const S=Dl(h[2]);c.push(S?la(p,h[1],S.href,S.title,l):f)}else if(b){const S=b[2]||b[1],T=l.referenceDefinitions.get(Co(S));c.push(T?la(p,b[1],T.href,T.title,l):f)}else if(E){const S=l.referenceDefinitions.get(Co(E[1]));c.push(S?la(p,E[1],S.href,S.title,l):f)}else c.push(f)}else if(f.startsWith("[^")){const h=Xf(f.slice(2,-1)),b=l.footnoteDefinitions.get(h);c.push(b?e.jsx("sup",{id:`fnref-${b.id}`,title:b.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${b.id}`,className:"text-primary no-underline",children:b.index})},p):f)}else if(f.startsWith("<http")){const h=f.slice(1,-1);c.push(e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(f.startsWith("<")&&f.endsWith(">")&&Uu(f.slice(1,-1))){const h=f.slice(1,-1);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(Uu(cl(f).linkText)){const{linkText:h,suffix:b}=cl(f);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:h,suffix:b}=cl(f),E=h.startsWith("www.")?`https://${h}`:h;c.push(e.jsx("a",{href:E,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else{const h=f.match(/^\[([^\]]+)\]\((.*)\)$/),b=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^\[([^\]]+)\]$/),S=b?b[2]||b[1]:E?.[1]??null,T=S?l.referenceDefinitions.get(Co(S)):null,D=h?Dl(h[2]):null,F=D?.href??T?.href??null,$=F?Kf(F):null,C=h?.[1]??b?.[1]??E?.[1]??"";c.push($?e.jsx("a",{href:$,title:D?.title??T?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ft(C,`${p}-link`,s,l)},p):f)}m=g+f.length}return m<d.length&&c.push(Hu(d.slice(m))),c.length>0?c:[r]}function ih(r){return/(?: {2,}|\\)$/.test(r)}function lh(r){return r.replace(/(?: {2,}|\\)$/,"")}function Do(r){return/^(?: {4}|\t)/.test(r)}function ch(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function dh(r,n,s){const l=[];return r.forEach((d,c)=>{const m=ih(d);l.push(...ft(lh(d),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Fl(r,n,s){const l=[],d=[];return r.forEach((c,m)=>{d.push(ih(c)),l.push(ft(lh(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function _l(r,n,s,l,d){const c=[];return r.forEach((m,g)=>{const f=s[g]??0,p=!!(d&&f>=d.start&&f<=d.end);c.push(e.jsx("span",{"data-md-ref-start":f,"data-md-ref-end":f,"data-selected":p?"true":void 0,children:m},`${l}-ref-${g}`)),g<r.length-1&&c.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),c}function ha(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,m=0;for(let g=0;g<n.length;g+=1){const f=n[g];if(d){l+=f,d=!1;continue}if(f==="\\"){d=!0;continue}if(f==="`"){const p=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const x=g-p+1;l+="`".repeat(x),c===0?c=x:c===x&&(c=0);continue}if(c===0&&f==="["?m+=1:c===0&&f==="]"&&m>0&&(m-=1),f==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=f}return d&&(l+="\\"),s.push(l.trim()),s}function uh(r){return ha(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Fo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function _o(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function fh(r,n){return r>96||r>44&&n>.35}function Wo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function ma(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function ql(r,n,s,l,d,c=new Set){const m=[],g=[];let f=n;for(;f<r.length;){const p=r[f];if(d&&(Io(p)||c.has(f))){f+=1;continue}const x=ma(p),h=Wo(p);if(!x){if(h>s&&g.length>0){([...g].reverse().find(T=>T.indent<h)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const T of g)T.item.lineEnd=f+1;f+=1;continue}break}if(h<s||h===s&&x.ordered!==l)break;const b={content:x.content,ordered:x.ordered,start:x.start,children:[],paragraphs:[],lineStart:f+1,lineEnd:f+1};for(;g.length>0&&g[g.length-1].indent>=h;)g.pop();const E=g[g.length-1]?.item??null;E?E.children.push(b):m.push(b),g.push({indent:h,item:b});for(const S of g)S.item.lineEnd=f+1;f+=1}return{items:m,nextIndex:f}}function Bx(r){const n=r.find(l=>ma(l));if(!n)return[];const s=ma(n);return s?ql(r,0,Wo(n),s.ordered,!0,Qf(r)).items:[]}function Vl(r,n,s,l=0){return s.budget.nested(()=>Ox(r,n,s,l))}function Ox(r,n,s,l=0){return r.map((d,c)=>{const m=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!m,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[m?e.jsx("input",{type:"checkbox",checked:m[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ft(m?.[2]??d.content,`li-${n}-${c}`,!0,s),d.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((g,f)=>e.jsx("p",{children:ft(g,`li-${n}-${c}-p-${f}`,!0,s)},`paragraph-${f}`))})]}),groups:Ux(d.children,`${n}-${c}`,s,l)}})}function Ux(r,n,s,l=0){const d=[];for(const c of r){const m=d[d.length-1];m&&m.ordered===c.ordered?m.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,m)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:Vl(c.items,`${n}-g${m}`,s,l)}))}function Yl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&Hx(s.groups,n)]},s.key)})}function Hx(r,n){return r.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Yl(s.items,n)},`nested-${l}`)})}function zx(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ft(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Wx(r,n,s,l){const d=[];let c=0;const m=g=>l?.[g]??g+1;for(;c<r.length;){s.budget.check();const g=r[c],f=g.trim();if(!f){c+=1;continue}if(/^<details>\s*$/i.test(f)){const F=c;let $="Details";const C=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const A=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);A?$=A[1].trim()||$:C.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ft($,`${n}-details-${F}-summary`,!0,s)}),C.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:dh(C,`${n}-details-${F}`,s)})]},`${n}-details-${F}`)});continue}const p=oh(g);if(p){const F=[g],$=c;for(c+=1;c<r.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(r[c]);)F.push(r[c]),c+=1;c<r.length&&!p.selfContained&&(F.push(r[c]),c+=1),d.push({kind:"static",node:e.jsx(ah,{html:F.join(`
|
|
1639
|
+
`)},`${n}-html-${$}`)});continue}const x=f.match(/^(```|~~~)\s*(.*)$/);if(x){const F=[],$=x[1],C=x[2]?.trim(),A=c;for(c+=1;c<r.length&&!r[c].trim().startsWith($);)F.push(r[c]),c+=1;c<r.length&&(c+=1),C.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(mh,{code:F.join(`
|
|
1640
|
+
`),blockKey:`${n}-code-${A}`},`${n}-code-${A}`)}):["math","latex","tex"].includes(C.toLowerCase())?d.push({kind:"static",node:e.jsx(fa,{tex:F.join(`
|
|
1641
|
+
`),display:!0},`${n}-code-${A}`)}):d.push({kind:"code",key:`${n}-code-${A}`,code:F.join(`
|
|
1642
|
+
`),lang:C,blockKey:`${n}-code-${A}`,codeStartLine:m(A)+1});continue}if(Do(g)){const F=[],$=c;for(;c<r.length&&(Do(r[c])||!r[c].trim());)F.push(r[c].trim()?ch(r[c]):""),c+=1;d.push({kind:"code",key:`${n}-indented-code-${$}`,code:F.join(`
|
|
1643
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${$}`,codeStartLine:m($)});continue}const h=f.match(/^(#{1,6})\s+(.+)$/);if(h){const $=`h${Math.min(6,h[1].length+1)}`,C=Yf(h[2]),A=Tl(C,s);d.push({kind:"static",node:e.jsx($,{id:A,className:"scroll-mt-16 font-semibold text-foreground",children:ft(C,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<r.length&&g.includes("|")&&_o(r[c+1])){const F=ha(g),$=uh(r[c+1]),C=[],A=c;for(c+=2;c<r.length&&r[c].includes("|")&&r[c].trim();)C.push(ha(r[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:Bf,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:F.map((O,q)=>e.jsx("th",{className:`${Ff} ${Fo($[q]??null)}`,children:e.jsx("div",{className:To,children:ft(O,`${n}-th-${A}-${q}`,!0,s)})},`h-${q}`))})}),e.jsx("tbody",{children:C.map((O,q)=>e.jsx("tr",{className:"border-t border-border/10",children:F.map((j,o)=>e.jsx("td",{className:`${_f} ${Fo($[o]??null)}`,children:e.jsx("div",{className:To,children:ft(O[o]??"",`${n}-td-${A}-${q}-${o}`,!0,s)})},`c-${o}`))},`r-${q}`))})]})},`${n}-table-${A}`)});continue}const b=ma(g);if(b){const F=b.ordered,$=Wo(g),C=b.start,A=c,O=ql(r,c,$,F,!1);c=O.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${A}`,ordered:F,start:F?C:void 0,renders:Vl(O.items,`${n}-list-${A}`,s,m(0)-1)});continue}const E=[g.trimStart()],S=[m(c)],T=c;for(c+=1;c<r.length&&r[c].trim()&&!Ll(r[c])&&!(c+1<r.length&&r[c].includes("|")&&_o(r[c+1]));)E.push(r[c].trimStart()),S.push(m(c)),c+=1;const D=Fl(E,`${n}-p-${T}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${T}`,perLine:D.perLine,hardBreaks:D.hardBreaks,lineNums:S})}return d}function Gx(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:_l(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:Yl(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)}})}const wo=16,hh=192;function Kx(r){const n=r.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return r;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=l;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return r;const m=Math.max(hh,Math.ceil(d)),g=Math.ceil(m/d*c);return r.replace(/<svg\b([^>]*)>/i,(f,p)=>`<svg${p.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${m}" height="${g}">`)}function qx(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-wo,d=s.y-wo,c=s.width+wo*2,m=s.height+wo*2,g=Math.max(hh,Math.ceil(c)),f=Math.ceil(g/c*m);n.setAttribute("viewBox",`${l} ${d} ${c} ${m}`),n.setAttribute("width",String(g)),n.setAttribute("height",String(f)),n.removeAttribute("style")}function Vx(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return mf(`code.${s}`)??s}function mh({code:r,blockKey:n}){const{t:s}=ht(),[l,d]=a.useState(null),[c,m]=a.useState(!1),g=a.useRef(null),f=a.useContext(qf);a.useEffect(()=>{let x=!1;return d(null),m(!1),kg().then(async h=>{Sg(h);const b=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:E}=await h.render(b,r);x||d(Kx(E))}).catch(()=>{x||m(!0)}),()=>{x=!0}},[n,r]),a.useLayoutEffect(()=>{l&&qx(g.current)},[l]);const p=a.useCallback(()=>{const x=g.current?.querySelector("svg")?.outerHTML??l;x&&f?.(x)},[f,l]);return c?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:x=>{x.stopPropagation(),p()},children:e.jsx("span",{ref:g,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:l}})}):e.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function Bo({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Vx(n),[m,g]=a.useState(null);a.useEffect(()=>{if(!c||!pf(r)){g(null);return}let p=!1;return gf().then(x=>{if(p||!x.registered(c)){p||g(null);return}try{g(bf(x,r,c))}catch{p||g(null)}}).catch(()=>{p||g(null)}),()=>{p=!0}},[s,r,c]);const f=m??(r||" ").split(`
|
|
1644
|
+
`).map(p=>[p||" "]);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[n&&e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("pre",{className:`${zl} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:f.map((p,x)=>{const h=l!=null?l+x:null,b=!!(d&&h!=null&&h>=d.start&&h<=d.end);return e.jsxs("span",{"data-md-ref-start":h??void 0,"data-md-ref-end":h??void 0,"data-selected":b?"true":void 0,children:[p,x<f.length-1?`
|
|
1645
|
+
`:null]},`${s}-line-${x}`)})})})]})}function Xl(r,n,s,l,d){const c=new gg;c.validateLines(r),r=jx(r);const m=kx(r),g=Qf(r),f=[],p={budget:c,markdownFilePath:n,rootPath:s,referenceDefinitions:m,footnoteDefinitions:Sx(r),headingSlugCounts:new Map,images:f,onImageOpen:l,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(E=>`Back to footnote ${E}`)},x=[];let h=0;for(;h<r.length;){p.budget.check();const E=r[h],S=E.trim();if(Io(E)||g.has(h)){h+=1;continue}if(!S){h+=1;continue}if(/^<details>\s*$/i.test(S)){const j=h;let o="Details";const _=[];for(h+=1;h<r.length&&!/^<\/details>\s*$/i.test(r[h].trim());){const I=r[h].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);I?o=I[1].trim()||o:_.push(r[h].trimStart()),h+=1}h<r.length&&(h+=1),x.push({key:`details-${j}`,startLine:j+1,endLine:h,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:ft(o,`details-${j}-summary`,!0,p)}),_.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:dh(_,`details-${j}`,p)})]})});continue}const T=oh(E);if(T){const j=[E],o=h;for(h+=1;h<r.length&&!T.selfContained&&!new RegExp(`</${T.tag}>`,"i").test(r[h]);)j.push(r[h]),h+=1;h<r.length&&!T.selfContained&&(j.push(r[h]),h+=1),x.push({key:`html-${o}`,startLine:o+1,endLine:h,content:e.jsx(ah,{html:j.join(`
|
|
1646
|
+
`)})});continue}const D=S.match(/^(```|~~~)\s*(.*)$/);if(D){const j=[],o=D[1],_=D[2]?.trim(),I=h;for(h+=1;h<r.length&&!r[h].trim().startsWith(o);)j.push(r[h]),h+=1;h<r.length&&(h+=1),x.push({key:`code-${I}`,startLine:I+1,endLine:h,fineGrained:_.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(_.toLowerCase()),content:_.toLowerCase()==="mermaid"?e.jsx(mh,{code:j.join(`
|
|
1647
|
+
`),blockKey:`code-${I}`}):["math","latex","tex"].includes(_.toLowerCase())?e.jsx(fa,{tex:j.join(`
|
|
1648
|
+
`),display:!0}):Y=>e.jsx(Bo,{code:j.join(`
|
|
1649
|
+
`),lang:_,blockKey:`code-${I}`,codeStartLine:I+2,lineRange:Y})});continue}if(Do(E)){const j=[],o=h;for(h+=0;h<r.length&&(Do(r[h])||!r[h].trim());)j.push(r[h].trim()?ch(r[h]):""),h+=1;x.push({key:`indented-code-${o}`,startLine:o+1,endLine:h,fineGrained:!0,content:_=>e.jsx(Bo,{code:j.join(`
|
|
1650
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${o}`,codeStartLine:o+1,lineRange:_})});continue}if(S.startsWith("$$")){const j=[],o=h,_=S.replace(/^\$\$\s*/,"");if(_.endsWith("$$")&&_.length>2)j.push(_.replace(/\s*\$\$$/,"")),h+=1;else{for(_&&j.push(_),h+=1;h<r.length&&!r[h].trim().endsWith("$$");)j.push(r[h]),h+=1;if(h<r.length){const I=r[h].trim().replace(/\s*\$\$$/,"");I&&j.push(I),h+=1}}x.push({key:`math-${o}`,startLine:o+1,endLine:h,content:e.jsx(fa,{tex:j.join(`
|
|
1651
|
+
`),display:!0})});continue}if(h+1<r.length&&S&&!Ll(E)&&/^(=+|-+)\s*$/.test(r[h+1].trim())){const j=r[h+1].trim().startsWith("=")?1:2,o=`h${j}`,_=Tl(S,p),I={level:j,text:Ou(S),id:_};x.push({key:`setext-heading-${h}`,startLine:h+1,endLine:h+2,heading:I,content:e.jsx(o,{id:_,className:`scroll-mt-16 font-semibold text-foreground ${j===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:ft(S,`setext-heading-${h}`,!0,p)})}),h+=2;continue}const F=S.match(/^(#{1,6})\s+(.+)$/);if(F){const j=F[1].length,o=Yf(F[2]),_={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},I=`h${j}`,Y=Tl(o,p),H={level:j,text:Ou(o),id:Y};x.push({key:`heading-${h}`,startLine:h+1,endLine:h+1,heading:H,content:e.jsx(I,{id:Y,className:`scroll-mt-16 font-semibold text-foreground ${_[j]}`,children:ft(o,`heading-${h}`,!0,p)})}),h+=1;continue}if(Gf(E)){x.push({key:`hr-${h}`,startLine:h+1,endLine:h+1,content:e.jsx("hr",{className:"border-border/20"})}),h+=1;continue}if(S.startsWith(">")){const j=[],o=[],_=h;for(;h<r.length&&/^>\s?/.test(r[h].trim());)j.push(r[h].trim().replace(/^>\s?/,"")),o.push(h+1),h+=1;const I=j[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(I){const H=I[1].toUpperCase(),U=I[2]?.trim(),R=[...U?[U]:[],...j.slice(1)],z=[...U?[o[0]]:[],...o.slice(1)],Z=Fl(R,`callout-${_}`,p);x.push({key:`callout-${_}`,startLine:_+1,endLine:h,fineGrained:!0,content:P=>e.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:H}),R.length>0&&e.jsx("div",{children:_l(Z.perLine,Z.hardBreaks,z,`callout-${_}`,P)})]})});continue}const Y=Wx(j,`quote-${_}`,p,o);x.push({key:`quote-${_}`,startLine:_+1,endLine:h,fineGrained:!0,content:H=>e.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:Gx(Y,H)})});continue}if(h+1<r.length&&E.includes("|")&&_o(r[h+1])){const j=ha(E),o=uh(r[h+1]),_=[],I=h;for(h+=2;h<r.length&&r[h].includes("|")&&r[h].trim();)_.push(ha(r[h])),h+=1;const Y=j.map((U,R)=>ft(U,`th-${I}-${R}`,!0,p)),H=_.map((U,R)=>j.map((z,Z)=>ft(U[Z]??"",`td-${I}-${R}-${Z}`,!0,p)));x.push({key:`table-${I}`,startLine:I+1,endLine:h,interactive:!1,kind:"table",content:U=>{const R=z=>!!(U&&z>=U.start&&z<=U.end);return e.jsx("div",{className:Bf,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{"data-markdown-table-row-line":I+1,"data-md-ref-start":I+1,"data-md-ref-end":I+1,"data-selected":R(I+1)?"true":void 0,children:Y.map((z,Z)=>e.jsx("th",{className:`${Ff} ${Fo(o[Z]??null)}`,children:e.jsx("div",{className:To,children:z})},`h-${Z}`))})}),e.jsx("tbody",{children:H.map((z,Z)=>{const P=I+Z+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":P,"data-md-ref-start":P,"data-md-ref-end":P,"data-selected":R(P)?"true":void 0,children:j.map((G,J)=>e.jsx("td",{className:`${_f} ${Fo(o[J]??null)}`,children:e.jsx("div",{className:To,children:z[J]})},`c-${J}`))},`r-${Z}`)})})]})})}});continue}const $=ma(E);if($){const j=$.ordered,o=Wo(E),_=$.start,I=h,Y=ql(r,h,o,j,!0,g);h=Y.nextIndex;const H=j?"ol":"ul",U=Vl(Y.items,`list-${I}`,p);x.push({key:`list-${I}`,startLine:I+1,endLine:h,fineGrained:!0,content:R=>e.jsx(H,{start:j?_:void 0,className:`${j?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:Yl(U,R)})});continue}const C=[E.trimStart()],A=[h+1],O=h;for(h+=1;h<r.length&&r[h].trim()&&!Ll(r[h])&&!(h+1<r.length&&r[h].includes("|")&&_o(r[h+1]));){if(Io(r[h])||g.has(h)){h+=1;continue}C.push(r[h].trimStart()),A.push(h+1),h+=1}const q=Fl(C,`p-${O}`,p);x.push({key:`p-${O}`,startLine:O+1,endLine:h,fineGrained:!0,content:j=>e.jsx("p",{className:"text-muted-foreground",children:_l(q.perLine,q.hardBreaks,A,`p-${O}`,j)})})}const b=zx(p);return b&&x.push({key:"footnotes",startLine:r.length,endLine:r.length,content:b}),c.check(),{blocks:x,images:f}}function Yx(r,n,s){return Xl(r,n,s).blocks}function ph(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function gh(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Xx({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const{t:d}=ht(),c=th(r),m=jf(c),[g,f]=a.useState(null),[p,x]=a.useState(0);a.useEffect(()=>{if(!m)return;const b=new AbortController;let E;return f(null),rf(c,{signal:b.signal}).then(async S=>{if(!S.ok)throw new Error(`HTTP ${S.status}`);const T=await S.blob();b.signal.aborted||(E=URL.createObjectURL(T),f({src:c,objectUrl:E}))}).catch(()=>{b.signal.aborted||f({src:c,failed:!0})}),()=>{b.abort(),E&&URL.revokeObjectURL(E)}},[m,c,p]);const h=g?.src===c?g:null;return m&&!h?.objectUrl?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",role:h?.failed?"alert":"status",children:h?.failed?e.jsxs("div",{className:"flex flex-col items-center gap-3",onClick:b=>b.stopPropagation(),children:[e.jsx("span",{children:d("rightSidebar.imageLoadFailed")}),e.jsx("button",{type:"button",className:"rounded bg-surface-2 px-3 py-2 hover:bg-surface-elevated",onClick:()=>x(b=>b+1),children:d("common.retry")})]}):d("rightSidebar.loadingImage")}):e.jsx(Eh,{src:m?h.objectUrl:c,vector:pa(r),alt:n,onLoad:()=>{},onError:()=>{m&&f({src:c,failed:!0})},onZoomChange:s,onDoubleTap:l})}function bh({images:r,index:n,onChange:s,onClose:l}){const{t:d}=ht(),c=r[n],m=r.length>1,g=a.useRef(null),f=a.useRef(null),p=a.useRef(null),x=a.useRef(0),[h,b]=a.useState(!1),[E,S]=a.useState(0),[T,D]=a.useState(!1),[F,$]=a.useState(!1),[C,A]=a.useState(null),O=a.useRef(!1),q=async()=>{if(!(!c||O.current)){j(),O.current=!0,$(!0),A(null);try{await wg(c)}catch(U){A({image:c,message:U instanceof Error?U.message:d("rightSidebar.downloadFailed")})}finally{O.current=!1,$(!1)}}},j=a.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),o=a.useCallback(()=>{h||Date.now()<x.current||(j(),p.current=window.setTimeout(()=>{p.current=null,l()},450))},[j,h,l]),_=a.useCallback(U=>{if(r.length===0)return;const R=(U+r.length)%r.length;g.current?.slideTo(R),s(R)},[r.length,s]),I=a.useCallback(()=>_(n-1),[_,n]),Y=a.useCallback(()=>_(n+1),[_,n]);if(a.useEffect(()=>{j(),S(0),D(!1),b(!1)},[j,n]),a.useEffect(()=>{const U=g.current;U&&(U.allowTouchMove=m&&!h)},[m,h]),a.useEffect(()=>{const U=g.current;!U||U.activeIndex===n||U.slideTo(n,0)},[n]),a.useEffect(()=>j,[j]),a.useEffect(()=>{const U=R=>{if(R.key==="Escape"){R.preventDefault(),l();return}m&&(R.key==="ArrowLeft"?(R.preventDefault(),I()):R.key==="ArrowRight"&&(R.preventDefault(),Y()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[m,Y,I,l]),lf({onDrag:({movement:[U,R],pinching:z})=>{z||h||Math.abs(R)<Math.abs(U)*1.15&&E===0||(D(!0),Math.abs(R)>8&&(x.current=Date.now()+300),S(Math.max(0,R)))},onDragEnd:({movement:[U,R],velocity:[,z],pinching:Z,canceled:P})=>{if(D(!1),Z||P||h||Math.abs(R)<Math.abs(U)*1.15){S(0);return}if(Math.abs(R)>8&&(x.current=Date.now()+300),fh(R,z)){l();return}S(0)}},{target:f,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const H=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:wr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:H}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[m&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:I,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.previousImage"),title:d("common.previous"),children:e.jsx(ca,{size:17})}),e.jsx("button",{type:"button",onClick:Y,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.nextImage"),title:d("common.next"),children:e.jsx(lp,{size:17})})]}),e.jsx("button",{type:"button",onClick:()=>{q()},disabled:F,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100","aria-label":d("rightSidebar.downloadFile"),title:d("rightSidebar.downloadFile"),"aria-busy":F,children:F?e.jsx(ut,{size:17,className:"animate-spin"}):e.jsx(of,{size:17})}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:e.jsx(Lt,{size:18})})]})]}),C?.image===c&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center justify-between gap-3 bg-surface px-3 py-2 text-xs text-destructive",children:[e.jsxs("span",{className:"min-w-0 break-words",children:[d("rightSidebar.downloadFailed"),": ",C.message]}),e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-3 py-1 text-foreground hover:bg-surface-elevated",onClick:()=>{q()},disabled:F,children:d("common.retry")})]}),e.jsx("div",{ref:f,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:U=>{if(!(Date.now()<x.current)){if(U.target instanceof Element&&U.target.closest('img, [role="img"]')){o();return}j(),l()}},children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${E}px, 0) scale(${Math.max(.86,1-E/900)})`,opacity:Math.max(.35,1-E/360),transition:T?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(cf,{onSwiper:U=>{g.current=U,U.allowTouchMove=m&&!h},onSlideChange:U=>{U.activeIndex!==n&&s(U.activeIndex)},onSliderMove:()=>{j(),x.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((U,R)=>e.jsx(vl,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:U.kind==="image"?e.jsx(Xx,{src:U.src,alt:U.alt||U.title||d("rightSidebar.markdownImage"),onZoomChange:b,onDoubleTap:j}):e.jsx(f0,{svg:U.svg,title:U.title||U.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:b,onDoubleTap:j})})},`${U.kind}-${R}-${U.alt}`))})})})]})]}),document.body)}function xh({referenceLines:r=!0,content:n,filePath:s,rootPath:l,lineRange:d,onLineRangeClick:c,onLineRangeDrag:m,scrollTop:g,outlineOpen:f,outlineCloseSignal:p,onOutlineOpen:x,onOutlineClose:h,lightboxOpen:b,lightboxCloseSignal:E,onLightboxOpen:S,onLightboxClose:T,onLocalLinkOpen:D}){const{t:F}=ht(),[$,C]=a.useState(null),[A,O]=a.useState(null),[q,j]=a.useState(1),[o,_]=a.useState(null),I=a.useRef(null),Y=a.useRef(null),{blocks:H,images:U,parseError:R}=a.useMemo(()=>{try{return{...Xl(n.split(`
|
|
1652
|
+
`),s,l,M=>{O(null),C(M),S?.()},{footnotes:F("rightSidebar.footnotes"),backToFootnote:M=>F("rightSidebar.backToFootnote",{index:M})}),parseError:null}}catch(M){return{blocks:[],images:[],parseError:M instanceof Error?M.message:String(M)}}},[n,s,l,S,F]);a.useEffect(()=>{R&&Mo("markdown_error",{filePath:s,rootPath:l,error:R,fallback:"plain_text"})},[R,s,l]);const z=a.useMemo(()=>A?[...U,A]:U,[U,A]),Z=a.useCallback(M=>{O({kind:"mermaid",svg:M,alt:"Mermaid diagram",title:"Mermaid diagram"}),C(U.length),S?.()},[U.length,S]);a.useEffect(()=>{C(null),O(null)},[n,s]),a.useEffect(()=>{C(null),O(null)},[E]),a.useEffect(()=>{b||(C(null),O(null))},[b]),a.useEffect(()=>{j(1)},[n,s]),a.useLayoutEffect(()=>{const M=I.current;if(!M||H.length===0)return;const he=Array.from(M.querySelectorAll("[data-markdown-preview-block-start]"));let fe=1;const Ne=28;for(const $e of he)if($e.offsetTop-g<=Ne)fe=Number($e.dataset.markdownPreviewBlockStart)||fe;else break;j($e=>$e===fe?$e:fe)},[H,g]);const P=a.useMemo(()=>ph(H,q),[q,H]),G=a.useMemo(()=>gh(H),[H]),J=`${s??""}
|
|
1653
|
+
${n}`,ie=a.useRef(J),pe=a.useRef(null),Se=a.useRef(null),ke=a.useRef(!1);a.useEffect(()=>{ie.current!==J&&(ie.current=J,h?.())},[h,J]),a.useEffect(()=>{p!==void 0&&_(null)},[p]),a.useLayoutEffect(()=>{if(!f){_(null);return}const M=()=>{const he=Y.current;if(!he)return;const fe=he.getBoundingClientRect(),Ne=window.innerWidth;_({top:fe.bottom+6,right:Math.max(8,Ne-fe.right)})};return M(),window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[f,g,P]);const Me=a.useCallback(M=>{const he=I.current,fe=he?.closest("[data-markdown-preview-scroller]"),Ne=he?.querySelector(`[data-markdown-preview-block-start="${M.startLine}"]`);if(!fe||!Ne)return;const $e=fe.getBoundingClientRect(),rt=Ne.getBoundingClientRect(),Te=he?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,qe=rt.top-$e.top+fe.scrollTop;fe.scrollTo({top:Math.max(0,qe-Te-8),behavior:"smooth"}),j(M.startLine),h?.()},[h]),Q=a.useCallback(M=>{M.pointerType==="mouse"&&M.button!==0||pl(M.target)||(pe.current={pointerId:M.pointerId,startX:M.clientX,startY:M.clientY})},[]),ge=a.useCallback((M,he,fe)=>{const Ne=pe.current;if(pe.current=null,!Ne||Ne.pointerId!==M.pointerId)return;const $e=Math.abs(M.clientX-Ne.startX),rt=Math.abs(M.clientY-Ne.startY);if($e>8||rt>8)return;const ce=M.target;if(pl(ce)||wl())return;const Te=Xu(ce,he,fe);c(M,Te.start,Te.end)},[c]),ue=a.useCallback(M=>{pe.current?.pointerId===M.pointerId&&(pe.current=null)},[]),_e=a.useCallback((M,he)=>{const fe=I.current;if(!fe||typeof document.elementFromPoint!="function")return null;const Ne=document.elementFromPoint(M,he);if(!(Ne instanceof HTMLElement)||!fe.contains(Ne))return null;const $e=Ne.closest("[data-md-ref-start]");if($e){const De=Number($e.dataset.mdRefStart);if(Number.isFinite(De)&&De>0)return De}const rt=Ne.closest("[data-markdown-preview-block-start]");if(!rt)return null;const ce=Number(rt.dataset.markdownPreviewBlockStart),Te=H.find(De=>De.startLine===ce);if(!Te)return Number.isFinite(ce)&&ce>0?ce:null;if(Te.endLine<=Te.startLine)return Te.startLine;const qe=rt.getBoundingClientRect(),Ie=qe.height>0?Math.min(1,Math.max(0,(he-qe.top)/qe.height)):0;return Math.round(Te.startLine+Ie*(Te.endLine-Te.startLine))},[H]),Ue=a.useCallback(M=>{if(!m||M.pointerType==="mouse"&&M.button!==0)return;const he=_e(M.clientX+24,M.clientY);if(he!=null){Se.current={pointerId:M.pointerId,anchorLine:he,moved:!1};try{M.currentTarget.setPointerCapture(M.pointerId)}catch{}}},[m,_e]),W=a.useCallback(M=>{const he=Se.current;if(!he||he.pointerId!==M.pointerId||!m)return;const fe=_e(M.clientX+16,M.clientY);fe!=null&&(!he.moved&&fe===he.anchorLine||(he.moved=!0,ke.current=!0,m(M,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"move")))},[m,_e]),we=a.useCallback(M=>{const he=Se.current;if(Se.current=null,!he||he.pointerId!==M.pointerId||!m||!he.moved)return;const fe=_e(M.clientX+16,M.clientY)??he.anchorLine;m(M,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"end")},[m,_e]),ye=a.useCallback(M=>{Se.current?.pointerId===M.pointerId&&(Se.current=null)},[]),He={onPointerDown:Ue,onPointerMove:W,onPointerUp:we,onPointerCancel:ye},Ke=()=>ke.current?(ke.current=!1,!0):!1;return R?e.jsxs("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground","data-markdown-preview-fallback":!0,children:[e.jsx("p",{role:"alert",className:"mb-3 text-destructive",children:F("rightSidebar.markdownParseFailed")}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:n})]}):H.length===0?e.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:e.jsx("p",{className:"text-muted-foreground",children:F("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:I,className:"relative min-w-0 max-w-full",onClickCapture:M=>{const he=M.target instanceof Element?M.target.closest("a[href]"):null;if(!he||!D)return;const fe=he.getAttribute("href");if(!fe)return;const Ne=Wl(fe,s,l);Ne&&(M.preventDefault(),D(Ne))},children:[r&&P.length>0&&e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:P.map(M=>M.text).join(" / "),children:[e.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:P[P.length-1].text}),G.length>1&&e.jsxs("button",{ref:Y,type:"button",onClick:()=>{f?h?.():x?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${f?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":f,"aria-label":F("rightSidebar.markdownOutline"),title:F("rightSidebar.markdownOutline"),children:[e.jsx(df,{size:12}),e.jsx("span",{children:F("rightSidebar.markdownOutlineShort")})]})]})}),f&&typeof document<"u"&&wr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:h}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:o?{top:`${o.top}px`,right:`${o.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:e.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:G.map(M=>{const he=P[P.length-1]?.startLine===M.startLine;return e.jsxs("button",{type:"button",onClick:()=>Me(M),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${he?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(M.level-1,4)*12+8}px`},title:M.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",M.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:M.text})]},`desktop-${M.id}-${M.startLine}`)})})}),e.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F("rightSidebar.markdownOutlineShort")}),e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":F("rightSidebar.closeMarkdownOutline"),title:F("common.close"),children:e.jsx(Lt,{size:14})})]}),e.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:G.map(M=>{const he=P[P.length-1]?.startLine===M.startLine;return e.jsxs("button",{type:"button",onClick:()=>Me(M),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${he?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(M.level-1,4)*12+8}px`},title:M.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${he?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",M.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:M.text})]},`${M.id}-${M.startLine}`)})})]})]}),document.body),e.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:e.jsx(qf.Provider,{value:Z,children:H.map(M=>{const he=!!(d&&M.startLine<=d.end&&M.endLine>=d.start),fe=!!(d&&d.start<=M.startLine&&d.end>=M.endLine),Ne=M.kind==="table"?!1:M.fineGrained?fe:he,$e=M.kind==="table"&&d?.start===M.startLine&&d.end===M.endLine;let rt=null;if(M.kind!=="table"&&M.fineGrained&&he&&!fe&&d){const Ie=M.endLine-M.startLine+1,De=Math.max(d.start,M.startLine),te=Math.min(d.end,M.endLine),je=(De-M.startLine)/Ie,nt=(te-De+1)/Ie;rt=e.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${je})`,height:`calc((100% - 0.5rem) * ${nt})`}})}const ce=typeof M.content=="function"?M.content(d):M.content;if(!r)return e.jsx("div",{"data-markdown-preview-block-start":M.startLine,className:"min-w-0 cursor-text select-text py-0.5",children:ce},M.key);const Te=M.startLine===M.endLine?String(M.startLine):`${M.startLine}-${M.endLine}`,qe=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:fl(Ne),"aria-hidden":"true",...He,children:[e.jsx("span",{className:hl(Ne)}),rt]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:ce})]});return M.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":M.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Ne?"bg-primary/10":""}`,title:`Line ${Te}`,"aria-label":`Line ${Te}`,children:[M.kind==="table"?e.jsx("button",{type:"button",className:fl($e,"self"),onClick:Ie=>{Ie.preventDefault(),!Ke()&&c(Ie,M.startLine,M.endLine)},title:`Reference table lines ${Te}`,"aria-label":`Reference table lines ${Te}`,...He,children:e.jsx("span",{className:hl($e,"self")})}):e.jsxs("span",{className:fl(Ne,"none"),"aria-hidden":"true",...He,children:[e.jsx("span",{className:hl(Ne,"none")}),rt]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:Q,onPointerUp:Ie=>ge(Ie,M.startLine,M.endLine),onPointerCancel:ue,onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),c(Ie,M.startLine,M.endLine))},title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:ce})]},M.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":M.startLine,onClick:Ie=>{const De=Ie.target;if(pl(De)||wl()||Ke())return;const te=Xu(De,M.startLine,M.endLine);c(Ie,te.start,te.end)},onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),c(Ie,M.startLine,M.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Ne?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:qe},M.key)})})})]}),b&&$!==null&&z[$]&&e.jsx(bh,{images:z,index:$,onChange:C,onClose:()=>{C(null),O(null),T?.()}})]})}function fs({label:r,value:n,options:s,placeholder:l,searchPlaceholder:d,emptyText:c,disabled:m,onChange:g}){const{t:f}=ht(),[p,x]=a.useState(!1),[h,b]=a.useState(""),[E,S]=a.useState(null),T=a.useRef(null),D=a.useRef(null),F=h.trim().toLowerCase(),$=a.useMemo(()=>F?s.filter(j=>`${j.label} ${j.meta??""}`.toLowerCase().includes(F)):s,[F,s]),C=s.find(j=>j.value===n),A=()=>{const j=h.trim();j&&(g(j),x(!1),b(""))},O=a.useCallback(()=>{const j=T.current?.getBoundingClientRect();if(!j)return!1;const o=12,_=Math.max(220,Math.min(j.width,window.innerWidth-o*2)),I=Math.min(Math.max(o,j.left),window.innerWidth-_-o),Y=window.innerHeight-j.bottom-o,H=j.top-o,U=Y>=180||Y>=H,R=Math.max(96,(U?Y:H)-4),z=Math.min(320,R);return S({left:I,top:U?j.bottom+4:Math.max(o,j.top-z-4),width:_,maxHeight:z}),!0},[]),q=()=>{O(),x(!0)};return a.useEffect(()=>{if(!p)return;let j=0;const o=()=>{j||(j=window.requestAnimationFrame(()=>{j=0,O()}))},_=I=>{const Y=I.target;Y instanceof Node&&(T.current?.contains(Y)||D.current?.contains(Y)||(x(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",_,!0),()=>{j&&window.cancelAnimationFrame(j),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",_,!0)}},[p,O]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:T,type:"button",disabled:m,onClick:()=>{if(!m){if(b(""),p){x(!1);return}q()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:C?.label??(n||l)})]}),e.jsx(da,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${p?"rotate-180":""}`})]}),p&&!m&&typeof document<"u"&&wr.createPortal(e.jsxs("div",{ref:D,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:j=>j.stopPropagation(),style:{left:E?.left??12,top:E?.top??12,width:E?.width??260,maxHeight:E?.maxHeight??320},children:[e.jsx("div",{className:"border-b border-border/10 p-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[e.jsx(ms,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:h,onChange:j=>b(j.target.value),onKeyDown:j=>{if(j.key==="Escape"){j.preventDefault(),x(!1),b("");return}j.key==="Enter"&&(j.preventDefault(),A())},onBlur:()=>{h.trim()&&$.length===0&&A()},placeholder:d,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),e.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(E?.maxHeight??320)-46)},children:[h.trim()&&!s.some(j=>j.value===h.trim())&&e.jsxs("button",{type:"button",onMouseDown:j=>j.preventDefault(),onClick:A,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[e.jsx("span",{className:"min-w-0 truncate",children:h.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:f("common.use")})]}),$.length>0?$.map(j=>e.jsxs("button",{type:"button",onClick:()=>{g(j.value),x(!1),b("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${j.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:j.label}),j.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:j.meta})]},j.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function Wu({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:d,selectedRoots:c,onToggleRepo:m,onGenerate:g,onSecondaryAction:f,disabled:p,generateDisabled:x,secondaryDisabled:h,inserted:b,buttonLabel:E,insertedLabel:S,title:T,ariaLabel:D,scopeTitle:F,scopeLabel:$,allLabel:C,generateLabel:A,secondaryLabel:O,secondaryTitle:q,secondaryLoading:j,loading:o,error:_,statusTitle:I,extraContent:Y,renderRepoExtra:H,menuItem:U=!1}){return e.jsxs("div",{className:U?"relative w-full":"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",role:U?"menuitem":void 0,tabIndex:U?-1:void 0,onClick:R=>{s?n(!r):x||g(R.currentTarget)},disabled:p,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${U?"min-h-10 w-full gap-2.5 px-2.5 text-left text-[12px] focus:bg-surface-2 focus:outline-none [@media(pointer:coarse)]:min-h-11":"h-7 shrink-0 justify-center gap-1 px-2 text-[11px] font-medium active:scale-95"} ${_?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":U?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:I??(s?`${F}: ${$}`:T),children:[o?e.jsx(ut,{size:U?15:13,className:"shrink-0 animate-spin"}):e.jsx(ua,{size:U?15:13,className:U?"shrink-0 text-muted-foreground":void 0}),e.jsx("span",{className:U?"min-w-0 flex-1":void 0,children:b?S:E}),s&&(U?e.jsx(hs,{size:13,className:"shrink-0 text-muted-foreground"}):e.jsx(da,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),_&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:F}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:$})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Lt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[Y,e.jsxs("button",{type:"button",onClick:()=>m(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:C}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),d.map(R=>{const z=c.includes(R.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${z?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>m(R.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${z?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:R.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:R.label}),R.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:R.branch})]}),z&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),H&&(l||z)&&e.jsx("div",{className:"px-2 pb-2",children:H(R)})]},R.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${f&&O?"sm:grid-cols-2":""}`,children:[f&&O&&e.jsxs("button",{type:"button",onClick:()=>{h||(n(!1),f())},disabled:h,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:q,children:[j?e.jsx(ut,{size:12,className:"animate-spin"}):e.jsx(vf,{size:12}),O]}),e.jsxs("button",{type:"button",onClick:async R=>{if(x)return;await g(R.currentTarget)!==!1&&n(!1)},disabled:x,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:T,children:[e.jsx(ua,{size:12}),A]})]})]})}),document.body)]})}function Jx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function vh(){return gt(Ul,Jx)??{}}function Qx(r,n){const s=vh(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Gb);aa(Ul,Object.fromEntries(l),qb)}function Zx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function e0(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Zx(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Jl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function yh(){return gt(Hl,e0)??{}}function Gu(r,n){const s=Jl(r,n);return s?yh()[s]??null:null}function dl(r,n,s){const l=Jl(r,n);if(!l)return;const d=yh(),c=d[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},m=Object.entries({...d,[l]:{...c,...s,updatedAt:Date.now()}}).sort(([,g],[,f])=>f.updatedAt-g.updatedAt).slice(0,Kb);aa(Hl,Object.fromEntries(m),Vb)}function ul({slow:r}){return e.jsx(zp,{slow:r})}function ko({message:r,onRetry:n}){const{t:s}=ht();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function Eo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function wt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function So(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function t0(r,n,s){return kl(r,n,s)}function fl(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function hl(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function wh(r){const n=new Map;for(const s of r)n.set(Ql(s),s);return n}function kh(r,n){const s=new Map(r);for(const l of n)s.set(Ql(l),l);return s}function Ku(r,n){let s=0;for(const l of r){const d=bt(l,n);d&&n&&d!==n&&(s+=1)}return s}function r0(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function n0(r,n){return Array.from(kh(wh(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function s0(r,n){const s=r.relativeRoot==="."?wt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||wt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:r0(r.files)}}function Sh(r,n){const s=wt(n??"")||n||"";return r.map(l=>s0(l,n)).sort((l,d)=>s&&l.label===s?-1:s&&d.label===s?1:l.label.localeCompare(d.label))}function jh(r,n,s,l,d){const c=Uf(s),m=c.find(T=>T.root===l)??c[0]??null,g=n.find(T=>T.root===l)??null,f=g?.relativeRoot??m?.relativeRoot??".",p=g?.name??m?.name??(wt(l)||l),x=(m?.files??s.files).map(T=>({...T,repoRoot:l,repoRelativeRoot:f,repoName:p})),h=m?.context??s.context,b={...g??m??{id:l,root:l,relativeRoot:f,name:p,depth:0,nested:!!(d&&l!==d),available:s.available,files:[],context:null},...m??{},id:g?.id??m?.id??l,root:l,displayRoot:g?.displayRoot??m?.displayRoot,relativeRoot:f,name:p,depth:g?.depth??m?.depth??0,nested:g?.nested??m?.nested??!!(d&&l!==d),available:m?.available??s.available,deferred:m?.deferred??!1,files:x,context:h?{...h,root:l,changedFiles:x.map(T=>({path:T.path,absolutePath:T.absolutePath,status:T.status}))}:null,untrackedDeferred:m?.untrackedDeferred??s.untrackedDeferred,error:m?.error??s.error},E=g?n.map(T=>T.root===l?b:T):[...n,b];return{files:Array.from(r).filter(T=>bt(T,d)!==l).concat(x),repositories:E,repoFilters:Sh(E,d)}}function bt(r,n){return r.repoRoot??n}function Ql(r){return`${r.repoRoot??""}\0${r.path}`}function vr(r){return r.absolutePath||r.path}function ml(r){return Ql(r)}function a0(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function qu(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Vu(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Zs(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function ea(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function yr(r){return r instanceof DOMException&&r.name==="AbortError"}function o0(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function Yu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function pl(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function Xu(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,d=Number(l?.dataset.mdRefStart),c=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(d)&&d>0&&Number.isFinite(c)&&c>0?{start:Math.min(d,c),end:Math.max(d,c)}:{start:n,end:s}}function i0({actions:r,running:n,completed:s}){const{t:l}=ht(),[d,c]=a.useState(!1),m=a.useRef(null),g=r.find(p=>n?.action===p.key),f=r.find(p=>s?.action===p.key);return r.length===0?null:(a.useEffect(()=>{if(!d)return;const p=h=>{const b=h.target;b instanceof Node&&m.current?.contains(b)||c(!1)},x=h=>{h.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",x)}},[d]),e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),c(x=>!x)},disabled:r.every(p=>p.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${d?"bg-surface-elevated text-foreground":f?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:g?.label??f?.label??l("rightSidebar.gitQuickActions"),children:g?e.jsx(ut,{size:13,className:"animate-spin"}):f?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx($o,{size:14})}),d&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(p=>{const x=n?.action===p.key,h=s?.action===p.key;return e.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),p.onClick(),c(!1)},disabled:p.disabled||!!n,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${h?"bg-accent/10 text-accent":p.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:x?e.jsx(ut,{size:13,className:"animate-spin"}):h?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.key)})})]}))}function l0(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Rh(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&l0(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function ps(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const gl=new WeakMap;function Oo(r){const n=gl.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),gl.delete(r)},1700);gl.set(r,s)}function c0(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let d=null;for(const g of l){if(!ps(g))continue;const f=g.querySelector(s);if(f&&ps(f)){d=f;break}}if(d??=Array.from(document.querySelectorAll(s)).find(ps)??null,!d)return;const c=Rh(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),Oo(d);return}const m=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,m),behavior:"instant"}),Oo(d)}function An(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,d=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,c=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,m=[s!==null&&d?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null&&d?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"]`:null,l!==null&&c?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${c}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(S=>!!S),g=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let f=null;for(const S of g)if(ps(S)){for(const T of m){const D=S.querySelector(T);if(D&&ps(D)){f=D;break}}if(f)break}if(f??=m.flatMap(S=>Array.from(document.querySelectorAll(S))).find(ps)??null,!f){c0(r.filePath);return}const p=Rh(f);if(!p){f.scrollIntoView({block:"center",behavior:"smooth"}),Oo(f);return}const x=f.getBoundingClientRect(),h=p.getBoundingClientRect(),E=x.top-h.top+p.scrollTop-Math.max(24,(p.clientHeight-x.height)/2);p.scrollTo({top:Math.max(0,E),behavior:"instant"}),Oo(f)}const Nh=1,Zl=8;function d0(r,n=Zl){return Math.min(n,Math.max(Nh,r))}function Ch({resetKey:r,maxScale:n=Zl,onZoomChange:s,onDoubleTap:l,children:d}){const c=a.useRef(null),[m,g]=a.useState({scale:1,x:0,y:0}),[f,p]=a.useState(!1),x=a.useRef(null),h=a.useRef(new Set),b=a.useRef(!1),E=a.useRef(null),S=a.useRef(0),T=a.useRef(m);T.current=m,a.useEffect(()=>{g({scale:1,x:0,y:0})},[r]);const D=a.useCallback((A,O,q)=>{const j=c.current;if(!j)return{x:O,y:q};const o=j.firstElementChild instanceof HTMLElement?j.firstElementChild:null,_=o?.clientWidth||j.clientWidth,I=o?.clientHeight||j.clientHeight,Y=Math.max(0,(_*A-j.clientWidth)/2),H=Math.max(0,(I*A-j.clientHeight)/2);return{x:Math.min(Y,Math.max(-Y,O)),y:Math.min(H,Math.max(-H,q))}},[]),F=a.useCallback((A,O,q)=>{g(j=>{const o=d0(A,n),_=c.current;if(!_||o===1)return{scale:o,x:0,y:0};const I=_.getBoundingClientRect(),Y=(O??I.left+I.width/2)-I.left-I.width/2,H=(q??I.top+I.height/2)-I.top-I.height/2,U=o/j.scale,R=Y-(Y-j.x)*U,z=H-(H-j.y)*U;return{scale:o,...D(o,R,z)}})},[D,n]),$=a.useCallback((A,O)=>{p(!0),T.current.scale>1?g({scale:1,x:0,y:0}):F(2.5,A,O),window.setTimeout(()=>p(!1),220)},[F]);a.useEffect(()=>{const A=c.current;if(!A)return;const O=o=>{if(o.pointerType==="mouse"&&o.button!==0)return;const _=h.current.size===0;if(h.current.add(o.pointerId),_){const I=Date.now(),Y=E.current;if(Y&&I-Y.time<350&&Math.hypot(o.clientX-Y.x,o.clientY-Y.y)<24){E.current=null,S.current=I,l?.(),$(o.clientX,o.clientY);return}}if(h.current.size>1){b.current=!0,x.current=null;return}if(!(T.current.scale<=1)){o.preventDefault(),x.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:T.current.x,originY:T.current.y,moved:!1};try{A.setPointerCapture?.(o.pointerId)}catch{}p(!1)}},q=o=>{const _=x.current;if(!_||_.pointerId!==o.pointerId)return;const I=o.clientX-_.startX,Y=o.clientY-_.startY;if(!_.moved){if(Math.hypot(I,Y)<6)return;_.moved=!0}o.stopPropagation(),o.preventDefault(),g(H=>({...H,...D(H.scale,_.originX+I,_.originY+Y)}))},j=o=>{const _=x.current,I=_?.pointerId===o.pointerId&&_.moved;if(_?.pointerId===o.pointerId){_.moved&&o.stopPropagation(),x.current=null;try{A.releasePointerCapture?.(o.pointerId)}catch{}}h.current.delete(o.pointerId)&&h.current.size===0&&(!b.current&&!I&&(E.current={time:Date.now(),x:o.clientX,y:o.clientY}),b.current=!1)};return A.addEventListener("pointerdown",O,{capture:!0,passive:!1}),window.addEventListener("pointermove",q,{capture:!0,passive:!1}),window.addEventListener("pointerup",j,{capture:!0}),window.addEventListener("pointercancel",j,{capture:!0}),()=>{A.removeEventListener("pointerdown",O,{capture:!0}),window.removeEventListener("pointermove",q,{capture:!0}),window.removeEventListener("pointerup",j,{capture:!0}),window.removeEventListener("pointercancel",j,{capture:!0})}},[D,l,$]),lf({onPinch:({offset:[A],origin:[O,q]})=>{p(!1),F(A,O,q)},onWheel:({event:A,delta:[O,q],ctrlKey:j})=>{if(j){A.preventDefault(),A.stopPropagation(),p(!1),F(T.current.scale*(1-q*.01),A.clientX,A.clientY);return}T.current.scale<=1||(A.preventDefault(),A.stopPropagation(),p(!1),g(o=>({...o,...D(o.scale,o.x-O,o.y-q)})))}},{target:c,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Nh,max:n},from:()=>[T.current.scale,0],rubberband:!0}});const C=m.scale>1;return a.useEffect(()=>{s?.(C)},[s,C]),e.jsx("div",{ref:c,"data-sidebar-gesture-ignore":C?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden","data-image-zoom-viewport":!0,style:{cursor:C?"grab":"zoom-in"},onDoubleClick:A=>{A.stopPropagation(),!(Date.now()-S.current<500)&&(l?.(),$(A.clientX,A.clientY))},children:d({scale:m.scale,zoomed:C,animateTransform:f,transformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0) scale(${m.scale})`,transformOrigin:"center center",transition:f?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0)`,transformOrigin:"center center",transition:f?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Eh({src:r,alt:n,vector:s,onLoad:l,onError:d,onZoomChange:c,onDoubleTap:m}){const g=Ho(r,d),[f,p]=a.useState(null),x=s??pa(r);return a.useEffect(()=>{p(null)},[r]),e.jsx(Ch,{resetKey:r,maxScale:Math.max(Zl,f?.originalScale??1),onZoomChange:c,onDoubleTap:m,children:({vectorTransformStyle:h,scale:b,animateTransform:E})=>e.jsx("div",{"data-image-zoom-surface":!0,"data-vector-zoom-surface":x?"":void 0,className:"relative shrink-0 touch-none select-none",style:f?{...h,width:f.width,height:f.height}:{width:"100%",height:"100%"},children:e.jsx("img",{src:g,alt:n,draggable:!1,className:"touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:{position:"absolute",left:"50%",top:"50%",width:f?f.width*b:void 0,height:f?f.height*b:void 0,maxWidth:f?"none":"100%",maxHeight:f?"none":"100%",transform:"translate(-50%, -50%)",transition:E?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"},onLoad:S=>{const T=S.currentTarget,D=T.closest("[data-image-zoom-viewport]");if(D&&T.naturalWidth>0&&T.naturalHeight>0){const F=Math.max(1,D.clientWidth-2),$=Math.max(1,D.clientHeight-2),C=Math.min(F/T.naturalWidth,$/T.naturalHeight),A=x?C:Math.min(C,1);p({width:T.naturalWidth*A,height:T.naturalHeight*A,originalScale:1/A})}l(S)},onError:d})})})}function u0({svg:r,title:n,scale:s,vectorTransformStyle:l}){const d=a.useRef(null);return a.useLayoutEffect(()=>{const c=d.current,m=c?.querySelector("svg");if(!c||!m)return;const g=()=>{const x=m.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let h=x[2],b=x[3];if((!Number.isFinite(h)||!Number.isFinite(b)||h<=0||b<=0)&&(h=Number(m.getAttribute("width")),b=Number(m.getAttribute("height"))),!Number.isFinite(h)||!Number.isFinite(b)||h<=0||b<=0)return;const E=Math.max(1,c.clientWidth-24),S=Math.max(1,c.clientHeight-24),T=Math.min(E/h,S/b,1);m.style.width=`${Math.max(1,Math.floor(h*T*s))}px`,m.style.height=`${Math.max(1,Math.floor(b*T*s))}px`,m.style.maxWidth="none",m.style.maxHeight="none",m.style.transform=String(l.transform??""),m.style.transformOrigin="center center",m.style.transition=String(l.transition??"none")};g();const f=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return f?.observe(c),()=>f?.disconnect()},[s,r,l]),e.jsx("div",{ref:d,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function f0({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Ch,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:d,scale:c})=>e.jsx(u0,{svg:r,title:n,scale:c,vectorTransformStyle:d})})}let h0=0,m0=0,p0=0,g0=0,b0=0;function Mo(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function dt(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++m0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ta(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++g0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function x0(){return`diff-ui-${Date.now().toString(36)}-${(++b0).toString(36)}`}function v0(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function y0(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function Uo({onReviewReference:r,filePath:n,active:s=!0,onInsertReference:l,onInsertText:d,onInsertFeature:c,onReferenceCopied:m,onClose:g,onDirectoryLinkOpen:f,isMobile:p,markdownOutlineOpen:x,markdownOutlineCloseSignal:h,onOpenMarkdownOutline:b,onCloseMarkdownOutline:E,markdownImageLightboxOpen:S,markdownImageLightboxCloseSignal:T,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:F,lineRange:$,onLineRangeChange:C,insertedReferenceKey:A,copiedReferenceKey:O,scrollToLine:q,onScrollToLineHandled:j}){const{t:o}=ht(),_=a.useRef(null),I=a.useRef({}),Y=a.useRef(s);Y.current=s,a.useEffect(()=>{s||_.current?.querySelectorAll("video").forEach(L=>L.pause())},[s]);const H=V(L=>L.rootPath),U=V(L=>L.selectFile),[R,z]=a.useState({kind:"idle"}),[Z,P]=a.useState("schematic"),[G,J]=a.useState(null),ie=a.useRef(null),[pe,Se]=a.useState(null),ke=a.useRef(new Map),Me=a.useRef(null),[Q,ge]=a.useState(null),[ue,_e]=a.useState(()=>Tu()),[Ue,W]=a.useState(()=>wu(H,n)),we=a.useRef(null),[ye,He]=a.useState(!1),[Ke,M]=a.useState(null),[he,fe]=a.useState(0),[Ne,$e]=a.useState([]),[rt,ce]=a.useState(null),Te=a.useRef(null),qe=a.useRef(n),[Ie,De]=a.useState(null),te=tb(H&&n&&!n.startsWith("/")?`${H}/${n}`:n,s),[je,nt]=a.useState(!1),[Rt,lr]=a.useState(""),[B,ae]=a.useState([]),[Ce,et]=a.useState(0),xt=a.useRef(null),kr=xf(m),Nt=Jl(H,n);a.useEffect(()=>{if(qe.current===n)return;qe.current=n;const L=n&&H&&!n.startsWith("/")?`${H}/${n}`:n;if(Te.current===L){Te.current=null;return}Te.current=null,$e([]),ce(null),nt(!1),lr("")},[n,H]);const Ct=n?H&&!n.startsWith("/")?`${H}/${n}`:n:null,Tn=V(L=>Ct?(L.fileChangeVersions.get(Ct)??0)+L.fileWatchEpoch:L.fileWatchEpoch),gs=a.useRef(null),Sr=a.useRef(null),[zt,en]=a.useState(0),er=a.useCallback(()=>en(L=>L+1),[]);a.useEffect(()=>{const L=ie.current;return ie.current=null,J(null),L&&URL.revokeObjectURL(L.objectUrl),()=>{const K=ie.current;ie.current=null,K&&URL.revokeObjectURL(K.objectUrl)}},[Ct,Tn,zt]),a.useEffect(()=>{if(!n){gs.current=null,z({kind:"idle"});return}const L=H&&!n.startsWith("/")?`${H}/${n}`:n,K=new AbortController,be=++h0,Ee=`right-sidebar-file-preview:${be}`,st=performance.now();let Be=!1;const Ye=(re,Je={})=>{Be||(Be=!0,Mo("end",{loadingId:be,reason:re,durationMs:Math.round(performance.now()-st),filePath:n,fullPath:L,rootPath:H,...Je}))};let Oe=null;const Xe=Xm(L),mt=Xe?L.toLowerCase().endsWith(".kicad_pcb")?Z==="schematic"?"pcb-front":Z:"schematic":Z,_n=!Xe&&Bl(L),dr=!Xe&&!_n&&Jm(L),Ss=!Xe&&!_n&&!dr&&ef(L),on=Qs(L),ln=Ys(L),Kr=Xe?"eda":_n?"image":dr?"model3d":Ss?"video":"text",cn=gs.current!==L;if(gs.current=L,cn){Mo("start",{loadingId:be,filePath:n,fullPath:L,rootPath:H,mode:Kr,externalVersion:Tn}),z({kind:"loading",mode:Kr}),Sr.current=null;const re=Gu(H,n);C(re?.lineRange??null),_e(on?Tu():"source"),W(ln?wu(H,n):"source"),Xe&&P(Qm(L))}cn||z(re=>re.kind==="error"?{kind:"loading",mode:Kr}:re);const dn=window.setTimeout(()=>{Be||K.signal.aborted||Mo("still_active",{loadingId:be,filePath:n,fullPath:L,rootPath:H,mode:Kr,durationMs:Math.round(performance.now()-st),isPathChange:cn})},3e3),js=window.setTimeout(()=>{if(Be||K.signal.aborted)return;const re=Xe?o("rightSidebar.edaTimeout"):dr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";K.abort(new DOMException(re,"TimeoutError")),z({kind:"error",message:re}),Ye("stuck_timeout",{error:re})},Xe?Zm+5e3:dr?ep+5e3:tp(L)?35e3:tx);if(Xe){const re=mt==="pcb-3d"?ie.current:null;re?(z(re),Ye("eda_3d_client_cache_hit",{bytes:re.meta.size,view:re.view,mimeType:re.meta.mimeType})):rp(L,mt,K.signal,"view_file",Ee).then(Je=>{if(K.signal.aborted)return;Oe=URL.createObjectURL(Je.blob);const Dt={kind:"eda",sourcePath:Je.path||L,objectUrl:Oe,view:Je.view,meta:{size:Je.size,mimeType:Je.mimeType,modified:Je.modified}};if(Je.view==="pcb-3d"){const ur=ie.current;ur&&ur.objectUrl!==Oe&&URL.revokeObjectURL(ur.objectUrl),ie.current=Dt,J(Dt),Oe=null}z(Dt),Ye("eda_loaded",{bytes:Je.size,view:Je.view,mimeType:Je.mimeType})}).catch(Je=>{K.signal.aborted||(z({kind:"error",message:Je instanceof Error&&/timed out/i.test(Je.message)?o("rightSidebar.edaTimeout"):Je instanceof Error?Je.message:o("rightSidebar.edaLoadFailed")}),Ye("error",{error:Je instanceof Error?Je.message:String(Je)}))})}else if(_n)np(L,K.signal,"view_file",Ee).then(re=>{Oe=URL.createObjectURL(re.blob),z({kind:"image",objectUrl:Oe,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),Ye("image_loaded",{bytes:re.size,mimeType:re.mimeType})}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error?re.message:o("rightSidebar.imageLoadFailed")}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});else if(dr)sp(L,K.signal,"view_file",Ee).then(re=>{K.signal.aborted||(Oe=URL.createObjectURL(re.blob),z({kind:"model3d",sourcePath:re.path||L,objectUrl:Oe,ext:re.ext,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),Ye("model3d_loaded",{bytes:re.size,ext:re.ext}))}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error&&(re.name==="TimeoutError"||/timed out/i.test(re.message))?o("rightSidebar.model3dTimeout"):re instanceof Error?re.message:o("rightSidebar.model3dLoadFailed")}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});else if(Ss){const re=ap(L)??"",Je=tf(L);z(Dt=>Dt.kind==="video"&&Dt.url===Je?Dt:{kind:"video",url:Je,meta:{size:null,mimeType:re,modified:null}}),Ye("video_ready",{mimeType:re})}else Gd(L,K.signal,"view_file",Ee).then(re=>{if(!K.signal.aborted){if(re.binary){z({kind:"binary"});return}z({kind:"text",content:re.content,sourcePath:re.path||L,meta:{size:re.size,truncated:re.truncated}}),Ye("text_loaded",{bytes:re.size,truncated:!!re.truncated})}}).catch(re=>{K.signal.aborted||(z({kind:"error",message:re instanceof Error?re.message:"Failed to read file"}),Ye("error",{error:re instanceof Error?re.message:String(re)}))});return()=>{K.abort(),jt(Ee),window.clearTimeout(dn),window.clearTimeout(js),Oe&&URL.revokeObjectURL(Oe),Ye("cleanup")}},[n,H,Tn,zt,C,o,Z]),a.useEffect(()=>{if(R.kind!=="model3d"||!n){Se(null);return}let L=!1;const K=n.lastIndexOf("/"),be=K>=0?n.slice(K+1):n,Ee=K>=0?n.slice(0,K):"",st=Ee.lastIndexOf("/"),Be=st>=0?Ee.slice(0,st):"",Ye=be.replace(/\.(stl|glb|gltf)$/i,""),Oe=`${Be?`${Be}/`:""}features/${Ye}.json`;return Gd(Oe).then(Xe=>{if(!L)try{const mt=JSON.parse(Xe.content);Se(mt.version===1&&Array.isArray(mt.features)&&mt.features.length>0?mt.features:null)}catch{Se(null)}}).catch(()=>{L||Se(null)}),()=>{L=!0}},[R,n]),a.useEffect(()=>{if(R.kind!=="text"){De(null);return}const L=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,K=mf(L),be=R.content,Ee=Qs(L??"")&&ue==="preview",st=Ys(L??"")&&Ue==="preview";if(!K||Ee||st||!pf(be)){De(null);return}let Be=!1;const Ye=Oe=>{if(Be||!Oe.registered(K)){Be||De(null);return}try{De(bf(Oe,be,K))}catch{De(null)}};return Ke?Ye(Ke):(De(null),gf().then(Oe=>{Be||(M(Oe),Ye(Oe))}).catch(()=>{})),()=>{Be=!0}},[R,Ke,n,H,ue,Ue]),a.useLayoutEffect(()=>{if(!Nt||R.kind!=="text")return;const L=`${Nt}:${ue}:${Ue}`;if(Sr.current===L)return;const K=Gu(H,n);if(Sr.current=L,!K)return;const be=requestAnimationFrame(()=>{const Ee=Me.current;if(!Ee)return;const st=ue==="preview"?K.markdownTop??K.top:K.top;Ee.scrollTo({top:Math.max(0,st??0),left:Math.max(0,K.left??0)}),fe(ue==="preview"?Math.max(0,st??0):0)});return()=>cancelAnimationFrame(be)},[n,ue,Ue,R.kind,Nt,H]),a.useEffect(()=>{Nt&&dl(H,n,{lineRange:$})},[n,$,Nt,H]),a.useEffect(()=>{if(q==null||R.kind!=="text")return;ge(null),C({start:q,end:q});const L=q,K=requestAnimationFrame(()=>{const be=ke.current.get(L);be&&be.scrollIntoView({block:"center"}),j?.()});return()=>cancelAnimationFrame(K)},[q,R,C,j]);const In=a.useCallback(L=>{const K=Me.current;if(!K)return!1;const be=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(L):L.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Ee=K.querySelector(`#${be}`);return Ee?(Ee.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const L=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,K=R.kind==="text"&&Qs(L??"")&&ue==="preview";if(!rt||!K)return;const be=requestAnimationFrame(()=>{In(rt)&&ce(null)});return()=>cancelAnimationFrame(be)},[n,In,ue,rt,R,H]),a.useLayoutEffect(()=>{const L=Me.current;if(!L||!$){ge(null);return}if(Q)return;const K=R.kind==="image"||R.kind==="loading"&&R.mode==="image",be=H&&n&&!n.startsWith("/")?`${H}/${n}`:n,Ee=R.kind==="text"&&Qs(be??"")&&ue==="preview",st=R.kind==="text"&&Ys(be??"")&&Ue==="preview";if(R.kind!=="text"||K||Ee||st){ge(null);return}const Be=()=>{const Oe=ke.current.get($.end);if(!Oe||!L){ge(null);return}const Xe=Oe.offsetTop+Oe.offsetHeight/2,mt=L.scrollLeft+Math.max(8,L.clientWidth-120);ge({top:Xe,left:mt})};Be();const Ye=new ResizeObserver(()=>Be());return Ye.observe(L),()=>Ye.disconnect()},[$,Q,R,ue,Ue,n,H,Ie]);const jr=R.kind==="text"&&!(Ys(Ct??"")&&Ue==="preview")&&!Ct?.toLowerCase().endsWith(".csv")&&!Ct?.toLowerCase().endsWith(".kicad_pro")&&!Ct?.toLowerCase().endsWith(".kicad_prl"),Dn=a.useCallback(()=>{nt(!1),lr(""),ae([]),et(0),xo(I.current)},[]),tn=a.useCallback(()=>{!s||!jr||(nt(!0),requestAnimationFrame(()=>{const L=_.current;!Y.current||!L?.isConnected||L.closest('[inert], [aria-hidden="true"], [hidden]')||L.getClientRects().length===0||getComputedStyle(L).visibility==="hidden"||!L.contains(document.activeElement)||(xt.current?.focus(),xt.current?.select())}))},[s,jr]),Or=a.useCallback(L=>{et(K=>B.length===0?0:(K+L+B.length)%B.length)},[B.length]),Wt=a.useCallback(L=>{if(L.nativeEvent.isComposing||!Db(_.current,s,L))return;const K=Fb(L);if(K==="open"&&jr){L.preventDefault(),tn();return}je&&(K==="close"?(L.preventDefault(),Dn()):(K==="next"||K==="previous")&&(L.preventDefault(),Or(K==="previous"?-1:1)))},[s,Dn,je,Or,tn,jr]);if(a.useLayoutEffect(()=>{if(xo(I.current),!s||!je||!Rt.trim()||!Me.current){ae([]),et(0);return}const L=Bb(Me.current,Rt);return ae(L),et(0),(_.current?.contains(document.activeElement)||Ru(I.current))&&(rl(L,0,I.current),Nu(L[0])),()=>xo(I.current)},[s,je,Rt,Ie,ue,R]),a.useEffect(()=>{!s||!je||!Rt.trim()||!_.current?.contains(document.activeElement)&&!Ru(I.current)||(rl(B,Ce,I.current),Nu(B[Ce]))},[s,Ce,B,je,Rt]),a.useEffect(()=>()=>xo(I.current),[]),!n)return e.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.selectFilePrompt")});const Ve=H&&!n.startsWith("/")?`${H}/${n}`:n,Tt=Eo(Ve,H),Rr=af(Ve,H),Nr=R.kind==="text"&&R.content?R.content.split(`
|
|
1654
|
+
`):[],ga=Math.max(2,String(Nr.length).length)+1,Cr=R.kind==="text"||R.kind==="image"||R.kind==="model3d"||R.kind==="video"||R.kind==="eda"?R.meta:null,Er=Qs(Ve),ba=Ve.toLowerCase().endsWith(".csv"),It=Ve.toLowerCase().endsWith(".kicad_pro"),bs=Ve.toLowerCase().endsWith(".kicad_prl"),Gt=R.kind==="text"&&Er&&ue==="preview",xa=Ys(Ve),Kt=R.kind==="text"&&xa&&Ue==="preview",va=R.kind==="image"||R.kind==="loading"&&R.mode==="image",Go=R.kind==="model3d"||R.kind==="loading"&&R.mode==="model3d",kt=R.kind==="video"||R.kind==="loading"&&R.mode==="video",rn=R.kind==="eda"||R.kind==="loading"&&R.mode==="eda",xs=R.kind==="text"?R.sourcePath:Ve,Ur=$p(xs,H,$),Hr=(()=>{if(!$||R.kind!=="text"||Nr.length===0)return Ur;const L=[];for(let Ee=$.start;Ee<=$.end;Ee+=1)L.push(`${Ee} ${Nr[Ee-1]??""}`);const K=Wf(Ve).replace(/^\./,""),be="```";return`${Ur}
|
|
1655
|
+
${be}${K}
|
|
1656
|
+
${L.join(`
|
|
1657
|
+
`)}
|
|
1658
|
+
${be}
|
|
1659
|
+
`})(),Mr=`path:${Ve}`,$r=$?`path:${Ve}:${$.start}-${$.end}`:Mr,zr=A===Mr,Wr=A===$r,Fn=O===Mr,vs=O===$r,nn=Wr||vs,tr=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,Gr=L=>{const K=Me.current;if(!K)return;const be=K.getBoundingClientRect(),Ee=L.currentTarget.getBoundingClientRect(),st=L.clientX||Ee.left+Ee.width/2,Ye=(L.clientY||Ee.top+Ee.height/2)-be.top+K.scrollTop,Oe=p?116:132,Xe=K.scrollLeft+Math.max(8,K.clientWidth-Oe),mt=Math.min(Math.max(8,st-be.left+K.scrollLeft+10),Xe);ge({top:Ye,left:mt})},ys=(L,K)=>{wl()||(Gr(L),C(be=>{const Ee=kl(be,K,K);return Ee||ge(null),Ee}))},ws=(L,K,be)=>{Gr(L),C(Ee=>{const st=kl(Ee,K,be);return st||ge(null),st})},Pr=(L,K,be,Ee)=>{Ee==="end"&&Gr(L),C({start:K,end:be})},cr=L=>{const{scrollTop:K,scrollLeft:be}=L.currentTarget;fe(K),dl(H,n,{top:K,left:be,markdownTop:K})},ve=L=>{if(L.directory){f?.(L.path);return}if(L.path===Ve||R.kind==="text"&&L.path===R.sourcePath){L.fragment&&In(L.fragment);return}$e(K=>[...K,Ve]),Te.current=L.path,ce(L.fragment),C(null),U(L.path)},rr=()=>{const L=Ne[Ne.length-1];L&&($e(K=>K.slice(0,-1)),Te.current=L,ce(null),C(null),U(L))},sn=L=>{const{scrollTop:K,scrollLeft:be}=L.currentTarget;dl(H,n,{top:K,left:be})},an=L=>{if(r){r(Hr,$r,void 0,L.currentTarget);return}$&&d(Hr,$r,L.currentTarget)},ks=()=>{if(!(R.kind==="loading"||R.kind==="error"))return te.start()};return e.jsxs("div",{ref:_,tabIndex:-1,onKeyDown:Wt,onFocusCapture:()=>{s&&je&&Rt.trim()&&rl(B,Ce,I.current)},onPointerDownCapture:L=>{L.target instanceof Element&&!L.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&L.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[kr.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(Gt||Kt)?"py-1.5":"py-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[p&&g&&e.jsx("button",{type:"button",onClick:g,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:e.jsx(df,{size:16})}),Ne.length>0&&e.jsxs("button",{type:"button",onClick:rr,className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-primary/10 text-primary transition hover:bg-primary/15 active:scale-95 ${p?"w-9":"px-2.5"}`,"aria-label":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[e.jsx(ca,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ve,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Tt.name}),Tt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Tt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[jr&&e.jsx("button",{type:"button",onClick:je?Dn:tn,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${je?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(ms,{size:14})}),Er&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{x&&E?.(),_e(L=>{const K=L==="preview"?"source":"preview";return At($f,K),K}),C(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?ue==="preview"?e.jsx(jl,{size:14}):e.jsx(Sl,{size:14}):o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),xa&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{W(L=>{const K=L==="preview"?"source":"preview";return nb(H,n,K),K}),C(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?Ue==="preview"?e.jsx(jl,{size:14}):e.jsx(Sl,{size:14}):o(Ue==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Kt&&e.jsx("button",{type:"button",onClick:()=>{we.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(uf,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:L=>l(Ve,Mr,L.currentTarget),...kr(Rr,Mr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${zr||Fn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Rr}),children:o(Fn?"rightSidebar.copied":zr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Rr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.copyReference",{reference:Rr}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(op,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ks()},disabled:te.status==="pending"||R.kind==="loading"||R.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:te.status==="error"?te.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(ut,{size:13,className:"animate-spin"}):e.jsx(of,{size:14})}),te.status==="pending"&&e.jsx("button",{type:"button",onClick:te.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),te.status==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",te.error]}),te.status==="canceled"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),te.status==="saved"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),te.status==="started"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),je&&jr&&e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:xt,type:"search",value:Rt,onChange:L=>lr(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),Or(L.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:B.length>0?`${Ce+1}/${B.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Or(-1),disabled:B.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Ol,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Or(1),disabled:B.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Pp,{size:13})}),e.jsx("button",{type:"button",onClick:Dn,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Lt,{size:13})})]}),Cr&&!(p&&(Gt||Kt))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Cr.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Cr.size.toLocaleString()})}),"truncated"in Cr&&Cr.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Cr&&e.jsx("span",{children:Cr.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(Gt||Kt))&&!Go&&R.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:rn?o("rightSidebar.edaPickHint"):ba?o("rightSidebar.csvTablePreview"):It||bs?o("rightSidebar.kicadProjectPickHint"):kt?o("rightSidebar.videoPreviewHint"):va?o("rightSidebar.imagePreviewHint"):Gt?$?o("rightSidebar.selectedLineHint",{lineLabel:tr??""}):o("rightSidebar.markdownPreviewHint"):Kt?o("rightSidebar.htmlPreviewHint"):$?o("rightSidebar.selectedLineHint",{lineLabel:tr??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||Kt)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(qi,{label:R.mode==="eda"?o("rightSidebar.edaLoading"):R.mode==="image"?o("rightSidebar.loadingImage"):R.mode==="model3d"?o("rightSidebar.model3dLoading"):R.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):R.kind==="error"?e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[e.jsx("div",{className:"mx-3 mt-3 border border-destructive/20 bg-destructive/5 px-4 py-4 text-sm text-destructive",children:R.message}),e.jsx("button",{type:"button",onClick:er,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):R.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:o("rightSidebar.binaryPreviewHint")})}):R.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:R.meta.mimeType==="image/svg+xml"?e.jsx(Rf,{blobUrl:R.objectUrl,filePath:Ve,viewLabel:"SVG 文件",onInsertAnnotation:r??c}):e.jsx(Eh,{src:R.objectUrl,alt:Tt.name,vector:!1,onLoad:L=>{const K=L.currentTarget;z(be=>be.kind==="image"?{...be,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:be)},onError:()=>z({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):R.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(mb,{url:R.url,onLoadError:()=>z({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):R.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(wb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Ve.toLowerCase().endsWith(".kicad_pcb"),onViewChange:P,onInsertAnnotation:r??c,onRefresh:er,interactive3d:G?e.jsx(a.Suspense,{fallback:e.jsx(qi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Lu,{blobUrl:G.objectUrl,ext:".glb",fileName:Tt.name,filePath:G.sourcePath,features:null,onInsertFeature:r??c,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:L=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(L)?L:"PCB板体/铜箔/丝印",active:R.view==="pcb-3d"})}):void 0})}):R.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx(qi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Lu,{blobUrl:R.objectUrl,ext:R.ext,fileName:Tt.name,filePath:R.sourcePath,features:pe,onInsertFeature:r??c,onRefresh:er})})}):R.kind==="text"&&ba?e.jsx(jb,{content:R.content,filePath:Ve,onInsertAnnotation:r??c},Ve):R.kind==="text"&&(It||bs)?e.jsx(Cb,{content:R.content,filePath:Ve,localState:bs,onInsertAnnotation:r??c},Ve):Gt?e.jsxs("div",{ref:Me,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:cr,style:{touchAction:"pan-x pan-y"},children:[e.jsx(xh,{content:R.content,filePath:R.sourcePath,rootPath:H,lineRange:$,onLineRangeClick:ws,onLineRangeDrag:Pr,scrollTop:he,outlineOpen:x,outlineCloseSignal:h,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:S,lightboxCloseSignal:T,onLightboxOpen:D,onLightboxClose:F,onLocalLinkOpen:ve}),$&&Q&&e.jsxs("button",{type:"button",onClick:an,...kr(Hr,$r),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:fu(p,nn),title:`Insert markdown reference: ${Ur}`,children:[e.jsx(Ao,{size:p?13:11}),vs?o("rightSidebar.copied"):Wr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:tr??""})]})]}):Kt?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Ib,{ref:we,src:ip(Ve),title:`${Tt.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:He},`${Ve}:${Tn}:${zt}`)}):R.kind==="text"?e.jsxs("div",{ref:Me,onScroll:sn,className:`${zl} termdock-native-select termdock-code relative min-h-0 flex-1 overflow-auto rounded-none bg-surface p-2 font-mono text-[11px] leading-relaxed text-foreground`,children:[Nr.length>0?e.jsx("div",{className:"min-w-full",children:Nr.map((L,K)=>{const be=K+1,Ee=!!($&&be>=$.start&&be<=$.end),st=Ie&&Ie.length===Nr.length?Ie[K]:null;return e.jsxs("div",{ref:Be=>{Be?ke.current.set(be,Be):ke.current.delete(be)},role:"button","data-file-preview-line":be,tabIndex:0,onClick:Be=>ys(Be,be),onKeyDown:Be=>{Be.key!=="Enter"&&Be.key!==" "||(Be.preventDefault(),ys(Be,be))},style:{gridTemplateColumns:`${ga}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Ee?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Rr}:${be}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Ee?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:be}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:st??(L||" ")})]},K)})}):"Empty file.",$&&Q&&e.jsxs("button",{type:"button",onClick:an,...kr(Hr,$r),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:fu(p,nn),title:`Insert code reference: ${Ur}`,children:[e.jsx(Ao,{size:p?13:11}),vs?o("rightSidebar.copied"):Wr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:tr??""})]})]}):null]})}function w0({rootPath:r,file:n,active:s,...l}){const[d,c]=a.useState(null),[m,g]=a.useState(n.line??1),f=a.useCallback(()=>g(null),[]);return e.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:e.jsx(Uo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:d,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:f,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function k0({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:f=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:x,onCloseRightSidebarFilePreview:h,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:E,onOpenRightSidebarRepoPicker:S,onCloseRightSidebarRepoPicker:T,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:C,markdownImageLightboxOpen:A=!1,markdownImageLightboxCloseSignal:O,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j}){const{t:o,locale:_}=ht(),[I,Y]=a.useState(""),H=V(t=>t.pendingTerminalPath),[U,R]=a.useState(null),z=a.useRef(0),Z=V(t=>t.rightSearchOpen),P=V(t=>t.setRightSearchOpen),G=V(t=>t.rightSidebarLayoutPreference),J=V(t=>t.setRightSidebarLayoutPreference),[ie,pe]=a.useState(()=>mx()),[Se,ke]=a.useState("."),[Me,Q]=a.useState(""),[ge,ue]=a.useState(!1),[_e,Ue]=a.useState(!1),[W,we]=a.useState(!1),[ye,He]=a.useState(!1),Ke=a.useDeferredValue(I),[M,he]=a.useState(null),[fe,Ne]=a.useState([]),[$e,rt]=a.useState([]),ce=V(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Te=V(t=>t.setActiveGitRepo),[qe,Ie]=a.useState(null),[De,te]=a.useState(null),[je,nt]=a.useState(null),[Rt,lr]=a.useState(!1),[B,ae]=a.useState(()=>gt(Eu,sa)??!1),[Ce,et]=a.useState(()=>gt(Mu,sa)??!1),[xt,kr]=a.useState(()=>gt($u,sa)??!1),[Nt,Ct]=a.useState(()=>gt(al,cx)??""),[Tn,gs]=a.useState(0),[Sr,zt]=a.useState(!1),[en,er]=a.useState(!1),In=a.useRef(null),jr=a.useRef(null),[Dn,tn]=a.useState(!1),[Or,Wt]=a.useState(null),[Ve,Tt]=a.useState(null),[Rr,Nr]=a.useState(()=>Iu(nl)),[ga,Cr]=a.useState(()=>Iu(Cu)),[Er,ba]=a.useState(()=>lx()),[It,bs]=a.useState(()=>dx()),[Gt,xa]=a.useState(()=>fx()),Kt="words",[va,Go]=a.useState(0),[kt,rn]=a.useState([]),[xs,Ur]=a.useState([]),[Hr,Mr]=a.useState(!1),[$r,zr]=a.useState(null),[Wr,Fn]=a.useState([]),[vs,nn]=a.useState(!1),[tr,Gr]=a.useState([]),[ys,ws]=a.useState([]),[Pr,cr]=a.useState(!1),[ve,rr]=a.useState(null),[sn,an]=a.useState([]),[ks,L]=a.useState({}),K=a.useRef(0),[be,Ee]=a.useState(0),[st,Be]=a.useState(!1),[Ye,Oe]=a.useState(null),[Xe,mt]=a.useState(null),[_n,dr]=a.useState(null),[Ss,on]=a.useState(null),[ln,Kr]=a.useState(!1),[cn,dn]=a.useState(""),js=a.useDeferredValue(cn),[re,Je]=a.useState({}),[Dt,ur]=a.useState([]),[ya,Rs]=a.useState(!1),[wa,Ns]=a.useState(!1),[Ko,Bn]=a.useState(null),[qo,On]=a.useState(!1),fr=a.useRef(null),qr=a.useRef(0),ec=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Mh,ka]=a.useState(null),[Cs,tc]=a.useState(()=>gt(sl,sa)??!1),[Vo,Yo]=a.useState(!1),[Sa,Xo]=a.useState([]),[nr,ja]=a.useState({}),[Et,Ra]=a.useState({}),[un,Jo]=a.useState({}),[rc,nc]=a.useState(()=>new Set),[Qe,fn]=a.useState(null),[Qo,hn]=a.useState(null),[$h,Ar]=a.useState(!1),[Zo,Lr]=a.useState(0),[,ei]=a.useState(0),[ti,Na]=a.useState(!1),[Ph,Ah]=a.useState(()=>V.getState().rightTab==="files"),[sr,ri]=a.useState(!1),[Lh,sc]=a.useState(()=>V.getState().rightTab==="diff"),[ni,ac]=a.useState(()=>V.getState().rightTab==="android"),[Vr,oc]=a.useState(!1),[ar,ic]=a.useState({architecture:!1,computer:!1}),Es=a.useRef(new Set),Ca=Vi(t=>t.docks[Xi]),Th=!!Ca,[We,Ms]=a.useState(null),[Un,$s]=a.useState(null),[vt,mn]=a.useState(null),[lc,qt]=a.useState(null),[Hn,cc]=a.useState(null),[si,Ih]=a.useState(()=>Date.now()),[Dh,Fh]=a.useState(!1),[pn,Ea]=a.useState(!1),[Ma,dc]=a.useState(""),[zn,$a]=a.useState(""),[gn,Pa]=a.useState(""),[bn,Aa]=a.useState(""),[uc,Wn]=a.useState(null),[fc,ai]=a.useState(!1),[hc,mc]=a.useState(!1),[La,_h]=a.useState({key:null,nonce:0}),pc=a.useRef(null),gc=a.useRef(null),se=vp(s,m,G),oi=Of(se,m,Gt),[ii,li]=a.useState(()=>wx(s)),ci=V(t=>t.rightTab),Ft=V(t=>t.setRightTab),v=V(t=>t.rootPath),Gn=V(t=>t.explorerRoot),bc=V(t=>t.pinnedExplorerRootsCache),xc=V(t=>t.hydratePinnedExplorerRoots),vc=V(t=>t.syncPinnedExplorerRoots),_t=V(t=>t.setExplorerRoot),yc=V(t=>t.resetExplorerToProject),Kn=V(t=>t.pinExplorerRoot),xn=V(t=>t.unpinExplorerRoot),ot=V(t=>t.selectedFilePath),it=V(t=>t.selectFile),di=V(t=>t.showHiddenFiles),Bh=V(t=>t.toggleShowHiddenFiles),ui=V(t=>!!(v&&t.nestedGitScanRoots[v])),Fe=V(t=>t.changedFiles),Ta=V(t=>t.setChangedFiles),Ps=V(t=>t.invalidateDirectoryCache),Oh=V(t=>t.setDirectorySortMode),wc=V(t=>t.applyFileWatchEvents),kc=V(t=>t.reconcileDirectoryCache),Sc=V(t=>t.bumpFileWatchEpoch),hr=V(t=>t.gitBundleLoading),jc=V(t=>t.gitBundleSlow),vn=V(t=>t.gitBundleError),qn=V(t=>t.gitBundleLastLoadedAt),Rc=V(t=>t.beginGitBundleLoading),Nc=V(t=>t.setGitBundleSlowFor),fi=V(t=>t.finishGitBundleLoading),Ia=V(t=>t.resetGitBundleLoading),hi=V(t=>t.setGitBundleError),Cc=V(t=>t.markGitBundleLoaded),le=Gn??v,Da=V(t=>!!(le&&t.hideGitIgnoredRoots[le])),Uh=V(t=>t.hideGitIgnoredRootsHydrated),Hh=V(t=>t.setHideGitIgnoredRoot),[mi,Ec]=a.useState(!1),[Mc,pi]=a.useState(null);a.useEffect(()=>{pi(null)},[le]);const $c=a.useMemo(()=>le?Ub(le,Se):"",[le,Se]),As=a.useMemo(()=>Ob(Me),[Me]),Pc=a.useMemo(()=>({excludePatterns:As,caseSensitive:_e,wholeWord:W,regex:ye}),[_e,As,ye,W]),Fa=V(t=>le?t.fileSortModes[le]??"name":"name"),Ac=V(t=>!!(le&&t.directoryCache.has(le))),Vn=a.useRef(null),St=a.useRef(0),[Lc]=a.useState(()=>++p0),Tr=a.useRef(null),Yr=a.useRef(null),_a=a.useRef(0),Vt=a.useRef(new Map),Yt=a.useRef(new Map),mr=a.useRef(new Set),yn=a.useRef(new Set),wn=a.useRef(0),Xr=a.useRef(null),Yn=a.useRef(0),Xn=a.useRef(null),Jn=a.useRef(0),Jr=a.useRef(null),gi=a.useRef(new Set),bi=a.useRef(null),xi=a.useRef(null),Ba=a.useRef(null),vi=a.useRef(null),yi=a.useRef(null),Ls=a.useRef(new Set);a.useEffect(()=>{if(Hn===null)return;const t=Math.max(0,Date.now()-Hn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,u=Math.max(50,i-t%i),w=window.setTimeout(()=>Ih(Date.now()),u);return()=>window.clearTimeout(w)},[si,Hn]);const Oa=a.useRef(null),Ir=a.useRef(null),wi=a.useRef(null),Tc=a.useRef(null),Ts=a.useRef(null),Pe=a.useCallback(t=>V.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=i=>{const u=v0(i.target);u&&ta("global_change_row_event",{...y0(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:V.getState().selectedFilePath,rightTab:V.getState().rightTab,activeGitRepoRoot:ce,changedFiles:V.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const Ic=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(mr.current.has(t)||yn.current.has(t))return dt("untracked_skip_cached",{cwd:t,rootPath:v,completed:mr.current.has(t),running:yn.current.has(t)}),null;const i=v,u=_a.current+1;_a.current=u,Vt.current.set(t,u);const w=`right-sidebar-git-untracked:${t}`,y=new AbortController;Yt.current.set(t,y),yn.current.add(t),dt("untracked_start",{requestId:u,cwd:t,rootPath:v});try{let k=await Kd(t,y.signal,w),N=0;for(;k.status==="running"&&N<120;){if(Vt.current.get(t)!==u||y.signal.aborted)return dt("untracked_stale_result",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,status:k.status}),null;if(!Pe(i))return dt("untracked_root_changed",{requestId:u,cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath}),null;await new Promise(oe=>window.setTimeout(oe,N<10?1e3:3e3)),N+=1,k=await Kd(t,y.signal,w)}if(Vt.current.get(t)!==u||!Pe(i))return dt("untracked_stale_result",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return Ta(kh(V.getState().changedFiles,k.files)),k.files.length>0&&Ne(oe=>{const Ae=new Map(oe.map(me=>[me.root,me])).get(t);if(!Ae)return oe;const Ze=n0(Ae.files,k.files),ee=oe.map(me=>me.root===t?{...me,files:Ze,context:me.context?{...me.context,changedFiles:Ze.map(Le=>({path:Le.path,absolutePath:Le.absolutePath,status:Le.status})),truncated:!1}:me.context,untrackedDeferred:!1}:me);rt(Sh(ee,v));const X=ee.find(me=>me.root===v);return X?.context&&he(me=>me?.root===X.root?{...me,...X.context}:me),ee}),mr.current.add(t),dt("untracked_apply",{requestId:u,cwd:t,files:k.files.length}),k;const ne=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return mr.current.add(t),dt("untracked_error",{requestId:u,cwd:t,message:ne,code:k.code,status:k.status}),null}catch(k){if(Vt.current.get(t)!==u||!Pe(i)||yr(k))return dt("untracked_aborted",{requestId:u,activeRequestId:Vt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const N=k instanceof Error?k.message:"Failed to scan untracked files";return mr.current.add(t),dt("untracked_error",{requestId:u,cwd:t,message:N}),null}finally{Yt.current.get(t)===y&&Yt.current.delete(t),Vt.current.get(t)===u&&Vt.current.delete(t),yn.current.delete(t)}},[M,Pe,v,Ta]),or=a.useMemo(()=>{const t=new Set($e.map(u=>u.root)),i=Wr.filter(u=>t.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Wr,$e]),Dc=or.length===0,kn=a.useMemo(()=>or.map(t=>fe.find(i=>i.root===t)).filter(t=>!!t),[or,fe]),zh=a.useMemo(()=>$e.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[$e]),pr=a.useCallback(async()=>{if(!v){rn([]),Ur([]);return}const t=v,i=Yn.current+1;Yn.current=i,Xn.current?.abort();const u=new AbortController;Xn.current=u,Mr(kt.length===0),zr(null);try{const w=or.length>0?await Promise.all(or.map(y=>qd({workspaceRoot:v,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(k=>k.records),walkthroughs:y.flatMap(k=>k.walkthroughs??[])})):await qd({workspaceRoot:v},u.signal);if(Yn.current!==i||!Pe(t))return;rn(w.records),Ur(w.walkthroughs??[])}catch(w){if(Yn.current!==i||!Pe(t)||yr(w))return;zr(w instanceof Error?w.message:"Failed to load change audit explanations")}finally{Xn.current===u&&(Xn.current=null),Yn.current===i&&Pe(t)&&Mr(!1)}},[kt.length,or,Pe,v]),Ua=a.useCallback(async(t,i,u)=>{if(!t&&!v){Gr([]),ws([]);return}const w=v,y=Jn.current+1;Jn.current=y,Jr.current?.abort();const k=new AbortController;Jr.current=k;try{const N=t?[t]:Array.from(new Set([v,...fe.map(oe=>oe.root)].filter(oe=>!!oe))),ne=await Promise.all(N.map(oe=>cp({repoRoot:oe,baseRef:i,branchName:u},k.signal))).then(oe=>{const xe=new Map,Ae=new Map;for(const Ze of oe){for(const ee of Ze.records)xe.set(ee.id,ee);for(const ee of Ze.walkthroughs??[])Ae.set(ee.id,ee)}return{records:Array.from(xe.values()),walkthroughs:Array.from(Ae.values())}});if(Jn.current!==y||!Pe(w))return;Gr(ne.records),ws(ne.walkthroughs??[])}catch(N){if(Jn.current!==y||!Pe(w)||yr(N))return;console.warn("[RightSidebar] Failed to load branch explanations",N)}finally{Jr.current===k&&(Jr.current=null)}},[fe,Pe,v]),Qn=a.useCallback((t,i={})=>{if(!Pe(v)){dt("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:V.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}dt(t.files.length===0?"empty_bundle":"apply",{rootPath:v,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let u=Uf(t),w=t.repoFilters??[],y=t.files;const k=V.getState().changedFiles;if(!!(i.cacheOnly&&!t.cached&&t.files.length===0&&u.length===0)&&(k.size>0||fe.length>0||M)){dt("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:fe.length});return}const ne=u.some(X=>X.deferred);if(ne&&!i.replaceWorkspace){const X=new Set(u.filter(Le=>!Le.deferred||Le.root===v).map(Le=>Le.root));y=[...Array.from(k.values()).filter(Le=>!X.has(bt(Le,v)??"")),...t.files]}const oe=Ku(k.values(),v),xe=Ku(t.files,v),Ae=u.some(X=>X.root!==v);if(!!(i.background&&!ne&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||oe>0&&xe===0&&!Ae))){dt("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:oe,nextNestedCount:xe,nextRepositories:u.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(i.replaceRepoRoot){const X=jh(k.values(),fe,t,i.replaceRepoRoot,v);y=X.files,u=X.repositories,w=X.repoFilters}if(Ta(wh(y)),Ne(X=>{if(!ne||i.replaceWorkspace)return u;const me=new Map(X.map(Le=>[Le.root,Le]));return u.map(Le=>{const Ge=me.get(Le.root);return!Le.deferred||!Ge?Le:{...Le,available:Ge.available,files:Ge.files,context:Ge.context,deferred:Ge.deferred,untrackedDeferred:Ge.untrackedDeferred,error:Ge.error}})}),rt(w),yi.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:me}=V.getState(),Le=X?me[X]??null:null,Ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:Le,ze=px({...t,repositories:u,repoFilters:w},Ge);Te(ze)}typeof t.cacheUpdatedAt=="number"&&cc(t.cacheUpdatedAt),he(X=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==v)return X;if(!t.context)return null;const me=X?.root??v;return!X?.available||me!==(t.context.root??v)?t.context:{...X,...t.context}}),i.reloadDiff&&Go(X=>X+1);const ee=V.getState().selectedFilePath;if(ee&&!ee.startsWith("/")&&!y.some(X=>X.path===ee||X.absolutePath===ee)&&it(null),Nr(X=>{const me=new Set(y.map(Ge=>bt(Ge,v)).filter(Boolean)),Le=new Set;for(const Ge of X)me.has(Ge)&&Le.add(Ge);return il(nl,Le),Le}),i.loadDeferred!==!1){const X=u.filter(me=>me.untrackedDeferred&&me.root).map(me=>me.root);for(const me of X)Ic(me)}i.loadAudit!==!1&&pr()},[Pe,pr,Ic,v,it,Te,Ta]);a.useEffect(()=>{Ia(),bi.current=null,xi.current=v;const t=[],i=[];St.current+=1,wn.current+=1,_a.current+=1,Tr.current?.abort(),jt(Zs(Yr.current?.cwd??v??void 0)),Yr.current=null,Tr.current=null,Xr.current?.abort(),jt("right-sidebar-git-details"),Xr.current=null;for(const N of Yt.current.values())N.abort();for(const N of Yt.current.keys())jt(`right-sidebar-git-untracked:${N}`);Yt.current.clear(),Vt.current.clear(),Yn.current+=1,Xn.current?.abort(),Xn.current=null,Jn.current+=1,Jr.current?.abort(),Jr.current=null,qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,rn([]),Ur([]),Mr(!1),zr(null),Fn([]),nn(!1),Gr([]),ws([]),cr(!1),rr(null),Be(!1),Oe(null),mt(null),dr(null),on(null),Kr(!1),dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1),ka(null),fn(null),hn(null),tc(!1),At(sl,!1),Yo(!1);const u=v?Du()[v]:null,w=u?.previewEntries??[],y=u?.selectedPreviewKey??null,k=y?w.find(N=>N.key===y)??null:null;++K.current,Be(!1),Xo(u?.selectedRepoRoots??[]),ja(u?.repoTargetBranches??{}),Ra(u?.repoBaseBranches??{}),an(w),L(u?.previewScrollTops??{}),k&&u?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(rr(k.diff),fn(k.key),hn(u.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),cr(!0)),Jo(u?.repoIncludeUncommitted??Object.fromEntries(Object.keys(u?.repoTargetBranches??{}).map(N=>[N,u?.includeUncommitted??!0]))),bi.current=v,Ea(!1),mr.current.clear(),yn.current.clear(),Ms(null),$s(null),mn(null),qt(null),cc(null),Ne(t),rt(i),he(null),vi.current=null,yi.current=null,Ls.current.clear()},[Ia,v]);const Bt=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const u=v,w=St.current;if(await vg(()=>Promise.all([V.getState().hydrateNestedGitScanRoots(),V.getState().hydrateActiveGitRepos()]).then(()=>{})),St.current!==w||!Pe(u))return null;const y=t===v&&Js(v),k=i.includeNested??y,N=i.refresh??i.reloadDiff??!1,ne=i.cacheOnly??!1,oe=i.background??!1,xe=k&&(i.discoverOnly??!1);N&&mr.current.clear();const Ae=Yr.current;if(Ae&&Ae.cwd===t&&Ae.includeNested===k&&Ae.refresh===N&&Ae.cacheOnly===ne&&Ae.discoverOnly===xe)return dt("reuse_pending",{cwd:t,includeNested:k,refresh:N,cacheOnly:ne,discoverOnly:xe}),Ae.promise;const Ze=St.current+1;St.current=Ze;const ee=`right-sidebar:${Lc}:${Ze}`;Tr.current?.abort();const X=Zs(t);jt(X);const me=new AbortController;Tr.current=me;let Le=null;oe||Rc(ee),hi(null),dt("start",{requestId:Ze,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:N,cacheOnly:ne,background:oe,existingChanges:Fe.size,lastLoadedAt:qn}),!oe&&typeof window<"u"&&(Le=window.setTimeout(()=>{St.current===Ze&&Nc(ee,!0)},Xb));const Ge=(async()=>{const ze=await Yi(t,me.signal,{includeNested:k,refresh:N,cacheOnly:ne,discoverOnly:xe,action:N?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:N?null:void 0});if(o0(ze)){if(dt("cancelled_result_ignored",{requestId:Ze,activeRequestId:St.current,cwd:t,error:ze.error??ze.context?.error}),me.signal.aborted)return null;throw new Error(ze.error??ze.context?.error??"Failed to load Git changes")}return St.current!==Ze||!Pe(u)?(dt("stale_result",{requestId:Ze,activeRequestId:St.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,files:ze.files.length,repositories:ze.repositories?.length??0}),null):(Qn(ze,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:oe,cacheOnly:ne,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),ze)})();Yr.current={cwd:t,includeNested:k,refresh:N,cacheOnly:ne,discoverOnly:xe,promise:Ge};try{const ze=await Ge;return St.current===Ze&&ze&&Pe(u)?Cc({cached:ze.cached,stale:ze.stale,cacheAgeMs:ze.cacheAgeMs,nestedDeferred:!k||ze.nestedDeferred,untrackedDeferred:ze.untrackedDeferred}):St.current===Ze&&Pe(u)&&fi(ee),ze}catch(ze){return St.current!==Ze||!Pe(u)||me.signal.aborted?(dt("aborted",{requestId:Ze,activeRequestId:St.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,message:ze instanceof Error?ze.message:String(ze)}),null):(dt("error",{requestId:Ze,cwd:t,includeNested:k,refresh:N,background:oe,message:ze instanceof Error?ze.message:String(ze)}),oe||(he(null),hi(ze instanceof Error?ze.message:"Failed to load Git changes")),null)}finally{Le!==null&&window.clearTimeout(Le),Tr.current===me&&(Tr.current=null),Yr.current?.promise===Ge&&(Yr.current=null),!oe&&St.current===Ze&&Pe(u)&&fi(ee)}},[Qn,Rc,Fe.size,fi,Lc,qn,Pe,Cc,v,hi,Nc]),Zn=a.useCallback(async()=>{v&&await Bt(v,{reloadDiff:!0,refresh:!0})},[Bt,v]),ki=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,u=wn.current+1;wn.current=u,Xr.current?.abort(),jt("right-sidebar-git-details");const w=new AbortController;Xr.current=w,Ea(!0);try{const y=await Vd(t,w.signal,"load_git_details","right-sidebar-git-details");return wn.current!==u||!Pe(i)?null:(Ne(k=>k.map(N=>N.root===y.root?{...N,available:y.available,context:y,error:y.error}:N)),he(k=>k?.root&&y.root&&k.root!==y.root?k:!k?.available||!y.available?y:{...k,...y}),y)}catch(y){return yr(y)||!Pe(i)||wn.current===u&&qt(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Xr.current===w&&(Xr.current=null),wn.current===u&&Pe(i)&&Ea(!1)}},[Pe,v]);a.useEffect(()=>{if(!r){St.current+=1,Ia(),vi.current=null,wn.current+=1,_a.current+=1,Tr.current?.abort(),jt(Zs(Yr.current?.cwd??v??void 0)),Yr.current=null,Tr.current=null,Xr.current?.abort(),jt("right-sidebar-git-details"),Xr.current=null;for(const t of Yt.current.values())t.abort();for(const t of Yt.current.keys())jt(`right-sidebar-git-untracked:${t}`);Yt.current.clear(),Vt.current.clear(),Jn.current+=1,Jr.current?.abort(),Jr.current=null,qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,Ea(!1),Be(!1),Oe(null),mt(null),dr(null),on(null),Kr(!1),dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1),Y(""),P(!1),Wt(null),ri(!1),se&&sc(!1)}},[se,r,Ia,P]),a.useEffect(()=>{if(!Z)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[Z]),a.useEffect(()=>{se||Ar(!1)},[se]);const Fc=a.useCallback(t=>{ei(t);const i=wi.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(se)if(Ar(f),f&&ot){Lr(1);const t=Ir.current;t&&(t.update(),t.activeIndex!==1&&(Ts.current=1,t.slideTo(1,0)))}else{Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Wt(null)}},[se,f,v,ot]),a.useEffect(()=>{if(p!==void 0&&!f){Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ar(!1),Wt(null)}},[p,f]),a.useEffect(()=>{E!==void 0&&Ie(null)},[E]),a.useEffect(()=>{!se&&f&&h?.()},[se,h,f]),a.useEffect(()=>{li(t=>Al(t,s))},[s]);const Wh=a.useCallback(t=>{se||(t.preventDefault(),Oa.current={startX:t.clientX,startWidth:ii,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[ii,se]),Gh=a.useCallback(t=>{const i=Oa.current;if(!i||i.pointerId!==t.pointerId)return;const u=Al(i.startWidth+t.clientX-i.startX,s);li(u),aa(na,u,Yb)},[s]),_c=a.useCallback(t=>{const i=Oa.current;if(!(!i||i.pointerId!==t.pointerId)){Oa.current=null,Xs(na);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),es=!!(v&&qn!==null&&Yu(M)),Si=!!(v&&!vn&&Fe.size===0&&qn===null),Mt=(()=>{let t=ci;return t==="android"&&!Vr&&(t="files"),(t==="architecture"||t==="computer")&&!ar[t]&&(t="files"),es&&(t==="git"||t==="diff")&&(t="files"),t})(),ct=Mt==="git",Dr=Mt==="files",$t=Mt==="diff",ts=Mt==="android",rs=Mt==="computer",Sn=Mt==="architecture",[Kh,qh]=a.useState(!1);a.useEffect(()=>{r&&rs&&qh(!0)},[r,rs]);const[Vh,Yh]=a.useState(!1);a.useEffect(()=>{r&&Sn&&Yh(!0)},[r,Sn]);const ji=a.useRef(null),ns=a.useCallback((t,i)=>{const u=V.getState().rightTab;if(u===t)return;const w=performance.now(),y=w-i.timeStamp;ji.current={from:u,to:t,startedAt:w,inputDelayMs:y>=0&&y<6e4?Math.round(y):null},Ft(t)},[Ft]);a.useEffect(()=>{const t=ji.current;if(!t||t.to!==Mt)return;ji.current=null;const i=Math.round(performance.now()-t.startedAt);let u=window.requestAnimationFrame(()=>{u=window.requestAnimationFrame(()=>{ta("tab_switch_presented",{from:t.from,to:t.to,inputDelayMs:t.inputDelayMs,commitMs:i,frameMs:Math.round(performance.now()-t.startedAt)})})});return()=>window.cancelAnimationFrame(u)},[Mt]);const Xh=Ap(t=>t.overlay==="sidebar")&&ts;a.useEffect(()=>{if(!se){Na(!0);return}if(!r){const i=window.setTimeout(()=>{Na(!1)},Zb);return()=>window.clearTimeout(i)}Na(!1);const t=window.setTimeout(()=>{Na(!0)},Qb);return()=>window.clearTimeout(t)},[se,r]),a.useEffect(()=>{if(!se||!$t)return;const t=wi.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[$t,se]),a.useEffect(()=>{if(!es||!v||hr)return;const t=window.setTimeout(()=>{Bt(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[es,v,hr,Bt]);const Jh=a.useCallback(t=>{Bt(t,{discoverOnly:!0})},[Bt]);yg({active:r&&(ct||$t),rootPath:v,loading:hr,delay:ct&&!se?0:ol,lastStartedRoot:vi,load:Jh}),a.useEffect(()=>{!r||!ct||(!se||ti)&&ri(!0)},[ct,se,r,ti]),a.useEffect(()=>{if(!r||ct)return;const t=window.setTimeout(()=>{ri(!0)},ol);return()=>window.clearTimeout(t)},[ct,r]),a.useEffect(()=>{Dr&&Ah(!0)},[Dr]),a.useEffect(()=>{$t&&sc(!0)},[$t]),a.useEffect(()=>{!r||!ts||(n&&Ca&&Ca.sessionId!==n&&(Vi.getState().setDock(Xi,null),ra({androidPanel:{docked:null}}).catch(()=>{})),ac(!0))},[ts,r,n,Ca]),a.useEffect(()=>{if(r&&ts||!ni)return;const t=window.setTimeout(()=>ac(!1),Jb);return()=>window.clearTimeout(t)},[r,ts,ni]),a.useEffect(()=>{let t=!1;return Zu().then(i=>{t||(Es.current.has("android")||oc(i.androidPanel?.enabled===!0),ic(u=>({architecture:Es.current.has("architecture")?u.architecture:i.rightSidebarTabs?.architecture===!0,computer:Es.current.has("computer")?u.computer:i.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{t=!0}},[]);const Bc=a.useCallback(t=>{Es.current.add("android"),oc(t),t?Ft("android"):V.getState().rightTab==="android"&&Ft("files"),ra({androidPanel:{enabled:t}}).catch(()=>{})},[Ft]),Qh=a.useCallback((t,i)=>{Es.current.add(t),ic(u=>({...u,[t]:i})),i?Ft(t):V.getState().rightTab===t&&Ft("files"),ra({rightSidebarTabs:{[t]:i}}).catch(()=>{})},[Ft]),Oc=a.useCallback(t=>{le&&Qx(le,t.currentTarget.scrollTop)},[le]);a.useEffect(()=>()=>{Tr.current?.abort(),Xs(Ul),Xs(Hl),Xs(na),Xs(al)},[]),a.useEffect(()=>{if(!le||!Ac)return;const t=vh()[le]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Vn.current&&(Vn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Vn.current&&(Vn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[le,Ac]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return dp(t.signal).then(i=>mc(!!i.available)).catch(()=>mc(!1)),()=>t.abort()},[r]);const Is=a.useCallback(t=>{if(R(null),it(t),Wt(null),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,it]),Ri=a.useCallback((t,i)=>{if(R(null),it(t),Tt(i),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,it]),Ot=Qg(t=>Ps(t,!1)),Ha=Ot.busy,Ds=a.useCallback(async(t,i)=>{const u=i||Gn||v;!u||!t.length||await Ot.start(u,t)},[Gn,v,Ot.start]),Uc=a.useCallback(async t=>{try{await up(t)}catch(i){qt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>qt(null),4e3)}},[o]),za=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&ai(!0)},[]),Hc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ai(!1)},[]),zc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ai(!1);const i=t.dataTransfer.files;i.length>0&&Ds(Array.from(i))},[Ds]),Ni=a.useCallback(t=>{te(t),window.setTimeout(()=>te(i=>i===t?null:i),1400)},[]),gr=a.useCallback(t=>{nt(t),window.setTimeout(()=>nt(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{At(Eu,B)},[B]),a.useEffect(()=>{At(Mu,Ce)},[Ce]),a.useEffect(()=>{At($u,xt)},[xt]),a.useEffect(()=>{aa(al,Nt,Wb)},[Nt]),a.useEffect(()=>(xc().catch(()=>{}),Yd(t=>{t.type==="pinned-explorer-roots"&&vc(t.pinnedExplorerRoots)})),[xc,vc]);const Wc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Wa=a.useRef(null),jn=a.useRef(null),[Gc,Ci]=a.useState(!1);a.useEffect(()=>{if(!r)return;Ci(!1);let t=!1;fp().then(u=>{t||(Wa.current=u.text,Ct(w=>u.text&&u.text!==w?u.text:w),Ci(!0))}).catch(()=>{t||Ci(!0)});const i=Yd(u=>{u.type==="context-draft"&&u.origin!==Wc.current&&(Wa.current=u.text,Ct(u.text))});return()=>{t=!0,i(),jn.current!==null&&(window.clearTimeout(jn.current),jn.current=null)}},[r]),a.useEffect(()=>{if(!Gc||Wa.current===Nt)return;jn.current!==null&&window.clearTimeout(jn.current);const t=Nt;jn.current=window.setTimeout(()=>{jn.current=null,hp(t,Wc.current).then(()=>{Wa.current=t}).catch(()=>{})},500)},[Nt,Gc]);const ss=a.useCallback(async(t,i,u,w)=>{if(!t)return!1;if(lr(!1),w&&!Ji(w)())return lr(!0),!1;if(mp(u?t+u:t))return Ni(i),!0;if(B)Ct(y=>Yg(y,t)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(et(!1),gs(y=>y+1));else{const y=n??Qr.getState().activeSessionId;if(!await sf(u?t+u:t,y,()=>_s.current&&y===Qr.getState().activeSessionId,w))return lr(!0),!1}return Ni(i),!0},[B,Ni,n]),Ga=a.useCallback(t=>{const i=Pn(t,v);return Lp(i,v)},[v]),Ei=xf(gr),Xt=a.useCallback((t,i,u)=>{const w=Pn(t,v);return ss(su(w,v),i??`path:${w}`,void 0,u)},[v,ss]),as=a.useRef({sessionId:n,contextDraftEnabled:B,isOpen:r});as.current={sessionId:n,contextDraftEnabled:B,isOpen:r};const Zh=a.useCallback(async(t,i)=>{const u=n??Qr.getState().activeSessionId,w=()=>_s.current&&as.current.isOpen&&(as.current.sessionId??Qr.getState().activeSessionId)===u&&Qr.getState().activeSessionId===u&&as.current.contextDraftEnabled===B;await Ot.start("/tmp",[t],k=>Xt(k,`path:${k}`,i),w)&&w()&&se&&!B&&l()},[B,Xt,se,l,n,Ot.start]),Fs=a.useRef(!0),Ka=a.useRef(n);Ka.current=n,a.useEffect(()=>(Fs.current=!0,()=>{Fs.current=!1}),[]);const em=a.useCallback(t=>{Tp.getState().enqueue(t,n??null,v||"/",async(i,u)=>{if(as.current.contextDraftEnabled&&Fs.current&&Ka.current===n){if(!await Mi.current(su(i,null),`path:${i}`,u))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return au(i,n,u)})},[n,v,B,Xt,o]),tm=a.useCallback(async(t,i)=>{const u=Ji(i),y=(await bl("/tmp",[t])).files[0]?.path;if(!y)throw new Error("截图上传未返回文件路径");if(!u()||!Fs.current||Ka.current!==n||as.current.contextDraftEnabled!==B)throw new Error(o("rightSidebar.uploadReferenceRejected"));if(B&&Fs.current&&Ka.current===n){if(!await Xt(y,void 0,i))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await au(y,n,i)},[B,Xt,n,o]),Fr=a.useCallback((t,i,u)=>{if(!t)return Promise.resolve(!1);const w=t.includes(`
|
|
1660
|
+
`)?`
|
|
1661
|
+
`:void 0;return ss(t.endsWith(`
|
|
1662
|
+
`)||t.endsWith(" ")?t:`${t} `,i,w,u)},[ss]),Mi=a.useRef(Fr);Mi.current=Fr;const _s=a.useRef(!0);a.useEffect(()=>(_s.current=!0,()=>{_s.current=!1}),[]);const $i=a.useRef(new Set),qa=a.useCallback((t,i,u,w)=>{if($i.current.has(i))return!1;const y=Ji(w);if(!y())return!1;const k=n??Qr.getState().activeSessionId;return $i.current.add(i),Eg(t,i,u,{insert:(N,ne)=>Fr(N,ne,w),upload:async(N,ne)=>(await bl("/tmp",[N],ne)).files[0]?.path,isCurrent:()=>y()&&_s.current&&Mi.current===Fr&&k===Qr.getState().activeSessionId}).catch(()=>(lr(!0),!1)).finally(()=>$i.current.delete(i))},[Fr,n]),_r=a.useCallback((t,i,u,w)=>i?ss(i.endsWith(" ")?i:`${i} `,u??`context:${t}`,`
|
|
1663
|
+
`,w):Promise.resolve(!1),[ss]),Kc=eb({text:Nt,sessionId:n??Qr.getState().activeSessionId,active:r&&B,onAccepted:()=>{tn(!1),Ct(""),xt&&et(!0)},onRejected:()=>{tn(!0),et(!1)}}),at=a.useMemo(()=>v?wt(v):o("rightSidebar.workspace"),[v,o]),rm=a.useMemo(()=>wt(le)||at,[le,at]),Va=a.useMemo(()=>So(le),[le]),Ya=a.useMemo(()=>v?bc[v]??[]:[],[bc,v]),Rn=a.useMemo(()=>new Set(Ya.map(t=>t.path)),[Ya]),Bs=!!(le&&Rn.has(le)),Pi=!!(v&&le&&le!==v),nm=!!(v&&Gn&&Gn!==v),Ut=le?`path:${le}`:null,qc="context:change-audit",sm=a.useCallback(()=>{Va&&_t(Va)},[Va,_t]),Vc=a.useCallback(()=>{yc()},[yc]),am=a.useCallback(()=>{le&&(Ps(le,!0),Sc())},[Sc,le,Ps]),om=a.useCallback(()=>{!le||!Pi||(Bs?xn(le):Kn(le,"directory"))},[Pi,le,Bs,Kn,xn]),Yc=a.useCallback(t=>{_t(t),Y("")},[_t]),Xc=a.useCallback(t=>{le&&(ke(Hb(le,t)),P(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[le,P]),Jc=a.useCallback(t=>{!v||t===v||(Rn.has(t)?xn(t):Kn(t,"directory"))},[Kn,Rn,v,xn]),Qc=a.useCallback(t=>{!v||!t||(Rn.has(t)?xn(t):Kn(t,"file"))},[Kn,Rn,v,xn]),Zc=V(t=>t.expandedPaths),Ai=a.useMemo(()=>{const t=new Set;if(Dr&&le){t.add(le);const i=`${le.replace(/\/+$/,"")}/`;for(const u of Zc)u.startsWith(i)&&t.add(u)}if(Dr&&v&&ot){const i=ot.startsWith("/")?ot:`${v}/${ot}`,u=So(i);u&&t.add(u)}return Ug(t).join(`
|
|
1664
|
+
`)},[Zc,Dr,le,v,ot]),Nn=a.useRef(new Map);a.useEffect(()=>{const t=Ai?Ai.split(`
|
|
1665
|
+
`):[];if(!r||t.length===0){Wn(null);return}const i=new AbortController;let u=!1,w=0,y=0;Wn(null);const k=async()=>{let N=0;for(;!u&&!i.signal.aborted;){let ne=null;try{Wn(null),await yp(t,xe=>{const{applicableEvents:Ae,unavailableReason:Ze}=zg(xe);Ae.length>0&&wc(Ae);const ee=new Set(Ae.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Da)for(const X of Ae){if(X.type==="created"||X.type==="updated"){const me=So(X.path);me&&ee.add(me)}X.path.endsWith("/.gitignore")&&le&&Ps(le,!0)}for(const X of ee){const me={path:X},Le=V.getState();if(!Le.directoryCache.has(me.path))continue;Nn.current.get(me.path)?.abort();const ze=new AbortController;Nn.current.set(me.path,ze);const Hd=`file-watch-rescan:${me.path}`;jt(Hd),Qu(me.path,ze.signal,Le.showHiddenFiles,"watch_rescan",Hd,Le.fileSortModes[me.path]??"name",le??void 0).then(qs=>{Nn.current.get(me.path)===ze&&kc(me.path,qs.entries)}).catch(qs=>{yr(qs)||Wn(qs instanceof Error?qs.message:"File refresh unavailable")}).finally(()=>{Nn.current.get(me.path)===ze&&Nn.current.delete(me.path)})}Ze&&Wn(Ze)},i.signal),ne=new Error("File watch stream ended")}catch(xe){ne=xe}if(u||i.signal.aborted||yr(ne))return;Wn(ne instanceof Error?ne.message:"File watching unavailable");const oe=Pu[Math.min(N,Pu.length-1)];N+=1,await new Promise(xe=>{y=window.setTimeout(xe,oe)})}};return w=window.setTimeout(()=>{u||k()},ol),()=>{u=!0,window.clearTimeout(w),window.clearTimeout(y),i.abort();for(const N of Nn.current.values())N.abort();Nn.current.clear()}},[wc,r,kc,Ai,le,Da,Ps]),a.useEffect(()=>{if(!v||bi.current!==v)return;if(xi.current===v){xi.current=null;return}const t=Du();aa(If,{...t,[v]:{selectedRepoRoots:Sa,repoTargetBranches:nr,repoBaseBranches:Et,previewEntries:sn,selectedPreviewKey:ve&&Pr?Qe:null,selectedPreviewFileKey:ve&&Pr?Qo:null,previewDetailOpen:!!(ve&&Pr),previewScrollTops:ks,previewMobileSlideIndex:1,repoIncludeUncommitted:un,updatedAt:Date.now()}},zb)},[Pr,un,ve,sn,ks,Et,nr,Sa,v,Qo,Qe]);const pt=a.useMemo(()=>Vu(Fe.values()),[Fe]),lt=a.useMemo(()=>{const t=new Map;for(const i of fe)t.set(i.root,i);return t},[fe]),Os=a.useMemo(()=>{const t=new Map;for(const i of fe)i.deferred||t.set(i.root,i.files.length);return t},[fe]),Xa=a.useCallback(t=>{if(t){if(!t.deferred){Ls.current.delete(t.root);return}Os.has(t.root)||Ls.current.has(t.root)||(Ls.current.add(t.root),Bt(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ls.current.delete(t.root)}))}},[Bt,Os]),ir=a.useMemo(()=>ce?$e.find(t=>t.root===ce)??null:null,[ce,$e]),Jt=a.useMemo(()=>ot?Array.from(Fe.values()).find(t=>t.path===ot||t.absolutePath===ot)??null:null,[Fe,ot]),Ht=a.useMemo(()=>{const t=new Map;for(const i of fe)i.available&&i.context?.available&&t.set(i.root,i);return t.size===0&&M?.available&&M.root&&t.set(M.root,{id:M.root,root:M.root,relativeRoot:".",name:at,depth:0,nested:!1,available:!0,files:Array.from(Fe.values()).filter(i=>bt(i,v)===M.root),context:M}),Array.from(t.values()).sort((i,u)=>i.root===v?-1:u.root===v?1:(i.relativeRoot||i.name).localeCompare(u.relativeRoot||u.name)).map(i=>{const u=i.relativeRoot==="."?at:i.relativeRoot||i.name||wt(i.root),w=qu(i.files),y=i.files.length;return{value:i.root,label:u,meta:[i.context?.branch,y>0?o("rightSidebar.repoChangedCount",{count:y}):null,w>0?o("rightSidebar.repoStagedCount",{count:w}):null].filter(Boolean).join(" · ")}})},[Fe,M,fe,at,v,o]),Re=a.useMemo(()=>ce&&Ht.some(t=>t.value===ce)?ce:Jt?.repoRoot&&Ht.some(t=>t.value===Jt.repoRoot)?Jt.repoRoot:Ht.length===1||Ht.length>1?Ht[0].value:null,[ce,Ht,Jt?.repoRoot]),ed=Re?lt.get(Re)??null:null,de=ed?.context?.available?ed.context:Re===M?.root?M:null,tt=Ht.length>0&&!Re,td=a.useMemo(()=>tt?[]:Re?Array.from(Fe.values()).filter(t=>bt(t,v)===Re):Array.from(Fe.values()),[Re,Fe,tt,v]),Cn=a.useMemo(()=>Vu(td),[td]),Li=!!(de?.available&&de.root&&Re&&de.root===Re),im=Re?Ht.find(t=>t.value===Re)?.label??wt(Re):o("rightSidebar.gitRepositoryPlaceholder"),rd=Li?de?.branch??"HEAD":tt?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",En=!!(de?.available&&de.root===Re&&de.status);a.useEffect(()=>{ec.current={count:Dt.length,loading:ya,loadingMore:wa,hasMore:qo}},[Dt.length,qo,ya,wa]),a.useEffect(()=>{qr.current+=1,fr.current?.abort(),jt("right-sidebar-recent-commits"),fr.current=null,dn(""),ur([]),Rs(!1),Ns(!1),Bn(null),On(!1)},[Re]);const Us=a.useCallback(async(t={})=>{if(!v||!Re||tt)return;const i=t.reset??!1,u=ec.current,w=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const y=qr.current+1;qr.current=y,fr.current?.abort(),jt("right-sidebar-recent-commits");const k=new AbortController;fr.current=k,i?Rs(!0):Ns(!0),Bn(null);try{const N=await pp({cwd:v,repoRoot:Re,limit:ex,skip:w,query:js.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(qr.current!==y)return;if(!N.available){Bn(N.error??"Recent commits are unavailable"),i&&ur([]),On(!1);return}Je(ne=>i?N.commitSyncStatus??{}:{...ne,...N.commitSyncStatus}),ur(ne=>i?N.commits:[...ne,...N.commits]),On(N.hasMore)}catch(N){if(qr.current!==y||yr(N))return;Bn(N instanceof Error?N.message:"Failed to load recent commits"),i&&ur([]),On(!1)}finally{fr.current===k&&(fr.current=null),qr.current===y&&(Rs(!1),Ns(!1))}},[Re,js,tt,v]);a.useEffect(()=>{ln&&Us({reset:!0})},[js,Us,ln,de?.ahead,de?.behind,de?.upstream]);const lm=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Us({reset:!1})},[Us]);a.useEffect(()=>{!Re||!M?.available||!ct||!sr||En||pn||tt||ki(Re)},[Re,M?.available,En,pn,ct,sr,ki,tt]);const nd=r&&($t||ct);a.useEffect(()=>{!nd||!v||pr()},[nd,pr,v]),a.useEffect(()=>{!r||!ct||!sr||!Cs||!v||Ua(null)},[Cs,ct,sr,r,Ua,v]);const cm=a.useMemo(()=>{if(!ce)return 0;const t=$e.findIndex(i=>i.root===ce);return t>=0?t+1:0},[ce,$e]),sd=a.useCallback(t=>{if(!t)return null;const i=Array.from(Fe.values()).filter(u=>bt(u,v)===t).sort((u,w)=>u.path.localeCompare(w.path))[0];return i?vr(i):null},[Fe,v]),Mn=$e.length>1,Ja=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Fe.size,branch:null,deferred:!1},...$e.map(t=>({root:t.root,label:t.label,count:t.deferred?Os.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Os.has(t.root)}))],[Fe.size,$e,Os,o]),ad=Ja[cm]??Ja[0],Qa=!!ce,od=a.useMemo(()=>Hf($e,fe),[$e,fe]);a.useEffect(()=>{yi.current===v&&ce&&!od.has(ce)&&Te(null),Fn(t=>t.filter(i=>$e.some(u=>u.root===i)))},[ce,$e,od,v,Te]),a.useEffect(()=>{ce&&Xa(lt.get(ce))},[ce,Xa,lt]);const dm=a.useMemo(()=>{const t=new Set;de?.branch&&t.add(de.branch);for(const i of de?.branches??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,o]),id=a.useMemo(()=>{const t=new Set;de?.upstreamRemote&&t.add(de.upstreamRemote);for(const i of de?.remotes??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,o]),ld=id.length>1,um=a.useMemo(()=>{const t=[],i=new Set,u=(y,k)=>{!y||i.has(y)||(i.add(y),t.push({value:y,label:y,meta:k}))};u(de?.upstreamBranch,de?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const y of de?.branches??[])u(y,y===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const w=de?.upstreamRemote;for(const y of de?.remoteBranches??[]){const k=y.indexOf("/"),N=k>=0?y.slice(0,k):null,ne=k>=0?y.slice(k+1):y;(!w||N===w)&&u(ne,"remote")}return t},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,o]),Qt=a.useMemo(()=>Ht.map(t=>{const i=lt.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Ht,lt]);a.useEffect(()=>{Qt.length!==0&&(ja(t=>{let i=!1;const u={...t},w=new Set(Qt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Qt)!u[y.root]&&y.branch&&(u[y.root]=y.branch,i=!0);return i?u:t}),Ra(t=>{let i=!1;const u={...t},w=new Set(Qt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Qt){const k=lt.get(y.root)?.context;if(u[y.root]&&zf(u[y.root],k?.branch)&&(delete u[y.root],i=!0),u[y.root])continue;const N=Bu(k);N&&(u[y.root]=N,i=!0)}return i?u:t}))},[Qt,lt]);const Za=a.useMemo(()=>{const t=new Set(Qt.map(i=>i.root));return Sa.filter(i=>t.has(i))},[Sa,Qt]),eo=Za.length===0,br=a.useMemo(()=>eo?Qt:Qt.filter(t=>Za.includes(t.root)),[Qt,Za,eo]),Hs=a.useMemo(()=>br.filter(t=>!!Et[t.root]?.trim()),[Et,br]),os=a.useCallback((t,i)=>{const u=lt.get(t)?.context?.branch;return!!(u&&i&&i.replace(/^refs\/heads\//,"")===u)},[lt]),cd=a.useMemo(()=>br.filter(t=>!Et[t.root]?.trim()),[Et,br]),dd=a.useCallback(async t=>{if(!t||gi.current.has(t))return;const i=lt.get(t)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=v;gi.current.add(t),nc(w=>new Set(w).add(t));try{const w=await Vd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!w.available||!Pe(u))return;Ne(y=>y.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...w},error:void 0}:k)),ja(y=>y[t]||!w.branch?y:{...y,[t]:w.branch}),Ra(y=>{if(y[t])return y;const k=Bu(w);return k?{...y,[t]:k}:y})}catch(w){yr(w)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,w)}finally{gi.current.delete(t),nc(w=>{const y=new Set(w);return y.delete(t),y})}},[lt,Pe,v]);a.useEffect(()=>{if(Vo)for(const t of br)dd(t.root)},[Vo,br,dd]),a.useEffect(()=>{!Li||!de||($a(de.branch||(de.branches?.[0]??"")),Pa(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),Aa(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Li]);const ud=a.useMemo(()=>{if(tt)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!En||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=de.ahead??0,i=de.behind??0;return t>0&&i>0?{text:o("rightSidebar.pushDivergedCount",{ahead:t,behind:i}),className:"bg-destructive/10 text-destructive"}:t>0?{text:o("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:i>0?{text:o("rightSidebar.pushBehindCount",{count:i}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,En,pn,tt,o]),fm=a.useCallback(t=>{if(t&&!se){const i=t.currentTarget.getBoundingClientRect();Ie({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else Ie(null);S?.()},[se,S]),Ti=a.useCallback(()=>{Ie(null),T?.()},[T]);function fd(){if(!Mn)return null;const t=ad?.label??o("rightSidebar.allRepositories"),i=ad?.count??Fe.size,u=wt(t)||t;return e.jsxs("button",{type:"button",onClick:fm,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${b?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":b,title:t,children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${i>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:i}),e.jsx(da,{size:12,className:"shrink-0"})]})}function hm(){if(!b||!Mn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(qe?.x??t-368,t-352)),w=Math.max(12,Math.min(qe?.y??80,i-420)),y=se?void 0:{left:u,top:w},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${se?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Ti,children:e.jsxs("div",{className:se?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:y,onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:se?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:se?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!se&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Ja.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Fe.size})]})]}),e.jsx("button",{type:"button",onClick:Ti,className:se?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:se?16:14})})]}),e.jsx("div",{className:se?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:Ja.map(N=>{const ne=(N.root??null)===ce,oe=wt(N.label)||N.label;return e.jsxs("button",{type:"button",onClick:()=>{Ad(N.root),Ti()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${se?"px-3 py-2":"px-2 py-1.5"} ${ne?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:N.label,role:"option","aria-selected":ne,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${ne?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),e.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${ne?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(xr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${se?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:oe}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:N.root===null?o("rightSidebar.allRepositories"):N.label})]}),N.branch&&e.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:N.branch}),N.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${N.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:N.count})]},N.root??"all")})})]})});return Mf(k,se,document.body)}function mm(){return hm()}function hd(t){const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=Eo(u,i??v);return{key:vr(t),path:t.path,absolutePath:u,displayName:w.name,displayDir:w.dir,oldPath:t.oldPath,status:t.status,title:u}}function md(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function to(t,i){const u=Pn(t,v),w=`path:${u}`,y=De===w,k=je===w,N=y||k;return e.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),Xt(u,w,ne.currentTarget)},...Ei(Ga(u),w),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${N?"max-w-20 px-2":"max-w-20 px-2 md:max-w-0 md:px-0 md:opacity-0 md:group-hover:max-w-20 md:group-hover:px-2 md:group-hover:opacity-100"} ${N?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function pd(t){const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=Hm(t),y=ml(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(i0,{actions:w,running:We,completed:Un?.path===y?Un:null}),to(u,o("rightSidebar.insertThisFile"))]})}function gd(t,i){const u=i.root??v;if(!u)return null;const w=Pn(t,u);return to(w,o("fileTree.insertRefTitle"))}function zs(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Nd("unified"),"aria-pressed":Gt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Gt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Nd("split"),"aria-pressed":Gt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Gt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function bd(){return Ws.map(t=>{const i=qu(t.files.map(([,k])=>k)),u=$l({activeGitRepoRoot:ce,groupCount:Ws.length,label:t.label,rootName:at}),w=!!(u&&t.root&&Rr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:w,files:t.files.map(([,k])=>hd(k)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${w?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Am(t.root),"aria-expanded":!w,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:w?e.jsx(hs,{size:13}):e.jsx(da,{size:13})}),e.jsx(xr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),i>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:i})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),lo("stage-all",t.root,t.label)},disabled:!!We,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),lo("stash-all",t.root,t.label)},disabled:!!We,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const $n=a.useMemo(()=>new Map(Array.from(Fe.values(),t=>[vr(t),t])),[Fe]);function xd(t){const i=$n.get(t.key),u=i?bt(i,v):null,w=$g(kt,u,i?.path??t.path);return e.jsx(Rl,{changeStatus:t.status,auditStatus:w,renderChangeBadge:y=>e.jsx(oa,{status:y})})}const ro=a.useCallback(t=>{if(se)return null;const i=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const w=t.getBoundingClientRect().top+48;let y=null,k=Number.POSITIVE_INFINITY;for(const ne of i){const oe=ne.getBoundingClientRect();if(oe.bottom<w)continue;const xe=Math.abs(oe.top-w);xe<k&&(y=ne,k=xe)}const N=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return N?(Ba.current===N&&V.getState().selectedFilePath===N||(Ba.current=N,it(N)),N):null},[se,it]),pm=!!(!We&&Re&&!tt&&(de?.upstream||gn.trim()&&bn.trim())),gm=!!(!We&&Re&&!tt&&(de?.upstream||gn.trim()&&bn.trim())),bm=!!(!We&&Re&&!tt&&zn.trim()&&zn.trim()!==de?.branch),Zt=a.useMemo(()=>{const t=Ke.trim().toLowerCase(),i=Array.from(Fe.entries()).filter(([,u])=>!ce||bt(u,v)===ce).sort(([u],[w])=>u.localeCompare(w));return t?i.filter(([u,w])=>`${u} ${w.path} ${w.status} ${w.repoRelativeRoot??""} ${w.repoName??""}`.toLowerCase().includes(t)):i},[ce,Fe,Ke,v]);a.useEffect(()=>{ta("selected_file_state",{selectedFilePath:ot,selectedChangedFilePath:Jt?.path??null,selectedChangedFileAbsolutePath:Jt?.absolutePath??null,selectedChangedFileRepoRoot:Jt?.repoRoot??null,rootPath:v,activeGitRepoRoot:ce,rightTab:ci,effectiveRightTab:Mt,diffPaneActive:$t,changedFiles:Fe.size,filteredChangedFiles:Zt.length,gitBundleLoading:hr,gitBundleLastLoadedAt:qn})},[ce,Fe.size,$t,Mt,Zt.length,qn,hr,ci,v,Jt?.absolutePath,Jt?.path,Jt?.repoRoot,ot]);const Ws=a.useMemo(()=>{const t=new Map;for(const i of Zt){const[,u]=i,w=bt(u,v),y=a0(u)||at,k=w??y,N=w?lt.get(w):void 0,ne=t.get(k)??{root:w,label:y,branch:N?.context?.branch,files:[]};ne.files.push(i),t.set(k,ne)}return Array.from(t.values()).sort((i,u)=>i.label===at?-1:u.label===at?1:i.label.localeCompare(u.label))},[Zt,lt,at,v]),Gs=a.useMemo(()=>{const t=[],i=new Map;for(const u of Zt)i.set(vr(u[1]),u);for(const u of Ws){if(!!(u.root&&$l({activeGitRepoRoot:ce,groupCount:Ws.length,label:u.label,rootName:at})&&Rr.has(u.root)))continue;if(Er!=="tree"){t.push(...u.files);continue}const y=u.files.map(([,k])=>hd(k));for(const k of Gp(y)){const N=i.get(k.key);N&&t.push(N)}}return t},[ce,Rr,Er,Ws,Zt,at]),vd=a.useMemo(()=>Fe.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Gs.map(([,t])=>{const i=bt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:vr(t),path:t.path,absolutePath:u,status:t.status,repoRoot:i,displayName:Eo(u,i).name,displayDir:Eo(u,i).dir,auditRecords:kt}}),[kt,Fe.size,Gs,v,o]);a.useEffect(()=>{if(!$t||Gs.length===0||se)return;const t=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&ro(u))return;const w=document.querySelector("[data-diff-stream-item]"),y=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;if(y){Ba.current=y,it(y);return}const k=Gs[0]?.[1];if(!k)return;const N=vr(k);Ba.current=N,it(N)};for(const u of[80,240,600,1200])t.push(window.setTimeout(i,u));return()=>t.forEach(u=>window.clearTimeout(u))},[$t,se,Gs,it,ro]);const Ii=a.useMemo(()=>{const t=N=>`'${N.replace(/'/g,"'\\''")}'`,i=or.length>0?kn:fe.filter(N=>N.files.length>0),u=i.length>0?i:v?[{root:v,relativeRoot:".",name:at}]:[],w=u.length>0?u.map(N=>`- ${N.relativeRoot==="."?".":N.relativeRoot} (${N.root})`).join(`
|
|
1666
|
+
`):`- ${v?".":""}`,y=u.length>0?u.map(N=>` td audit-export ${t(N.root)}`).join(`
|
|
1667
|
+
`):" td audit-export",k=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${v??""}`,"目标仓库:",w,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",y,"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(`
|
|
1668
|
+
`)},[or.length,kn,fe,at,v]),xm=a.useCallback(async(t="generate",i)=>{if(Mn&&Wr.length===0&&!ce){nn(!0);return}const u=t==="generate"?Ii:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Ii].join(`
|
|
1669
|
+
`);return dt("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:or,mode:t,hasAuditListCommand:u.includes("td audit-list"),promptLength:u.length}),await _r(o("rightSidebar.insertChangeAuditPrompt"),u,`${qc}:${t}`,i)?(pr(),c||l(),!0):!1},[ce,Ii,Wr.length,or,_r,pr,l,c,v,Mn,o]),no=a.useCallback(async t=>{try{await Xd({ids:[t]}),rn(i=>i.filter(u=>u.id!==t))}catch{pr()}},[pr]),vm=a.useCallback(async()=>{if(kt.length===0)return;const t=kt.map(i=>i.id);try{await Xd({ids:t}),rn(i=>i.filter(u=>!t.includes(u.id))),zr(null)}catch(i){const u=i instanceof Error?i.message:"Failed to clear change audit explanations";zr(o("rightSidebar.changeAuditClearFailed",{message:u})),pr()}},[kt,pr,o]),ym=a.useCallback(async t=>{if(t.records.length===0)return;const i=t.records.map(u=>u.id);try{await gp({ids:i}),Gr(u=>u.filter(w=>!i.includes(w.id))),Qe===t.key&&(fn(null),cr(!1))}catch(u){qt(o("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),Ua(null)}},[Ua,Qe,o]),wm=a.useCallback(t=>{Fn(i=>t===null?(nn(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),km=a.useCallback(t=>{Xo(i=>t===null?(Yo(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),Di=a.useMemo(()=>{if(!sr)return[];const t=i=>{const u=i.diff??"";let w=0,y=0;for(const k of u.split(`
|
|
1670
|
+
`))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(w+=1),k.startsWith("-")&&(y+=1));return{filePath:i.filePath,oldPath:i.oldPath,newPath:i.newPath,hunkHeader:i.hunkHeader,hunkIndex:i.hunkIndex??0,fingerprint:i.fingerprint,additions:w,deletions:y,diff:u}};return ve?(ve.hunks??[]).map(i=>{const u=ve.comparisonRepos&&ve.comparisonRepos.length>1?[...ve.comparisonRepos].sort((y,k)=>k.label.length-y.label.length).find(y=>i.filePath.startsWith(`${y.label}/`)):void 0,w=tr.find(y=>y.repoRoot===ve.repoRoot&&y.baseRef===ve.baseRef&&(y.branchName??null)===(ve.currentBranch??null)&&y.filePath===i.filePath&&y.hunkHeader===i.hunkHeader&&(y.hunkIndex??0)===i.hunkIndex&&y.fingerprint===i.fingerprint)??null;return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex}`,repoRoot:u?.repoRoot??ve.repoRoot,repositoryPath:u?i.filePath.slice(u.label.length+1):i.filePath,hunk:i.previewRevert&&!os(i.previewRevert.cwd,i.previewRevert.comparisonBranch)?{...i,previewRevert:void 0}:i,current:w,stale:null}}):Qe?tr.filter(i=>Fu(i)===Qe).map(i=>{const u=t(i);return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex??0}`,hunk:u,current:i,stale:null}}):[]},[ve,tr,os,sr,Qe]),Fi=tr.length>0,is=a.useMemo(()=>{if(!sr)return[];const t=new Map;for(const i of tr){const u=i.repoRoot,w=lt.get(u),y=w?.relativeRoot==="."?at:w?.relativeRoot||w?.name||wt(u),k=Fu(i),N=t.get(k)??{key:k,repoRoot:u,repoLabel:y,baseRef:i.baseRef,branchName:i.branchName??null,headRef:i.headRef??null,diffFingerprint:i.diffFingerprint??null,records:[],latestInjectedAt:0};N.records.push(i),N.latestInjectedAt=Math.max(N.latestInjectedAt,i.injectedAt??0),t.set(k,N)}return Array.from(t.values()).sort((i,u)=>u.latestInjectedAt-i.latestInjectedAt)},[tr,lt,sr,at]),_i=a.useMemo(()=>Qe?is.find(t=>t.key===Qe)??null:null,[is,Qe]),Ks=ve?{repoRoot:ve.repoRoot??"",repoLabel:ve.repoRoot?lt.get(ve.repoRoot)?.relativeRoot==="."?at:lt.get(ve.repoRoot)?.relativeRoot||lt.get(ve.repoRoot)?.name||wt(ve.repoRoot):at,baseRef:ve.baseRef??ve.baseBranch??"",branchName:ve.currentBranch??null,headRef:ve.headRef??null,diffFingerprint:ve.diffFingerprint??null}:_i,Sm=a.useMemo(()=>(Xe?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,repoRoot:Xe?.repoRoot,hunk:t,current:null,stale:null})),[Xe?.hunks,Xe?.repoRoot]),jm=a.useMemo(()=>{if(ve)return[];const t=_i;return t?ys.filter(i=>i.repoRoot===t.repoRoot&&i.baseRef===t.baseRef&&(i.branchName??null)===t.branchName&&(!t.diffFingerprint||i.diffFingerprint===t.diffFingerprint)):[]},[ve,ys,_i]),Rm=a.useCallback(t=>{const i=Di.find(u=>u.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${u.hunk.filePath}`===t.filePath:!1));i&&(hn(i.key),window.setTimeout(()=>An(t),90),window.setTimeout(()=>An(t),320),window.setTimeout(()=>An(t),760))},[Di]),Bi=a.useMemo(()=>{const t=y=>`'${y.replace(/'/g,"'\\''")}'`,i=Hs,u=i.length>0?i.map(y=>`- ${y.label} (${y.root}),目标分支:${nr[y.root]||y.branch||"(current branch)"},基线分支:${Et[y.root]||"(not set)"},包含本地未提交更改:${os(y.root,nr[y.root]||y.branch)&&(un[y.root]??!0)?"是":"否"}`).join(`
|
|
1671
|
+
`):`- ${v?".":""}`,w=i.length>0?i.map(y=>{const k=nr[y.root]||y.branch||"",N=Et[y.root]||"",ne=y.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(y.root)} switch ${t(k)}`:` # ${y.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(N)} ${t(y.root)} > ~/.termdock/branch-audit/branch-audit-export-${ne}.json`].join(`
|
|
1672
|
+
`)}).join(`
|
|
1673
|
+
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",u,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",w,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:v??null,repoRoot:"<target repo root>",baseRef:"<target repo base branch>",branchName:"<from export currentBranch>",headRef:"<from export headRef>",diffFingerprint:"<from export diffFingerprint>",generatedBy:"termdock-branch-audit",walkthrough:{title:"<one-line branch change title>",summary:"<branch change goal and effect>",highlights:[{what:"<what changed>",effect:"<user/system effect>",tag:"<category>"}],nodes:[{id:"n1",title:"<node title>",kind:"process",business:"<zero-context business explanation>",anchor:{repoRoot:"<target repo root>",filePath:"<from hunk.filePath>",hunkIndex:0,hunkFingerprint:"<from hunk.fingerprint>"}}],edges:[{from:"n1",to:"n2",label:"<relationship>",desc:"<business meaning>"}],risks:[{title:"<real risk or validation gap>"}],checks:["<executable validation step>"]},records:[{filePath:"<from hunk.filePath>",oldPath:"<from hunk.oldPath or null>",newPath:"<from hunk.newPath or null>",hunkHeader:"<from hunk.hunkHeader>",hunkIndex:0,fingerprint:"<from hunk.fingerprint>",diff:"<copy from hunk.diff exactly>",explanation:"<replace with hunk explanation>",summary:""}]},null,2),"```"].join(`
|
|
1674
|
+
`)},[un,os,Hs,Et,nr,v]),Nm=a.useCallback(async(t="generate",i)=>{const u=t==="generate"?Bi:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Bi].join(`
|
|
1675
|
+
`);return await _r(o("rightSidebar.branchAuditShort"),u,`context:branch-audit-scope:${t}`,i)?(c||l(),!0):!1},[Bi,_r,l,c,o]),Oi=a.useCallback(async(t={})=>{const i=t.refresh===!0,u=i&&ve?.comparisonRepos?ve.comparisonRepos:Hs.map(N=>{const ne=(nr[N.root]||N.branch||"").trim();return{repoRoot:N.root,label:N.label,base:Et[N.root]?.trim()??"",head:ne||null,includeUncommitted:un[N.root]??!0}});if(!v||u.length===0)return;const w=++K.current,y=v,k=()=>Pe(y)&&w===K.current;Be(!0),Oe(null),i||(rr(null),mt(null));try{const N=await Promise.all(u.map(async ee=>{if(!ee.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:ee.label}));return Jd({cwd:v,repoRoot:ee.repoRoot,base:ee.base,head:ee.head,includeUncommitted:t.repoRoot===ee.repoRoot?t.includeUncommitted??!1:ee.includeUncommitted??ve?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${ee.repoRoot}`})}));if(!k())return;const ne=N.find(ee=>!ee.available);if(ne){Oe(ne.error??"Branch diff is unavailable");return}const oe=N.length===1?N[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:N.map(ee=>ee.baseRef??ee.baseBranch).filter(Boolean).join(", "),currentBranch:N.map(ee=>ee.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:N.map(ee=>ee.headRef).filter(Boolean).join(", "),diffFingerprint:N.map(ee=>ee.diffFingerprint).filter(Boolean).join("+"),stat:N.map(ee=>ee.stat).filter(Boolean).join(`
|
|
1676
|
+
`),files:N.flatMap((ee,X)=>{const me=u[X];return(ee.files??[]).map(Le=>`${me?.label??ee.repoRoot??"repo"}/${Le}`)}),hunks:N.flatMap((ee,X)=>{const Le=u[X]?.label??ee.repoRoot??"repo";return(ee.hunks??[]).map(Ge=>({...Ge,filePath:`${Le}/${Ge.filePath}`,oldPath:Ge.oldPath?`${Le}/${Ge.oldPath}`:Ge.oldPath,newPath:Ge.newPath?`${Le}/${Ge.newPath}`:Ge.newPath}))}),commits:N.flatMap(ee=>ee.commits??[]),commitCount:N.reduce((ee,X)=>ee+(X.commitCount??X.commits?.length??0),0),diff:N.map(ee=>ee.diff).filter(Boolean).join(`
|
|
1677
|
+
`),truncated:N.some(ee=>ee.truncated)};if(oe.comparisonRepos=u.map((ee,X)=>({...ee,head:ee.head??N[X].currentBranch??null,includeUncommitted:N[X].includeUncommitted===!0,canIncludeUncommitted:N[X].canIncludeUncommitted})),oe.canIncludeUncommitted=N.every(ee=>ee.canIncludeUncommitted===!0),oe.includeUncommitted=N.some(ee=>ee.includeUncommitted===!0),Jo(ee=>({...ee,...Object.fromEntries(oe.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(oe.hunks??[]).length===0){Oe(o("rightSidebar.branchAuditDiffEmpty"));return}const xe=Date.now(),Ae=(i?Qe:null)??["preview",oe.repoRoot??v,oe.baseRef??oe.baseBranch??"",oe.currentBranch??"",oe.headRef??"",oe.diffFingerprint??xe].join("\0"),Ze=u.length===1?u[0].label:`${u.length} repos`;rr(oe),an(ee=>[{key:Ae,diff:oe,repoLabel:Ze,createdAt:xe},...ee.filter(X=>X.key!==Ae)].slice(0,8)),i||L(ee=>ee[Ae]===void 0?ee:{...ee,[Ae]:0}),fn(Ae),hn(ee=>{const X=oe.hunks?.[0],me=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&ee&&(oe.hunks??[]).some(Le=>Le.filePath===ee.split("\0")[0])?ee:me}),cr(!0)}catch(N){if(!k()||yr(N))return;Oe(N instanceof Error?N.message:"Failed to load branch diff")}finally{k()&&Be(!1)}},[un,ve,Qe,Hs,Et,nr,Pe,v,o]),Cm=a.useCallback(t=>{++K.current,Be(!1),rr(t.diff),Oe(null),fn(t.key),hn(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),cr(!0)},[]),Em=a.useCallback(t=>{an(i=>i.filter(u=>u.key!==t)),L(i=>{if(!(t in i))return i;const u={...i};return delete u[t],u}),Qe===t&&(fn(null),rr(null),cr(!1))},[Qe]),Mm=a.useCallback(t=>{++K.current,Be(!1);const i=is.find(u=>u.key===t);i&&(rr(null),Oe(null),fn(t),hn(i.records[0]?.filePath??null),cr(!0))},[is]),$m=a.useCallback(async t=>{if(!v||!Re)return;const[i]=t.split(/\s+/);if(i){dr(i),on(null),mt(null);try{const u=await bp({cwd:v,repoRoot:Re,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){on(u.error??"Commit diff is unavailable");return}mt(u);const w=u.hunks?.[0];ka(w?`${w.filePath}\0${w.hunkHeader}\0${w.hunkIndex}`:null)}catch(u){on(u instanceof Error?u.message:"Failed to load commit diff")}finally{dr(null)}}},[Re,v]),Pm=a.useCallback(t=>{if(!ve||!Qe)return;const i=Math.max(0,Math.round(t));L(u=>Math.abs((u[Qe]??0)-i)<24?u:{...u,[Qe]:i})},[ve,Qe]);a.useEffect(()=>{!ve||!Qe||an(t=>t.map(i=>i.key===Qe&&i.diff!==ve?{...i,diff:ve}:i))},[ve,Qe]);const yd=!!ve;a.useEffect(()=>{if(!se||!Pr||!yd)return;const t=Tc.current;if(!t||t.destroyed)return;t.update(),t.slideTo(1,0);const i=window.requestAnimationFrame(()=>{t.destroyed||(t.update(),t.slideTo(1,0))});return()=>window.cancelAnimationFrame(i)},[Pr,yd,se]);const wd=a.useCallback(t=>{t&&_h(i=>Kp(i,t))},[]),kd=La.key===ot?La.key:null,so=a.useCallback(t=>{const i=V.getState(),u=x0();ta("select_diff_file",{interactionId:u,path:t,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),it(t),Ft("diff"),se&&t&&Fc(1),wd(t),queueMicrotask(()=>{const w=V.getState();ta("select_diff_file_after",{interactionId:u,requestedPath:t,selectedFilePath:w.selectedFilePath,rootPath:w.rootPath,rightTab:w.rightTab,changedFiles:w.changedFiles.size,activeGitRepoRoot:ce})})},[ce,se,wd,it,Ft,Fc]),Sd=a.useCallback(t=>{const i=Array.from(Fe.values()).find(u=>{const w=bt(u,v),y=vr(u);return u.path===t.filePath||y===t.filePath||u.absolutePath===t.filePath||(w?`${w}/${u.path}`===t.filePath:!1)||t.repoRoot&&w===t.repoRoot&&u.path===t.filePath});if(i){so(vr(i)),window.setTimeout(()=>An(t),90),window.setTimeout(()=>An(t),320),window.setTimeout(()=>An(t),760);return}An(t)},[Fe,v,so]),jd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:u}={})=>xs.length>0?e.jsx(ff,{walkthroughs:xs,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:w=>{se&&window.requestAnimationFrame(()=>t?.()),Sd(w)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(ua,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[ce,xs,Sd,se,o]),Am=a.useCallback(t=>{t&&Nr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),il(nl,u),u})},[]),Rd=a.useCallback(t=>{Cr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),il(Cu,u),u})},[]),ao=a.useCallback(t=>{ba(t),At(Pf,t)},[]);a.useEffect(()=>{Qa||Er!=="ai"||ao("tree")},[Er,ao,Qa]);const oo=a.useCallback(()=>{bs(t=>{const i=!t;return At(Af,i),i})},[]),Nd=a.useCallback(t=>{xa(t),At(Lf,t)},[]),{whitespace:Cd,context:Ed}=Vp(),Md=a.useMemo(()=>({algorithm:"histogram",whitespace:Cd,context:Ed}),[Cd,Ed]),$d=a.useCallback(t=>{pe(t),At(Tf,t)},[]),io=a.useCallback(async(t,i,u,w)=>{let y=t;for(;y.ok&&y.status==="running";)await new Promise(N=>window.setTimeout(N,1500)),y=await Qd({jobId:y.jobId,cwd:i.cwd,action:i.action});if(!y.ok)throw new Error("Git action status is unavailable");if(y.status==="error")throw new Error(y.error||y.message||"Git action failed");const k={action:i.action,path:w,label:u};return $s(k),window.setTimeout(()=>$s(N=>N?.action===k.action&&N.path===k.path?null:N),1400),y},[]),yt=a.useCallback(async(t,i,u)=>{const w=v;v&&mr.current.delete(v),qt(null),$s(null),Ms({action:t.action,path:u});try{const y=await xp({...t,includeNested:Js(v)}),k=await io(y,t,i,u);if(!Pe(w))return!1;const N=v?await Yi(v,void 0,{includeNested:Js(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Zs(v)}).catch(()=>k.bundle):k.bundle;return Pe(w)?(N&&Qn(N,{reloadDiff:!0,cacheOnly:!0}),mn(null),!0):!1}catch(y){return $s(null),qt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Pe(w)&&Ms(null)}},[Qn,Pe,v,o,io]),Pd=a.useCallback(async t=>{const i=v;await Zd({...t,includeNested:Js(v)}),Pe(i)&&Bt(v??void 0,{refresh:!0,background:!0})},[Pe,Bt,v]),Lm=a.useCallback(async t=>{const i=ve,u=K.current,w=i?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!i||!w||!t.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));Ee(k=>k+1),Oe(null);try{await Zd(t)}catch(k){throw Ee(N=>N-1),k}if(u!==K.current||!Pe(v)){Ee(k=>k-1);return}const y=k=>{rr(N=>{if(!N||u!==K.current)return N;const ne=N.hunks??[],oe=k===void 0?ne.filter(Ae=>!(Ae.previewRevert?.cwd===t.cwd&&Ae.previewRevert.patch===t.patch)):[...ne.filter(Ae=>Ae.filePath!==w.filePath),...k];return{...N,hunks:oe}})};y(),Jd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(u!==K.current||!Pe(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const N=t.path.slice(t.cwd.length+1),ne=w.filePath.slice(0,w.filePath.length-N.length);y((k.hunks??[]).map(oe=>({...oe,filePath:`${ne}${oe.filePath}`,oldPath:oe.oldPath?`${ne}${oe.oldPath}`:oe.oldPath,newPath:oe.newPath?`${ne}${oe.newPath}`:oe.newPath})))}).catch(k=>{u===K.current&&Pe(v)&&!yr(k)&&Oe(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>Ee(k=>k-1))},[ve,Pe,v,o]),lo=a.useCallback((t,i,u)=>{if(i){if(t==="stage-all"){yt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}mn({kind:"stash-all",repoRoot:i,repoLabel:u})}},[yt,o]),Ad=a.useCallback(t=>{Te(t),$a(""),Pa(""),Aa(""),it(sd(t)),ct||Ft("diff"),t&&Xa(lt.get(t))},[Xa,sd,ct,lt,it,Te,Ft]),Ld=a.useCallback(t=>{const i=new Set([...Yt.current.keys(),...yn.current,...mr.current]);for(const u of i)u!==t&&(Vt.current.delete(u),Yt.current.get(u)?.abort(),Yt.current.delete(u),jt(`right-sidebar-git-untracked:${u}`),yn.current.delete(u),mr.current.delete(u))},[]),Tm=a.useCallback(async t=>{const i=v;if(!i||(await V.getState().setNestedGitScanRoot(i,t),!Pe(i)))return;if(t){await Bt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Ld(i),$a(""),Pa(""),Aa(""),Xo(w=>w.filter(y=>y===i));const u=Jt;u&&bt(u,i)!==i&&it(null),await Bt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Ld,Pe,Bt,v,it,Jt]),Im=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=zn.trim();!t||t===de?.branch||await yt({action:"switch-branch",cwd:Re,branch:t},o("rightSidebar.switchBranch"))},[de?.branch,Re,tt,yt,zn,o]),Td=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Ma.trim();if(!t)return;await yt({action:"commit",cwd:Re,message:t},o("rightSidebar.commitChanges"))&&dc("")},[Re,Ma,tt,yt,o]),Dm=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=gn.trim(),i=bn.trim();await yt({action:"push",cwd:Re,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Re,bn,gn,tt,yt,o]),Fm=a.useCallback(async()=>{if(!Re||tt){qt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=gn.trim(),i=bn.trim();await yt({action:"pull",cwd:Re,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Re,bn,gn,tt,yt,o]);a.useEffect(()=>{if(!ct||!Re||We)return;let t=!1;const i={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const w=await Qd({cwd:Re,action:u}).catch(()=>null);if(!w?.ok||w.status!=="running")continue;const y={action:u,cwd:Re},k=i[u]??u;Ms({action:u});try{const N=await io(w,y,k);if(t||!Pe(v))return;const ne=v?await Yi(v,void 0,{includeNested:Js(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Zs(v)}).catch(()=>N.bundle):N.bundle;ne&&Qn(ne,{reloadDiff:!0,cacheOnly:!0})}catch(N){t||qt(o("rightSidebar.gitActionFailed",{message:N instanceof Error?N.message:"Unknown error"}))}finally{t||Ms(null)}return}})(),()=>{t=!0}},[Re,Qn,ct,Pe,v,We,o,io]);const Ui=Un?.action==="commit",Hi=Un?.action==="switch-branch",zi=Un?.action==="pull",Wi=Un?.action==="push",co=ct||Dh,Gi=eo?o("rightSidebar.changeAuditScopeAll"):br.length===1?br[0].label:`${br.length} repos`,_m=br.length>0,Id=Hs.length>0,Bm=v?e.jsx(Wu,{open:Vo,onOpenChange:Yo,showScopePicker:!0,selectedAll:eo,repos:Qt,selectedRoots:Za,onToggleRepo:km,onGenerate:t=>Nm(Fi?"regenerate":"generate",t),disabled:!_m,generateDisabled:!Id,inserted:De?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Fi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Gi,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Fi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Oi()},secondaryDisabled:!Id||st,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:st,loading:rc.size>0,statusTitle:rc.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:cd.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:o("rightSidebar.missingBaseReposSkipped",{repositories:cd.map(t=>t.label).join(_==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=lt.get(t.root),u=os(t.root,nr[t.root]||i?.context?.branch),w=[],y=new Set,k=(xe,Ae)=>{!xe||y.has(xe)||(y.add(xe),w.push({value:xe,label:xe,meta:Ae}))};k(nr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const xe of i?.context?.branches??[])k(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const xe of i?.context?.remoteBranches??[])k(xe,o("rightSidebar.remoteBranch"));const N=[],ne=new Set,oe=(xe,Ae)=>{!xe||ne.has(xe)||(ne.add(xe),N.push({value:xe,label:xe,meta:Ae}))};oe(Et[t.root],Et[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),oe(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const xe of i?.context?.remoteBranches??[])oe(xe,"remote");for(const xe of i?.context?.branches??[])oe(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:nr[t.root]||i?.context?.branch||"",options:w,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:xe=>{ja(Ae=>({...Ae,[t.root]:xe}))}}),e.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:N,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:xe=>{Ra(Ae=>({...Ae,[t.root]:xe}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(u?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:u&&(un[t.root]??!0),disabled:!u,onChange:xe=>Jo(Ae=>({...Ae,[t.root]:xe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Dd=ea(kt.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),_),Om=()=>v?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>tc(t=>{const i=!t;return At(sl,i),i}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(ua,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Gi})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Cs?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]}),Cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",Gi]}),Bm]}),Ye&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ye}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[sn.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Cm(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),ea(t.createdAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:ea(t.createdAt,_)})]}),e.jsx("button",{type:"button",onClick:()=>Em(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:e.jsx(jo,{size:12})})]},t.key)),is.length>0?is.slice(0,Math.max(0,8-sn.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Mm(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),ea(t.latestInjectedAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:ea(t.latestInjectedAt,_)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{ym(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:e.jsx(jo,{size:12})})]},t.key)):sn.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Um=()=>sr&&v&&En?e.jsxs("div",{className:co?"overflow-visible":"overflow-hidden",children:[Om(),e.jsxs("button",{type:"button",onClick:()=>{ct||Fh(t=>{const i=!t;return i&&Re&&!En&&!pn&&ki(Re),i})},"aria-expanded":co,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${ct?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(xr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&e.jsx(ut,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!ct&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${co?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),co&&e.jsxs("div",{className:"space-y-0",children:[Ht.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:im})]})}),e.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:Re??"",options:Ht,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!We,onChange:t=>{Ad(t||null)}}),tt&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:o("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:zn!==rd?rd:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Im()},disabled:!bm,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Hi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[e.jsx("span",{className:We?.action==="switch-branch"||Hi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),We?.action==="switch-branch"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),Hi&&We?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:zn,options:dm,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!We,onChange:$a})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:tt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Td()},disabled:!!We||tt||Cn.staged===0||!Ma.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${Ui?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:tt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:We?.action==="commit"||Ui?"opacity-0":"",children:o("rightSidebar.commitChanges")}),We?.action==="commit"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),Ui&&We?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ma,onChange:t=>dc(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Td())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!We,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Kr(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":ln,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[ya&&e.jsx(ut,{size:12,className:"animate-spin text-muted-foreground"}),e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${ln?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),ln&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:12,className:"shrink-0"}),e.jsx("input",{value:cn,onChange:t=>dn(t.target.value),placeholder:o("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),cn&&e.jsx("button",{type:"button",onClick:()=>dn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:lm,children:[Dt.length>0?Dt.map(t=>{const[i,...u]=t.split(/\s+/),w=u.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{$m(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:w,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:w,children:w}),re[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${re[i]==="ahead"?"bg-accent/10 text-accent":re[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(re[i]==="ahead"?"rightSidebar.commitAhead":re[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),_n===i&&e.jsx(ut,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):ya?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):Ko?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),wa&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(ut,{size:12,className:"animate-spin"})}),qo&&!wa&&Dt.length>0&&e.jsx("button",{type:"button",onClick:()=>{Us({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:o("rightSidebar.recentCommitsLoadMore")})]})]}),Ss&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ss}),Ko&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ko})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Fm()},disabled:!pm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${zi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[e.jsx("span",{className:We?.action==="pull"||zi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),We?.action==="pull"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),zi&&We?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Dm()},disabled:!gm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Wi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[e.jsx("span",{className:We?.action==="push"||Wi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),We?.action==="push"&&e.jsx(ut,{size:12,className:"absolute animate-spin"}),Wi&&We?.action!=="push"&&e.jsx("span",{className:"absolute",children:"✓"})]})]})]}),e.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${ud.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:ud.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:de?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${ld?"grid-cols-2":"grid-cols-1"}`,children:[ld&&e.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:gn,options:id,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!We,onChange:Pa}),e.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:bn,options:um,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!We,onChange:Aa})]})]})]})]}):null,Hm=a.useCallback(t=>{const i=bt(t,v);if(!i)return[];const u=ml(t),w=[];return t.canStage&&w.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{yt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),u)}}),t.canUnstage&&w.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{yt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),u)}}),t.canStash&&w.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{yt({action:"stash-file",cwd:i,paths:[t.path]},o("rightSidebar.stashFile"),u)}}),t.canRestoreWorktree&&w.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>mn({kind:"restore",file:t,phrase:""})}),w},[v,yt,o]),zm=a.useCallback(()=>{if(f){h?.();return}Lr(0),Ir.current?.slideTo(0),Ar(!1),Wt(null)},[h,f]),Fd=a.useCallback(t=>{if(Y(""),_t(t),it(null),Wt(null),R(null),se){f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1);return}},[se,h,f,it,_t]);a.useEffect(()=>{if(!H||V.getState().pendingTerminalPath!==H)return;V.setState({pendingTerminalPath:null}),(()=>{const i=H,u=i.path;if(!u.startsWith("/"))return;Y(""),Wt(null),Tt(null);const w=!!(v&&(u===v||u.startsWith(`${v}/`)));if(i.kind==="file"){const y=So(u);Is(u),typeof i.line=="number"&&Number.isSafeInteger(i.line)&&i.line>0&&Tt(i.line),_t(w?null:y),R({path:u,nonce:++z.current});return}it(null),w?(_t(null),R({path:u,nonce:++z.current})):(R(null),_t(u)),se&&(f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1))})()},[H,Is,se,h,f,v,it,_t]),a.useEffect(()=>{r||(zt(!1),er(!1))},[r]),a.useEffect(()=>{if(!Sr&&!en)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(In.current?.contains(i.target)||jr.current?.contains(i.target))||(zt(!1),er(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[en,Sr]);const _d=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:sm,disabled:!Va,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:e.jsx(Ol,{size:14})}),e.jsx("button",{type:"button",onClick:Vc,disabled:!v||Gn===v,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:e.jsx(ou,{size:14})}),e.jsx("button",{type:"button",onClick:am,disabled:!le,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:uc?o("rightSidebar.fileWatchUnavailable",{message:uc}):o("rightSidebar.refreshFiles"),children:e.jsx(Ro,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:le??void 0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[e.jsx("span",{className:"truncate",children:rm}),Fa==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(iu,{size:11})})]})}),e.jsx("button",{type:"button",onClick:t=>le&&Xt(le,Ut??void 0,t.currentTarget),disabled:!le,...le&&Ut?Ei(Ga(le),Ut):{},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-35 active:scale-95 ${Ut&&(De===Ut||je===Ut)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ut&&je===Ut?"rightSidebar.copied":Ut&&De===Ut?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ut&&(De===Ut||je===Ut)?e.jsx(Po,{size:13}):e.jsx(Ao,{size:13})}),e.jsx(Rg,{rootPath:le,disabled:!le||!Uh||mi,pressed:Da,saving:mi,onToggle:()=>{if(!le||mi)return;const t=le;Ec(!0),pi(null),Hh(t,!Da).catch(()=>{const i=V.getState();(i.explorerRoot??i.rootPath)===t&&pi(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>Ec(!1))}}),e.jsxs("div",{ref:jr,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),er(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${en?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":en,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx($o,{size:14})}),en&&e.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{er(!1),om()},disabled:!Pi,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Bs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Bs?e.jsx(Qi,{size:14}):e.jsx(ho,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(Bs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{er(!1),Bh()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${di?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[di?e.jsx(Qp,{size:14}):e.jsx(Sl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(di?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!le,onClick:()=>{le&&(er(!1),Oh(le,Fa==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[Fa==="modified"?e.jsx(Ip,{size:14}):e.jsx(iu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(Fa==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),Mc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:Mc}),v&&(Ya.length>0||nm)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Vc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${le===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(ou,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:at})]}),Ya.map(t=>{const i=t.path,u=t.kind==="file",w=u?ot===i:le===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${w?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?Is(i):_t(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(jl,{size:10,className:"shrink-0"}):e.jsx(ho,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:wt(i)})]}),e.jsx("button",{type:"button",onClick:()=>xn(i),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.unpinFolder",{name:wt(i)}),title:o("rightSidebar.unpinFolder",{name:wt(i)}),children:e.jsx(Lt,{size:9})})]},i)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),Ki=a.useMemo(()=>{if(Hn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((si-Hn)/1e3)),u=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[w,y]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return u.format(w,y)},[si,Hn]),uo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Bd=v&&!es?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{Tm(!ui)},"aria-checked":ui,title:o("rightSidebar.multiRepoScanTitle"),className:uo,children:[e.jsx(xr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),ui&&e.jsx(Po,{size:14,className:"shrink-0 text-primary"})]}):null,Od=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Ki?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Ki}),children:Ki}):null,e.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:e.jsx(Ro,{size:13,className:hr?"animate-spin":""})})]}):null,Wm=Dc?o("rightSidebar.changeAuditScopeAll"):kn.length===1?kn[0].relativeRoot==="."?at:kn[0].relativeRoot||kn[0].name:`${kn.length} repos`,Gm=t=>v?e.jsxs("div",{role:"none",children:[e.jsx(Wu,{menuItem:!0,open:vs,onOpenChange:i=>{nn(i),i&&t()},showScopePicker:Mn,selectedAll:Dc,repos:zh,selectedRoots:or,onToggleRepo:wm,onGenerate:async i=>{const u=await xm("generate",i);return u!==!1&&t(),u},disabled:!v,inserted:De===qc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Wm,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Hr,error:!!$r,statusTitle:$r??(Hr?o("rightSidebar.changeAuditLoading"):kt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:kt.length})}${Dd?` · ${o("rightSidebar.changeAuditLoadedAt",{time:Dd})}`:""}`:void 0)}),kt.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),vm()},disabled:Hr||kt.length===0,className:uo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(jo,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ls=ir??(M?.available&&v&&Fe.size>0&&fe.length<=1?{root:v,label:at}:null),Ud=t=>e.jsxs(e.Fragment,{children:[ls&&e.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),lo("stage-all",ls.root,ls.label)},disabled:!!We,className:uo,children:[e.jsx(wp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),lo("stash-all",ls.root,ls.label)},disabled:!!We,className:uo,children:[e.jsx(Wp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ls&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Gm(t),Bd&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Bd]}),fo=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[M?.available&&M.branch&&e.jsxs("span",{className:"inline-flex min-w-0 max-w-[8rem] items-center gap-0.5 truncate rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",title:M.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:M.branch})]}),pt.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[pt.modified,"M"]}),pt.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",pt.added]}),pt.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",pt.deleted]}),pt.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.renamed,"R"]}),pt.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.copied,"C"]}),pt.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.untracked,"U"]}),pt.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[pt.conflicted,"!"]}),pt.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.other,"?"]}),pt.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:pt.staged})})]});return e.jsxs(Dp,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m,children:[Ei.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Xh?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:v??void 0,children:at}),(!se||ti)&&M?.available&&M.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:M.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:M.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!Z;P(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):Y("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Z?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:e.jsx(ms,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":B,onClick:()=>{ae(t=>!t),et(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${B?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[e.jsx(Fp,{size:14}),!B&&Nt.trim()&&e.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),e.jsx("input",{ref:pc,type:"file",multiple:!0,className:"hidden",onChange:t=>{const i=t.target.files;!i||i.length===0||(Ds(Array.from(i)),t.target.value="")}}),e.jsx("input",{ref:gc,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&Zh(i,t.currentTarget.closest("[data-sidebar]")??void 0)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${m?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:m?e.jsx(Qi,{size:14}):e.jsx(ho,{size:14})}),e.jsxs("div",{ref:In,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{er(!1),zt(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Sr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Sr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx($o,{size:15})}),Sr&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[["architecture","computer"].map(t=>e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":ar[t],onClick:()=>Qh(t,!ar[t]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t==="architecture"?e.jsx(lu,{size:14,className:"text-muted-foreground"}):e.jsx(eu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o(t==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${ar[t]?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${ar[t]?"left-3.5":"left-0.5"}`})})]},t)),e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Vr,onClick:()=>Bc(!Vr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(tu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Vr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Vr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),pc.current?.click()},disabled:Ha,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[Ha?e.jsx(ut,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(_p,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),gc.current?.click()},disabled:Ha,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[Ha?e.jsx(ut,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(sg,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${m?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[m?e.jsx(Qi,{size:14}):e.jsx(ho,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),m&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":o("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([t,i])=>{const u=G===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(t),zt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:i},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:14})})]}),Z&&e.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-3 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(ms,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:t=>Y(t.target.value),placeholder:o(ie==="content"?"rightSidebar.searchPlaceholderContent":"rightSidebar.filterChanges"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",enterKeyHint:"search",spellCheck:!1}),e.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${se?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>$d("name"),"aria-pressed":ie==="name",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${ie==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>$d("content"),"aria-pressed":ie==="content",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${ie==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>Y(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(Bp,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:Se,onChange:t=>ke(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Se!=="."&&e.jsx("button",{type:"button",onClick:()=>ke("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:e.jsx(Lt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>ue(t=>!t),"aria-expanded":ge,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${ge||As.length>0||_e||W||ye?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[e.jsx(Op,{size:13}),As.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[8px] font-bold leading-4 text-primary-foreground",children:As.length})]})]}),ge&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:Me,onChange:t=>Q(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Me&&e.jsx("button",{type:"button",onClick:()=>Q(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:e.jsx(Lt,{size:11})})]}),ie==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[_e,()=>Ue(t=>!t),Xp,o("rightSidebar.matchCase")],[W,()=>we(t=>!t),dg,o("rightSidebar.matchWholeWord")],[ye,()=>He(t=>!t),og,o("rightSidebar.useRegex")]].map(([t,i,u,w])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),w]},w))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(es?1:3)+Number(ar.architecture)+Number(ar.computer)+Number(Vr)}, minmax(0, 1fr))`},children:[!es&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>ns("git",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>ns("diff",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(vf,{size:12}),o("rightSidebar.tabChanges"),Fe.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Fe.size}):null]})]}),e.jsxs("button",{type:"button",onClick:t=>ns("files",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xl,{size:12}),o("rightSidebar.tabFiles")]}),ar.architecture&&e.jsxs("button",{type:"button",onClick:t=>ns("architecture",t),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Sn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(lu,{size:12}),o("architecture.tab")]}),ar.computer&&e.jsxs("button",{type:"button",onClick:t=>ns("computer",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${rs?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(eu,{size:12}),o("rightSidebar.tabComputer")]}),Vr&&e.jsxs("button",{type:"button",onClick:t=>ns("android",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(tu,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),lc&&e.jsx("div",{className:"pointer-events-none absolute right-3 top-10 z-20 max-w-[72%] rounded-lg bg-destructive/95 px-3 py-2 text-[11px] font-medium text-destructive-foreground shadow-md animate-fade-in",children:lc})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(ds,{active:ct,mounted:sr,fallback:e.jsx(ul,{slow:!1}),children:()=>Xe?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(xu,{items:Sm,diffViewType:oi,inlineMode:Kt,viewControls:m?zs():void 0,renderPathReference:(t,i)=>to(Pn(t,Xe.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Mh,onSelect:ka,emptyText:o("rightSidebar.noChanges"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Xe.headRef??""}${Xe.commits?.[0]?` · ${Xe.commits[0]}`:""}`,onClose:()=>{mt(null),ka(null)},closeLabel:o("common.back"),wrap:It,onToggleWrap:oo,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no})}):Pr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(xu,{items:Di,diffViewType:oi,inlineMode:Kt,viewControls:m?zs():void 0,renderPathReference:(t,i)=>{const u=ve?.comparisonRepos,w=u&&u.length>1?[...u].sort((k,N)=>N.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,y=w?t===w.label?w.repoRoot:Pn(t.slice(w.label.length+1),w.repoRoot):Pn(t,Ks?.repoRoot||v);return to(y,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Qo,onSelect:hn,emptyText:o(ve?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(ve?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Ks?`${Ks.repoLabel} · ${Ks.branchName??"HEAD"} → ${Ks.baseRef}`:void 0,onClose:()=>{++K.current,Be(!1),cr(!1),rr(null)},closeLabel:o("common.back"),wrap:It,onToggleWrap:oo,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no,localOptions:ve?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??ve.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??os(t.repoRoot,t.head)),onChange:i=>{Oi({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:ve?.includeUncommitted?Lm:void 0,error:Ye,actionsBusy:be>0,onRefresh:()=>{Oi({refresh:!0})},refreshing:st,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:jm,onWalkthroughNavigate:Rm,initialDetailScrollTop:ve&&Qe?ks[Qe]:void 0,onDetailScrollPositionChange:Pm,externalSwiperRef:se?Tc:void 0,onMobileSlideChange:se?ei:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:sr&&v&&En?e.jsx("div",{className:"px-3",children:Um()}):hr?e.jsx(ul,{slow:jc}):vn?e.jsx(ko,{message:vn,onRetry:()=>{Zn()}}):Yu(M)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):M?.available===!1?e.jsx(ko,{message:M.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Zn()}}):v?e.jsx(ul,{slow:jc}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(ds,{active:Dr,mounted:Ph||Dr,children:()=>se?e.jsxs(cf,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Ir.current=t,t.slideTo(Zo,0)},onSlideChange:t=>{if(Lr(t.activeIndex),Ts.current===t.activeIndex){Ts.current=null;return}t.activeIndex===0&&(Ar(!1),Wt(null),h?.())},children:[e.jsx(vl,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Vn,onScroll:Oc,onDragOver:za,onDragEnter:za,onDragLeave:Hc,onDrop:zc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[fc&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!I.trim()&&_d,e.jsx(cu,{rootPath:le??"",onFileSelect:Is,onPathReference:Xt,getReferenceText:Ga,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onDirectoryRoot:Yc,onSearchFromDirectory:Xc,onDirectoryPinToggle:Jc,onFilePinToggle:Qc,pinnedPaths:Rn,selectedFilePath:ot,query:Ke,searchRootPath:$c,searchOptions:Pc,searchMode:ie,onContentMatchSelect:Ri,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:U,canOpenInFileBrowser:hc,onOpenInFileBrowser:Uc})]})}),e.jsx(vl,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Uo,{filePath:$h||Zo===1?ot:null,active:r&&Dr&&Zo===1,onInsertReference:Xt,onInsertText:Fr,onInsertFeature:qa,onReviewReference:qa,onReferenceCopied:gr,onClose:zm,onDirectoryLinkOpen:Fd,isMobile:!0,lineRange:Or,onLineRangeChange:Wt,insertedReferenceKey:De,copiedReferenceKey:je,scrollToLine:Ve,onScrollToLineHandled:()=>Tt(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:C,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:O,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Vn,onScroll:Oc,onDragOver:za,onDragEnter:za,onDragLeave:Hc,onDrop:zc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:ii},children:[fc&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!I.trim()&&_d,e.jsx(cu,{rootPath:le??"",onFileSelect:Is,onPathReference:Xt,getReferenceText:Ga,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onDirectoryRoot:Yc,onSearchFromDirectory:Xc,onDirectoryPinToggle:Jc,onFilePinToggle:Qc,pinnedPaths:Rn,selectedFilePath:ot,query:Ke,searchRootPath:$c,searchOptions:Pc,searchMode:ie,onContentMatchSelect:Ri,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:U,canOpenInFileBrowser:hc,onOpenInFileBrowser:Uc})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:Wh,onPointerMove:Gh,onPointerUp:_c,onPointerCancel:_c,onDoubleClick:()=>{li(Ml),At(na,Ml)},children:e.jsx("span",{className:"absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-border/20 transition group-hover:bg-primary/45"})}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Uo,{filePath:ot,active:r&&Dr,onInsertReference:Xt,onInsertText:Fr,onInsertFeature:qa,onReviewReference:qa,onReferenceCopied:gr,onDirectoryLinkOpen:Fd,isMobile:!1,lineRange:Or,onLineRangeChange:Wt,insertedReferenceKey:De,copiedReferenceKey:je,scrollToLine:Ve,onScrollToLineHandled:()=>Tt(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:C,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:O,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})]})}),e.jsx(ds,{active:$t,mounted:Lh||$t,children:()=>Si?e.jsx(Up,{}):se?e.jsx(yl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:wi,onMobileSlideChange:ei,groups:Zt.length>0?bd():[],mode:Er,onModeChange:ao,selectedKey:ot,scrollToKey:kd,scrollToKeyNonce:La.nonce,compact:!1,collapsedDirectoryKeys:ga,onToggleDirectory:Rd,onSelectFile:t=>{const i=$n.get(t.key);i&&so(vr(i))},renderLeading:xd,renderTrailing:t=>{const i=$n.get(t.key);return i?pd(i):null},renderDirectoryTrailing:gd,renderSubtitle:t=>{const i=$n.get(t.key);return i?md(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[fo&&e.jsx("div",{className:"mb-2",children:fo}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Zt.length,"/",Fe.size]})]}),e.jsxs(pu,{actions:Ud,children:[fd(),t,m&&zs(),Od]},v),ir&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&Mn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Qa?(t=>jd(t)):void 0,emptyContent:Si?null:vn&&Fe.size===0?e.jsx(ko,{message:vn,onRetry:()=>{Zn()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Zt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:t})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[e.jsx(ca,{size:14}),o("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[m&&zs(),e.jsxs("button",{type:"button",onClick:oo,"aria-pressed":It,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${It?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(It?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:e.jsx(Ro,{size:14,className:hr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:vd,activePane:$t,wrap:It,diffViewType:oi,inlineMode:Kt,diffOptions:Md,reloadKey:va,renderStreamBadge:t=>e.jsx(oa,{status:t}),onHunkGitAction:Pd,onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no,onDetailScroll:ro}):e.jsx(yl,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:o("rightSidebar.backToChangeList"),groups:Zt.length>0?bd():[],mode:Er,onModeChange:ao,selectedKey:ot,scrollToKey:kd,scrollToKeyNonce:La.nonce,compact:!0,collapsedDirectoryKeys:ga,onToggleDirectory:Rd,onSelectFile:t=>{const i=$n.get(t.key);i&&so(vr(i))},renderLeading:xd,renderTrailing:t=>{const i=$n.get(t.key);return i?pd(i):null},renderDirectoryTrailing:gd,renderSubtitle:t=>{const i=$n.get(t.key);return i?md(i):null},aiContent:Qa?(t=>jd(t)):void 0,emptyContent:Si?null:vn&&Fe.size===0?e.jsx(ko,{message:vn,onRetry:()=>{Zn()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Zt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[fo&&e.jsx("div",{className:"mb-2",children:fo}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Zt.length,"/",Fe.size]})})]}),e.jsxs(pu,{actions:Ud,children:[fd(),t,zs(),e.jsxs("button",{type:"button",onClick:oo,"aria-pressed":It,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${It?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(It?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Od]},v),ir&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&Mn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:vd,activePane:$t,wrap:It,diffViewType:Gt,inlineMode:Kt,diffOptions:Md,reloadKey:va,renderStreamBadge:t=>e.jsx(oa,{status:t}),onHunkGitAction:Pd,onInsertDiffReference:_r,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je,onClearAuditRecord:no,onDetailScroll:ro})}),e.jsx(ds,{active:Sn,mounted:ar.architecture&&(Vh||r&&Sn),children:e.jsx(a.Suspense,{fallback:e.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:e.jsx(nx,{rootPath:v,active:r&&Sn,onInsertPrompt:(t,i)=>Fr(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(w0,{rootPath:v,file:t,active:r&&Sn,isMobile:se,onInsertReference:Xt,onInsertText:Fr,onReferenceCopied:gr,insertedReferenceKey:De,copiedReferenceKey:je},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(Ft("files"),_t(null),Ri(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(ds,{active:r&&rs,mounted:ar.computer&&(Kh||r&&rs),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(sx,{active:r&&rs})})}),e.jsx(ds,{active:ts,mounted:ni&&Vr,children:Th?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:o("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{Vi.getState().setDock(Xi,null),ra({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Hp,{sessionId:n??null,onCloseTab:()=>Bc(!1),onInsertPrompt:async(t,i)=>{if(!await _r("android-deps",t,void 0,i))throw new Error(o("rightSidebar.uploadReferenceRejected"))},onInsertFile:tm,onRecordingComplete:em})})]}),r&&Rt&&e.jsx("div",{role:"alert",className:"shrink-0 border-t border-border/15 px-3 py-2 text-xs text-destructive",children:o("rightSidebar.referenceInsertFailed")}),r&&Ot.task&&e.jsx(Zg,{task:Ot.task,onCancel:Ot.cancel,onRetry:()=>{Ot.retry()},onDismiss:Ot.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Ot.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Ot.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:Ot.task.files.length})}}),r&&B&&e.jsx(Vg,{value:Nt,collapsed:Ce,autoCollapseAfterSend:xt,focusRequest:Tn,insertError:Dn?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{tn(!1),Ct(t)},onCollapsedChange:et,onAutoCollapseAfterSendChange:kr,onDisable:()=>ae(!1),onClear:()=>Ct(""),onInsert:t=>Kc(!1,t),onInsertAndSend:t=>Kc(!0,t),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>o("rightSidebar.contextDraftCharacterCount",{count:t})}}),mm(),vt&&typeof document<"u"&&wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>mn(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:vt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:vt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:af(vt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),vt.kind==="restore"&&e.jsx("input",{value:vt.phrase,onChange:t=>mn({...vt,phrase:t.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>mn(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),e.jsx("button",{type:"button",disabled:!!We||vt.kind==="restore"&&vt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(vt.kind==="restore"){const t=bt(vt.file,v);if(!t)return;yt({action:"restore-worktree-file",cwd:t,paths:[vt.file.path],confirm:{acknowledged:!0,phrase:vt.phrase}},o("rightSidebar.restoreFile"),ml(vt.file))}else{const t=vt.repoRoot??v;if(!t)return;yt({action:"stash-all",cwd:t},o("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${vt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(We?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const T0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Uo,MarkdownImageLightbox:bh,MarkdownPreview:xh,RightSidebar:k0,__testParseMarkdownListBlock:Bx,buildMarkdownPreviewBlocks:Yx,buildMarkdownPreviewRenderResult:Xl,collectKnownGitRepoRoots:Hf,computeMarkdownImageDisplayBox:eh,getMarkdownHeadingOutline:gh,getMarkdownHeadingPathAtLine:ph,getNextMarkdownPreviewLineRange:t0,isSvgImageSrc:pa,mountRightSidebarRepoPickerOverlay:Mf,replaceGitRepositorySnapshot:jh,resolveMarkdownLocalLinkTarget:Wl,resolveRightSidebarDiffViewType:Of,shouldCloseMarkdownImageLightboxDrag:fh,showsGitRepoGroupHeader:$l},Symbol.toStringTag,{value:"Module"}));export{Sl as E,T0 as R,lg as S,Qp as a,Yx as b,Ng as c,Sg as i,kg as l,L0 as m};
|