termdock 1.4.331 → 1.4.332
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/THIRD_PARTY_NOTICES.md +12 -0
- package/dist/client/assets/{App-xBkso5In.js → App-BB9Zns7R.js} +37 -37
- package/dist/client/assets/App-BB9Zns7R.js.br +0 -0
- package/dist/client/assets/App-BB9Zns7R.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-DCxpe1Bj.js +9 -0
- package/dist/client/assets/ArchitecturePanel-DCxpe1Bj.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-DCxpe1Bj.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-xvUzbgKh.js → ChangeWalkthroughPanel-CAyVfccZ.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-CAyVfccZ.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-CAyVfccZ.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-Bey7tYQF.js +1 -0
- package/dist/client/assets/CollaborationMainWorkspace-Bey7tYQF.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-Bey7tYQF.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-Q5KzPAOz.js +2 -0
- package/dist/client/assets/{ComputerControlView-D-1UEmtr.js → ComputerControlView-CojIu02o.js} +3 -3
- package/dist/client/assets/ComputerControlView-CojIu02o.js.br +0 -0
- package/dist/client/assets/ComputerControlView-CojIu02o.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-1KaifMRo.js → DagPlayground-BeyWYMaL.js} +1 -1
- package/dist/client/assets/DagPlayground-BeyWYMaL.js.br +0 -0
- package/dist/client/assets/DagPlayground-BeyWYMaL.js.gz +0 -0
- package/dist/client/assets/{DiffLab-Dh7lMk1W.js → DiffLab-DW3LP4Zk.js} +1 -1
- package/dist/client/assets/DiffLab-DW3LP4Zk.js.br +0 -0
- package/dist/client/assets/DiffLab-DW3LP4Zk.js.gz +0 -0
- package/dist/client/assets/{DiffReview-Bxe6OacV.js → DiffReview-CsQjyKYd.js} +1 -1
- package/dist/client/assets/DiffReview-CsQjyKYd.js.br +0 -0
- package/dist/client/assets/DiffReview-CsQjyKYd.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-CwdLf6kM.js → DiffReviewLab-DRvhZLgu.js} +1 -1
- package/dist/client/assets/DiffReviewLab-DRvhZLgu.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-DRvhZLgu.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-oGb-V3AK.js → DiffViewer-CwTOIjTT.js} +1 -1
- package/dist/client/assets/DiffViewer-CwTOIjTT.js.br +0 -0
- package/dist/client/assets/DiffViewer-CwTOIjTT.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-BTunplWr.js → ModelPreview-BHmMm0Pj.js} +1 -1
- package/dist/client/assets/ModelPreview-BHmMm0Pj.js.br +0 -0
- package/dist/client/assets/ModelPreview-BHmMm0Pj.js.gz +0 -0
- package/dist/client/assets/RightSidebar-Coc7x6Q-.js +1677 -0
- package/dist/client/assets/RightSidebar-Coc7x6Q-.js.br +0 -0
- package/dist/client/assets/RightSidebar-Coc7x6Q-.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-D4LxQjpJ.js → abnfDiagram-VCTEODGH-wY9KgDKQ.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-wY9KgDKQ.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-wY9KgDKQ.js.gz +0 -0
- package/dist/client/assets/app-D-AilvVY.js +35 -0
- package/dist/client/assets/app-D-AilvVY.js.br +0 -0
- package/dist/client/assets/app-D-AilvVY.js.gz +0 -0
- package/dist/client/assets/{arc-BcCf73Fm.js → arc-DVBtoEGf.js} +1 -1
- package/dist/client/assets/arc-DVBtoEGf.js.br +0 -0
- package/dist/client/assets/arc-DVBtoEGf.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-Dfg95GK6.js → architectureDiagram-5GKGNRK7-CQPsSdTB.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CQPsSdTB.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CQPsSdTB.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-BwXSp0xK.js → blockDiagram-I7D4REHJ-OB_hCQwv.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-OB_hCQwv.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-OB_hCQwv.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-D4GfUedH.js → c4Diagram-7LVT6UL2-Cp72_koy.js} +1 -1
- package/dist/client/assets/{c4Diagram-7LVT6UL2-D4GfUedH.js.br → c4Diagram-7LVT6UL2-Cp72_koy.js.br} +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-Cp72_koy.js.gz +0 -0
- package/dist/client/assets/channel-CYCNCfSN.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-BqcmDKjo.js → chunk-2Q5K7J3B-wZpiUjnH.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-BBV3_wnk.js → chunk-5VM5RSS4-DZA-nY7e.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-B-r7e040.js → chunk-F27PBJKO-DWjLrbpP.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-DWjLrbpP.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-DWjLrbpP.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-B83oWEy_.js → chunk-IMKFNOWR-Dmq185X2.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-Dmq185X2.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Dmq185X2.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-C2FW583q.js → chunk-JWPE2WC7-Bw9j-pi5.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-BWU7oLd-.js → chunk-POPQ4Y6H-BjWtrh1M.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-C5OgXymb.js → chunk-SVP7TREG-VIH7H3Pr.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-VIH7H3Pr.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-VIH7H3Pr.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-B1LlRwu4.js → chunk-TICWLB2K-D8lo3HVO.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-D8lo3HVO.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-D8lo3HVO.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-7l9gcG6S.js → chunk-XXDRQBXY-DTbG8Qn9.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-CV6z7LP1.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CV6z7LP1.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-DNBCyqkI.js → cose-bilkent-JH36ORCC-Cey1iRcB.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-Cey1iRcB.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-Cey1iRcB.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-BiCAbJSv.js → cynefin-OW5HDTMX-BSP2A8yQ.js} +1 -1
- package/dist/client/assets/{cynefin-OW5HDTMX-BiCAbJSv.js.br → cynefin-OW5HDTMX-BSP2A8yQ.js.br} +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-BiCAbJSv.js.gz → cynefin-OW5HDTMX-BSP2A8yQ.js.gz} +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CaRucQy9.js → cynefinDiagram-5FMLGOSQ-Wq4INzwW.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Wq4INzwW.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Wq4INzwW.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-kU4wdq9U.js → dagre-GXQ25YYZ-UgOLsTAJ.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-UgOLsTAJ.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-UgOLsTAJ.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-BvDFZeQg.js → diagram-S7CK7UJ4-CXi8ez4a.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-CXi8ez4a.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-CXi8ez4a.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-DYTly1n3.js → diagram-UQ7AKVKN-WD44iVkL.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-WD44iVkL.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-WD44iVkL.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-C0bMSg7N.js → diagram-VSXAHHWV-DeeTr7nX.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-DeeTr7nX.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DeeTr7nX.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-C9_Uoa7n.js → diagram-VX7I27RA-r3wdM6Nm.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-r3wdM6Nm.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-r3wdM6Nm.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-CLsF0k3J.js → diagram-Z3DM3KII-q2jyvUdh.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-q2jyvUdh.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-q2jyvUdh.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-Bt6b2Ygi.js → ebnfDiagram-PWID7BFC-Cb7oWq7z.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Cb7oWq7z.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Cb7oWq7z.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-Bs5jB7E2.js → erDiagram-RLTQ6QDP-CNuNvK3_.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-CNuNvK3_.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-CNuNvK3_.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-BCSeo8DJ.js → flowDiagram-HODETNUW-BYdnedTN.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-BYdnedTN.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BYdnedTN.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-BnCBe-Ue.js → ganttDiagram-EL5Y4UJY-CaxdXqhz.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CaxdXqhz.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CaxdXqhz.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-W1Lo4NZw.js → gestureArbiter-DPJowqRM.js} +1 -1
- package/dist/client/assets/gestureArbiter-DPJowqRM.js.br +0 -0
- package/dist/client/assets/gestureArbiter-DPJowqRM.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-C7BJXlkD.js → gitGraphDiagram-WWUBYQGX-DRO8nFRo.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DRO8nFRo.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DRO8nFRo.js.gz +0 -0
- package/dist/client/assets/index-CRxcDATF.css +1 -0
- package/dist/client/assets/index-CRxcDATF.css.br +0 -0
- package/dist/client/assets/index-CRxcDATF.css.gz +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-CJXzvnav.js → infoDiagram-27XIBGKW-D8154Axl.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BoBCZ1Wa.js → ishikawaDiagram-5VMMS53U-C-m2YcvO.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-C-m2YcvO.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-C-m2YcvO.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-C5bywqIt.js → journeyDiagram-3NMN7TZE-BaYbc4fI.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-BaYbc4fI.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-BaYbc4fI.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-ChHpoQyu.js → kanban-definition-UXKFOSKX-C4ZmM3W8.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-C4ZmM3W8.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-C4ZmM3W8.js.gz +0 -0
- package/dist/client/assets/{layout-e7M-xuok.js → layout-TUsrKU-t.js} +1 -1
- package/dist/client/assets/layout-TUsrKU-t.js.br +0 -0
- package/dist/client/assets/layout-TUsrKU-t.js.gz +0 -0
- package/dist/client/assets/{linear-A5CrihlL.js → linear-nScEH6bm.js} +1 -1
- package/dist/client/assets/{linear-A5CrihlL.js.br → linear-nScEH6bm.js.br} +0 -0
- package/dist/client/assets/linear-nScEH6bm.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-BNac_Y3z.js → mermaid.core-WM_j9CSC.js} +5 -5
- package/dist/client/assets/mermaid.core-WM_j9CSC.js.br +0 -0
- package/dist/client/assets/mermaid.core-WM_j9CSC.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-fQoEGcCr.js → mindmap-definition-YA3MSWOX-D5bLjroL.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D5bLjroL.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D5bLjroL.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap--0YoOXsx.js → passwordBootstrap-BHUt4zht.js} +1 -1
- package/dist/client/assets/passwordBootstrap-BHUt4zht.js.br +0 -0
- package/dist/client/assets/{passwordBootstrap--0YoOXsx.js.gz → passwordBootstrap-BHUt4zht.js.gz} +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-CYbfla8A.js → pegDiagram-XKGWAZYB-BCJ-HO-6.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-BCJ-HO-6.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-BCJ-HO-6.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-B6--ZKXC.js → pieDiagram-E7YTZNPT-Dg3u_zy9.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-Dg3u_zy9.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-Dg3u_zy9.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Bau_h7Jl.js → quadrantDiagram-AXDQQJYC-Bi9SzqYi.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Bi9SzqYi.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Bi9SzqYi.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-CApEuiEL.js → railroadDiagram-O6MQD6OU-Kbg4uhta.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-Kbg4uhta.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-Kbg4uhta.js.gz +0 -0
- package/dist/client/assets/{rdpSession-CydBq1bk.js → rdpSession-D_TLn9lr.js} +1 -1
- package/dist/client/assets/rdpSession-D_TLn9lr.js.br +0 -0
- package/dist/client/assets/rdpSession-D_TLn9lr.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-8ExgTbB3.js → referenceLongPress-CalVNheA.js} +1 -1
- package/dist/client/assets/referenceLongPress-CalVNheA.js.br +0 -0
- package/dist/client/assets/referenceLongPress-CalVNheA.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-Rxe80d7j.js → requirementDiagram-BXWQKSXE-DY1nJYdk.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DY1nJYdk.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DY1nJYdk.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-BaPl8d6E.js → sankeyDiagram-P5KCCOFB-Ch9oVvbH.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-Ch9oVvbH.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-Ch9oVvbH.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-Asyx5gWK.js → sequenceDiagram-WJ2MYXX4-BXQhyqVP.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BXQhyqVP.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BXQhyqVP.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-BQaSglof.js → sizeCapture-INFHLROL-CHCCkDzJ.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-CHCCkDzJ.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-CHCCkDzJ.js.gz +0 -0
- package/dist/client/assets/{sparkles-BMR6NziM.js → sparkles-CbQl9qpO.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-DycNNggj.js → stateDiagram-D77RDMKH-BsAiJFKS.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-BsAiJFKS.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-BsAiJFKS.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-joTNV3tX.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-2Z5Zd5j6.js → swimlanes-42K2YHIH-9JFTgCXC.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-9JFTgCXC.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-9JFTgCXC.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-C-2Ixi86.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-BHiRARcP.js → timeline-definition-24CTP7MA-tkuoWWzM.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-tkuoWWzM.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-tkuoWWzM.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-TsfoVQJR.js → triangle-alert-DTiOfHLO.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-JgKZ8N2y.js → vennDiagram-4TSXK5OY-CEnwO3RG.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-CEnwO3RG.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CEnwO3RG.js.gz +0 -0
- package/dist/client/assets/{videoCompression-DGfMcwdq.js → videoCompression-q9AAJQ5R.js} +1 -1
- package/dist/client/assets/videoCompression-q9AAJQ5R.js.br +0 -0
- package/dist/client/assets/videoCompression-q9AAJQ5R.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-DNmP9dmD.js → wardleyDiagram-VM6X3IG4-BFLZVXWw.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFLZVXWw.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFLZVXWw.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BBFR9gmo.js → xychartDiagram-S5SC5T6Z-CyZtg8vv.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CyZtg8vv.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CyZtg8vv.js.gz +0 -0
- package/dist/client/fonts/MapleMono-Bold.woff2 +0 -0
- package/dist/client/fonts/MapleMono-BoldItalic.woff2 +0 -0
- package/dist/client/fonts/MapleMono-Italic.woff2 +0 -0
- package/dist/client/fonts/MapleMono-OFL.txt +94 -0
- package/dist/client/fonts/MapleMono-OFL.txt.br +0 -0
- package/dist/client/fonts/MapleMono-OFL.txt.gz +0 -0
- package/dist/client/fonts/MapleMono-Regular.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-Bold-ascii-71449796b4f8.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-Bold-text-57c71f86a6f8.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-BoldItalic-ascii-6b6deb59a8cd.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-BoldItalic-text-b2e1a12c67be.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-Italic-ascii-cd2f6088ed50.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-Italic-text-a346c77141da.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-Regular-ascii-9a80fd4a5743.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockMaple-Regular-text-58438803bf4c.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockPromptIcons-Bold-icons-fa87935d39d0.woff2 +0 -0
- package/dist/client/fonts/terminal/TermdockPromptIcons-Regular-icons-0d64d12759b8.woff2 +0 -0
- package/dist/client/fonts/terminal/manifest.json +98 -0
- package/dist/client/fonts/terminal/manifest.json.br +0 -0
- package/dist/client/fonts/terminal/manifest.json.gz +0 -0
- package/dist/client/index.html +12 -11
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/dist/server/agent/collaborationPeerTransport.js +2 -2
- package/dist/server/entry.js +2 -1
- package/dist/server/federation/selfRelay.js +12 -8
- package/package.json +1 -1
- package/runtime-manifest.json +3 -3
- package/scripts/generate-font-subsets.py +64 -9
- package/dist/client/assets/App-xBkso5In.js.br +0 -0
- package/dist/client/assets/App-xBkso5In.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-DNY0prqs.js +0 -9
- package/dist/client/assets/ArchitecturePanel-DNY0prqs.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-DNY0prqs.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-xvUzbgKh.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-xvUzbgKh.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DsIWXeh0.js +0 -1
- package/dist/client/assets/CollaborationMainWorkspace-DsIWXeh0.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DsIWXeh0.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-DatXl2k_.js +0 -2
- package/dist/client/assets/ComputerControlView-D-1UEmtr.js.br +0 -0
- package/dist/client/assets/ComputerControlView-D-1UEmtr.js.gz +0 -0
- package/dist/client/assets/DagPlayground-1KaifMRo.js.br +0 -0
- package/dist/client/assets/DagPlayground-1KaifMRo.js.gz +0 -0
- package/dist/client/assets/DiffLab-Dh7lMk1W.js.br +0 -0
- package/dist/client/assets/DiffLab-Dh7lMk1W.js.gz +0 -0
- package/dist/client/assets/DiffReview-Bxe6OacV.js.br +0 -0
- package/dist/client/assets/DiffReview-Bxe6OacV.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-CwdLf6kM.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-CwdLf6kM.js.gz +0 -0
- package/dist/client/assets/DiffViewer-oGb-V3AK.js.br +0 -0
- package/dist/client/assets/DiffViewer-oGb-V3AK.js.gz +0 -0
- package/dist/client/assets/ModelPreview-BTunplWr.js.br +0 -0
- package/dist/client/assets/ModelPreview-BTunplWr.js.gz +0 -0
- package/dist/client/assets/RightSidebar-DvYmab8z.js +0 -1677
- package/dist/client/assets/RightSidebar-DvYmab8z.js.br +0 -0
- package/dist/client/assets/RightSidebar-DvYmab8z.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-D4LxQjpJ.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-D4LxQjpJ.js.gz +0 -0
- package/dist/client/assets/app-A96wp9Xv.js +0 -35
- package/dist/client/assets/app-A96wp9Xv.js.br +0 -0
- package/dist/client/assets/app-A96wp9Xv.js.gz +0 -0
- package/dist/client/assets/arc-BcCf73Fm.js.br +0 -0
- package/dist/client/assets/arc-BcCf73Fm.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-Dfg95GK6.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-Dfg95GK6.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BwXSp0xK.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BwXSp0xK.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-D4GfUedH.js.gz +0 -0
- package/dist/client/assets/channel-k5dcS0_z.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-B-r7e040.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-B-r7e040.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-B83oWEy_.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-B83oWEy_.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-C5OgXymb.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-C5OgXymb.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-B1LlRwu4.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-B1LlRwu4.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-DQzBzWJL.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DQzBzWJL.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-DNBCyqkI.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-DNBCyqkI.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CaRucQy9.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CaRucQy9.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-kU4wdq9U.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-kU4wdq9U.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BvDFZeQg.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BvDFZeQg.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DYTly1n3.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DYTly1n3.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-C0bMSg7N.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-C0bMSg7N.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C9_Uoa7n.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C9_Uoa7n.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CLsF0k3J.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CLsF0k3J.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Bt6b2Ygi.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Bt6b2Ygi.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Bs5jB7E2.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Bs5jB7E2.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BCSeo8DJ.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BCSeo8DJ.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BnCBe-Ue.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-BnCBe-Ue.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-W1Lo4NZw.js.br +0 -0
- package/dist/client/assets/gestureArbiter-W1Lo4NZw.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C7BJXlkD.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C7BJXlkD.js.gz +0 -0
- package/dist/client/assets/index-e1PkqIqN.css +0 -1
- package/dist/client/assets/index-e1PkqIqN.css.br +0 -0
- package/dist/client/assets/index-e1PkqIqN.css.gz +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BoBCZ1Wa.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BoBCZ1Wa.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-C5bywqIt.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-C5bywqIt.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-ChHpoQyu.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-ChHpoQyu.js.gz +0 -0
- package/dist/client/assets/layout-e7M-xuok.js.br +0 -0
- package/dist/client/assets/layout-e7M-xuok.js.gz +0 -0
- package/dist/client/assets/linear-A5CrihlL.js.gz +0 -0
- package/dist/client/assets/mermaid.core-BNac_Y3z.js.br +0 -0
- package/dist/client/assets/mermaid.core-BNac_Y3z.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-fQoEGcCr.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-fQoEGcCr.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap--0YoOXsx.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CYbfla8A.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CYbfla8A.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-B6--ZKXC.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-B6--ZKXC.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Bau_h7Jl.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Bau_h7Jl.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CApEuiEL.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CApEuiEL.js.gz +0 -0
- package/dist/client/assets/rdpSession-CydBq1bk.js.br +0 -0
- package/dist/client/assets/rdpSession-CydBq1bk.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-8ExgTbB3.js.br +0 -0
- package/dist/client/assets/referenceLongPress-8ExgTbB3.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-Rxe80d7j.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-Rxe80d7j.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-BaPl8d6E.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-BaPl8d6E.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-Asyx5gWK.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-Asyx5gWK.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-BQaSglof.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-BQaSglof.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DycNNggj.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DycNNggj.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CS1AgP_n.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-2Z5Zd5j6.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-2Z5Zd5j6.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Cxqp7K9j.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-BHiRARcP.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BHiRARcP.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-JgKZ8N2y.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-JgKZ8N2y.js.gz +0 -0
- package/dist/client/assets/videoCompression-DGfMcwdq.js.br +0 -0
- package/dist/client/assets/videoCompression-DGfMcwdq.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-DNmP9dmD.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-DNmP9dmD.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BBFR9gmo.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BBFR9gmo.js.gz +0 -0
|
@@ -0,0 +1,1677 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-WM_j9CSC.js","assets/app-D-AilvVY.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CRxcDATF.css","assets/purify.es-4eNOHKSq.js","assets/ModelPreview-BHmMm0Pj.js","assets/App-BB9Zns7R.js","assets/gestureArbiter-DPJowqRM.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-DTiOfHLO.js","assets/referenceLongPress-CalVNheA.js","assets/DiffReview-CsQjyKYd.js","assets/sparkles-CbQl9qpO.js","assets/DiffViewer-CwTOIjTT.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-CAyVfccZ.js","assets/ArchitecturePanel-DCxpe1Bj.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-CojIu02o.js","assets/katex-55ZPZeOF.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ah as _r,df as mt,bA as e,h as No,cv as Od,ar as qu,_ as Dn,bI as Vu,L as ft,e as hs,X as Lt,dl as V,dt as At,bV as gt,a as la,b3 as Yu,C as Co,d as ca,db as ta,dc as fl,U as Ud,c_ as Hm,cA as zm,bl as Wm,O as qs,aA as Gm,bs as Km,bu as Tl,bv as qm,bw as Xu,bt as Vs,aQ as Vm,E as Ym,k as Xm,bp as Jm,bX as Qm,bZ as Zm,b_ as ep,bg as tp,bY as Hd,N as Rt,g as rp,j as zi,I as np,b as sp,dd as Wi,bf as zd,aK as Wd,aG as ap,aU as Gi,aV as Gd,du as sa,ax as Ys,aW as op,bN as ip,cX as Kd,aN as lp,d9 as cp,cq as dp,dm as Jr,aZ as up,a2 as qd,a1 as fp,aH as Vd,aM as hp,aS as Yd,cs as mp,z as Xd,l as Jd,r as Qd,J as Ju,av as Qu,ci as pp,dr as gp,n as bp}from"./app-D-AilvVY.js";import{b as a,r as Rr}from"./dnd-BCFAPC0L.js";import{i as Il,F as xp,O as Zu,y as vp,s as Zd,Q as eu,W as yo,m as yp,ai as ef,Z as wp,x as kp,I as Sp,t as jp,M as Rp,R as wo,a6 as tf,a7 as Np,S as ms,n as rf,g as Cp,ao as nf,A as Ki,al as Ep,aj as Tn,a8 as Mp,a9 as $p,am as Pp,ab as tu,r as ru,k as nu,E as qi,B as lo,h as Ap,T as Lp,z as Tp,N as su,Y as Ip,q as Dp,U as Fp,o as au,C as _p,c as Bp,G as Op,f as Up}from"./App-BB9Zns7R.js";import{F as hl,a as ou,S as iu,b as sf,c as ml}from"./gestureArbiter-DPJowqRM.js";import{D as pl,C as aa,L as af,f as Hp,n as zp}from"./DiffReview-CsQjyKYd.js";import{T as Wp,L as Eo,M as of,G as kr}from"./triangle-alert-DTiOfHLO.js";import{S as da}from"./sparkles-CbQl9qpO.js";import{C as lf,M as cf}from"./ChangeWalkthroughPanel-CAyVfccZ.js";import{r as df,s as uf,l as ff,a as lu,h as gl,u as Gp,g as bl,b as hf}from"./DiffViewer-CwTOIjTT.js";import{u as mf,G as pf}from"./referenceLongPress-CalVNheA.js";const Kp=[["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"}]],qp=_r("case-sensitive",Kp);const Vp=[["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"}]],Yp=_r("eye-off",Vp);const Xp=[["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"}]],xl=_r("eye",Xp);const Jp=[["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"}]],vl=_r("file-text",Jp);const Qp=[["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"}]],Zp=_r("funnel",Qp);const eg=[["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"}]],tg=_r("image-plus",eg);const rg=[["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"}]],ng=_r("regex",rg);const sg=[["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"}]],ag=_r("scan",sg);const og=[["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"}]],ig=_r("whole-word",og),lg=100,cg=5e5,dg=1e4,cu=16384,ug=32,fg=1e5;class cs extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class hg{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>fg)throw new cs("complexity");if(performance.now()-this.startedAt>=lg)throw new cs("timeout")}validateLines(n){if(n.length>dg)throw new cs("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>cg||l.length>cu)throw new cs("size")}validateInline(n){if(this.check(),n.length>cu)throw new cs("size")}nested(n){if(this.check(),this.depth>=ug)throw new cs("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const du=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 mg(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*pg(r,n){n.validateInline(r);const s=new RegExp(du.source,du.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=mg(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 uu({children:r,actions:n}){const{t:s}=mt(),[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(),L=(h?.offsetLeft??0)+8,D=(h?.offsetTop??0)+8,F=Math.max(0,(h?.width??window.innerWidth)-16),$=D+(h?.height??window.innerHeight)-16,N=Math.min(240,F),A=Math.max(0,S.top-D-6),B=Math.max(0,$-S.bottom-6),q=x.scrollHeight>B&&A>B;Object.assign(x.style,{width:`${N}px`,left:`${Math.max(L,Math.min(S.right-N,L+F-N))}px`,top:`${q?S.top-6:S.bottom+6}px`,maxHeight:`${q?A:B}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(No,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&Rr.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 Vi="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(Vi)&&f(h),h.querySelectorAll(Vi).forEach(f)};p(m);const x=new MutationObserver(h=>{for(const b of h)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Vi)&&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 gg(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function bg({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 xg(r){if(r.kind==="mermaid"){await Od(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 qu(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 Od(l,d)}let co=null,fu=!1;function vg(){return co||(co=Dn(()=>import("./mermaid.core-WM_j9CSC.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw co=null,r})),co}function yg(r){fu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),fu=!0)}function wg({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:d}=mt(),[c,m]=a.useState(""),[g,f]=a.useState(0),[p,x]=a.useState(null),[h,b]=a.useState(!1),[E,S]=a.useState(!1),L=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const N=new AbortController;return x(null),b(!1),Vu(L,N.signal,!0,"pick_git_ignore_exception").then(A=>{N.signal.aborted||x({directory:c,entries:A.entries,truncated:!!A.truncated})}).catch(()=>{N.signal.aborted||b(!0)}),()=>N.abort()},[L,c,g]);const D=N=>{x(null),b(!1),m(N)},F=p?.directory===c,$=N=>{if(N.length>200){S(!0);return}S(!1),l(N)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":d("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(Il,{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(hl,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:L,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(N=>N+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:d("common.retry")})]}):F?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(N=>{const A=c?`${c}/${N.name}`:N.name,B=A+(N.type==="directory"?"/":""),q=n.includes(B)||n.includes(A),j=n.some(_=>_.endsWith("/")&&A.startsWith(_)),o=N.type==="directory"?hl:xp;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(_=>_!==B&&_!==A):[...n,B]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),e.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",title:N.name,children:N.name})]}),N.type==="directory"&&e.jsx("button",{type:"button",disabled:s,onClick:()=>D(A),"aria-label":d("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:N.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:e.jsx(hs,{size:15})})]},N.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{size:18})}),F&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:d("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>$([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:d("rightSidebar.gitIgnoreExceptionsClear")})]}),n.length>0&&e.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:n.map(N=>e.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:N,children:N}),e.jsx("button",{type:"button",disabled:s,onClick:()=>$(n.filter(A=>A!==N)),"aria-label":d("rightSidebar.gitIgnoreExceptionsRemove",{path:N}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:13})})]},N))}),E&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function kg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:d}){const{t:c}=mt(),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,L]=a.useState([]),[D,F]=a.useState(!1),[$,N]=a.useState(null),A=V(I=>I.setGitIgnoreExceptions),B=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,x.current=null},q=()=>{B(),!(n||D||!r)&&(L([...V.getState().gitIgnoreExceptions[r]??[]]),N(null),E(!0))},j=()=>{D||E(!1)},o=I=>{B(),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),B(),B),[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&&B()},onPointerUp:B,onPointerCancel:B,onLostPointerCapture:B,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${s?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:l?e.jsx(ft,{size:14}):e.jsx(Zp,{size:14})}),b&&Rr.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 U=Y[0],O=Y[Y.length-1];I.shiftKey&&document.activeElement===U&&(I.preventDefault(),O?.focus()),document.activeElement===f.current?(I.preventDefault(),(I.shiftKey?O:U)?.focus()):!I.shiftKey&&document.activeElement===O&&(I.preventDefault(),U?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||D)){if(S.length>200){N(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}F(!0),N(null),A(r,S).then(()=>E(!1)).catch(()=>N(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>F(!1))}},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:`${m}-title`,className:"text-sm font-medium",children:c("rightSidebar.gitIgnoreExceptionsTitle")}),e.jsx("button",{type:"button",disabled:D,onClick: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(wg,{rootPath:r,paths:S,onChange:L,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(ft,{size:13}),c("common.save")]})]})]})}),document.body)]})}function Sg(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 jg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
+
`)}function $0(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 Rg(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?jg(r,"",d,g):r,n):!1}function Ng(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function hu(r,n){return`${r??""}\0${n}`}function Cg(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=hu(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=>hu(m.repoRoot,p)===l)||g.some(p=>Ng(p,s)))&&(d+=1)}return{explained:d,stale:c}}function Eg({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(Wp,{size:10}):e.jsx(da,{size:10})})}function yl({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(Eg,{status:n})]})}const gf="termdock:right-sidebar:diff-change-list-mode:v1";function Mg(r){return r==="list"||r==="tree"}function $g(){return gt(gf,Mg)??"tree"}function Pg(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 Ag(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=Pg(l.items);return s}function Lg(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 Tg(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]??"",L=p?S===p:!0,D=S||p||E.join(`
|
|
5
|
+
`);L&&!d.has(D)&&(l.push(...E),d.add(D)),x=h}}return l.join(`
|
|
6
|
+
`)}function Ig({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Tg(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 Dg(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 mu({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:L,wrapOnLabel:D="Wrap on",wrapOffLabel:F="Wrap off",desktopLayout:$="split",onInsertDiffReference:N,onReferenceCopied:A,renderPathReference:B,insertedReferenceKey:q,copiedReferenceKey:j,onClearAuditRecord:o,onRefresh:_,localOptions:I,onHunkGitAction:Y,error:U,refreshing:O,actionsBusy:R,refreshLabel:z,refreshTitle:Z,walkthroughs:P=[],onWalkthroughNavigate:W,initialDetailScrollTop:J,onDetailScrollPositionChange:oe,scrollToKey:pe,scrollToKeyNonce:Se,externalSwiperRef:we,onMobileSlideChange:Me}){const{t:Q}=mt(),be=a.useMemo(()=>Ag(r),[r]),ue=a.useMemo(()=>new Map(be.map(te=>[te.key,te])),[be]),[Be,Oe]=a.useState(()=>$g()),[G,je]=a.useState(()=>new Set),[ye,Ue]=a.useState({key:null,nonce:0}),Ye=be.find(te=>te.explained>0||te.stale>0)?.key??be[0]?.key??null,M=n&&be.some(te=>te.key===n)?n:Ye,he=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:be.map(Lg)}],[be]),fe=a.useMemo(()=>Ig({groups:be,onInsertDiffReference:N}),[be,N]),Ee=a.useRef(Ye),$e=a.useRef(s);Ee.current=Ye,$e.current=s,a.useEffect(()=>{!n&&Ee.current&&$e.current(Ee.current)},[n]);const tt=S?e.jsxs("button",{type:"button",onClick:S,"aria-pressed":x,title:L,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:O||R||te.disabled&&!te.checked,onChange:Re=>te.onChange(Re.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=U?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:U}):null,Je=_?e.jsxs("button",{type:"button",onClick:_,disabled:O||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(Zu,{size:12,className:O?"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(la,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[te,ce,Je,E,tt,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(la,{size:14}),c]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[ce,Je,E,S&&e.jsxs("button",{type:"button",onClick:S,"aria-pressed":x,title:L,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(pl,{mobile:d,preserveScrollOnUpdate:!!I?.length,desktopLayout:$,backLabel:c,groups:he,selectedKey:M,mode:Be,onModeChange:te=>{Oe(te),te!=="ai"&&At(gf,te)},compact:d,collapsedDirectoryKeys:G,onToggleDirectory:te=>{je(Re=>{const rt=new Set(Re);return rt.has(te)?rt.delete(te):rt.add(te),rt})},onSelectFile:te=>{s(te.key),Ue(Re=>({key:te.key,nonce:Re.nonce+1}))},renderLeading:te=>{const Re=ue.get(te.key);return e.jsx(yl,{changeStatus:te.status,auditStatus:Re,renderChangeBadge:rt=>e.jsx(aa,{status:rt})})},renderTrailing:te=>{const Re=ue.get(te.key);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[Re&&e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",Re.additions," -",Re.deletions]}),B?.(te.path,"file")]})},renderDirectoryTrailing:te=>B?.(te,"directory"),renderListHeader:Ie,aiContent:({slideToDetail:te,fullscreen:Re,toggleFullscreen:rt})=>P.length>0&&W?e.jsx(lf,{walkthroughs:P,repoRoot:P[0]?.repoRoot,fullscreen:Re,onToggleFullscreen:rt,onNavigate:We=>{d&&window.requestAnimationFrame(te),W(We)}}):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:we,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=>{Dg(te,M,s),oe?.(te.scrollTop)},files:fe,activePane:!0,wrap:x,diffViewType:h,inlineMode:b,renderStreamBadge:(te,Re)=>{const rt=ue.get(Re.key);return e.jsx(yl,{changeStatus:te,auditStatus:rt,renderChangeBadge:We=>e.jsx(aa,{status:We})})},onInsertDiffReference:N,onReferenceCopied:A,insertedReferenceKey:q,copiedReferenceKey:j,onClearAuditRecord:o,onHunkGitAction:O?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 Fg(r){return r.replace(/\/+$/,"")||"/"}function _g(r){return[...new Set(Array.from(r,Fg))].sort((n,s)=>n.localeCompare(s))}function Bg(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function Og(r){let n=null;return{applicableEvents:r.filter(l=>{const d=l.type==="rescan-required"&&!Bg(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const Ug=1400,Hg=1200,bf=44,zg=.7;function Yi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function wl(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Wg(r){try{const n=window.localStorage.getItem(wl(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=bf?s:null}catch{return null}}function pu(r,n){try{n===null?window.localStorage.removeItem(wl(r)):window.localStorage.setItem(wl(r),String(n))}catch{}}function uo(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Gg({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),[L,D]=a.useState(!1),F=a.useRef(!1),$=a.useRef(!0),[N,A]=a.useState(!1),[B,q]=a.useState(()=>Wg(Yi())),j=a.useRef(B),o=a.useRef(null),_=a.useRef(null),I=a.useRef(r),Y=a.useRef(null),U=a.useRef(null),O=!!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 G=!1;const je=Yi();return Yu().then(ye=>{if(G)return;const Ue=ye.contextDraftHeight?.[je]??null;pu(je,Ue),j.current=Ue,q(Ue)}).catch(()=>{}),()=>{G=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const G=Y.current;if(!G)return;uo()||G.focus(),G.setSelectionRange(G.value.length,G.value.length),G.scrollTop=G.scrollHeight}},[l]),a.useEffect(()=>{const G=I.current;I.current=r,!(!n||r.length<=G.length)&&(A(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{_.current=null,A(!1)},Hg))},[r,n]),a.useEffect(()=>{if(n)return;const G=Y.current;G&&(G.style.height=B!==null?`${B}px`:"")},[r,n,B]),a.useEffect(()=>{if(n)return;const G=Y.current;!G||document.activeElement===G||(G.scrollTop=G.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||uo())return;const G=Y.current;!G||document.activeElement===G||(G.focus(),G.setSelectionRange(G.value.length,G.value.length))},[n]);const Z=a.useRef(null);a.useLayoutEffect(()=>{if(!uo())return;const G=window.visualViewport;if(!G)return;const je=()=>{const ye=Z.current;if(!ye)return;if(G.height>=window.innerHeight*.75){ye.style.transform="";return}const Ue=ye.getBoundingClientRect(),Ye=Math.round(G.height-Ue.bottom);ye.style.transform=Ye!==0?`translateY(${Ye}px)`:""};return je(),G.addEventListener("resize",je),G.addEventListener("scroll",je),()=>{G.removeEventListener("resize",je),G.removeEventListener("scroll",je),Z.current&&(Z.current.style.transform="")}},[n]);const P=G=>{S(G),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,S(null)},Ug)},W=G=>{g(!1),uo()&&window.requestAnimationFrame(()=>{const je=Y.current;if(!je)return;je.focus();const ye=je.value.length;je.setSelectionRange(ye,ye),window.requestAnimationFrame(()=>{je.setSelectionRange(ye,ye)})})},J=async G=>{if(!(!O||F.current)){F.current=!0,D(!0),S(null);try{await(G==="sent"?b():h())&&$.current&&P(G)}catch{}finally{F.current=!1,$.current&&D(!1)}}},oe=()=>{J("inserted")},pe=()=>{J("sent")},Se=G=>{if(G.key==="Escape"){G.preventDefault(),g(!0);return}G.nativeEvent.isComposing||G.keyCode===229||G.key!=="Enter"||!G.metaKey&&!G.ctrlKey||(G.preventDefault(),pe())},we=G=>{G.preventDefault()},Me=G=>{G.preventDefault();const je=Y.current;je&&(U.current={startY:G.clientY,startHeight:je.getBoundingClientRect().height},G.currentTarget.setPointerCapture?.(G.pointerId))},Q=G=>{const je=U.current;if(!je)return;const ye=window.visualViewport?.height??window.innerHeight,Ue=Math.round(Math.min(Math.max(je.startHeight+(je.startY-G.clientY),bf),ye*zg));j.current=Ue,q(Ue)},be=G=>{const je=Yi();pu(je,G),ta({contextDraftHeight:{[je]:G}}).catch(()=>{})},ue=()=>{U.current&&(U.current=null,j.current!==null&&be(j.current))},Be=()=>{j.current=null,q(null),be(null)},Oe=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:()=>W(),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(vp,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:`truncate text-[11px] ${d?"text-destructive":N?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(N?s.appended:O?R:s.title)})]}),Oe,e.jsx("button",{type:"button",onClick:pe,disabled:!O||L,"aria-busy":L,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:L?e.jsx(Zd,{size:12,className:"animate-spin"}):E==="sent"?e.jsx(Co,{size:12}):e.jsx(eu,{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:Be,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:we,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(ca,{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}),Oe]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:we,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:we,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:G=>m(G.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:we,onClick:x,disabled:!O,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(yo,{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:we,onClick:oe,disabled:!O||L,"aria-busy":L,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(yp,{size:11}),e.jsx("span",{children:L?s.pending??s.insert:E==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:we,onClick:pe,disabled:!O||L,"aria-busy":L,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:[L?e.jsx(Zd,{size:11,className:"animate-spin"}):E==="sent"?e.jsx(Co,{size:11}):e.jsx(eu,{size:11}),e.jsx("span",{children:E==="sent"?s.sent:s.send})]})]})]})})]})}function Kg(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 qg(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}function Vg(r,n){return{text:qg(r,n),options:{paste:/[\r\n]/.test(r),submitAfterPaste:n}}}function Yg(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 fl(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 L=new Set(S.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw E({retryFiles:S.results?b.task.retryFiles.filter((D,F)=>!L.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 Ud&&S.result?.files.length){const L=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)=>!L.has(F)):[]}),m.current(b.task.directory)}return E({status:b.controller.signal.aborted?"canceled":"error",error:S instanceof Ud&&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,L)=>E.length?g({task:{kind:S?"image":"files",directory:b,files:E,retryFiles:E,uploaded:[],status:"uploading"},controller:new AbortController,insert:S,isCurrent:L}):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 Xg({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 Jg(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=>{if(d.current||!n.current.active)return!1;const m=n.current,g=s.current,{text:f,options:p}=Vg(m.text,c);if(!f)return!1;d.current=!0;try{const x=await ef(f,m.sessionId,()=>l.current&&n.current.active&&n.current.sessionId===m.sessionId,void 0,p),h=l.current&&g===s.current;return h&&(x?n.current.onAccepted():n.current.onRejected()),x&&h}finally{d.current=!1}},[])}const gu={status:"idle",error:null,result:null};function Qg(r,n=!0){const[s,l]=a.useState(gu),d=a.useRef(null);a.useEffect(()=>Hm(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(gu),()=>{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=zm()?.targetPeerId;d.current={controller:g,targetPeerId:f},l({status:"pending",error:null,result:null});try{const p=await qu(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 kl="termdock:right-sidebar:html-view-mode-by-file:v1";function Zg(r){return r==="preview"||r==="source"}function xf(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Zg)}function vf(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function bu(r,n){const s=vf(r,n);return s?gt(kl,xf)?.[s]??"source":"source"}function eb(r,n,s){const l=vf(r,n);if(!l)return;const d=gt(kl,xf)??{};At(kl,{...d,[l]:s})}function yf(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const tb=1500,xu=256*1024*1024;async function rb(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>xu)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>xu)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 _o(r,n){const s=yf(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(()=>{rb(r,x.signal).then(b=>{if(f){URL.revokeObjectURL(b);return}p=b,m(b)}).catch(()=>{f||x.signal.aborted||g.current?.()})},tb);return()=>{f=!0,window.clearTimeout(h),x.abort(),p&&URL.revokeObjectURL(p)}},[s,l,r]),!s||l?r:c}function Xi(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 nb(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const Qr=2,sb=8,ab=60,fo=5,vu=.05,ob=900;function ib(r){return!Number.isFinite(r)||r<=0?Qr:Math.min(sb,Qr+Math.floor(r/ab))}const lb=350,cb=6,db=90;function ub({url:r,onLoadError:n}){const s=_o(r,n),{t:l}=mt(),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),L=a.useRef(null),D=a.useRef(null),F=a.useRef(!1),$=a.useRef(1),N=a.useRef(!1),[A,B]=a.useState(0),[q,j]=a.useState(0),[o,_]=a.useState(!1),[I,Y]=a.useState(!1),[U,O]=a.useState(null),[R,z]=a.useState(!1),[Z,P]=a.useState(0),[W,J]=a.useState(!1),[oe,pe]=a.useState({width:0,height:0}),[Se,we]=a.useState(Qr),[Me,Q]=a.useState(1),[be,ue]=a.useState(null),Be=a.useRef(Qr),Oe=a.useRef(null),G=a.useCallback(()=>{L.current!==null&&(clearTimeout(L.current),L.current=null)},[]),je=a.useCallback(()=>{G();const H=D.current;if(D.current=null,!F.current)return!1;const ne=m.current;if(ne&&(ne.playbackRate=$.current,H))try{ne.releasePointerCapture?.(H.id)}catch{}return F.current=!1,Be.current=Qr,z(!1),!0},[G]);a.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),x.current!==null&&clearTimeout(x.current),Oe.current!==null&&clearTimeout(Oe.current),G();const H=m.current;H&&F.current&&(H.playbackRate=$.current)},[G]),a.useEffect(()=>{const H=c.current;if(!H||typeof ResizeObserver>"u")return;const ne=new ResizeObserver(([Ce])=>{Ce&&pe({width:Ce.contentRect.width,height:Ce.contentRect.height})});return ne.observe(H),()=>ne.disconnect()},[]),a.useEffect(()=>{const H=()=>J(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]);const ye=a.useCallback((H,ne=!1)=>{const Ce=m.current;if(!Ce)return!1;const lt=Number.isFinite(Ce.duration)?Ce.duration:H,ct=Math.min(Math.max(H,0),lt);if(j(ct),Math.abs(Ce.currentTime-ct)<1/120)return!1;const Nt=Ce.fastSeek;return ne&&typeof Nt=="function"?Nt.call(Ce,ct):Ce.currentTime=ct,!0},[]),Ue=a.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const H=m.current;if(!H||!b.current||E.current||H.seeking)return;const ne=S.current;S.current=!1,E.current=ye(h.current,!ne)}))},[ye]),Ye=a.useCallback(H=>{const ne=g.current,Ce=m.current;if(!ne||!Ce)return;const lt=ne.getBoundingClientRect(),ct=nb(H,lt,Ce.duration);h.current=ct,O(ct),S.current=!1,Ue(),x.current!==null&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,S.current=!0,Ue()},db)},[Ue]),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(H=>{const ne=m.current;if(!(!ne||!Number.isFinite(ne.duration)||ne.duration<=0)){f.current=!ne.paused,ne.pause(),b.current=!0,Y(!0);try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}Ye(H.clientX)}},[Ye]),fe=a.useCallback(()=>{b.current=!1,M(),Y(!1),O(null);const H=m.current;H&&f.current&&!H.ended&&H.play().catch(()=>{}),f.current=!1},[M]),Ee=a.useCallback(()=>{const H=m.current;if(H){if(N.current){N.current=!1;return}H.paused?H.play().catch(()=>{}):H.pause()}},[]),$e=a.useCallback(H=>{const ne=m.current;if(!ne)return;const Ce=Math.min(1,Math.max(0,Math.round((ne.volume+H)*100)/100));ne.volume=Ce,Ce>0&&(ne.muted=!1),Q(Ce),ue(Ce),Oe.current!==null&&clearTimeout(Oe.current),Oe.current=setTimeout(()=>{Oe.current=null,ue(null)},ob)},[]),tt=a.useCallback(H=>{const ne=m.current;if(ne){if(H.key==="ArrowLeft"){H.preventDefault(),ye(ne.currentTime-(H.shiftKey?fo*2:fo));return}if(H.key==="ArrowRight"){H.preventDefault(),ye(ne.currentTime+(H.shiftKey?fo*2:fo));return}if(H.key==="ArrowUp"){H.preventDefault(),$e(vu);return}if(H.key==="ArrowDown"){H.preventDefault(),$e(-vu);return}(H.key===" "||H.key==="Spacebar"||H.key==="k"||H.key==="K")&&(H.preventDefault(),ne.paused?ne.play().catch(()=>{}):ne.pause())}},[ye,$e]),ce=a.useCallback(H=>{const ne=m.current;!ne||ne.paused||H.button!==0||(G(),D.current={id:H.pointerId,x:H.clientX,y:H.clientY},L.current=setTimeout(()=>{L.current=null;const Ce=D.current;if($.current=ne.playbackRate,ne.playbackRate=Qr,Be.current=Qr,we(Qr),F.current=!0,z(!0),Ce)try{ne.setPointerCapture?.(Ce.id)}catch{}},lb))},[G]),Te=a.useCallback(H=>{const ne=D.current;if(!ne||ne.id!==H.pointerId)return;if(!F.current){Math.hypot(H.clientX-ne.x,H.clientY-ne.y)>cb&&(G(),D.current=null);return}const Ce=ib(H.clientX-ne.x);if(Ce===Be.current)return;Be.current=Ce,we(Ce);const lt=m.current;lt&&(lt.playbackRate=Ce)},[G]),Je=a.useCallback(()=>{je()&&(N.current=!0)},[je]);a.useEffect(()=>(window.addEventListener("pointerup",Je),window.addEventListener("pointercancel",Je),window.addEventListener("blur",Je),()=>{window.removeEventListener("pointerup",Je),window.removeEventListener("pointercancel",Je),window.removeEventListener("blur",Je)}),[Je]);const Ie=a.useCallback(async()=>{const H=d.current,ne=m.current;if(!(!H||!ne))try{document.fullscreenElement===H?await document.exitFullscreen():H.requestFullscreen?await H.requestFullscreen():ne.webkitEnterFullscreen?.()}catch{ne.webkitEnterFullscreen?.()}},[]),De=a.useCallback(()=>P(H=>(H+90)%360),[]),te=a.useCallback(H=>{const ne=m.current;if(!ne||!Number.isFinite(ne.duration))return;const Ce=H.shiftKey?10:5;let lt=null;H.key==="ArrowLeft"?lt=ne.currentTime-Ce:H.key==="ArrowRight"?lt=ne.currentTime+Ce:H.key==="Home"?lt=0:H.key==="End"&&(lt=ne.duration),lt!==null&&(H.preventDefault(),ye(lt))},[ye]),Re=I&&U!==null?U:q,rt=A>0?Math.min(1,Math.max(0,Re/A)):0,Br=(Z===90||Z===270)&&oe.width>0&&oe.height>0?{width:`${oe.height}px`,height:`${oe.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?` ${ou}`:""}`,style:{...Br,transform:`translate(-50%, -50%) rotate(${Z}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...R?{[iu]:""}:{},onClick:Ee,onKeyDown:tt,onVolumeChange:H=>Q(H.currentTarget.volume),onPointerDown:ce,onPointerMove:Te,onPointerUp:Je,onPointerCancel:Je,onContextMenu:H=>{F.current&&H.preventDefault()},onPlay:()=>_(!0),onPause:()=>_(!1),onTimeUpdate:H=>j(H.currentTarget.currentTime),onSeeked:H=>{const ne=H.currentTarget;if(j(ne.currentTime),E.current=!1,!b.current)return;const Ce=ne.requestVideoFrameCallback;typeof Ce=="function"?Ce.call(ne,()=>{b.current&&Ue()}):requestAnimationFrame(()=>{b.current&&Ue()})},onLoadedMetadata:H=>B(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onDurationChange:H=>B(Number.isFinite(H.currentTarget.duration)?H.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)})}),be!==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(wp,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Me*100)})]}),I&&U!==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:`${rt*100}%`},"data-testid":"file-preview-video-scrub-time",children:Xi(U)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${ou}`,[iu]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Ee,"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(kp,{size:14}):e.jsx(Sp,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(A),"aria-valuenow":Math.floor(Re),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:H=>{I&&Ye(H.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:`${rt*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:`${rt*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Xi(Re)," / ",Xi(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(Zu,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Ie()},"aria-label":l(W?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(W?"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:W?e.jsx(jp,{size:14}):e.jsx(Rp,{size:14})})]})})]})}function fb(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 Bo({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()},title:d,style:fb(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(Eo,{size:11}),n]})}function hb(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 mb(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 pb(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 gb(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 wf({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,L]=a.useState(null),D=a.useRef(new Map),F=a.useRef(null),$=a.useRef(!1),N=a.useRef(null),A=a.useRef(x);A.current=x,a.useEffect(()=>{const P=new AbortController;return g(null),p(null),L(null),h(1),fetch(r,{signal:P.signal}).then(W=>W.text()).then(W=>g(pb(W))).catch(W=>{P.signal.aborted||p(W instanceof Error?W.message:"SVG preview failed")}),()=>P.abort()},[r]),a.useEffect(()=>{if(!b)return;const P=W=>{W.key==="Escape"&&E(!1)};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[b]),a.useLayoutEffect(()=>{const P=c.current,W=P?.querySelector("[data-svg-document] > svg");if(!P||!W)return;let J;try{J=W.getBBox()}catch{return}if(!J.width||!J.height)return;const oe=Math.max(2,Math.min(J.width,J.height)*.025);W.setAttribute("viewBox",`${J.x-oe} ${J.y-oe} ${J.width+2*oe} ${J.height+2*oe}`),W.style.width=`${x*100}%`,W.style.height=`${x*100}%`,W.style.minWidth=`${x*100}%`,W.style.minHeight=`${x*100}%`,W.style.display="block"},[m,x]);const B=a.useMemo(()=>S?mb(n,s,S):null,[n,S,s]),q=P=>{if($.current){$.current=!1;return}const W=c.current,J=W?.querySelector("[data-svg-document] > svg"),oe=d.current;if(!W||!J||!oe)return;const pe=J.viewBox.baseVal,Se=hb(P.clientX,P.clientY,J.getBoundingClientRect(),pe);if(!Se)return;const we=oe.getBoundingClientRect();L({...Se,nearestText:gb(J,Se.x,Se.y),stageX:P.clientX-we.left,stageY:P.clientY-we.top,stageXPercent:(P.clientX-we.left)/we.width*100,stageYPercent:(P.clientY-we.top)/we.height*100})},j=P=>Math.max(1,Math.min(12,P)),o=(P,W)=>{const J=j(W),oe=P.querySelector("[data-svg-document] > svg");if(!oe)return J;const pe=`${J*100}%`;return oe.style.width=pe,oe.style.height=pe,oe.style.minWidth=pe,oe.style.minHeight=pe,A.current=J,J},_=(P,W,J,oe)=>{const pe=A.current,Se=P.getBoundingClientRect(),we=J-Se.left,Me=oe-Se.top,Q=(P.scrollLeft+we)/pe,be=(P.scrollTop+Me)/pe,ue=o(P,W);return P.scrollLeft=Q*ue-we,P.scrollTop=be*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 W=c.current;W&&(D.current.set(P.pointerId,{x:P.clientX,y:P.clientY}),W.setPointerCapture?.(P.pointerId),D.current.size>=2?(F.current={kind:"pinch",startX:P.clientX,startY:P.clientY,startScrollLeft:W.scrollLeft,startScrollTop:W.scrollTop,startDistance:I(),startZoom:A.current,moved:!1},$.current=!0):A.current>1&&(F.current={kind:"pan",startX:P.clientX,startY:P.clientY,startScrollLeft:W.scrollLeft,startScrollTop:W.scrollTop,startZoom:A.current,moved:!1}))},U=P=>{if(!D.current.has(P.pointerId))return;D.current.set(P.pointerId,{x:P.clientX,y:P.clientY});const W=c.current,J=F.current;if(!(!W||!J)){if(D.current.size>=2&&J.kind==="pinch"){const oe=I();if(!J.startDistance||!oe)return;const pe=j(J.startZoom*oe/J.startDistance);if(Math.abs(pe-A.current)<.01)return;const Se=Array.from(D.current.values()),we=(Se[0].x+Se[1].x)/2,Me=(Se[0].y+Se[1].y)/2;J.moved=!0,$.current=!0,_(W,pe,we,Me),P.preventDefault();return}if(J.kind==="pan"&&D.current.size===1){const oe=P.clientX-J.startX,pe=P.clientY-J.startY;if(!J.moved&&Math.hypot(oe,pe)<6)return;J.moved=!0,$.current=!0,W.scrollLeft=J.startScrollLeft-oe,W.scrollTop=J.startScrollTop-pe,P.preventDefault()}}},O=P=>{const W=c.current,J=F.current,oe=D.current.size===1&&!J?.moved;D.current.delete(P.pointerId);try{W?.releasePointerCapture?.(P.pointerId)}catch{}if(D.current.size===1&&J?.kind==="pinch"){const we=Array.from(D.current.values())[0];F.current=W?{kind:"pan",startX:we.x,startY:we.y,startScrollLeft:W.scrollLeft,startScrollTop:W.scrollTop,startZoom:A.current,moved:!1}:null;return}if(D.current.size>0||(F.current=null,J?.kind==="pinch"&&h(A.current),!oe||$.current))return;const pe=Date.now(),Se=N.current;Se&&pe-Se.time<350&&Math.hypot(P.clientX-Se.x,P.clientY-Se.y)<24?(N.current=null,$.current=!0,h(we=>we>1?1:2.5)):N.current={time:pe,x:P.clientX,y:P.clientY}},R=P=>{if(!P.ctrlKey&&!P.metaKey)return;const W=c.current;if(!W)return;P.preventDefault();const J=_(W,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(W=>W>1?1:2.5)},onPointerDown:Y,onPointerMove:U,onPointerUp:O,onPointerCancel:O,onWheel:R,onScroll:()=>L(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&&B&&e.jsx(Bo,{anchor:{xPercent:S.stageXPercent,yPercent:S.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(B,`svg:${S.x.toFixed(2)}:${S.y.toFixed(2)}`),L(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(ag,{size:14})}),e.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:P=>{P.stopPropagation(),E(W=>!W)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:b?e.jsx(cf,{size:14}):e.jsx(of,{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?Rr.createPortal(Z,document.body):Z}function ko(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function bb(r,n,s,l){const d=[`电子标注: ${r}`,`视图: ${ko(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 xb({blobUrl:r,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:m,interactive3d:g}){const{t:f}=mt(),p=a.useRef(null),x=a.useRef(null),h=a.useRef(null),[b,E]=a.useState(null),[S,L]=a.useState(!1);a.useEffect(()=>(h.current?.abort(),E(null),L(!1),()=>h.current?.abort()),[r,s]);const D=a.useMemo(()=>b?bb(n,s,b,b.inspection):null,[n,b,s]),F=N=>{const A=p.current,B=x.current;if(!A||!B||!B.naturalWidth||!B.naturalHeight)return;const q=A.getBoundingClientRect(),j=B.getBoundingClientRect(),o=Math.min(j.width/B.naturalWidth,j.height/B.naturalHeight),_=B.naturalWidth*o,I=B.naturalHeight*o,Y=j.left+(j.width-_)/2,U=j.top+(j.height-I)/2,O=N.clientX-Y,R=N.clientY-U;if(O<0||R<0||O>_||R>I)return;const z={xPercent:Math.max(0,Math.min(100,O/_*100)),yPercent:Math.max(0,Math.min(100,R/I*100)),stageXPercent:(N.clientX-q.left)/q.width*100,stageYPercent:(N.clientY-q.top)/q.height*100,inspecting:l&&s!=="pcb-3d"};if(E(z),h.current?.abort(),!z.inspecting)return;const Z=new AbortController;h.current=Z,Wm(n,s,z.xPercent,z.yPercent,Z.signal).then(P=>E(W=>W===z?{...W,inspection:P,inspecting:!1}:W)).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(N=>e.jsx("button",{type:"button",onClick:()=>d(N),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${N===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:ko(N)},N))}),e.jsx("button",{type:"button",onClick:m,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:f("rightSidebar.edaRefresh"),"aria-label":f("rightSidebar.edaRefresh"),children:e.jsx(wo,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:p,role:"button",tabIndex:0,onClick:F,onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),E({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:f("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:x,src:r,alt:`${n} ${ko(s)}`,onLoad:()=>L(!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(Bo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:f("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(D,`eda:${s}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:x.current?Sg(x.current,b):Promise.resolve(null)}),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(wf,{blobUrl:r,filePath:n,viewLabel:ko(s),onInsertAnnotation:c})})]})}function vb(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 yb(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 wb({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=mt(),d=a.useMemo(()=>vb(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?yb(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,L)=>{const D=f?.row===E&&f.column===L;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(),N=F.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const A=F.clientX||N.left+N.width/2,B=F.clientY||N.top+N.height/2;p({row:E,column:L,xPercent:(A-$.left)/$.width*100,yPercent:(B-$.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[L]||" "})},`cell:${E}:${L}`)})]},`row:${E}`))})]})}),f&&h&&e.jsx(Bo,{anchor:{xPercent:f.xPercent,yPercent:f.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(h,`csv:${n}:${f.row+1}:${f.column+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 kb(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 Sb(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function jb({content:r,filePath:n,localState:s,onInsertAnnotation:l}){const{t:d}=mt(),c=a.useRef(null),[m,g]=a.useState(null),f=a.useMemo(()=>{try{return{items:kb(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 L=b.clientX||S.left+S.width/2,D=b.clientY||S.top+S.height/2;g({index:h,xPercent:(L-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(Bo,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(Sb(n,p),`kicad-project:${n}:${p.label}`),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 Rb=`/** 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
|
+
`,Nb=`/* 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
|
+
`,ho="/api/terminal/fs/preview/",Cb=8*1024*1024,Eb=32*1024*1024,Mb=128,$b="data:,";function Pt(r){throw new Error(r)}function Pb(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function yu(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 kf(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!qs(l.pathname)?.startsWith(ho))&&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 L=new Set,D=()=>{S=!0;for(const z of[...L])z();f.clear(),p.length=0};async function F(z){z.ok||Pt(`预览资源读取失败(${z.status})`);const Z=z.body?.getReader(),P=[];let W=0;try{if(Z)for(;;){const pe=await Z.read();if(pe.done)break;W+=pe.value.byteLength,E+=pe.value.byteLength,(W>Cb||E>Eb)&&Pt("预览资源超出大小限制"),P.push(pe.value)}}catch(pe){throw await Z?.cancel().catch(()=>{}),pe}finally{Z?.releaseLock()}const J=new Uint8Array(W);let oe=0;for(const pe of P)J.set(pe,oe),oe+=pe.length;return{bytes:J,type:z.headers.get("content-type")??"application/octet-stream",status:z.status}}let $=l,N;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)){N=Z;break}const P=Z.headers.get("location");await Z.body?.cancel(),P||Pt("预览重定向缺少目标");const W=new URL(P,$);(W.origin!==s||!qs(W.pathname)?.startsWith(ho))&&Pt("预览重定向越出文件范围"),$=W}N||Pt("预览重定向次数过多");const A=qs($.pathname),B=A.slice(ho.length).split("/");/^[a-f0-9]{32}$/.test(B[0])||Pt("服务未提供有效的预览资源授权");const q=qs(l.pathname).slice(ho.length).split("/");/^[a-f0-9]{32}$/.test(q[0])&&q.shift(),q.join("/").replace(/\/$/,"")!==B.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:(qs(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>=Mb)return Promise.reject(new Error("预览资源数量超出限制"));const W=n.fetch(Z,{signal:n.signal,redirect:"manual"}).then(F);return h.set(Z,W),W}function U(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 O(z,Z,P,W=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 oe=`${P}:${J.href}`;(W.has(oe)||W.size>=8)&&Pt("预览资源存在循环或过深引用");const pe=b.get(oe);if(pe)return pe;const Se=new Set(W);Se.add(oe);const we=(async()=>{const Me=await Y(J);return P==="css"?U(await R(new TextDecoder().decode(Me.bytes),J,Se),"text/css"):P==="script"?U(Me.bytes,"text/javascript"):U(Me.bytes,Me.type)})();return b.set(oe,we),await we}catch(J){return g(J instanceof Error?J.message:"部分预览资源未能加载"),$b}}async function R(z,Z,P){return z=await yu(z,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async W=>`@import url("${await O(W[1],Z,"css",P)}")${W[2]};`),yu(z,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async W=>{const J=(W[1]??W[2]??W[3]).trim();return f.has(J)?W[0]:`url("${await O(J,Z,"resource",P)}")`})}try{const z=await F(N),Z=U(Rb,"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 be=Q.getAttribute("href");try{if(be&&!be.startsWith("#")){const ue=_(be,$);if(ue)Q.setAttribute("href",new URL(ue.pathname.slice(o.pathname.length)+ue.search+ue.hash,c).href);else{const Be=new URL(be,$);if(Be.protocol!=="https:"){Q.removeAttribute("href");continue}x.add(Be.origin),Q.setAttribute("href",Be.href)}}}catch(ue){Q.removeAttribute("href"),g(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const be of["data","manifest"])Q.removeAttribute(be);if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="module"){Q.setAttribute("type","module-shim");const be=Q.getAttribute("src");if(be){const ue=_(be,$);if(ue)Q.setAttribute("src",new URL(ue.pathname.slice(o.pathname.length)+ue.search,c).href);else{const Be=new URL(be,$);if(Be.protocol!=="https:"){Q.remove();continue}x.add(Be.origin),Q.setAttribute("src",Be.href)}}continue}if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="importmap"){Q.setAttribute("type","importmap-shim");continue}if(Q.tagName==="LINK"){const be=(Q.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(be)){Q.remove();continue}const ue=Q.getAttribute("href");ue&&Q.setAttribute("href",await O(ue,$,be==="stylesheet"?"css":"resource"))}if(Q.hasAttribute("src")&&Q.setAttribute("src",await O(Q.getAttribute("src"),$,Q.tagName==="SCRIPT"?"script":"resource")),Q.hasAttribute("poster")&&Q.setAttribute("poster",await O(Q.getAttribute("poster"),$,"resource")),Q.hasAttribute("srcset")){const be=Q.getAttribute("srcset");/data:/i.test(be)?(Q.removeAttribute("srcset"),g("混合内嵌图片候选暂不支持安全预览")):Q.setAttribute("srcset",(await Promise.all(be.split(",").map(async ue=>{const[Be,...Oe]=ue.trim().split(/\s+/);return`${await O(Be,$,"resource")} ${Oe.join(" ")}`}))).join(", "))}Q.setAttribute("referrerpolicy","no-referrer"),Q.removeAttribute("integrity"),Q.removeAttribute("crossorigin")}const W=[...x].join(" "),J=P.createElement("meta");J.httpEquiv="Content-Security-Policy",J.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${W}; style-src 'unsafe-inline' blob: ${W}; img-src blob: data: ${W}; font-src blob: data: ${W}; media-src blob: data: ${W}; connect-src blob: ${W} ${[...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 oe=P.createElement("base");oe.href=c;const pe=P.createElement("meta");pe.name="referrer",pe.content="no-referrer";const Se=P.createElement("script");Se.textContent=Nb+`
|
|
1636
|
+
installPreviewRuntime(`+[d,c,[...x],Z].map(Pb).join(",")+");";const we=P.createElement("script");we.src=Z,P.head.prepend(J,pe,oe,Se,we);const Me=`<!doctype html>
|
|
1637
|
+
`+P.documentElement.outerHTML;return{html:Me,shellUrl:`/preview-shell.html#${d}`,errors:m,attach(Q,be){const ue=new Set,Be=G=>{if(G.source!==Q.contentWindow||G.data?.capability!==d)return;if(G.data.type==="preview-ready"){Q.contentWindow?.postMessage({type:"preview-init",capability:d,html:Me,resources:p},"*");return}if(G.data.type==="preview-error"){be("部分动态内容被安全预览限制");return}if(G.data.type==="preview-navigate"){(async()=>{const ye=I(String(G.data.url)),Ue=await kf(ye.pathname+ye.search,n);if(S){Ue.dispose();return}const Ye=Ue.attach(Q,be);L.add(()=>{Ye(),Ue.dispose()}),Q.src=Ue.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ye=>be(ye instanceof Error?ye.message:"无法打开预览页面"));return}if(G.data.type==="preview-external"){try{const ye=new URL(String(G.data.url));ye.protocol==="https:"&&x.has(ye.origin)&&window.open(ye.href,"_blank","noopener,noreferrer")}catch{}return}if(G.data.type!=="preview-fetch"||G.ports.length!==1)return;const je=G.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(G.data.method)){je.postMessage({error:"预览仅允许读取已授权目录资源"}),je.close();return}ue.add(je),(async()=>{const ye=I(String(G.data.url)),Ue=await Y(ye);if(!ue.has(je)||S)return;const Ye=G.data.method==="HEAD"?new Uint8Array:Ue.bytes.slice();je.postMessage({status:Ue.status,headers:{"content-type":Ue.type},data:Ye.buffer},[Ye.buffer])})().catch(()=>{je.postMessage({error:"预览资源不在授权范围或无法加载"}),be("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(je),je.close()})};window.addEventListener("message",Be);const Oe=()=>{window.removeEventListener("message",Be);for(const G of ue)G.close();ue.clear(),L.delete(Oe)};return L.add(Oe),Oe},dispose:D}}catch(z){throw D(),z}}const Ab=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 B;return x(void 0),b(""),(async()=>{const q=await Gm();if(B=await kf(n,{fetch:(j,o)=>q.fetch(j,o),signal:A.signal}),A.signal.aborted){B.dispose();return}x(B),B.errors.length&&b(B.errors.join(";"))})().catch(q=>{A.signal.aborted||b(q instanceof Error?q.message:"安全预览加载失败")}),()=>{A.abort(),B?.dispose()}},[n]),a.useEffect(()=>{if(!(!p||!g))return p.attach(g,b)},[p,g]);const[E,S]=a.useState(!1),[L,D]=a.useState(!1),F=E||L;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(!L)return;const A=B=>{B.key==="Escape"&&D(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[L]);const $=a.useCallback(async()=>{const A=m.current;if(A){if(L){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)}},[L]);a.useImperativeHandle(c,()=>({toggleFullscreen:$}),[$]);const N=e.jsxs("div",{ref:m,"data-html-preview-frame":!0,className:F?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[F&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{$()},"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(cf,{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 L?Rr.createPortal(N,document.body):N}),Sf="termdock-file-search-match",Sl="termdock-file-search-current";function Lb(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 Tb(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 Ib(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Db(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=Ib(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 jf(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let Mo;function wu(r){return Mo===r}function mo(r){if(r&&Mo!==r)return;const n=jf();n?.delete(Sf),n?.delete(Sl),Mo=void 0}function Ji(r,n,s){const l=jf();if(!l||typeof Highlight>"u")return;Mo=s,l.set(Sf,new Highlight(...r));const d=r[n];d?l.set(Sl,new Highlight(d)):l.delete(Sl)}function ku(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Fb(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function _b(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Bb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Rf(r,n,s){return n?r:Rr.createPortal(r,s)}const Dl="termdock:right-sidebar:file-tree-scroll:v1",Fl="termdock:right-sidebar:file-preview-reading-state:v1",ra="termdock:right-sidebar:file-tree-width:v1",Nf="termdock:right-sidebar:markdown-view-mode:v1",Cf="termdock:right-sidebar:diff-change-list-mode:v1",Ef="termdock:right-sidebar:diff-wrap:v1",Mf="termdock:diff-viewer:view-type:v1",$f="termdock:right-sidebar:file-search-mode:v1",Qi="termdock:right-sidebar:collapsed-git-repo-groups:v1",Su="termdock:right-sidebar:collapsed-diff-directories:v1",Zi="termdock:right-sidebar:branch-audit-module-open:v1",Pf="termdock:right-sidebar:branch-audit-module:v1",Ob=150,ju="termdock:right-sidebar:context-draft-enabled:v1",Ru="termdock:right-sidebar:context-draft-collapsed:v1",Nu="termdock:right-sidebar:context-draft-auto-collapse:v1",el="termdock:right-sidebar:context-draft-text:v1",Ub=300,Hb=20,zb=120,Wb=250,Gb=250,Kb=120,qb=700,tl=600,Vb=6e4;function Xs(r){return!!(r&&V.getState().nestedGitScanRoots[r])}const Cu=[2e3,5e3,15e3,3e4],Yb=320,Xb=500,Jb=20,Qb=12e3,jl=300,Eu=240,Zb=560,Af="border-r px-2 py-1.5 sm:px-3 sm:py-2",$o="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Lf=`${Af} border-b border-border/15 font-semibold last:border-r-0`,Tf=`${Af} border-border/10 align-top text-muted-foreground last:border-r-0`,_l="termdock-file-preview-horizontal-scroll",Mu=a.lazy(()=>Dn(()=>import("./ModelPreview-BHmMm0Pj.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),ex=a.lazy(()=>Dn(()=>import("./ArchitecturePanel-DCxpe1Bj.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}))),tx=a.lazy(()=>Dn(()=>import("./ComputerControlView-CojIu02o.js").then(r=>r.a),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),If=`${_l} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Df(r,n,s){return r&&!n?"unified":s}const rx=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function nx(r){return r==="preview"||r==="source"}function sx(r){return r==="list"||r==="tree"||r==="ai"}function $u(){return gt(Nf,nx)??"preview"}function ax(){return gt(Cf,sx)??"tree"}function na(r){return typeof r=="boolean"}function ox(r){return typeof r=="string"}function ix(){return gt(Ef,na)??!0}function lx(r){return r==="unified"||r==="split"}function cx(){return gt(Mf,lx)??"unified"}function dx(r){return r==="name"||r==="content"||r==="regex"}function ux(){return gt($f,dx)??"name"}function Ff(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:kt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function fx(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 Rl(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function _f(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Nl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Pu(r){const n=gt(r,Nl);return n?new Set(n):new Set}function rl(r,n){At(r,[...n])}function hx(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 mx(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||Nl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(hx))&&(n.commits===void 0||Nl(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 px(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&mx(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function gx(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(px))&&(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 Au(){return gt(Pf,gx)??{}}function Lu(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Tu(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Bf(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Tu(s)===Tu(l)}function Iu(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Bf(l,n))??""}function Cl(r,n){const s=Math.max(Eu,n-320),l=Math.min(Zb,s);return Math.min(l,Math.max(Eu,r))}function bx(r){return typeof r=="number"&&Number.isFinite(r)}function xx(r){return Cl(gt(ra,bx)??jl,r)}function Of(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Js(r){return rx.has(Of(r))}function Uf(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function El(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Uf(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Hf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const zf=a.createContext(null);function So(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Wf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Gf(r){return r.replace(/\s+#+\s*$/,"").trim()}function Ml(r,n){const l=Wf(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 Du(r){return Wf(r)||r.trim()}function Po(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Pl(n[2]);return s?{id:So(n[1]),definition:{href:s.href,title:s.title}}:null}function vx(r){const n=new Map;for(const s of r){const l=Po(s);l&&n.set(l.id,l.definition)}return n}function Kf(r){return r.trim().toLowerCase()}function qf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Kf(n[1]),text:n[2]}:null}function yx(r){const n=new Map;let s=null;for(const l of r){const d=qf(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function Vf(r){const n=new Set;let s=!1;return r.forEach((l,d)=>{if(qf(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function wx(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 Yf(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function oa(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 Bl(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?oa(s):null;let h;if(f.startsWith("/")){const b=x&&(f===x||f.startsWith(`${x}/`));h=oa(x&&!b?`${x}/${f.slice(1)}`:f)}else{if(!n)return null;h=oa(`${Yf(n)}/${f}`)}return x&&h!==x&&!h.startsWith(`${x}/`)?null:{path:h,fragment:p,directory:/\/$/.test(g)}}function Ol(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=oa(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=oa(`${Yf(n)}/${c}`)}return d(m)}function kx(r,n,s){return Ol(r,n,s,Tl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Sx(r,n,s){return Ol(r,n,s,Xu,Ju)}const $l=128,jx=360,nl=480;function ma(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function Xf(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):ma(r)?(m=Math.min(Math.max(s,$l),jx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>nl&&(c=c*nl/m,m=nl),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function Rx(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function Jf(r){const n=Rx(r),s=V(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function Nx({src:r,alt:n,title:s,requestedWidthPx:l}){const d=ma(r),c=Jf(r),m=_o(c),g=a.useRef(null),[f,p]=a.useState(!1),[x,h]=a.useState(0),[b,E]=a.useState({status:"loading"}),[S,L]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current;let N=$?.parentElement?.parentElement??$?.parentElement;for(;N;){const j=window.getComputedStyle(N).display;if(j!=="inline"&&j!=="contents")break;N=N.parentElement}if(!N)return;const A=N,B=()=>{const j=window.getComputedStyle(A),o=(parseFloat(j.paddingLeft)||0)+(parseFloat(j.paddingRight)||0);h(Math.max(0,A.clientWidth-o))};if(B(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(B);return q.observe(A),()=>q.disconnect()},[]),a.useEffect(()=>{if(f)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const N=new IntersectionObserver(A=>{A.some(B=>B.isIntersecting)&&(p(!0),N.disconnect())},{rootMargin:"400px"});return N.observe($),()=>N.disconnect()},[f]),a.useEffect(()=>{if(!f)return;const $=new AbortController;let N=null;E({status:"loading"});const A=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Qu(c,{signal:$.signal}).then(async B=>{if(!B.ok)throw new Error(`HTTP ${B.status}`);const q=Number(B.headers.get("X-Image-Width"))||0,j=Number(B.headers.get("X-Image-Height"))||0;return{blob:await B.blob(),width:q,height:j}}).then(({blob:B,width:q,height:j})=>{$.signal.aborted||(N=URL.createObjectURL(B),q>0&&j>0&&L({width:q,height:j}),E({status:"ready",objectUrl:N}))}).catch(()=>{const B=$.signal.reason;$.signal.aborted&&!(B instanceof DOMException&&B.name==="TimeoutError")||E({status:"fallback"})}).finally(()=>{window.clearTimeout(A)}),()=>{window.clearTimeout(A),$.abort(),N&&URL.revokeObjectURL(N)}},[f,c]);const D=Xf(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:$l*2,height:$l});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 N=$.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(S?.width!==N.naturalWidth||S?.height!==N.naturalHeight)&&L({width:N.naturalWidth,height:N.naturalHeight})}}):b.status==="fallback"?e.jsx("img",{src:m,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const N=$.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(S?.width!==N.naturalWidth||S?.height!==N.naturalHeight)&&L({width:N.naturalWidth,height:N.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:F.width,height:F.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function ia(r,n,s,l,d,c){const m=kx(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(Nx,{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 sl(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Fu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function Pl(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 Qf="",Cx=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Ex(r){return r.replace(Cx,(n,s)=>`${Qf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function _u(r){return r.replace(new RegExp(`${Qf}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Mx(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Zf={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 po=null;function eh(){return po||(po=Dn(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw po=null,r})),po}function th({html:r}){const{t:n}=mt(),[s,l]=a.useState(null);return a.useEffect(()=>{let d=!1;return l(null),eh().then(c=>{d||l(c.sanitize(r,Zf))}).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 $x({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),eh().then(d=>{l||s(d.sanitize(r,Zf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function rh(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 go=null;function Px(){return go||(go=Promise.all([Dn(()=>import("./katex-DnlPpQZa.js"),[]),Dn(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw go=null,r})),go}function ua({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),Px().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 Ul(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 Bu(r){const n=Ul(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 Ax(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Ul(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 Lx({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=mt(),[c,m]=a.useState(!1),g=_o(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 Tx(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=Ul(m).get("href")?.trim()??"",f=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:x,title:h,widthPx:b}=Bu(f);if(!p)return null;const E=Ol(p,s.markdownFilePath,s.rootPath,Tl,$=>$);if(!E)return null;const S=g?Bl(g,s.markdownFilePath,s.rootPath):null,D=!!!(S&&S.path===E)&&g?Hf(g):null,F=ia(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}=Bu(r);return m?ia(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}=Ax(r);if(!m)return null;const x=Sx(m,s.markdownFilePath,s.rootPath);return x?e.jsx(Lx,{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($x,{html:r},n):null;const d=l[1].toLowerCase(),c=ht(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 ht(r,n,s=!0,l){return l.budget.nested(()=>Ix(r,n,s,l))}function Ix(r,n,s=!0,l){l.budget.validateInline(r);const d=Ex(r),c=[];let m=0;for(const{index:g,token:f}of pg(d,l.budget)){g>m&&c.push(_u(d.slice(m,g)));const p=`${n}-${g}`,x=f.startsWith("<")?Tx(f,p,l):null;if(x)c.push(x);else if(f.startsWith("\\(")&&f.endsWith("\\)"))c.push(e.jsx(ua,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))c.push(e.jsx(ua,{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:Mx(f.slice(h,-h))},p))}else if(f.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ht(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:ht(f.slice(2,-2),`${p}-strong`,s,l)},p));else if(f.startsWith("*")||f.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ht(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=Pl(h[2]);c.push(S?ia(p,h[1],S.href,S.title,l):f)}else if(b){const S=b[2]||b[1],L=l.referenceDefinitions.get(So(S));c.push(L?ia(p,b[1],L.href,L.title,l):f)}else if(E){const S=l.referenceDefinitions.get(So(E[1]));c.push(S?ia(p,E[1],S.href,S.title,l):f)}else c.push(f)}else if(f.startsWith("[^")){const h=Kf(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(">")&&Fu(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(Fu(sl(f).linkText)){const{linkText:h,suffix:b}=sl(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}=sl(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,L=S?l.referenceDefinitions.get(So(S)):null,D=h?Pl(h[2]):null,F=D?.href??L?.href??null,$=F?Hf(F):null,N=h?.[1]??b?.[1]??E?.[1]??"";c.push($?e.jsx("a",{href:$,title:D?.title??L?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ht(N,`${p}-link`,s,l)},p):f)}m=g+f.length}return m<d.length&&c.push(_u(d.slice(m))),c.length>0?c:[r]}function nh(r){return/(?: {2,}|\\)$/.test(r)}function sh(r){return r.replace(/(?: {2,}|\\)$/,"")}function Ao(r){return/^(?: {4}|\t)/.test(r)}function ah(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function oh(r,n,s){const l=[];return r.forEach((d,c)=>{const m=nh(d);l.push(...ht(sh(d),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Al(r,n,s){const l=[],d=[];return r.forEach((c,m)=>{d.push(nh(c)),l.push(ht(sh(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function Ll(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 fa(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 ih(r){return fa(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Lo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function To(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function lh(r,n){return r>96||r>44&&n>.35}function Oo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function ha(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 Hl(r,n,s,l,d,c=new Set){const m=[],g=[];let f=n;for(;f<r.length;){const p=r[f];if(d&&(Po(p)||c.has(f))){f+=1;continue}const x=ha(p),h=Oo(p);if(!x){if(h>s&&g.length>0){([...g].reverse().find(L=>L.indent<h)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const L of g)L.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 Dx(r){const n=r.find(l=>ha(l));if(!n)return[];const s=ha(n);return s?Hl(r,0,Oo(n),s.ordered,!0,Vf(r)).items:[]}function zl(r,n,s,l=0){return s.budget.nested(()=>Fx(r,n,s,l))}function Fx(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,ht(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:ht(g,`li-${n}-${c}-p-${f}`,!0,s)},`paragraph-${f}`))})]}),groups:_x(d.children,`${n}-${c}`,s,l)}})}function _x(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:zl(c.items,`${n}-g${m}`,s,l)}))}function Wl(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&&Bx(s.groups,n)]},s.key)})}function Bx(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:Wl(s.items,n)},`nested-${l}`)})}function Ox(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:[ht(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 Ux(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 N=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const A=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);A?$=A[1].trim()||$:N.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ht($,`${n}-details-${F}-summary`,!0,s)}),N.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:oh(N,`${n}-details-${F}`,s)})]},`${n}-details-${F}`)});continue}const p=rh(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(th,{html:F.join(`
|
|
1639
|
+
`)},`${n}-html-${$}`)});continue}const x=f.match(/^(```|~~~)\s*(.*)$/);if(x){const F=[],$=x[1],N=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),N.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(dh,{code:F.join(`
|
|
1640
|
+
`),blockKey:`${n}-code-${A}`},`${n}-code-${A}`)}):["math","latex","tex"].includes(N.toLowerCase())?d.push({kind:"static",node:e.jsx(ua,{tex:F.join(`
|
|
1641
|
+
`),display:!0},`${n}-code-${A}`)}):d.push({kind:"code",key:`${n}-code-${A}`,code:F.join(`
|
|
1642
|
+
`),lang:N,blockKey:`${n}-code-${A}`,codeStartLine:m(A)+1});continue}if(Ao(g)){const F=[],$=c;for(;c<r.length&&(Ao(r[c])||!r[c].trim());)F.push(r[c].trim()?ah(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)}`,N=Gf(h[2]),A=Ml(N,s);d.push({kind:"static",node:e.jsx($,{id:A,className:"scroll-mt-16 font-semibold text-foreground",children:ht(N,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<r.length&&g.includes("|")&&To(r[c+1])){const F=fa(g),$=ih(r[c+1]),N=[],A=c;for(c+=2;c<r.length&&r[c].includes("|")&&r[c].trim();)N.push(fa(r[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:If,"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((B,q)=>e.jsx("th",{className:`${Lf} ${Lo($[q]??null)}`,children:e.jsx("div",{className:$o,children:ht(B,`${n}-th-${A}-${q}`,!0,s)})},`h-${q}`))})}),e.jsx("tbody",{children:N.map((B,q)=>e.jsx("tr",{className:"border-t border-border/10",children:F.map((j,o)=>e.jsx("td",{className:`${Tf} ${Lo($[o]??null)}`,children:e.jsx("div",{className:$o,children:ht(B[o]??"",`${n}-td-${A}-${q}-${o}`,!0,s)})},`c-${o}`))},`r-${q}`))})]})},`${n}-table-${A}`)});continue}const b=ha(g);if(b){const F=b.ordered,$=Oo(g),N=b.start,A=c,B=Hl(r,c,$,F,!1);c=B.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${A}`,ordered:F,start:F?N:void 0,renders:zl(B.items,`${n}-list-${A}`,s,m(0)-1)});continue}const E=[g.trimStart()],S=[m(c)],L=c;for(c+=1;c<r.length&&r[c].trim()&&!El(r[c])&&!(c+1<r.length&&r[c].includes("|")&&To(r[c+1]));)E.push(r[c].trimStart()),S.push(m(c)),c+=1;const D=Al(E,`${n}-p-${L}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${L}`,perLine:D.perLine,hardBreaks:D.hardBreaks,lineNums:S})}return d}function Hx(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:Ll(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,n)},s.keyPrefix);case"list":{const l=s.ordered?"ol":"ul";return e.jsx(l,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:Wl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Io,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}const bo=16,ch=192;function zx(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(ch,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 Wx(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-bo,d=s.y-bo,c=s.width+bo*2,m=s.height+bo*2,g=Math.max(ch,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 Gx(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return df(`code.${s}`)??s}function dh({code:r,blockKey:n}){const{t:s}=mt(),[l,d]=a.useState(null),[c,m]=a.useState(!1),g=a.useRef(null),f=a.useContext(zf);a.useEffect(()=>{let x=!1;return d(null),m(!1),vg().then(async h=>{yg(h);const b=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:E}=await h.render(b,r);x||d(zx(E))}).catch(()=>{x||m(!0)}),()=>{x=!0}},[n,r]),a.useLayoutEffect(()=>{l&&Wx(g.current)},[l]);const p=a.useCallback(()=>{const x=g.current?.querySelector("svg")?.outerHTML??l;x&&f?.(x)},[f,l]);return c?e.jsx(Io,{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 Io({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Gx(n),[m,g]=a.useState(null);a.useEffect(()=>{if(!c||!uf(r)){g(null);return}let p=!1;return ff().then(x=>{if(p||!x.registered(c)){p||g(null);return}try{g(hf(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:`${_l} 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 Gl(r,n,s,l,d){const c=new hg;c.validateLines(r),r=wx(r);const m=vx(r),g=Vf(r),f=[],p={budget:c,markdownFilePath:n,rootPath:s,referenceDefinitions:m,footnoteDefinitions:yx(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(Po(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:ht(o,`details-${j}-summary`,!0,p)}),_.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:oh(_,`details-${j}`,p)})]})});continue}const L=rh(E);if(L){const j=[E],o=h;for(h+=1;h<r.length&&!L.selfContained&&!new RegExp(`</${L.tag}>`,"i").test(r[h]);)j.push(r[h]),h+=1;h<r.length&&!L.selfContained&&(j.push(r[h]),h+=1),x.push({key:`html-${o}`,startLine:o+1,endLine:h,content:e.jsx(th,{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(dh,{code:j.join(`
|
|
1647
|
+
`),blockKey:`code-${I}`}):["math","latex","tex"].includes(_.toLowerCase())?e.jsx(ua,{tex:j.join(`
|
|
1648
|
+
`),display:!0}):Y=>e.jsx(Io,{code:j.join(`
|
|
1649
|
+
`),lang:_,blockKey:`code-${I}`,codeStartLine:I+2,lineRange:Y})});continue}if(Ao(E)){const j=[],o=h;for(h+=0;h<r.length&&(Ao(r[h])||!r[h].trim());)j.push(r[h].trim()?ah(r[h]):""),h+=1;x.push({key:`indented-code-${o}`,startLine:o+1,endLine:h,fineGrained:!0,content:_=>e.jsx(Io,{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(ua,{tex:j.join(`
|
|
1651
|
+
`),display:!0})});continue}if(h+1<r.length&&S&&!El(E)&&/^(=+|-+)\s*$/.test(r[h+1].trim())){const j=r[h+1].trim().startsWith("=")?1:2,o=`h${j}`,_=Ml(S,p),I={level:j,text:Du(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:ht(S,`setext-heading-${h}`,!0,p)})}),h+=2;continue}const F=S.match(/^(#{1,6})\s+(.+)$/);if(F){const j=F[1].length,o=Gf(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=Ml(o,p),U={level:j,text:Du(o),id:Y};x.push({key:`heading-${h}`,startLine:h+1,endLine:h+1,heading:U,content:e.jsx(I,{id:Y,className:`scroll-mt-16 font-semibold text-foreground ${_[j]}`,children:ht(o,`heading-${h}`,!0,p)})}),h+=1;continue}if(Uf(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 U=I[1].toUpperCase(),O=I[2]?.trim(),R=[...O?[O]:[],...j.slice(1)],z=[...O?[o[0]]:[],...o.slice(1)],Z=Al(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:U}),R.length>0&&e.jsx("div",{children:Ll(Z.perLine,Z.hardBreaks,z,`callout-${_}`,P)})]})});continue}const Y=Ux(j,`quote-${_}`,p,o);x.push({key:`quote-${_}`,startLine:_+1,endLine:h,fineGrained:!0,content:U=>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:Hx(Y,U)})});continue}if(h+1<r.length&&E.includes("|")&&To(r[h+1])){const j=fa(E),o=ih(r[h+1]),_=[],I=h;for(h+=2;h<r.length&&r[h].includes("|")&&r[h].trim();)_.push(fa(r[h])),h+=1;const Y=j.map((O,R)=>ht(O,`th-${I}-${R}`,!0,p)),U=_.map((O,R)=>j.map((z,Z)=>ht(O[Z]??"",`td-${I}-${R}-${Z}`,!0,p)));x.push({key:`table-${I}`,startLine:I+1,endLine:h,interactive:!1,kind:"table",content:O=>{const R=z=>!!(O&&z>=O.start&&z<=O.end);return e.jsx("div",{className:If,"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:`${Lf} ${Lo(o[Z]??null)}`,children:e.jsx("div",{className:$o,children:z})},`h-${Z}`))})}),e.jsx("tbody",{children:U.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((W,J)=>e.jsx("td",{className:`${Tf} ${Lo(o[J]??null)}`,children:e.jsx("div",{className:$o,children:z[J]})},`c-${J}`))},`r-${Z}`)})})]})})}});continue}const $=ha(E);if($){const j=$.ordered,o=Oo(E),_=$.start,I=h,Y=Hl(r,h,o,j,!0,g);h=Y.nextIndex;const U=j?"ol":"ul",O=zl(Y.items,`list-${I}`,p);x.push({key:`list-${I}`,startLine:I+1,endLine:h,fineGrained:!0,content:R=>e.jsx(U,{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:Wl(O,R)})});continue}const N=[E.trimStart()],A=[h+1],B=h;for(h+=1;h<r.length&&r[h].trim()&&!El(r[h])&&!(h+1<r.length&&r[h].includes("|")&&To(r[h+1]));){if(Po(r[h])||g.has(h)){h+=1;continue}N.push(r[h].trimStart()),A.push(h+1),h+=1}const q=Al(N,`p-${B}`,p);x.push({key:`p-${B}`,startLine:B+1,endLine:h,fineGrained:!0,content:j=>e.jsx("p",{className:"text-muted-foreground",children:Ll(q.perLine,q.hardBreaks,A,`p-${B}`,j)})})}const b=Ox(p);return b&&x.push({key:"footnotes",startLine:r.length,endLine:r.length,content:b}),c.check(),{blocks:x,images:f}}function Kx(r,n,s){return Gl(r,n,s).blocks}function uh(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 fh(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function qx({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const{t:d}=mt(),c=Jf(r),m=yf(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),Qu(c,{signal:b.signal}).then(async S=>{if(!S.ok)throw new Error(`HTTP ${S.status}`);const L=await S.blob();b.signal.aborted||(E=URL.createObjectURL(L),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(jh,{src:m?h.objectUrl:c,vector:ma(r),alt:n,onLoad:()=>{},onError:()=>{m&&f({src:c,failed:!0})},onZoomChange:s,onDoubleTap:l})}function hh({images:r,index:n,onChange:s,onClose:l}){const{t:d}=mt(),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),[L,D]=a.useState(!1),[F,$]=a.useState(!1),[N,A]=a.useState(null),B=a.useRef(!1),q=async()=>{if(!(!c||B.current)){j(),B.current=!0,$(!0),A(null);try{await xg(c)}catch(O){A({image:c,message:O instanceof Error?O.message:d("rightSidebar.downloadFailed")})}finally{B.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(O=>{if(r.length===0)return;const R=(O+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 O=g.current;O&&(O.allowTouchMove=m&&!h)},[m,h]),a.useEffect(()=>{const O=g.current;!O||O.activeIndex===n||O.slideTo(n,0)},[n]),a.useEffect(()=>j,[j]),a.useEffect(()=>{const O=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",O),()=>document.removeEventListener("keydown",O)},[m,Y,I,l]),nf({onDrag:({movement:[O,R],pinching:z})=>{z||h||Math.abs(R)<Math.abs(O)*1.15&&E===0||(D(!0),Math.abs(R)>8&&(x.current=Date.now()+300),S(Math.max(0,R)))},onDragEnd:({movement:[O,R],velocity:[,z],pinching:Z,canceled:P})=>{if(D(!1),Z||P||h||Math.abs(R)<Math.abs(O)*1.15){S(0);return}if(Math.abs(R)>8&&(x.current=Date.now()+300),lh(R,z)){l();return}S(0)}},{target:f,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const U=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:Rr.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:U}),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(la,{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(sp,{size:17})})]}),e.jsx("button",{type:"button",onClick:()=>{q()},disabled:F,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100","aria-label":d("rightSidebar.downloadFile"),title:d("rightSidebar.downloadFile"),"aria-busy":F,children:F?e.jsx(ft,{size:17,className:"animate-spin"}):e.jsx(rf,{size:17})}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:e.jsx(Lt,{size:18})})]})]}),N?.image===c&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center justify-between gap-3 bg-surface px-3 py-2 text-xs text-destructive",children:[e.jsxs("span",{className:"min-w-0 break-words",children:[d("rightSidebar.downloadFailed"),": ",N.message]}),e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-3 py-1 text-foreground hover:bg-surface-elevated",onClick:()=>{q()},disabled:F,children:d("common.retry")})]}),e.jsx("div",{ref:f,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:O=>{if(!(Date.now()<x.current)){if(O.target instanceof Element&&O.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:L?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(sf,{onSwiper:O=>{g.current=O,O.allowTouchMove=m&&!h},onSlideChange:O=>{O.activeIndex!==n&&s(O.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((O,R)=>e.jsx(ml,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:O.kind==="image"?e.jsx(qx,{src:O.src,alt:O.alt||O.title||d("rightSidebar.markdownImage"),onZoomChange:b,onDoubleTap:j}):e.jsx(c0,{svg:O.svg,title:O.title||O.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:b,onDoubleTap:j})})},`${O.kind}-${R}-${O.alt}`))})})})]})]}),document.body)}function mh({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:L,onLocalLinkOpen:D}){const{t:F}=mt(),[$,N]=a.useState(null),[A,B]=a.useState(null),[q,j]=a.useState(1),[o,_]=a.useState(null),I=a.useRef(null),Y=a.useRef(null),{blocks:U,images:O,parseError:R}=a.useMemo(()=>{try{return{...Gl(n.split(`
|
|
1652
|
+
`),s,l,M=>{B(null),N(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&&Ro("markdown_error",{filePath:s,rootPath:l,error:R,fallback:"plain_text"})},[R,s,l]);const z=a.useMemo(()=>A?[...O,A]:O,[O,A]),Z=a.useCallback(M=>{B({kind:"mermaid",svg:M,alt:"Mermaid diagram",title:"Mermaid diagram"}),N(O.length),S?.()},[O.length,S]);a.useEffect(()=>{N(null),B(null)},[n,s]),a.useEffect(()=>{N(null),B(null)},[E]),a.useEffect(()=>{b||(N(null),B(null))},[b]),a.useEffect(()=>{j(1)},[n,s]),a.useLayoutEffect(()=>{const M=I.current;if(!M||U.length===0)return;const he=Array.from(M.querySelectorAll("[data-markdown-preview-block-start]"));let fe=1;const Ee=28;for(const $e of he)if($e.offsetTop-g<=Ee)fe=Number($e.dataset.markdownPreviewBlockStart)||fe;else break;j($e=>$e===fe?$e:fe)},[U,g]);const P=a.useMemo(()=>uh(U,q),[q,U]),W=a.useMemo(()=>fh(U),[U]),J=`${s??""}
|
|
1653
|
+
${n}`,oe=a.useRef(J),pe=a.useRef(null),Se=a.useRef(null),we=a.useRef(!1);a.useEffect(()=>{oe.current!==J&&(oe.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(),Ee=window.innerWidth;_({top:fe.bottom+6,right:Math.max(8,Ee-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]"),Ee=he?.querySelector(`[data-markdown-preview-block-start="${M.startLine}"]`);if(!fe||!Ee)return;const $e=fe.getBoundingClientRect(),tt=Ee.getBoundingClientRect(),Te=he?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,Je=tt.top-$e.top+fe.scrollTop;fe.scrollTo({top:Math.max(0,Je-Te-8),behavior:"smooth"}),j(M.startLine),h?.()},[h]),Q=a.useCallback(M=>{M.pointerType==="mouse"&&M.button!==0||dl(M.target)||(pe.current={pointerId:M.pointerId,startX:M.clientX,startY:M.clientY})},[]),be=a.useCallback((M,he,fe)=>{const Ee=pe.current;if(pe.current=null,!Ee||Ee.pointerId!==M.pointerId)return;const $e=Math.abs(M.clientX-Ee.startX),tt=Math.abs(M.clientY-Ee.startY);if($e>8||tt>8)return;const ce=M.target;if(dl(ce)||gl())return;const Te=Ku(ce,he,fe);c(M,Te.start,Te.end)},[c]),ue=a.useCallback(M=>{pe.current?.pointerId===M.pointerId&&(pe.current=null)},[]),Be=a.useCallback((M,he)=>{const fe=I.current;if(!fe||typeof document.elementFromPoint!="function")return null;const Ee=document.elementFromPoint(M,he);if(!(Ee instanceof HTMLElement)||!fe.contains(Ee))return null;const $e=Ee.closest("[data-md-ref-start]");if($e){const De=Number($e.dataset.mdRefStart);if(Number.isFinite(De)&&De>0)return De}const tt=Ee.closest("[data-markdown-preview-block-start]");if(!tt)return null;const ce=Number(tt.dataset.markdownPreviewBlockStart),Te=U.find(De=>De.startLine===ce);if(!Te)return Number.isFinite(ce)&&ce>0?ce:null;if(Te.endLine<=Te.startLine)return Te.startLine;const Je=tt.getBoundingClientRect(),Ie=Je.height>0?Math.min(1,Math.max(0,(he-Je.top)/Je.height)):0;return Math.round(Te.startLine+Ie*(Te.endLine-Te.startLine))},[U]),Oe=a.useCallback(M=>{if(!m||M.pointerType==="mouse"&&M.button!==0)return;const he=Be(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,Be]),G=a.useCallback(M=>{const he=Se.current;if(!he||he.pointerId!==M.pointerId||!m)return;const fe=Be(M.clientX+16,M.clientY);fe!=null&&(!he.moved&&fe===he.anchorLine||(he.moved=!0,we.current=!0,m(M,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"move")))},[m,Be]),je=a.useCallback(M=>{const he=Se.current;if(Se.current=null,!he||he.pointerId!==M.pointerId||!m||!he.moved)return;const fe=Be(M.clientX+16,M.clientY)??he.anchorLine;m(M,Math.min(he.anchorLine,fe),Math.max(he.anchorLine,fe),"end")},[m,Be]),ye=a.useCallback(M=>{Se.current?.pointerId===M.pointerId&&(Se.current=null)},[]),Ue={onPointerDown:Oe,onPointerMove:G,onPointerUp:je,onPointerCancel:ye},Ye=()=>we.current?(we.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})]}):U.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 Ee=Bl(fe,s,l);Ee&&(M.preventDefault(),D(Ee))},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}),W.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(af,{size:12}),e.jsx("span",{children:F("rightSidebar.markdownOutlineShort")})]})]})}),f&&typeof document<"u"&&Rr.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:W.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:W.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(zf.Provider,{value:Z,children:U.map(M=>{const he=!!(d&&M.startLine<=d.end&&M.endLine>=d.start),fe=!!(d&&d.start<=M.startLine&&d.end>=M.endLine),Ee=M.kind==="table"?!1:M.fineGrained?fe:he,$e=M.kind==="table"&&d?.start===M.startLine&&d.end===M.endLine;let tt=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),Re=(De-M.startLine)/Ie,rt=(te-De+1)/Ie;tt=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) * ${Re})`,height:`calc((100% - 0.5rem) * ${rt})`}})}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}`,Je=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:il(Ee),"aria-hidden":"true",...Ue,children:[e.jsx("span",{className:ll(Ee)}),tt]}),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 ${Ee?"bg-primary/10":""}`,title:`Line ${Te}`,"aria-label":`Line ${Te}`,children:[M.kind==="table"?e.jsx("button",{type:"button",className:il($e,"self"),onClick:Ie=>{Ie.preventDefault(),!Ye()&&c(Ie,M.startLine,M.endLine)},title:`Reference table lines ${Te}`,"aria-label":`Reference table lines ${Te}`,...Ue,children:e.jsx("span",{className:ll($e,"self")})}):e.jsxs("span",{className:il(Ee,"none"),"aria-hidden":"true",...Ue,children:[e.jsx("span",{className:ll(Ee,"none")}),tt]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:Q,onPointerUp:Ie=>be(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(dl(De)||gl()||Ye())return;const te=Ku(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 ${Ee?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:Je},M.key)})})})]}),b&&$!==null&&z[$]&&e.jsx(hh,{images:z,index:$,onChange:N,onClose:()=>{N(null),B(null),L?.()}})]})}function fs({label:r,value:n,options:s,placeholder:l,searchPlaceholder:d,emptyText:c,disabled:m,onChange:g}){const{t:f}=mt(),[p,x]=a.useState(!1),[h,b]=a.useState(""),[E,S]=a.useState(null),L=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]),N=s.find(j=>j.value===n),A=()=>{const j=h.trim();j&&(g(j),x(!1),b(""))},B=a.useCallback(()=>{const j=L.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,U=j.top-o,O=Y>=180||Y>=U,R=Math.max(96,(O?Y:U)-4),z=Math.min(320,R);return S({left:I,top:O?j.bottom+4:Math.max(o,j.top-z-4),width:_,maxHeight:z}),!0},[]),q=()=>{B(),x(!0)};return a.useEffect(()=>{if(!p)return;let j=0;const o=()=>{j||(j=window.requestAnimationFrame(()=>{j=0,B()}))},_=I=>{const Y=I.target;Y instanceof Node&&(L.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,B]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:L,type:"button",disabled:m,onClick:()=>{if(!m){if(b(""),p){x(!1);return}q()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:N?.label??(n||l)})]}),e.jsx(ca,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${p?"rotate-180":""}`})]}),p&&!m&&typeof document<"u"&&Rr.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 Ou({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:L,ariaLabel:D,scopeTitle:F,scopeLabel:$,allLabel:N,generateLabel:A,secondaryLabel:B,secondaryTitle:q,secondaryLoading:j,loading:o,error:_,statusTitle:I,extraContent:Y,renderRepoExtra:U,menuItem:O=!1}){return e.jsxs("div",{className:O?"relative w-full":"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",role:O?"menuitem":void 0,tabIndex:O?-1:void 0,onClick:()=>{s?n(!r):x||g()},disabled:p,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${O?"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":O?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:I??(s?`${F}: ${$}`:L),children:[o?e.jsx(ft,{size:O?15:13,className:"shrink-0 animate-spin"}):e.jsx(da,{size:O?15:13,className:O?"shrink-0 text-muted-foreground":void 0}),e.jsx("span",{className:O?"min-w-0 flex-1":void 0,children:b?S:E}),s&&(O?e.jsx(hs,{size:13,className:"shrink-0 text-muted-foreground"}):e.jsx(ca,{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"&&Rr.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:N}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),d.map(R=>{const z=c.includes(R.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${z?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>m(R.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${z?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:R.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:R.label}),R.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:R.branch})]}),z&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),U&&(l||z)&&e.jsx("div",{className:"px-2 pb-2",children:U(R)})]},R.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${f&&B?"sm:grid-cols-2":""}`,children:[f&&B&&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(ft,{size:12,className:"animate-spin"}):e.jsx(pf,{size:12}),B]}),e.jsxs("button",{type:"button",onClick:()=>{x||(n(!1),g())},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:L,children:[e.jsx(da,{size:12}),A]})]})]})}),document.body)]})}function Vx(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 ph(){return gt(Dl,Vx)??{}}function Yx(r,n){const s=ph(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Hb);sa(Dl,Object.fromEntries(l),Wb)}function Xx(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 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)||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&&!Xx(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Kl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function gh(){return gt(Fl,Jx)??{}}function Uu(r,n){const s=Kl(r,n);return s?gh()[s]??null:null}function al(r,n,s){const l=Kl(r,n);if(!l)return;const d=gh(),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,zb);sa(Fl,Object.fromEntries(m),Gb)}function ol({slow:r}){return e.jsx(Op,{slow:r})}function xo({message:r,onRetry:n}){const{t:s}=mt();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 jo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function kt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function vo(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 Qx(r,n,s){return bl(r,n,s)}function il(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 ll(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 bh(r){const n=new Map;for(const s of r)n.set(ql(s),s);return n}function xh(r,n){const s=new Map(r);for(const l of n)s.set(ql(l),l);return s}function Hu(r,n){let s=0;for(const l of r){const d=xt(l,n);d&&n&&d!==n&&(s+=1)}return s}function Zx(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function e0(r,n){return Array.from(xh(bh(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function t0(r,n){const s=r.relativeRoot==="."?kt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||kt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:Zx(r.files)}}function vh(r,n){const s=kt(n??"")||n||"";return r.map(l=>t0(l,n)).sort((l,d)=>s&&l.label===s?-1:s&&d.label===s?1:l.label.localeCompare(d.label))}function yh(r,n,s,l,d){const c=Ff(s),m=c.find(L=>L.root===l)??c[0]??null,g=n.find(L=>L.root===l)??null,f=g?.relativeRoot??m?.relativeRoot??".",p=g?.name??m?.name??(kt(l)||l),x=(m?.files??s.files).map(L=>({...L,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(L=>({path:L.path,absolutePath:L.absolutePath,status:L.status}))}:null,untrackedDeferred:m?.untrackedDeferred??s.untrackedDeferred,error:m?.error??s.error},E=g?n.map(L=>L.root===l?b:L):[...n,b];return{files:Array.from(r).filter(L=>xt(L,d)!==l).concat(x),repositories:E,repoFilters:vh(E,d)}}function xt(r,n){return r.repoRoot??n}function ql(r){return`${r.repoRoot??""}\0${r.path}`}function Sr(r){return r.absolutePath||r.path}function cl(r){return ql(r)}function r0(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function zu(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Wu(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 Qs(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 Zs(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 jr(r){return r instanceof DOMException&&r.name==="AbortError"}function n0(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function Gu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function dl(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function Ku(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 s0({actions:r,running:n,completed:s}){const{t:l}=mt(),[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(ft,{size:13,className:"animate-spin"}):f?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(No,{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(ft,{size:13,className:"animate-spin"}):h?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.key)})})]}))}function a0(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function wh(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&a0(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 ul=new WeakMap;function Do(r){const n=ul.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"),ul.delete(r)},1700);ul.set(r,s)}function o0(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=wh(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),Do(d);return}const m=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,m),behavior:"instant"}),Do(d)}function In(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 L of m){const D=S.querySelector(L);if(D&&ps(D)){f=D;break}}if(f)break}if(f??=m.flatMap(S=>Array.from(document.querySelectorAll(S))).find(ps)??null,!f){o0(r.filePath);return}const p=wh(f);if(!p){f.scrollIntoView({block:"center",behavior:"smooth"}),Do(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"}),Do(f)}const kh=1,Vl=8;function i0(r,n=Vl){return Math.min(n,Math.max(kh,r))}function Sh({resetKey:r,maxScale:n=Vl,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),L=a.useRef(m);L.current=m,a.useEffect(()=>{g({scale:1,x:0,y:0})},[r]);const D=a.useCallback((A,B,q)=>{const j=c.current;if(!j)return{x:B,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),U=Math.max(0,(I*A-j.clientHeight)/2);return{x:Math.min(Y,Math.max(-Y,B)),y:Math.min(U,Math.max(-U,q))}},[]),F=a.useCallback((A,B,q)=>{g(j=>{const o=i0(A,n),_=c.current;if(!_||o===1)return{scale:o,x:0,y:0};const I=_.getBoundingClientRect(),Y=(B??I.left+I.width/2)-I.left-I.width/2,U=(q??I.top+I.height/2)-I.top-I.height/2,O=o/j.scale,R=Y-(Y-j.x)*O,z=U-(U-j.y)*O;return{scale:o,...D(o,R,z)}})},[D,n]),$=a.useCallback((A,B)=>{p(!0),L.current.scale>1?g({scale:1,x:0,y:0}):F(2.5,A,B),window.setTimeout(()=>p(!1),220)},[F]);a.useEffect(()=>{const A=c.current;if(!A)return;const B=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(!(L.current.scale<=1)){o.preventDefault(),x.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:L.current.x,originY:L.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(U=>({...U,...D(U.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",B,{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",B,{capture:!0}),window.removeEventListener("pointermove",q,{capture:!0}),window.removeEventListener("pointerup",j,{capture:!0}),window.removeEventListener("pointercancel",j,{capture:!0})}},[D,l,$]),nf({onPinch:({offset:[A],origin:[B,q]})=>{p(!1),F(A,B,q)},onWheel:({event:A,delta:[B,q],ctrlKey:j})=>{if(j){A.preventDefault(),A.stopPropagation(),p(!1),F(L.current.scale*(1-q*.01),A.clientX,A.clientY);return}L.current.scale<=1||(A.preventDefault(),A.stopPropagation(),p(!1),g(o=>({...o,...D(o.scale,o.x-B,o.y-q)})))}},{target:c,eventOptions:{passive:!1},pinch:{scaleBounds:{min:kh,max:n},from:()=>[L.current.scale,0],rubberband:!0}});const N=m.scale>1;return a.useEffect(()=>{s?.(N)},[s,N]),e.jsx("div",{ref:c,"data-sidebar-gesture-ignore":N?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden","data-image-zoom-viewport":!0,style:{cursor:N?"grab":"zoom-in"},onDoubleClick:A=>{A.stopPropagation(),!(Date.now()-S.current<500)&&(l?.(),$(A.clientX,A.clientY))},children:d({scale:m.scale,zoomed:N,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 jh({src:r,alt:n,vector:s,onLoad:l,onError:d,onZoomChange:c,onDoubleTap:m}){const g=_o(r,d),[f,p]=a.useState(null),x=s??ma(r);return a.useEffect(()=>{p(null)},[r]),e.jsx(Sh,{resetKey:r,maxScale:Math.max(Vl,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 L=S.currentTarget,D=L.closest("[data-image-zoom-viewport]");if(D&&L.naturalWidth>0&&L.naturalHeight>0){const F=Math.max(1,D.clientWidth-2),$=Math.max(1,D.clientHeight-2),N=Math.min(F/L.naturalWidth,$/L.naturalHeight),A=x?N:Math.min(N,1);p({width:L.naturalWidth*A,height:L.naturalHeight*A,originalScale:1/A})}l(S)},onError:d})})})}function l0({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),L=Math.min(E/h,S/b,1);m.style.width=`${Math.max(1,Math.floor(h*L*s))}px`,m.style.height=`${Math.max(1,Math.floor(b*L*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 c0({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Sh,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:d,scale:c})=>e.jsx(l0,{svg:r,title:n,scale:c,vectorTransformStyle:d})})}let d0=0,u0=0,f0=0,h0=0,m0=0;function Ro(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ut(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++u0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ea(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++h0,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function p0(){return`diff-ui-${Date.now().toString(36)}-${(++m0).toString(36)}`}function g0(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function b0(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 Fo({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:L,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:F,lineRange:$,onLineRangeChange:N,insertedReferenceKey:A,copiedReferenceKey:B,scrollToLine:q,onScrollToLineHandled:j}){const{t:o}=mt(),_=a.useRef(null),I=a.useRef({}),Y=a.useRef(s);Y.current=s,a.useEffect(()=>{s||_.current?.querySelectorAll("video").forEach(T=>T.pause())},[s]);const U=V(T=>T.rootPath),O=V(T=>T.selectFile),[R,z]=a.useState({kind:"idle"}),[Z,P]=a.useState("schematic"),[W,J]=a.useState(null),oe=a.useRef(null),[pe,Se]=a.useState(null),we=a.useRef(new Map),Me=a.useRef(null),[Q,be]=a.useState(null),[ue,Be]=a.useState(()=>$u()),[Oe,G]=a.useState(()=>bu(U,n)),je=a.useRef(null),[ye,Ue]=a.useState(!1),[Ye,M]=a.useState(null),[he,fe]=a.useState(0),[Ee,$e]=a.useState([]),[tt,ce]=a.useState(null),Te=a.useRef(null),Je=a.useRef(n),[Ie,De]=a.useState(null),te=Qg(U&&n&&!n.startsWith("/")?`${U}/${n}`:n,s),[Re,rt]=a.useState(!1),[We,Br]=a.useState(""),[H,ne]=a.useState([]),[Ce,lt]=a.useState(0),ct=a.useRef(null),Nt=mf(m),Zr=Kl(U,n);a.useEffect(()=>{if(Je.current===n)return;Je.current=n;const T=n&&U&&!n.startsWith("/")?`${U}/${n}`:n;if(Te.current===T){Te.current=null;return}Te.current=null,$e([]),ce(null),rt(!1),Br("")},[n,U]);const Nr=n?U&&!n.startsWith("/")?`${U}/${n}`:n:null,lr=V(T=>Nr?(T.fileChangeVersions.get(Nr)??0)+T.fileWatchEpoch:T.fileWatchEpoch),zt=a.useRef(null),Cr=a.useRef(null),[Jt,pa]=a.useState(0),Fn=a.useCallback(()=>pa(T=>T+1),[]);a.useEffect(()=>{const T=oe.current;return oe.current=null,J(null),T&&URL.revokeObjectURL(T.objectUrl),()=>{const K=oe.current;oe.current=null,K&&URL.revokeObjectURL(K.objectUrl)}},[Nr,lr,Jt]),a.useEffect(()=>{if(!n){zt.current=null,z({kind:"idle"});return}const T=U&&!n.startsWith("/")?`${U}/${n}`:n,K=new AbortController,ge=++d0,ke=`right-sidebar-file-preview:${ge}`,nt=performance.now();let _e=!1;const ze=(re,Ke={})=>{_e||(_e=!0,Ro("end",{loadingId:ge,reason:re,durationMs:Math.round(performance.now()-nt),filePath:n,fullPath:T,rootPath:U,...Ke}))};let Ge=null;const bt=Km(T),vt=bt?T.toLowerCase().endsWith(".kicad_pcb")?Z==="schematic"?"pcb-front":Z:"schematic":Z,un=!bt&&Tl(T),tr=!bt&&!un&&qm(T),Gr=!bt&&!un&&!tr&&Xu(T),js=Js(T),Rs=Vs(T),pr=bt?"eda":un?"image":tr?"model3d":Gr?"video":"text",fn=zt.current!==T;if(zt.current=T,fn){Ro("start",{loadingId:ge,filePath:n,fullPath:T,rootPath:U,mode:pr,externalVersion:lr}),z({kind:"loading",mode:pr}),Cr.current=null;const re=Uu(U,n);N(re?.lineRange??null),Be(js?$u():"source"),G(Rs?bu(U,n):"source"),bt&&P(Vm(T))}fn||z(re=>re.kind==="error"?{kind:"loading",mode:pr}:re);const hn=window.setTimeout(()=>{_e||K.signal.aborted||Ro("still_active",{loadingId:ge,filePath:n,fullPath:T,rootPath:U,mode:pr,durationMs:Math.round(performance.now()-nt),isPathChange:fn})},3e3),Uo=window.setTimeout(()=>{if(_e||K.signal.aborted)return;const re=bt?o("rightSidebar.edaTimeout"):tr?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}),ze("stuck_timeout",{error:re})},bt?Ym+5e3:tr?Xm+5e3:Jm(T)?35e3:Qb);if(bt){const re=vt==="pcb-3d"?oe.current:null;re?(z(re),ze("eda_3d_client_cache_hit",{bytes:re.meta.size,view:re.view,mimeType:re.meta.mimeType})):Qm(T,vt,K.signal,"view_file",ke).then(Ke=>{if(K.signal.aborted)return;Ge=URL.createObjectURL(Ke.blob);const Wt={kind:"eda",sourcePath:Ke.path||T,objectUrl:Ge,view:Ke.view,meta:{size:Ke.size,mimeType:Ke.mimeType,modified:Ke.modified}};if(Ke.view==="pcb-3d"){const Pr=oe.current;Pr&&Pr.objectUrl!==Ge&&URL.revokeObjectURL(Pr.objectUrl),oe.current=Wt,J(Wt),Ge=null}z(Wt),ze("eda_loaded",{bytes:Ke.size,view:Ke.view,mimeType:Ke.mimeType})}).catch(Ke=>{K.signal.aborted||(z({kind:"error",message:Ke instanceof Error&&/timed out/i.test(Ke.message)?o("rightSidebar.edaTimeout"):Ke instanceof Error?Ke.message:o("rightSidebar.edaLoadFailed")}),ze("error",{error:Ke instanceof Error?Ke.message:String(Ke)}))})}else if(un)Zm(T,K.signal,"view_file",ke).then(re=>{Ge=URL.createObjectURL(re.blob),z({kind:"image",objectUrl:Ge,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),ze("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")}),ze("error",{error:re instanceof Error?re.message:String(re)}))});else if(tr)ep(T,K.signal,"view_file",ke).then(re=>{K.signal.aborted||(Ge=URL.createObjectURL(re.blob),z({kind:"model3d",sourcePath:re.path||T,objectUrl:Ge,ext:re.ext,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),ze("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")}),ze("error",{error:re instanceof Error?re.message:String(re)}))});else if(Gr){const re=tp(T)??"",Ke=Ju(T);z(Wt=>Wt.kind==="video"&&Wt.url===Ke?Wt:{kind:"video",url:Ke,meta:{size:null,mimeType:re,modified:null}}),ze("video_ready",{mimeType:re})}else Hd(T,K.signal,"view_file",ke).then(re=>{if(!K.signal.aborted){if(re.binary){z({kind:"binary"});return}z({kind:"text",content:re.content,sourcePath:re.path||T,meta:{size:re.size,truncated:re.truncated}}),ze("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"}),ze("error",{error:re instanceof Error?re.message:String(re)}))});return()=>{K.abort(),Rt(ke),window.clearTimeout(hn),window.clearTimeout(Uo),Ge&&URL.revokeObjectURL(Ge),ze("cleanup")}},[n,U,lr,Jt,N,o,Z]),a.useEffect(()=>{if(R.kind!=="model3d"||!n){Se(null);return}let T=!1;const K=n.lastIndexOf("/"),ge=K>=0?n.slice(K+1):n,ke=K>=0?n.slice(0,K):"",nt=ke.lastIndexOf("/"),_e=nt>=0?ke.slice(0,nt):"",ze=ge.replace(/\.(stl|glb|gltf)$/i,""),Ge=`${_e?`${_e}/`:""}features/${ze}.json`;return Hd(Ge).then(bt=>{if(!T)try{const vt=JSON.parse(bt.content);Se(vt.version===1&&Array.isArray(vt.features)&&vt.features.length>0?vt.features:null)}catch{Se(null)}}).catch(()=>{T||Se(null)}),()=>{T=!0}},[R,n]),a.useEffect(()=>{if(R.kind!=="text"){De(null);return}const T=U&&n&&!n.startsWith("/")?`${U}/${n}`:n,K=df(T),ge=R.content,ke=Js(T??"")&&ue==="preview",nt=Vs(T??"")&&Oe==="preview";if(!K||ke||nt||!uf(ge)){De(null);return}let _e=!1;const ze=Ge=>{if(_e||!Ge.registered(K)){_e||De(null);return}try{De(hf(Ge,ge,K))}catch{De(null)}};return Ye?ze(Ye):(De(null),ff().then(Ge=>{_e||(M(Ge),ze(Ge))}).catch(()=>{})),()=>{_e=!0}},[R,Ye,n,U,ue,Oe]),a.useLayoutEffect(()=>{if(!Zr||R.kind!=="text")return;const T=`${Zr}:${ue}:${Oe}`;if(Cr.current===T)return;const K=Uu(U,n);if(Cr.current=T,!K)return;const ge=requestAnimationFrame(()=>{const ke=Me.current;if(!ke)return;const nt=ue==="preview"?K.markdownTop??K.top:K.top;ke.scrollTo({top:Math.max(0,nt??0),left:Math.max(0,K.left??0)}),fe(ue==="preview"?Math.max(0,nt??0):0)});return()=>cancelAnimationFrame(ge)},[n,ue,Oe,R.kind,Zr,U]),a.useEffect(()=>{Zr&&al(U,n,{lineRange:$})},[n,$,Zr,U]),a.useEffect(()=>{if(q==null||R.kind!=="text")return;be(null),N({start:q,end:q});const T=q,K=requestAnimationFrame(()=>{const ge=we.current.get(T);ge&&ge.scrollIntoView({block:"center"}),j?.()});return()=>cancelAnimationFrame(K)},[q,R,N,j]);const gs=a.useCallback(T=>{const K=Me.current;if(!K)return!1;const ge=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(T):T.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),ke=K.querySelector(`#${ge}`);return ke?(ke.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const T=U&&n&&!n.startsWith("/")?`${U}/${n}`:n,K=R.kind==="text"&&Js(T??"")&&ue==="preview";if(!tt||!K)return;const ge=requestAnimationFrame(()=>{gs(tt)&&ce(null)});return()=>cancelAnimationFrame(ge)},[n,gs,ue,tt,R,U]),a.useLayoutEffect(()=>{const T=Me.current;if(!T||!$){be(null);return}if(Q)return;const K=R.kind==="image"||R.kind==="loading"&&R.mode==="image",ge=U&&n&&!n.startsWith("/")?`${U}/${n}`:n,ke=R.kind==="text"&&Js(ge??"")&&ue==="preview",nt=R.kind==="text"&&Vs(ge??"")&&Oe==="preview";if(R.kind!=="text"||K||ke||nt){be(null);return}const _e=()=>{const Ge=we.current.get($.end);if(!Ge||!T){be(null);return}const bt=Ge.offsetTop+Ge.offsetHeight/2,vt=T.scrollLeft+Math.max(8,T.clientWidth-120);be({top:bt,left:vt})};_e();const ze=new ResizeObserver(()=>_e());return ze.observe(T),()=>ze.disconnect()},[$,Q,R,ue,Oe,n,U,Ie]);const cr=R.kind==="text"&&!(Vs(Nr??"")&&Oe==="preview")&&!Nr?.toLowerCase().endsWith(".csv")&&!Nr?.toLowerCase().endsWith(".kicad_pro")&&!Nr?.toLowerCase().endsWith(".kicad_prl"),en=a.useCallback(()=>{rt(!1),Br(""),ne([]),lt(0),mo(I.current)},[]),Ct=a.useCallback(()=>{!s||!cr||(rt(!0),requestAnimationFrame(()=>{const T=_.current;!Y.current||!T?.isConnected||T.closest('[inert], [aria-hidden="true"], [hidden]')||T.getClientRects().length===0||getComputedStyle(T).visibility==="hidden"||!T.contains(document.activeElement)||(ct.current?.focus(),ct.current?.select())}))},[s,cr]),Or=a.useCallback(T=>{lt(K=>H.length===0?0:(K+T+H.length)%H.length)},[H.length]),tn=a.useCallback(T=>{if(T.nativeEvent.isComposing||!Lb(_.current,s,T))return;const K=Tb(T);if(K==="open"&&cr){T.preventDefault(),Ct();return}Re&&(K==="close"?(T.preventDefault(),en()):(K==="next"||K==="previous")&&(T.preventDefault(),Or(K==="previous"?-1:1)))},[s,en,Re,Or,Ct,cr]);if(a.useLayoutEffect(()=>{if(mo(I.current),!s||!Re||!We.trim()||!Me.current){ne([]),lt(0);return}const T=Db(Me.current,We);return ne(T),lt(0),(_.current?.contains(document.activeElement)||wu(I.current))&&(Ji(T,0,I.current),ku(T[0])),()=>mo(I.current)},[s,Re,We,Ie,ue,R]),a.useEffect(()=>{!s||!Re||!We.trim()||!_.current?.contains(document.activeElement)&&!wu(I.current)||(Ji(H,Ce,I.current),ku(H[Ce]))},[s,Ce,H,Re,We]),a.useEffect(()=>()=>mo(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 Xe=U&&!n.startsWith("/")?`${U}/${n}`:n,dr=jo(Xe,U),Ur=tf(Xe,U),Hr=R.kind==="text"&&R.content?R.content.split(`
|
|
1654
|
+
`):[],zr=Math.max(2,String(Hr.length).length)+1,Er=R.kind==="text"||R.kind==="image"||R.kind==="model3d"||R.kind==="video"||R.kind==="eda"?R.meta:null,Tt=Js(Xe),ga=Xe.toLowerCase().endsWith(".csv"),Mr=Xe.toLowerCase().endsWith(".kicad_pro"),bs=Xe.toLowerCase().endsWith(".kicad_prl"),ur=R.kind==="text"&&Tt&&ue==="preview",xs=Vs(Xe),$r=R.kind==="text"&&xs&&Oe==="preview",St=R.kind==="image"||R.kind==="loading"&&R.mode==="image",rn=R.kind==="model3d"||R.kind==="loading"&&R.mode==="model3d",vs=R.kind==="video"||R.kind==="loading"&&R.mode==="video",ys=R.kind==="eda"||R.kind==="loading"&&R.mode==="eda",ws=R.kind==="text"?R.sourcePath:Xe,Wr=Np(ws,U,$),nn=(()=>{if(!$||R.kind!=="text"||Hr.length===0)return Wr;const T=[];for(let ke=$.start;ke<=$.end;ke+=1)T.push(`${ke} ${Hr[ke-1]??""}`);const K=Of(Xe).replace(/^\./,""),ge="```";return`${Wr}
|
|
1655
|
+
${ge}${K}
|
|
1656
|
+
${T.join(`
|
|
1657
|
+
`)}
|
|
1658
|
+
${ge}
|
|
1659
|
+
`})(),Qt=`path:${Xe}`,Zt=$?`path:${Xe}:${$.start}-${$.end}`:Qt,_n=A===Qt,ks=A===Zt,sn=B===Qt,fr=B===Zt,an=ks||fr,on=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,ln=T=>{const K=Me.current;if(!K)return;const ge=K.getBoundingClientRect(),ke=T.currentTarget.getBoundingClientRect(),nt=T.clientX||ke.left+ke.width/2,ze=(T.clientY||ke.top+ke.height/2)-ge.top+K.scrollTop,Ge=p?116:132,bt=K.scrollLeft+Math.max(8,K.clientWidth-Ge),vt=Math.min(Math.max(8,nt-ge.left+K.scrollLeft+10),bt);be({top:ze,left:vt})},hr=(T,K)=>{gl()||(ln(T),N(ge=>{const ke=bl(ge,K,K);return ke||be(null),ke}))},mr=(T,K,ge)=>{ln(T),N(ke=>{const nt=bl(ke,K,ge);return nt||be(null),nt})},ve=(T,K,ge,ke)=>{ke==="end"&&ln(T),N({start:K,end:ge})},er=T=>{const{scrollTop:K,scrollLeft:ge}=T.currentTarget;fe(K),al(U,n,{top:K,left:ge,markdownTop:K})},cn=T=>{if(T.directory){f?.(T.path);return}if(T.path===Xe||R.kind==="text"&&T.path===R.sourcePath){T.fragment&&gs(T.fragment);return}$e(K=>[...K,Xe]),Te.current=T.path,ce(T.fragment),N(null),O(T.path)},Bn=()=>{const T=Ee[Ee.length-1];T&&($e(K=>K.slice(0,-1)),Te.current=T,ce(null),N(null),O(T))},Ss=T=>{const{scrollTop:K,scrollLeft:ge}=T.currentTarget;al(U,n,{top:K,left:ge})},dn=T=>{if(r){r(nn,Zt);return}$&&d(nn,Zt,T.currentTarget)},It=()=>{if(!(R.kind==="loading"||R.kind==="error"))return te.start()};return e.jsxs("div",{ref:_,tabIndex:-1,onKeyDown:tn,onFocusCapture:()=>{s&&Re&&We.trim()&&Ji(H,Ce,I.current)},onPointerDownCapture:T=>{T.target instanceof Element&&!T.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&T.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Nt.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(ur||$r)?"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(af,{size:16})}),Ee.length>0&&e.jsxs("button",{type:"button",onClick:Bn,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(la,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Xe,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:dr.name}),dr.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:dr.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[cr&&e.jsx("button",{type:"button",onClick:Re?en:Ct,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 ${Re?"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})}),Tt&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{x&&E?.(),Be(T=>{const K=T==="preview"?"source":"preview";return At(Nf,K),K}),N(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?ue==="preview"?e.jsx(vl,{size:14}):e.jsx(xl,{size:14}):o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),xs&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{G(T=>{const K=T==="preview"?"source":"preview";return eb(U,n,K),K}),N(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?Oe==="preview"?e.jsx(vl,{size:14}):e.jsx(xl,{size:14}):o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),$r&&e.jsx("button",{type:"button",onClick:()=>{je.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(of,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:T=>l(Xe,Qt,T.currentTarget),...Nt(Ur,Qt),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${_n||sn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Ur}),children:o(sn?"rightSidebar.copied":_n?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Ur)},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:Ur}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(rp,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{It()},disabled:te.status==="pending"||R.kind==="loading"||R.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:te.status==="error"?te.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(ft,{size:13,className:"animate-spin"}):e.jsx(rf,{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")}),Re&&cr&&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:ct,type:"search",value:We,onChange:T=>Br(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Or(T.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:H.length>0?`${Ce+1}/${H.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Or(-1),disabled:H.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(Il,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Or(1),disabled:H.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(Cp,{size:13})}),e.jsx("button",{type:"button",onClick:en,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})})]}),Er&&!(p&&(ur||$r))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Er.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Er.size.toLocaleString()})}),"truncated"in Er&&Er.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Er&&e.jsx("span",{children:Er.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(ur||$r))&&!rn&&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:ys?o("rightSidebar.edaPickHint"):ga?o("rightSidebar.csvTablePreview"):Mr||bs?o("rightSidebar.kicadProjectPickHint"):vs?o("rightSidebar.videoPreviewHint"):St?o("rightSidebar.imagePreviewHint"):ur?$?o("rightSidebar.selectedLineHint",{lineLabel:on??""}):o("rightSidebar.markdownPreviewHint"):$r?o("rightSidebar.htmlPreviewHint"):$?o("rightSidebar.selectedLineHint",{lineLabel:on??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||$r)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(zi,{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:Fn,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(wf,{blobUrl:R.objectUrl,filePath:Xe,viewLabel:"SVG 文件",onInsertAnnotation:c}):e.jsx(jh,{src:R.objectUrl,alt:dr.name,vector:!1,onLoad:T=>{const K=T.currentTarget;z(ge=>ge.kind==="image"?{...ge,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:ge)},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(ub,{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(xb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Xe.toLowerCase().endsWith(".kicad_pcb"),onViewChange:P,onInsertAnnotation:r??c,onRefresh:Fn,interactive3d:W?e.jsx(a.Suspense,{fallback:e.jsx(zi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Mu,{blobUrl:W.objectUrl,ext:".glb",fileName:dr.name,filePath:W.sourcePath,features:null,onInsertFeature:r??c,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:T=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(T)?T:"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(zi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Mu,{blobUrl:R.objectUrl,ext:R.ext,fileName:dr.name,filePath:R.sourcePath,features:pe,onInsertFeature:r??c,onRefresh:Fn})})}):R.kind==="text"&&ga?e.jsx(wb,{content:R.content,filePath:Xe,onInsertAnnotation:r??c},Xe):R.kind==="text"&&(Mr||bs)?e.jsx(jb,{content:R.content,filePath:Xe,localState:bs,onInsertAnnotation:r??c},Xe):ur?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:er,style:{touchAction:"pan-x pan-y"},children:[e.jsx(mh,{content:R.content,filePath:R.sourcePath,rootPath:U,lineRange:$,onLineRangeClick:mr,onLineRangeDrag:ve,scrollTop:he,outlineOpen:x,outlineCloseSignal:h,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:S,lightboxCloseSignal:L,onLightboxOpen:D,onLightboxClose:F,onLocalLinkOpen:cn}),$&&Q&&e.jsxs("button",{type:"button",onClick:dn,...Nt(nn,Zt),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:lu(p,an),title:`Insert markdown reference: ${Wr}`,children:[e.jsx(Eo,{size:p?13:11}),fr?o("rightSidebar.copied"):ks?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:on??""})]})]}):$r?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Ab,{ref:je,src:np(Xe),title:`${dr.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ue},`${Xe}:${lr}:${Jt}`)}):R.kind==="text"?e.jsxs("div",{ref:Me,onScroll:Ss,className:`${_l} 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:[Hr.length>0?e.jsx("div",{className:"min-w-full",children:Hr.map((T,K)=>{const ge=K+1,ke=!!($&&ge>=$.start&&ge<=$.end),nt=Ie&&Ie.length===Hr.length?Ie[K]:null;return e.jsxs("div",{ref:_e=>{_e?we.current.set(ge,_e):we.current.delete(ge)},role:"button","data-file-preview-line":ge,tabIndex:0,onClick:_e=>hr(_e,ge),onKeyDown:_e=>{_e.key!=="Enter"&&_e.key!==" "||(_e.preventDefault(),hr(_e,ge))},style:{gridTemplateColumns:`${zr}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${ke?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Ur}:${ge}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${ke?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ge}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:nt??(T||" ")})]},K)})}):"Empty file.",$&&Q&&e.jsxs("button",{type:"button",onClick:dn,...Nt(nn,Zt),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:lu(p,an),title:`Insert code reference: ${Wr}`,children:[e.jsx(Eo,{size:p?13:11}),fr?o("rightSidebar.copied"):ks?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:on??""})]})]}):null]})}function x0({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(Fo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:d,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:f,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function v0({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:L,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A=!1,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j}){const{t:o,locale:_}=mt(),[I,Y]=a.useState(""),U=V(t=>t.pendingTerminalPath),[O,R]=a.useState(null),z=a.useRef(0),Z=V(t=>t.rightSearchOpen),P=V(t=>t.setRightSearchOpen),W=V(t=>t.rightSidebarLayoutPreference),J=V(t=>t.setRightSidebarLayoutPreference),[oe,pe]=a.useState(()=>ux()),[Se,we]=a.useState("."),[Me,Q]=a.useState(""),[be,ue]=a.useState(!1),[Be,Oe]=a.useState(!1),[G,je]=a.useState(!1),[ye,Ue]=a.useState(!1),Ye=a.useDeferredValue(I),[M,he]=a.useState(null),[fe,Ee]=a.useState([]),[$e,tt]=a.useState([]),ce=V(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Te=V(t=>t.setActiveGitRepo),[Je,Ie]=a.useState(null),[De,te]=a.useState(null),[Re,rt]=a.useState(null),[We,Br]=a.useState(()=>gt(ju,na)??!1),[H,ne]=a.useState(()=>gt(Ru,na)??!1),[Ce,lt]=a.useState(()=>gt(Nu,na)??!1),[ct,Nt]=a.useState(()=>gt(el,ox)??""),[Zr,Nr]=a.useState(0),[lr,zt]=a.useState(!1),[Cr,Jt]=a.useState(!1),pa=a.useRef(null),Fn=a.useRef(null),[gs,cr]=a.useState(!1),[en,Ct]=a.useState(null),[Or,tn]=a.useState(null),[Xe,dr]=a.useState(()=>Pu(Qi)),[Ur,Hr]=a.useState(()=>Pu(Su)),[zr,Er]=a.useState(()=>ax()),[Tt,ga]=a.useState(()=>ix()),[Mr,bs]=a.useState(()=>cx()),ur="words",[xs,$r]=a.useState(0),[St,rn]=a.useState([]),[vs,ys]=a.useState([]),[ws,Wr]=a.useState(!1),[nn,Qt]=a.useState(null),[Zt,_n]=a.useState([]),[ks,sn]=a.useState(!1),[fr,an]=a.useState([]),[on,ln]=a.useState([]),[hr,mr]=a.useState(!1),[ve,er]=a.useState(null),[cn,Bn]=a.useState([]),[Ss,dn]=a.useState({}),It=a.useRef(0),[T,K]=a.useState(0),[ge,ke]=a.useState(!1),[nt,_e]=a.useState(null),[ze,Ge]=a.useState(null),[bt,vt]=a.useState(null),[un,tr]=a.useState(null),[Gr,js]=a.useState(!1),[Rs,pr]=a.useState(""),fn=a.useDeferredValue(Rs),[hn,Uo]=a.useState({}),[re,Ke]=a.useState([]),[Wt,Pr]=a.useState(!1),[ba,Ns]=a.useState(!1),[Ho,On]=a.useState(null),[zo,Un]=a.useState(!1),gr=a.useRef(null),Kr=a.useRef(0),Yl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Rh,xa]=a.useState(null),[Cs,Xl]=a.useState(()=>gt(Zi,na)??!1),[Wo,Go]=a.useState(!1),[va,Ko]=a.useState([]),[rr,ya]=a.useState({}),[Et,wa]=a.useState({}),[mn,qo]=a.useState({}),[Jl,Ql]=a.useState(()=>new Set),[Qe,pn]=a.useState(null),[Vo,gn]=a.useState(null),[Nh,Ar]=a.useState(!1),[Yo,Lr]=a.useState(0),[,Xo]=a.useState(0),[Jo,ka]=a.useState(!1),[Ch,Eh]=a.useState(()=>V.getState().rightTab==="files"),[nr,Qo]=a.useState(!1),[Mh,Zl]=a.useState(()=>V.getState().rightTab==="diff"),[Zo,ec]=a.useState(()=>V.getState().rightTab==="android"),[qr,tc]=a.useState(!1),[sr,rc]=a.useState({architecture:!1,computer:!1}),Es=a.useRef(new Set),Sa=Wi(t=>t.docks[Ki]),$h=!!Sa,[qe,Ms]=a.useState(null),[Hn,$s]=a.useState(null),[yt,bn]=a.useState(null),[nc,Gt]=a.useState(null),[zn,sc]=a.useState(null),[ei,Ph]=a.useState(()=>Date.now()),[Ah,Lh]=a.useState(!1),[xn,ja]=a.useState(!1),[Ra,ac]=a.useState(""),[Wn,Na]=a.useState(""),[vn,Ca]=a.useState(""),[yn,Ea]=a.useState(""),[oc,Gn]=a.useState(null),[ic,ti]=a.useState(!1),[lc,cc]=a.useState(!1),[Ma,Th]=a.useState({key:null,nonce:0}),dc=a.useRef(null),uc=a.useRef(null),se=pp(s,m,W),ri=Df(se,m,Mr),[ni,si]=a.useState(()=>xx(s)),ai=V(t=>t.rightTab),Dt=V(t=>t.setRightTab),v=V(t=>t.rootPath),Kn=V(t=>t.explorerRoot),fc=V(t=>t.pinnedExplorerRootsCache),hc=V(t=>t.hydratePinnedExplorerRoots),mc=V(t=>t.syncPinnedExplorerRoots),Ft=V(t=>t.setExplorerRoot),pc=V(t=>t.resetExplorerToProject),qn=V(t=>t.pinExplorerRoot),wn=V(t=>t.unpinExplorerRoot),at=V(t=>t.selectedFilePath),ot=V(t=>t.selectFile),oi=V(t=>t.showHiddenFiles),Ih=V(t=>t.toggleShowHiddenFiles),ii=V(t=>!!(v&&t.nestedGitScanRoots[v])),Fe=V(t=>t.changedFiles),$a=V(t=>t.setChangedFiles),Ps=V(t=>t.invalidateDirectoryCache),Dh=V(t=>t.setDirectorySortMode),gc=V(t=>t.applyFileWatchEvents),bc=V(t=>t.reconcileDirectoryCache),xc=V(t=>t.bumpFileWatchEpoch),br=V(t=>t.gitBundleLoading),vc=V(t=>t.gitBundleSlow),kn=V(t=>t.gitBundleError),Vn=V(t=>t.gitBundleLastLoadedAt),yc=V(t=>t.beginGitBundleLoading),wc=V(t=>t.setGitBundleSlowFor),li=V(t=>t.finishGitBundleLoading),Pa=V(t=>t.resetGitBundleLoading),ci=V(t=>t.setGitBundleError),kc=V(t=>t.markGitBundleLoaded),ie=Kn??v,Aa=V(t=>!!(ie&&t.hideGitIgnoredRoots[ie])),Fh=V(t=>t.hideGitIgnoredRootsHydrated),_h=V(t=>t.setHideGitIgnoredRoot),[di,Sc]=a.useState(!1),[jc,ui]=a.useState(null);a.useEffect(()=>{ui(null)},[ie]);const Rc=a.useMemo(()=>ie?_b(ie,Se):"",[ie,Se]),As=a.useMemo(()=>Fb(Me),[Me]),Nc=a.useMemo(()=>({excludePatterns:As,caseSensitive:Be,wholeWord:G,regex:ye}),[Be,As,ye,G]),La=V(t=>ie?t.fileSortModes[ie]??"name":"name"),Cc=V(t=>!!(ie&&t.directoryCache.has(ie))),Yn=a.useRef(null),jt=a.useRef(0),[Ec]=a.useState(()=>++f0),Tr=a.useRef(null),Vr=a.useRef(null),Ta=a.useRef(0),Kt=a.useRef(new Map),qt=a.useRef(new Map),xr=a.useRef(new Set),Sn=a.useRef(new Set),jn=a.useRef(0),Yr=a.useRef(null),Xn=a.useRef(0),Jn=a.useRef(null),Qn=a.useRef(0),Xr=a.useRef(null),fi=a.useRef(new Set),hi=a.useRef(null),mi=a.useRef(null),Ia=a.useRef(null),pi=a.useRef(null),gi=a.useRef(null),Ls=a.useRef(new Set);a.useEffect(()=>{if(zn===null)return;const t=Math.max(0,Date.now()-zn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,u=Math.max(50,i-t%i),w=window.setTimeout(()=>Ph(Date.now()),u);return()=>window.clearTimeout(w)},[ei,zn]);const Da=a.useRef(null),Ir=a.useRef(null),bi=a.useRef(null),Mc=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=g0(i.target);u&&ea("global_change_row_event",{...b0(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 $c=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(xr.current.has(t)||Sn.current.has(t))return ut("untracked_skip_cached",{cwd:t,rootPath:v,completed:xr.current.has(t),running:Sn.current.has(t)}),null;const i=v,u=Ta.current+1;Ta.current=u,Kt.current.set(t,u);const w=`right-sidebar-git-untracked:${t}`,y=new AbortController;qt.current.set(t,y),Sn.current.add(t),ut("untracked_start",{requestId:u,cwd:t,rootPath:v});try{let k=await zd(t,y.signal,w),C=0;for(;k.status==="running"&&C<120;){if(Kt.current.get(t)!==u||y.signal.aborted)return ut("untracked_stale_result",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,status:k.status}),null;if(!Pe(i))return ut("untracked_root_changed",{requestId:u,cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath}),null;await new Promise(ae=>window.setTimeout(ae,C<10?1e3:3e3)),C+=1,k=await zd(t,y.signal,w)}if(Kt.current.get(t)!==u||!Pe(i))return ut("untracked_stale_result",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return $a(xh(V.getState().changedFiles,k.files)),k.files.length>0&&Ee(ae=>{const Ae=new Map(ae.map(me=>[me.root,me])).get(t);if(!Ae)return ae;const Ze=e0(Ae.files,k.files),ee=ae.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);tt(vh(ee,v));const X=ee.find(me=>me.root===v);return X?.context&&he(me=>me?.root===X.root?{...me,...X.context}:me),ee}),xr.current.add(t),ut("untracked_apply",{requestId:u,cwd:t,files:k.files.length}),k;const le=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return xr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:le,code:k.code,status:k.status}),null}catch(k){if(Kt.current.get(t)!==u||!Pe(i)||jr(k))return ut("untracked_aborted",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const C=k instanceof Error?k.message:"Failed to scan untracked files";return xr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:C}),null}finally{qt.current.get(t)===y&&qt.current.delete(t),Kt.current.get(t)===u&&Kt.current.delete(t),Sn.current.delete(t)}},[M,Pe,v,$a]),ar=a.useMemo(()=>{const t=new Set($e.map(u=>u.root)),i=Zt.filter(u=>t.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Zt,$e]),Pc=ar.length===0,Rn=a.useMemo(()=>ar.map(t=>fe.find(i=>i.root===t)).filter(t=>!!t),[ar,fe]),Bh=a.useMemo(()=>$e.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[$e]),vr=a.useCallback(async()=>{if(!v){rn([]),ys([]);return}const t=v,i=Xn.current+1;Xn.current=i,Jn.current?.abort();const u=new AbortController;Jn.current=u,Wr(St.length===0),Qt(null);try{const w=ar.length>0?await Promise.all(ar.map(y=>Wd({workspaceRoot:v,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(k=>k.records),walkthroughs:y.flatMap(k=>k.walkthroughs??[])})):await Wd({workspaceRoot:v},u.signal);if(Xn.current!==i||!Pe(t))return;rn(w.records),ys(w.walkthroughs??[])}catch(w){if(Xn.current!==i||!Pe(t)||jr(w))return;Qt(w instanceof Error?w.message:"Failed to load change audit explanations")}finally{Jn.current===u&&(Jn.current=null),Xn.current===i&&Pe(t)&&Wr(!1)}},[St.length,ar,Pe,v]),Fa=a.useCallback(async(t,i,u)=>{if(!t&&!v){an([]),ln([]);return}const w=v,y=Qn.current+1;Qn.current=y,Xr.current?.abort();const k=new AbortController;Xr.current=k;try{const C=t?[t]:Array.from(new Set([v,...fe.map(ae=>ae.root)].filter(ae=>!!ae))),le=await Promise.all(C.map(ae=>ap({repoRoot:ae,baseRef:i,branchName:u},k.signal))).then(ae=>{const xe=new Map,Ae=new Map;for(const Ze of ae){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(Qn.current!==y||!Pe(w))return;an(le.records),ln(le.walkthroughs??[])}catch(C){if(Qn.current!==y||!Pe(w)||jr(C))return;console.warn("[RightSidebar] Failed to load branch explanations",C)}finally{Xr.current===k&&(Xr.current=null)}},[fe,Pe,v]),Zn=a.useCallback((t,i={})=>{if(!Pe(v)){ut("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:V.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}ut(t.files.length===0?"empty_bundle":"apply",{rootPath:v,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let u=Ff(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)){ut("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:fe.length});return}const le=u.some(X=>X.deferred);if(le&&!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(xt(Le,v)??"")),...t.files]}const ae=Hu(k.values(),v),xe=Hu(t.files,v),Ae=u.some(X=>X.root!==v);if(!!(i.background&&!le&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||ae>0&&xe===0&&!Ae))){ut("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:ae,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=yh(k.values(),fe,t,i.replaceRepoRoot,v);y=X.files,u=X.repositories,w=X.repoFilters}if($a(bh(y)),Ee(X=>{if(!le||i.replaceWorkspace)return u;const me=new Map(X.map(Le=>[Le.root,Le]));return u.map(Le=>{const Ve=me.get(Le.root);return!Le.deferred||!Ve?Le:{...Le,available:Ve.available,files:Ve.files,context:Ve.context,deferred:Ve.deferred,untrackedDeferred:Ve.untrackedDeferred,error:Ve.error}})}),tt(w),gi.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:me}=V.getState(),Le=X?me[X]??null:null,Ve=i.activeRepoRoot!==void 0?i.activeRepoRoot:Le,He=fx({...t,repositories:u,repoFilters:w},Ve);Te(He)}typeof t.cacheUpdatedAt=="number"&&sc(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&&$r(X=>X+1);const ee=V.getState().selectedFilePath;if(ee&&!ee.startsWith("/")&&!y.some(X=>X.path===ee||X.absolutePath===ee)&&ot(null),dr(X=>{const me=new Set(y.map(Ve=>xt(Ve,v)).filter(Boolean)),Le=new Set;for(const Ve of X)me.has(Ve)&&Le.add(Ve);return rl(Qi,Le),Le}),i.loadDeferred!==!1){const X=u.filter(me=>me.untrackedDeferred&&me.root).map(me=>me.root);for(const me of X)$c(me)}i.loadAudit!==!1&&vr()},[Pe,vr,$c,v,ot,Te,$a]);a.useEffect(()=>{Pa(),hi.current=null,mi.current=v;const t=[],i=[];jt.current+=1,jn.current+=1,Ta.current+=1,Tr.current?.abort(),Rt(Qs(Vr.current?.cwd??v??void 0)),Vr.current=null,Tr.current=null,Yr.current?.abort(),Rt("right-sidebar-git-details"),Yr.current=null;for(const C of qt.current.values())C.abort();for(const C of qt.current.keys())Rt(`right-sidebar-git-untracked:${C}`);qt.current.clear(),Kt.current.clear(),Xn.current+=1,Jn.current?.abort(),Jn.current=null,Qn.current+=1,Xr.current?.abort(),Xr.current=null,Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,rn([]),ys([]),Wr(!1),Qt(null),_n([]),sn(!1),an([]),ln([]),mr(!1),er(null),ke(!1),_e(null),Ge(null),vt(null),tr(null),js(!1),pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1),xa(null),pn(null),gn(null),Xl(!1),At(Zi,!1),Go(!1);const u=v?Au()[v]:null,w=u?.previewEntries??[],y=u?.selectedPreviewKey??null,k=y?w.find(C=>C.key===y)??null:null;++It.current,ke(!1),Ko(u?.selectedRepoRoots??[]),ya(u?.repoTargetBranches??{}),wa(u?.repoBaseBranches??{}),Bn(w),dn(u?.previewScrollTops??{}),k&&u?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(er(k.diff),pn(k.key),gn(u.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),mr(!0)),qo(u?.repoIncludeUncommitted??Object.fromEntries(Object.keys(u?.repoTargetBranches??{}).map(C=>[C,u?.includeUncommitted??!0]))),hi.current=v,ja(!1),xr.current.clear(),Sn.current.clear(),Ms(null),$s(null),bn(null),Gt(null),sc(null),Ee(t),tt(i),he(null),pi.current=null,gi.current=null,Ls.current.clear()},[Pa,v]);const _t=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const u=v,w=jt.current;if(await gg(()=>Promise.all([V.getState().hydrateNestedGitScanRoots(),V.getState().hydrateActiveGitRepos()]).then(()=>{})),jt.current!==w||!Pe(u))return null;const y=t===v&&Xs(v),k=i.includeNested??y,C=i.refresh??i.reloadDiff??!1,le=i.cacheOnly??!1,ae=i.background??!1,xe=k&&(i.discoverOnly??!1);C&&xr.current.clear();const Ae=Vr.current;if(Ae&&Ae.cwd===t&&Ae.includeNested===k&&Ae.refresh===C&&Ae.cacheOnly===le&&Ae.discoverOnly===xe)return ut("reuse_pending",{cwd:t,includeNested:k,refresh:C,cacheOnly:le,discoverOnly:xe}),Ae.promise;const Ze=jt.current+1;jt.current=Ze;const ee=`right-sidebar:${Ec}:${Ze}`;Tr.current?.abort();const X=Qs(t);Rt(X);const me=new AbortController;Tr.current=me;let Le=null;ae||yc(ee),ci(null),ut("start",{requestId:Ze,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:C,cacheOnly:le,background:ae,existingChanges:Fe.size,lastLoadedAt:Vn}),!ae&&typeof window<"u"&&(Le=window.setTimeout(()=>{jt.current===Ze&&wc(ee,!0)},qb));const Ve=(async()=>{const He=await Gi(t,me.signal,{includeNested:k,refresh:C,cacheOnly:le,discoverOnly:xe,action:C?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:C?null:void 0});if(n0(He)){if(ut("cancelled_result_ignored",{requestId:Ze,activeRequestId:jt.current,cwd:t,error:He.error??He.context?.error}),me.signal.aborted)return null;throw new Error(He.error??He.context?.error??"Failed to load Git changes")}return jt.current!==Ze||!Pe(u)?(ut("stale_result",{requestId:Ze,activeRequestId:jt.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,files:He.files.length,repositories:He.repositories?.length??0}),null):(Zn(He,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:ae,cacheOnly:le,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),He)})();Vr.current={cwd:t,includeNested:k,refresh:C,cacheOnly:le,discoverOnly:xe,promise:Ve};try{const He=await Ve;return jt.current===Ze&&He&&Pe(u)?kc({cached:He.cached,stale:He.stale,cacheAgeMs:He.cacheAgeMs,nestedDeferred:!k||He.nestedDeferred,untrackedDeferred:He.untrackedDeferred}):jt.current===Ze&&Pe(u)&&li(ee),He}catch(He){return jt.current!==Ze||!Pe(u)||me.signal.aborted?(ut("aborted",{requestId:Ze,activeRequestId:jt.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,message:He instanceof Error?He.message:String(He)}),null):(ut("error",{requestId:Ze,cwd:t,includeNested:k,refresh:C,background:ae,message:He instanceof Error?He.message:String(He)}),ae||(he(null),ci(He instanceof Error?He.message:"Failed to load Git changes")),null)}finally{Le!==null&&window.clearTimeout(Le),Tr.current===me&&(Tr.current=null),Vr.current?.promise===Ve&&(Vr.current=null),!ae&&jt.current===Ze&&Pe(u)&&li(ee)}},[Zn,yc,Fe.size,li,Ec,Vn,Pe,kc,v,ci,wc]),es=a.useCallback(async()=>{v&&await _t(v,{reloadDiff:!0,refresh:!0})},[_t,v]),xi=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,u=jn.current+1;jn.current=u,Yr.current?.abort(),Rt("right-sidebar-git-details");const w=new AbortController;Yr.current=w,ja(!0);try{const y=await Gd(t,w.signal,"load_git_details","right-sidebar-git-details");return jn.current!==u||!Pe(i)?null:(Ee(k=>k.map(C=>C.root===y.root?{...C,available:y.available,context:y,error:y.error}:C)),he(k=>k?.root&&y.root&&k.root!==y.root?k:!k?.available||!y.available?y:{...k,...y}),y)}catch(y){return jr(y)||!Pe(i)||jn.current===u&&Gt(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Yr.current===w&&(Yr.current=null),jn.current===u&&Pe(i)&&ja(!1)}},[Pe,v]);a.useEffect(()=>{if(!r){jt.current+=1,Pa(),pi.current=null,jn.current+=1,Ta.current+=1,Tr.current?.abort(),Rt(Qs(Vr.current?.cwd??v??void 0)),Vr.current=null,Tr.current=null,Yr.current?.abort(),Rt("right-sidebar-git-details"),Yr.current=null;for(const t of qt.current.values())t.abort();for(const t of qt.current.keys())Rt(`right-sidebar-git-untracked:${t}`);qt.current.clear(),Kt.current.clear(),Qn.current+=1,Xr.current?.abort(),Xr.current=null,Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,ja(!1),ke(!1),_e(null),Ge(null),vt(null),tr(null),js(!1),pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1),Y(""),P(!1),Ct(null),Qo(!1),se&&Zl(!1)}},[se,r,Pa,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 Ac=a.useCallback(t=>{Xo(t);const i=bi.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(se)if(Ar(f),f&&at){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)),Ct(null)}},[se,f,v,at]),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),Ct(null)}},[p,f]),a.useEffect(()=>{E!==void 0&&Ie(null)},[E]),a.useEffect(()=>{!se&&f&&h?.()},[se,h,f]),a.useEffect(()=>{si(t=>Cl(t,s))},[s]);const Oh=a.useCallback(t=>{se||(t.preventDefault(),Da.current={startX:t.clientX,startWidth:ni,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[ni,se]),Uh=a.useCallback(t=>{const i=Da.current;if(!i||i.pointerId!==t.pointerId)return;const u=Cl(i.startWidth+t.clientX-i.startX,s);si(u),sa(ra,u,Kb)},[s]),Lc=a.useCallback(t=>{const i=Da.current;if(!(!i||i.pointerId!==t.pointerId)){Da.current=null,Ys(ra);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),ts=!!(v&&Vn!==null&&Gu(M)),vi=!!(v&&!kn&&Fe.size===0&&Vn===null),Mt=(()=>{let t=ai;return t==="android"&&!qr&&(t="files"),(t==="architecture"||t==="computer")&&!sr[t]&&(t="files"),ts&&(t==="git"||t==="diff")&&(t="files"),t})(),dt=Mt==="git",Dr=Mt==="files",$t=Mt==="diff",rs=Mt==="android",ns=Mt==="computer",Nn=Mt==="architecture",[Hh,zh]=a.useState(!1);a.useEffect(()=>{r&&ns&&zh(!0)},[r,ns]);const[Wh,Gh]=a.useState(!1);a.useEffect(()=>{r&&Nn&&Gh(!0)},[r,Nn]);const yi=a.useRef(null),ss=a.useCallback((t,i)=>{const u=V.getState().rightTab;if(u===t)return;const w=performance.now(),y=w-i.timeStamp;yi.current={from:u,to:t,startedAt:w,inputDelayMs:y>=0&&y<6e4?Math.round(y):null},Dt(t)},[Dt]);a.useEffect(()=>{const t=yi.current;if(!t||t.to!==Mt)return;yi.current=null;const i=Math.round(performance.now()-t.startedAt);let u=window.requestAnimationFrame(()=>{u=window.requestAnimationFrame(()=>{ea("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 Kh=Ep(t=>t.overlay==="sidebar")&&rs;a.useEffect(()=>{if(!se){ka(!0);return}if(!r){const i=window.setTimeout(()=>{ka(!1)},Xb);return()=>window.clearTimeout(i)}ka(!1);const t=window.setTimeout(()=>{ka(!0)},Yb);return()=>window.clearTimeout(t)},[se,r]),a.useEffect(()=>{if(!se||!$t)return;const t=bi.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[$t,se]),a.useEffect(()=>{if(!ts||!v||br)return;const t=window.setTimeout(()=>{_t(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[ts,v,br,_t]);const qh=a.useCallback(t=>{_t(t,{discoverOnly:!0})},[_t]);bg({active:r&&(dt||$t),rootPath:v,loading:br,delay:dt&&!se?0:tl,lastStartedRoot:pi,load:qh}),a.useEffect(()=>{!r||!dt||(!se||Jo)&&Qo(!0)},[dt,se,r,Jo]),a.useEffect(()=>{if(!r||dt)return;const t=window.setTimeout(()=>{Qo(!0)},tl);return()=>window.clearTimeout(t)},[dt,r]),a.useEffect(()=>{Dr&&Eh(!0)},[Dr]),a.useEffect(()=>{$t&&Zl(!0)},[$t]),a.useEffect(()=>{!r||!rs||(n&&Sa&&Sa.sessionId!==n&&(Wi.getState().setDock(Ki,null),ta({androidPanel:{docked:null}}).catch(()=>{})),ec(!0))},[rs,r,n,Sa]),a.useEffect(()=>{if(r&&rs||!Zo)return;const t=window.setTimeout(()=>ec(!1),Vb);return()=>window.clearTimeout(t)},[r,rs,Zo]),a.useEffect(()=>{let t=!1;return Yu().then(i=>{t||(Es.current.has("android")||tc(i.androidPanel?.enabled===!0),rc(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 Tc=a.useCallback(t=>{Es.current.add("android"),tc(t),t?Dt("android"):V.getState().rightTab==="android"&&Dt("files"),ta({androidPanel:{enabled:t}}).catch(()=>{})},[Dt]),Vh=a.useCallback((t,i)=>{Es.current.add(t),rc(u=>({...u,[t]:i})),i?Dt(t):V.getState().rightTab===t&&Dt("files"),ta({rightSidebarTabs:{[t]:i}}).catch(()=>{})},[Dt]),Ic=a.useCallback(t=>{ie&&Yx(ie,t.currentTarget.scrollTop)},[ie]);a.useEffect(()=>()=>{Tr.current?.abort(),Ys(Dl),Ys(Fl),Ys(ra),Ys(el)},[]),a.useEffect(()=>{if(!ie||!Cc)return;const t=ph()[ie]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Yn.current&&(Yn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Yn.current&&(Yn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[ie,Cc]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return op(t.signal).then(i=>cc(!!i.available)).catch(()=>cc(!1)),()=>t.abort()},[r]);const Is=a.useCallback(t=>{if(R(null),ot(t),Ct(null),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,ot]),wi=a.useCallback((t,i)=>{if(R(null),ot(t),tn(i),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,ot]),Bt=Yg(t=>Ps(t,!1)),_a=Bt.busy,Ds=a.useCallback(async(t,i)=>{const u=i||Kn||v;!u||!t.length||await Bt.start(u,t)},[Kn,v,Bt.start]),Dc=a.useCallback(async t=>{try{await ip(t)}catch(i){Gt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>Gt(null),4e3)}},[o]),Ba=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&ti(!0)},[]),Fc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ti(!1)},[]),_c=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ti(!1);const i=t.dataTransfer.files;i.length>0&&Ds(Array.from(i))},[Ds]),ki=a.useCallback(t=>{te(t),window.setTimeout(()=>te(i=>i===t?null:i),1400)},[]),yr=a.useCallback(t=>{rt(t),window.setTimeout(()=>rt(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{At(ju,We)},[We]),a.useEffect(()=>{At(Ru,H)},[H]),a.useEffect(()=>{At(Nu,Ce)},[Ce]),a.useEffect(()=>{sa(el,ct,Ub)},[ct]),a.useEffect(()=>(hc().catch(()=>{}),Kd(t=>{t.type==="pinned-explorer-roots"&&mc(t.pinnedExplorerRoots)})),[hc,mc]);const Bc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Oa=a.useRef(null),Cn=a.useRef(null),[Oc,Si]=a.useState(!1);a.useEffect(()=>{if(!r)return;Si(!1);let t=!1;lp().then(u=>{t||(Oa.current=u.text,Nt(w=>u.text&&u.text!==w?u.text:w),Si(!0))}).catch(()=>{t||Si(!0)});const i=Kd(u=>{u.type==="context-draft"&&u.origin!==Bc.current&&(Oa.current=u.text,Nt(u.text))});return()=>{t=!0,i(),Cn.current!==null&&(window.clearTimeout(Cn.current),Cn.current=null)}},[r]),a.useEffect(()=>{if(!Oc||Oa.current===ct)return;Cn.current!==null&&window.clearTimeout(Cn.current);const t=ct;Cn.current=window.setTimeout(()=>{Cn.current=null,cp(t,Bc.current).then(()=>{Oa.current=t}).catch(()=>{})},500)},[ct,Oc]);const as=a.useCallback(async(t,i,u,w)=>{if(!t)return!1;if(dp(u?t+u:t))return ki(i),!0;if(We)Nt(y=>Kg(y,t)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(ne(!1),Nr(y=>y+1));else{const y=n??Jr.getState().activeSessionId;if(!await ef(u?t+u:t,y,()=>Fs.current&&y===Jr.getState().activeSessionId,w))return!1}return ki(i),!0},[We,ki,n]),Ua=a.useCallback(t=>{const i=Tn(t,v);return Mp(i,v)},[v]),ji=mf(yr),Ot=a.useCallback((t,i,u)=>{const w=Tn(t,v);return as($p(w,v),i??`path:${w}`,void 0,u)},[v,as]),Ha=a.useRef({sessionId:n,contextDraftEnabled:We,isOpen:r});Ha.current={sessionId:n,contextDraftEnabled:We,isOpen:r};const Yh=a.useCallback(async t=>{const i=n??Jr.getState().activeSessionId,u=()=>Fs.current&&Ha.current.isOpen&&(Ha.current.sessionId??Jr.getState().activeSessionId)===i&&Jr.getState().activeSessionId===i&&Ha.current.contextDraftEnabled===We;await Bt.start("/tmp",[t],y=>Ot(y,`path:${y}`),u)&&u()&&se&&!We&&l()},[We,Ot,se,l,n,Bt.start]),za=a.useRef(!0),Ri=a.useRef(n);Ri.current=n,a.useEffect(()=>(za.current=!0,()=>{za.current=!1}),[]);const Xh=a.useCallback(t=>{Pp.getState().enqueue(t,n??null,v||"/",i=>{if(We&&za.current&&Ri.current===n)Ot(i);else return tu(i,n)})},[n,v,We,Ot]),Jh=a.useCallback(async t=>{const u=(await fl("/tmp",[t])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");We&&za.current&&Ri.current===n?Ot(u):await tu(u,n)},[We,Ot,n]),or=a.useCallback((t,i,u)=>{if(!t)return Promise.resolve(!1);const w=t.includes(`
|
|
1660
|
+
`)?`
|
|
1661
|
+
`:void 0;return as(t.endsWith(`
|
|
1662
|
+
`)||t.endsWith(" ")?t:`${t} `,i,w,u)},[as]),Uc=a.useRef(or);Uc.current=or;const Fs=a.useRef(!0);a.useEffect(()=>(Fs.current=!0,()=>{Fs.current=!1}),[]);const Ni=a.useRef(new Set),Hc=a.useCallback((t,i,u)=>{if(Ni.current.has(i))return;const w=n??Jr.getState().activeSessionId;Ni.current.add(i),Rg(t,i,u,{insert:or,upload:async(y,k)=>(await fl("/tmp",[y],k)).files[0]?.path,isCurrent:()=>Fs.current&&Uc.current===or&&w===Jr.getState().activeSessionId}).catch(()=>{}).finally(()=>Ni.current.delete(i))},[or,n]),Fr=a.useCallback((t,i,u)=>{i&&as(i.endsWith(" ")?i:`${i} `,u??`context:${t}`,`
|
|
1663
|
+
`)},[as]),zc=Jg({text:ct,sessionId:n??Jr.getState().activeSessionId,active:r&&We,onAccepted:()=>{cr(!1),Nt(""),Ce&&ne(!0)},onRejected:()=>{cr(!0),ne(!1)}}),st=a.useMemo(()=>v?kt(v):o("rightSidebar.workspace"),[v,o]),Qh=a.useMemo(()=>kt(ie)||st,[ie,st]),Wa=a.useMemo(()=>vo(ie),[ie]),Ga=a.useMemo(()=>v?fc[v]??[]:[],[fc,v]),En=a.useMemo(()=>new Set(Ga.map(t=>t.path)),[Ga]),_s=!!(ie&&En.has(ie)),Ci=!!(v&&ie&&ie!==v),Zh=!!(v&&Kn&&Kn!==v),Ut=ie?`path:${ie}`:null,Wc="context:change-audit",em=a.useCallback(()=>{Wa&&Ft(Wa)},[Wa,Ft]),Gc=a.useCallback(()=>{pc()},[pc]),tm=a.useCallback(()=>{ie&&(Ps(ie,!0),xc())},[xc,ie,Ps]),rm=a.useCallback(()=>{!ie||!Ci||(_s?wn(ie):qn(ie,"directory"))},[Ci,ie,_s,qn,wn]),Kc=a.useCallback(t=>{Ft(t),Y("")},[Ft]),qc=a.useCallback(t=>{ie&&(we(Bb(ie,t)),P(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ie,P]),Vc=a.useCallback(t=>{!v||t===v||(En.has(t)?wn(t):qn(t,"directory"))},[qn,En,v,wn]),Yc=a.useCallback(t=>{!v||!t||(En.has(t)?wn(t):qn(t,"file"))},[qn,En,v,wn]),Xc=V(t=>t.expandedPaths),Ei=a.useMemo(()=>{const t=new Set;if(Dr&&ie){t.add(ie);const i=`${ie.replace(/\/+$/,"")}/`;for(const u of Xc)u.startsWith(i)&&t.add(u)}if(Dr&&v&&at){const i=at.startsWith("/")?at:`${v}/${at}`,u=vo(i);u&&t.add(u)}return _g(t).join(`
|
|
1664
|
+
`)},[Xc,Dr,ie,v,at]),Mn=a.useRef(new Map);a.useEffect(()=>{const t=Ei?Ei.split(`
|
|
1665
|
+
`):[];if(!r||t.length===0){Gn(null);return}const i=new AbortController;let u=!1,w=0,y=0;Gn(null);const k=async()=>{let C=0;for(;!u&&!i.signal.aborted;){let le=null;try{Gn(null),await gp(t,xe=>{const{applicableEvents:Ae,unavailableReason:Ze}=Og(xe);Ae.length>0&&gc(Ae);const ee=new Set(Ae.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Aa)for(const X of Ae){if(X.type==="created"||X.type==="updated"){const me=vo(X.path);me&&ee.add(me)}X.path.endsWith("/.gitignore")&&ie&&Ps(ie,!0)}for(const X of ee){const me={path:X},Le=V.getState();if(!Le.directoryCache.has(me.path))continue;Mn.current.get(me.path)?.abort();const He=new AbortController;Mn.current.set(me.path,He);const Bd=`file-watch-rescan:${me.path}`;Rt(Bd),Vu(me.path,He.signal,Le.showHiddenFiles,"watch_rescan",Bd,Le.fileSortModes[me.path]??"name",ie??void 0).then(Ks=>{Mn.current.get(me.path)===He&&bc(me.path,Ks.entries)}).catch(Ks=>{jr(Ks)||Gn(Ks instanceof Error?Ks.message:"File refresh unavailable")}).finally(()=>{Mn.current.get(me.path)===He&&Mn.current.delete(me.path)})}Ze&&Gn(Ze)},i.signal),le=new Error("File watch stream ended")}catch(xe){le=xe}if(u||i.signal.aborted||jr(le))return;Gn(le instanceof Error?le.message:"File watching unavailable");const ae=Cu[Math.min(C,Cu.length-1)];C+=1,await new Promise(xe=>{y=window.setTimeout(xe,ae)})}};return w=window.setTimeout(()=>{u||k()},tl),()=>{u=!0,window.clearTimeout(w),window.clearTimeout(y),i.abort();for(const C of Mn.current.values())C.abort();Mn.current.clear()}},[gc,r,bc,Ei,ie,Aa,Ps]),a.useEffect(()=>{if(!v||hi.current!==v)return;if(mi.current===v){mi.current=null;return}const t=Au();sa(Pf,{...t,[v]:{selectedRepoRoots:va,repoTargetBranches:rr,repoBaseBranches:Et,previewEntries:cn,selectedPreviewKey:ve&&hr?Qe:null,selectedPreviewFileKey:ve&&hr?Vo:null,previewDetailOpen:!!(ve&&hr),previewScrollTops:Ss,previewMobileSlideIndex:1,repoIncludeUncommitted:mn,updatedAt:Date.now()}},Ob)},[hr,mn,ve,cn,Ss,Et,rr,va,v,Vo,Qe]);const pt=a.useMemo(()=>Wu(Fe.values()),[Fe]),it=a.useMemo(()=>{const t=new Map;for(const i of fe)t.set(i.root,i);return t},[fe]),Bs=a.useMemo(()=>{const t=new Map;for(const i of fe)i.deferred||t.set(i.root,i.files.length);return t},[fe]),Ka=a.useCallback(t=>{if(t){if(!t.deferred){Ls.current.delete(t.root);return}Bs.has(t.root)||Ls.current.has(t.root)||(Ls.current.add(t.root),_t(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ls.current.delete(t.root)}))}},[_t,Bs]),ir=a.useMemo(()=>ce?$e.find(t=>t.root===ce)??null:null,[ce,$e]),Vt=a.useMemo(()=>at?Array.from(Fe.values()).find(t=>t.path===at||t.absolutePath===at)??null:null,[Fe,at]),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:st,depth:0,nested:!1,available:!0,files:Array.from(Fe.values()).filter(i=>xt(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==="."?st:i.relativeRoot||i.name||kt(i.root),w=zu(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,st,v,o]),Ne=a.useMemo(()=>ce&&Ht.some(t=>t.value===ce)?ce:Vt?.repoRoot&&Ht.some(t=>t.value===Vt.repoRoot)?Vt.repoRoot:Ht.length===1||Ht.length>1?Ht[0].value:null,[ce,Ht,Vt?.repoRoot]),Jc=Ne?it.get(Ne)??null:null,de=Jc?.context?.available?Jc.context:Ne===M?.root?M:null,et=Ht.length>0&&!Ne,Qc=a.useMemo(()=>et?[]:Ne?Array.from(Fe.values()).filter(t=>xt(t,v)===Ne):Array.from(Fe.values()),[Ne,Fe,et,v]),$n=a.useMemo(()=>Wu(Qc),[Qc]),Mi=!!(de?.available&&de.root&&Ne&&de.root===Ne),nm=Ne?Ht.find(t=>t.value===Ne)?.label??kt(Ne):o("rightSidebar.gitRepositoryPlaceholder"),Zc=Mi?de?.branch??"HEAD":et?o("rightSidebar.selectRepositoryForGitActions"):xn?o("rightSidebar.gitActionRunning"):"HEAD",Pn=!!(de?.available&&de.root===Ne&&de.status);a.useEffect(()=>{Yl.current={count:re.length,loading:Wt,loadingMore:ba,hasMore:zo}},[re.length,zo,Wt,ba]),a.useEffect(()=>{Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1)},[Ne]);const Os=a.useCallback(async(t={})=>{if(!v||!Ne||et)return;const i=t.reset??!1,u=Yl.current,w=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const y=Kr.current+1;Kr.current=y,gr.current?.abort(),Rt("right-sidebar-recent-commits");const k=new AbortController;gr.current=k,i?Pr(!0):Ns(!0),On(null);try{const C=await up({cwd:v,repoRoot:Ne,limit:Jb,skip:w,query:fn.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Kr.current!==y)return;if(!C.available){On(C.error??"Recent commits are unavailable"),i&&Ke([]),Un(!1);return}Uo(le=>i?C.commitSyncStatus??{}:{...le,...C.commitSyncStatus}),Ke(le=>i?C.commits:[...le,...C.commits]),Un(C.hasMore)}catch(C){if(Kr.current!==y||jr(C))return;On(C instanceof Error?C.message:"Failed to load recent commits"),i&&Ke([]),Un(!1)}finally{gr.current===k&&(gr.current=null),Kr.current===y&&(Pr(!1),Ns(!1))}},[Ne,fn,et,v]);a.useEffect(()=>{Gr&&Os({reset:!0})},[fn,Os,Gr,de?.ahead,de?.behind,de?.upstream]);const sm=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Os({reset:!1})},[Os]);a.useEffect(()=>{!Ne||!M?.available||!dt||!nr||Pn||xn||et||xi(Ne)},[Ne,M?.available,Pn,xn,dt,nr,xi,et]);const ed=r&&($t||dt);a.useEffect(()=>{!ed||!v||vr()},[ed,vr,v]),a.useEffect(()=>{!r||!dt||!nr||!Cs||!v||Fa(null)},[Cs,dt,nr,r,Fa,v]);const am=a.useMemo(()=>{if(!ce)return 0;const t=$e.findIndex(i=>i.root===ce);return t>=0?t+1:0},[ce,$e]),td=a.useCallback(t=>{if(!t)return null;const i=Array.from(Fe.values()).filter(u=>xt(u,v)===t).sort((u,w)=>u.path.localeCompare(w.path))[0];return i?Sr(i):null},[Fe,v]),An=$e.length>1,qa=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Fe.size,branch:null,deferred:!1},...$e.map(t=>({root:t.root,label:t.label,count:t.deferred?Bs.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Bs.has(t.root)}))],[Fe.size,$e,Bs,o]),rd=qa[am]??qa[0],Va=!!ce,nd=a.useMemo(()=>_f($e,fe),[$e,fe]);a.useEffect(()=>{gi.current===v&&ce&&!nd.has(ce)&&Te(null),_n(t=>t.filter(i=>$e.some(u=>u.root===i)))},[ce,$e,nd,v,Te]),a.useEffect(()=>{ce&&Ka(it.get(ce))},[ce,Ka,it]);const om=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]),sd=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]),ad=sd.length>1,im=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("/"),C=k>=0?y.slice(0,k):null,le=k>=0?y.slice(k+1):y;(!w||C===w)&&u(le,"remote")}return t},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,o]),Yt=a.useMemo(()=>Ht.map(t=>{const i=it.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Ht,it]);a.useEffect(()=>{Yt.length!==0&&(ya(t=>{let i=!1;const u={...t},w=new Set(Yt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Yt)!u[y.root]&&y.branch&&(u[y.root]=y.branch,i=!0);return i?u:t}),wa(t=>{let i=!1;const u={...t},w=new Set(Yt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Yt){const k=it.get(y.root)?.context;if(u[y.root]&&Bf(u[y.root],k?.branch)&&(delete u[y.root],i=!0),u[y.root])continue;const C=Iu(k);C&&(u[y.root]=C,i=!0)}return i?u:t}))},[Yt,it]);const Ya=a.useMemo(()=>{const t=new Set(Yt.map(i=>i.root));return va.filter(i=>t.has(i))},[va,Yt]),Xa=Ya.length===0,wr=a.useMemo(()=>Xa?Yt:Yt.filter(t=>Ya.includes(t.root)),[Yt,Ya,Xa]),Us=a.useMemo(()=>wr.filter(t=>!!Et[t.root]?.trim()),[Et,wr]),os=a.useCallback((t,i)=>{const u=it.get(t)?.context?.branch;return!!(u&&i&&i.replace(/^refs\/heads\//,"")===u)},[it]),od=a.useMemo(()=>wr.filter(t=>!Et[t.root]?.trim()),[Et,wr]),id=a.useCallback(async t=>{if(!t||fi.current.has(t))return;const i=it.get(t)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=v;fi.current.add(t),Ql(w=>new Set(w).add(t));try{const w=await Gd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!w.available||!Pe(u))return;Ee(y=>y.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...w},error:void 0}:k)),ya(y=>y[t]||!w.branch?y:{...y,[t]:w.branch}),wa(y=>{if(y[t])return y;const k=Iu(w);return k?{...y,[t]:k}:y})}catch(w){jr(w)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,w)}finally{fi.current.delete(t),Ql(w=>{const y=new Set(w);return y.delete(t),y})}},[it,Pe,v]);a.useEffect(()=>{if(Wo)for(const t of wr)id(t.root)},[Wo,wr,id]),a.useEffect(()=>{!Mi||!de||(Na(de.branch||(de.branches?.[0]??"")),Ca(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),Ea(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Mi]);const ld=a.useMemo(()=>{if(et)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Pn||xn)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,Pn,xn,et,o]),lm=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]),$i=a.useCallback(()=>{Ie(null),L?.()},[L]);function cd(){if(!An)return null;const t=rd?.label??o("rightSidebar.allRepositories"),i=rd?.count??Fe.size,u=kt(t)||t;return e.jsxs("button",{type:"button",onClick:lm,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(kr,{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(ca,{size:12,className:"shrink-0"})]})}function cm(){if(!b||!An||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(Je?.x??t-368,t-352)),w=Math.max(12,Math.min(Je?.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:$i,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:C=>C.stopPropagation(),children:[e.jsxs("div",{className:se?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:se?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!se&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:qa.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Fe.size})]})]}),e.jsx("button",{type:"button",onClick:$i,className:se?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:se?16:14})})]}),e.jsx("div",{className:se?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:qa.map(C=>{const le=(C.root??null)===ce,ae=kt(C.label)||C.label;return e.jsxs("button",{type:"button",onClick:()=>{Md(C.root),$i()},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"} ${le?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:C.label,role:"option","aria-selected":le,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${le?"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 ${le?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(kr,{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:ae}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:C.root===null?o("rightSidebar.allRepositories"):C.label})]}),C.branch&&e.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:C.branch}),C.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${C.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:C.count})]},C.root??"all")})})]})});return Rf(k,se,document.body)}function dm(){return cm()}function dd(t){const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=jo(u,i??v);return{key:Sr(t),path:t.path,absolutePath:u,displayName:w.name,displayDir:w.dir,oldPath:t.oldPath,status:t.status,title:u}}function ud(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 Ja(t,i){const u=Tn(t,v),w=`path:${u}`,y=De===w,k=Re===w,C=y||k;return e.jsx("button",{type:"button",onClick:le=>{le.stopPropagation(),Ot(u,w)},...ji(Ua(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 ${C?"max-w-20 px-2":"max-w-20 px-2 md:max-w-0 md:px-0 md:opacity-0 md:group-hover:max-w-20 md:group-hover:px-2 md:group-hover:opacity-100"} ${C?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function fd(t){const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=_m(t),y=cl(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(s0,{actions:w,running:qe,completed:Hn?.path===y?Hn:null}),Ja(u,o("rightSidebar.insertThisFile"))]})}function hd(t,i){const u=i.root??v;if(!u)return null;const w=Tn(t,u);return Ja(w,o("fileTree.insertRefTitle"))}function Hs(){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:()=>Sd("unified"),"aria-pressed":Mr==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mr==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Sd("split"),"aria-pressed":Mr==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mr==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function md(){return zs.map(t=>{const i=zu(t.files.map(([,k])=>k)),u=Rl({activeGitRepoRoot:ce,groupCount:zs.length,label:t.label,rootName:st}),w=!!(u&&t.root&&Xe.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])=>dd(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:()=>Em(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(ca,{size:13})}),e.jsx(kr,{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(),so("stage-all",t.root,t.label)},disabled:!!qe,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(),so("stash-all",t.root,t.label)},disabled:!!qe,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 Ln=a.useMemo(()=>new Map(Array.from(Fe.values(),t=>[Sr(t),t])),[Fe]);function pd(t){const i=Ln.get(t.key),u=i?xt(i,v):null,w=Cg(St,u,i?.path??t.path);return e.jsx(yl,{changeStatus:t.status,auditStatus:w,renderChangeBadge:y=>e.jsx(aa,{status:y})})}const Qa=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 le of i){const ae=le.getBoundingClientRect();if(ae.bottom<w)continue;const xe=Math.abs(ae.top-w);xe<k&&(y=le,k=xe)}const C=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return C?(Ia.current===C&&V.getState().selectedFilePath===C||(Ia.current=C,ot(C)),C):null},[se,ot]),um=!!(!qe&&Ne&&!et&&(de?.upstream||vn.trim()&&yn.trim())),fm=!!(!qe&&Ne&&!et&&(de?.upstream||vn.trim()&&yn.trim())),hm=!!(!qe&&Ne&&!et&&Wn.trim()&&Wn.trim()!==de?.branch),Xt=a.useMemo(()=>{const t=Ye.trim().toLowerCase(),i=Array.from(Fe.entries()).filter(([,u])=>!ce||xt(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,Ye,v]);a.useEffect(()=>{ea("selected_file_state",{selectedFilePath:at,selectedChangedFilePath:Vt?.path??null,selectedChangedFileAbsolutePath:Vt?.absolutePath??null,selectedChangedFileRepoRoot:Vt?.repoRoot??null,rootPath:v,activeGitRepoRoot:ce,rightTab:ai,effectiveRightTab:Mt,diffPaneActive:$t,changedFiles:Fe.size,filteredChangedFiles:Xt.length,gitBundleLoading:br,gitBundleLastLoadedAt:Vn})},[ce,Fe.size,$t,Mt,Xt.length,Vn,br,ai,v,Vt?.absolutePath,Vt?.path,Vt?.repoRoot,at]);const zs=a.useMemo(()=>{const t=new Map;for(const i of Xt){const[,u]=i,w=xt(u,v),y=r0(u)||st,k=w??y,C=w?it.get(w):void 0,le=t.get(k)??{root:w,label:y,branch:C?.context?.branch,files:[]};le.files.push(i),t.set(k,le)}return Array.from(t.values()).sort((i,u)=>i.label===st?-1:u.label===st?1:i.label.localeCompare(u.label))},[Xt,it,st,v]),Ws=a.useMemo(()=>{const t=[],i=new Map;for(const u of Xt)i.set(Sr(u[1]),u);for(const u of zs){if(!!(u.root&&Rl({activeGitRepoRoot:ce,groupCount:zs.length,label:u.label,rootName:st})&&Xe.has(u.root)))continue;if(zr!=="tree"){t.push(...u.files);continue}const y=u.files.map(([,k])=>dd(k));for(const k of Hp(y)){const C=i.get(k.key);C&&t.push(C)}}return t},[ce,Xe,zr,zs,Xt,st]),gd=a.useMemo(()=>Fe.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ws.map(([,t])=>{const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:Sr(t),path:t.path,absolutePath:u,status:t.status,repoRoot:i,displayName:jo(u,i).name,displayDir:jo(u,i).dir,auditRecords:St}}),[St,Fe.size,Ws,v,o]);a.useEffect(()=>{if(!$t||Ws.length===0||se)return;const t=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&Qa(u))return;const w=document.querySelector("[data-diff-stream-item]"),y=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;if(y){Ia.current=y,ot(y);return}const k=Ws[0]?.[1];if(!k)return;const C=Sr(k);Ia.current=C,ot(C)};for(const u of[80,240,600,1200])t.push(window.setTimeout(i,u));return()=>t.forEach(u=>window.clearTimeout(u))},[$t,se,Ws,ot,Qa]);const Pi=a.useMemo(()=>{const t=C=>`'${C.replace(/'/g,"'\\''")}'`,i=ar.length>0?Rn:fe.filter(C=>C.files.length>0),u=i.length>0?i:v?[{root:v,relativeRoot:".",name:st}]:[],w=u.length>0?u.map(C=>`- ${C.relativeRoot==="."?".":C.relativeRoot} (${C.root})`).join(`
|
|
1666
|
+
`):`- ${v?".":""}`,y=u.length>0?u.map(C=>` td audit-export ${t(C.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
|
+
`)},[ar.length,Rn,fe,st,v]),mm=a.useCallback((t="generate")=>{if(An&&Zt.length===0&&!ce){sn(!0);return}const i=t==="generate"?Pi:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Pi].join(`
|
|
1669
|
+
`);ut("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:ar,mode:t,hasAuditListCommand:i.includes("td audit-list"),promptLength:i.length}),Fr(o("rightSidebar.insertChangeAuditPrompt"),i,`${Wc}:${t}`),vr(),c||l()},[ce,Pi,Zt.length,ar,Fr,vr,l,c,v,An,o]),Za=a.useCallback(async t=>{try{await qd({ids:[t]}),rn(i=>i.filter(u=>u.id!==t))}catch{vr()}},[vr]),pm=a.useCallback(async()=>{if(St.length===0)return;const t=St.map(i=>i.id);try{await qd({ids:t}),rn(i=>i.filter(u=>!t.includes(u.id))),Qt(null)}catch(i){const u=i instanceof Error?i.message:"Failed to clear change audit explanations";Qt(o("rightSidebar.changeAuditClearFailed",{message:u})),vr()}},[St,vr,o]),gm=a.useCallback(async t=>{if(t.records.length===0)return;const i=t.records.map(u=>u.id);try{await fp({ids:i}),an(u=>u.filter(w=>!i.includes(w.id))),Qe===t.key&&(pn(null),mr(!1))}catch(u){Gt(o("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),Fa(null)}},[Fa,Qe,o]),bm=a.useCallback(t=>{_n(i=>t===null?(sn(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),xm=a.useCallback(t=>{Ko(i=>t===null?(Go(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),Ai=a.useMemo(()=>{if(!nr)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=fr.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?fr.filter(i=>Lu(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,fr,os,nr,Qe]),Li=fr.length>0,is=a.useMemo(()=>{if(!nr)return[];const t=new Map;for(const i of fr){const u=i.repoRoot,w=it.get(u),y=w?.relativeRoot==="."?st:w?.relativeRoot||w?.name||kt(u),k=Lu(i),C=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};C.records.push(i),C.latestInjectedAt=Math.max(C.latestInjectedAt,i.injectedAt??0),t.set(k,C)}return Array.from(t.values()).sort((i,u)=>u.latestInjectedAt-i.latestInjectedAt)},[fr,it,nr,st]),Ti=a.useMemo(()=>Qe?is.find(t=>t.key===Qe)??null:null,[is,Qe]),Gs=ve?{repoRoot:ve.repoRoot??"",repoLabel:ve.repoRoot?it.get(ve.repoRoot)?.relativeRoot==="."?st:it.get(ve.repoRoot)?.relativeRoot||it.get(ve.repoRoot)?.name||kt(ve.repoRoot):st,baseRef:ve.baseRef??ve.baseBranch??"",branchName:ve.currentBranch??null,headRef:ve.headRef??null,diffFingerprint:ve.diffFingerprint??null}:Ti,vm=a.useMemo(()=>(ze?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,repoRoot:ze?.repoRoot,hunk:t,current:null,stale:null})),[ze?.hunks,ze?.repoRoot]),ym=a.useMemo(()=>{if(ve)return[];const t=Ti;return t?on.filter(i=>i.repoRoot===t.repoRoot&&i.baseRef===t.baseRef&&(i.branchName??null)===t.branchName&&(!t.diffFingerprint||i.diffFingerprint===t.diffFingerprint)):[]},[ve,on,Ti]),wm=a.useCallback(t=>{const i=Ai.find(u=>u.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${u.hunk.filePath}`===t.filePath:!1));i&&(gn(i.key),window.setTimeout(()=>In(t),90),window.setTimeout(()=>In(t),320),window.setTimeout(()=>In(t),760))},[Ai]),Ii=a.useMemo(()=>{const t=y=>`'${y.replace(/'/g,"'\\''")}'`,i=Us,u=i.length>0?i.map(y=>`- ${y.label} (${y.root}),目标分支:${rr[y.root]||y.branch||"(current branch)"},基线分支:${Et[y.root]||"(not set)"},包含本地未提交更改:${os(y.root,rr[y.root]||y.branch)&&(mn[y.root]??!0)?"是":"否"}`).join(`
|
|
1671
|
+
`):`- ${v?".":""}`,w=i.length>0?i.map(y=>{const k=rr[y.root]||y.branch||"",C=Et[y.root]||"",le=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(C)} ${t(y.root)} > ~/.termdock/branch-audit/branch-audit-export-${le}.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
|
+
`)},[mn,os,Us,Et,rr,v]),km=a.useCallback((t="generate")=>{const i=t==="generate"?Ii:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ii].join(`
|
|
1675
|
+
`);Fr(o("rightSidebar.branchAuditShort"),i,`context:branch-audit-scope:${t}`),c||l()},[Ii,Fr,l,c,o]),Di=a.useCallback(async(t={})=>{const i=t.refresh===!0,u=i&&ve?.comparisonRepos?ve.comparisonRepos:Us.map(C=>{const le=(rr[C.root]||C.branch||"").trim();return{repoRoot:C.root,label:C.label,base:Et[C.root]?.trim()??"",head:le||null,includeUncommitted:mn[C.root]??!0}});if(!v||u.length===0)return;const w=++It.current,y=v,k=()=>Pe(y)&&w===It.current;ke(!0),_e(null),i||(er(null),Ge(null));try{const C=await Promise.all(u.map(async ee=>{if(!ee.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:ee.label}));return Vd({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 le=C.find(ee=>!ee.available);if(le){_e(le.error??"Branch diff is unavailable");return}const ae=C.length===1?C[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:C.map(ee=>ee.baseRef??ee.baseBranch).filter(Boolean).join(", "),currentBranch:C.map(ee=>ee.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:C.map(ee=>ee.headRef).filter(Boolean).join(", "),diffFingerprint:C.map(ee=>ee.diffFingerprint).filter(Boolean).join("+"),stat:C.map(ee=>ee.stat).filter(Boolean).join(`
|
|
1676
|
+
`),files:C.flatMap((ee,X)=>{const me=u[X];return(ee.files??[]).map(Le=>`${me?.label??ee.repoRoot??"repo"}/${Le}`)}),hunks:C.flatMap((ee,X)=>{const Le=u[X]?.label??ee.repoRoot??"repo";return(ee.hunks??[]).map(Ve=>({...Ve,filePath:`${Le}/${Ve.filePath}`,oldPath:Ve.oldPath?`${Le}/${Ve.oldPath}`:Ve.oldPath,newPath:Ve.newPath?`${Le}/${Ve.newPath}`:Ve.newPath}))}),commits:C.flatMap(ee=>ee.commits??[]),commitCount:C.reduce((ee,X)=>ee+(X.commitCount??X.commits?.length??0),0),diff:C.map(ee=>ee.diff).filter(Boolean).join(`
|
|
1677
|
+
`),truncated:C.some(ee=>ee.truncated)};if(ae.comparisonRepos=u.map((ee,X)=>({...ee,head:ee.head??C[X].currentBranch??null,includeUncommitted:C[X].includeUncommitted===!0,canIncludeUncommitted:C[X].canIncludeUncommitted})),ae.canIncludeUncommitted=C.every(ee=>ee.canIncludeUncommitted===!0),ae.includeUncommitted=C.some(ee=>ee.includeUncommitted===!0),qo(ee=>({...ee,...Object.fromEntries(ae.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(ae.hunks??[]).length===0){_e(o("rightSidebar.branchAuditDiffEmpty"));return}const xe=Date.now(),Ae=(i?Qe:null)??["preview",ae.repoRoot??v,ae.baseRef??ae.baseBranch??"",ae.currentBranch??"",ae.headRef??"",ae.diffFingerprint??xe].join("\0"),Ze=u.length===1?u[0].label:`${u.length} repos`;er(ae),Bn(ee=>[{key:Ae,diff:ae,repoLabel:Ze,createdAt:xe},...ee.filter(X=>X.key!==Ae)].slice(0,8)),i||dn(ee=>ee[Ae]===void 0?ee:{...ee,[Ae]:0}),pn(Ae),gn(ee=>{const X=ae.hunks?.[0],me=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&ee&&(ae.hunks??[]).some(Le=>Le.filePath===ee.split("\0")[0])?ee:me}),mr(!0)}catch(C){if(!k()||jr(C))return;_e(C instanceof Error?C.message:"Failed to load branch diff")}finally{k()&&ke(!1)}},[mn,ve,Qe,Us,Et,rr,Pe,v,o]),Sm=a.useCallback(t=>{++It.current,ke(!1),er(t.diff),_e(null),pn(t.key),gn(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),mr(!0)},[]),jm=a.useCallback(t=>{Bn(i=>i.filter(u=>u.key!==t)),dn(i=>{if(!(t in i))return i;const u={...i};return delete u[t],u}),Qe===t&&(pn(null),er(null),mr(!1))},[Qe]),Rm=a.useCallback(t=>{++It.current,ke(!1);const i=is.find(u=>u.key===t);i&&(er(null),_e(null),pn(t),gn(i.records[0]?.filePath??null),mr(!0))},[is]),Nm=a.useCallback(async t=>{if(!v||!Ne)return;const[i]=t.split(/\s+/);if(i){vt(i),tr(null),Ge(null);try{const u=await hp({cwd:v,repoRoot:Ne,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){tr(u.error??"Commit diff is unavailable");return}Ge(u);const w=u.hunks?.[0];xa(w?`${w.filePath}\0${w.hunkHeader}\0${w.hunkIndex}`:null)}catch(u){tr(u instanceof Error?u.message:"Failed to load commit diff")}finally{vt(null)}}},[Ne,v]),Cm=a.useCallback(t=>{if(!ve||!Qe)return;const i=Math.max(0,Math.round(t));dn(u=>Math.abs((u[Qe]??0)-i)<24?u:{...u,[Qe]:i})},[ve,Qe]);a.useEffect(()=>{!ve||!Qe||Bn(t=>t.map(i=>i.key===Qe&&i.diff!==ve?{...i,diff:ve}:i))},[ve,Qe]);const bd=!!ve;a.useEffect(()=>{if(!se||!hr||!bd)return;const t=Mc.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)},[hr,bd,se]);const xd=a.useCallback(t=>{t&&Th(i=>zp(i,t))},[]),vd=Ma.key===at?Ma.key:null,eo=a.useCallback(t=>{const i=V.getState(),u=p0();ea("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}),ot(t),Dt("diff"),se&&t&&Ac(1),xd(t),queueMicrotask(()=>{const w=V.getState();ea("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,xd,ot,Dt,Ac]),yd=a.useCallback(t=>{const i=Array.from(Fe.values()).find(u=>{const w=xt(u,v),y=Sr(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){eo(Sr(i)),window.setTimeout(()=>In(t),90),window.setTimeout(()=>In(t),320),window.setTimeout(()=>In(t),760);return}In(t)},[Fe,v,eo]),wd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:u}={})=>vs.length>0?e.jsx(lf,{walkthroughs:vs,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:w=>{se&&window.requestAnimationFrame(()=>t?.()),yd(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(da,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[ce,vs,yd,se,o]),Em=a.useCallback(t=>{t&&dr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),rl(Qi,u),u})},[]),kd=a.useCallback(t=>{Hr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),rl(Su,u),u})},[]),to=a.useCallback(t=>{Er(t),At(Cf,t)},[]);a.useEffect(()=>{Va||zr!=="ai"||to("tree")},[zr,to,Va]);const ro=a.useCallback(()=>{ga(t=>{const i=!t;return At(Ef,i),i})},[]),Sd=a.useCallback(t=>{bs(t),At(Mf,t)},[]),{whitespace:jd,context:Rd}=Gp(),Nd=a.useMemo(()=>({algorithm:"histogram",whitespace:jd,context:Rd}),[jd,Rd]),Cd=a.useCallback(t=>{pe(t),At($f,t)},[]),no=a.useCallback(async(t,i,u,w)=>{let y=t;for(;y.ok&&y.status==="running";)await new Promise(C=>window.setTimeout(C,1500)),y=await Yd({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(C=>C?.action===k.action&&C.path===k.path?null:C),1400),y},[]),wt=a.useCallback(async(t,i,u)=>{const w=v;v&&xr.current.delete(v),Gt(null),$s(null),Ms({action:t.action,path:u});try{const y=await mp({...t,includeNested:Xs(v)}),k=await no(y,t,i,u);if(!Pe(w))return!1;const C=v?await Gi(v,void 0,{includeNested:Xs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(v)}).catch(()=>k.bundle):k.bundle;return Pe(w)?(C&&Zn(C,{reloadDiff:!0,cacheOnly:!0}),bn(null),!0):!1}catch(y){return $s(null),Gt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Pe(w)&&Ms(null)}},[Zn,Pe,v,o,no]),Ed=a.useCallback(async t=>{const i=v;await Xd({...t,includeNested:Xs(v)}),Pe(i)&&_t(v??void 0,{refresh:!0,background:!0})},[Pe,_t,v]),Mm=a.useCallback(async t=>{const i=ve,u=It.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"));K(k=>k+1),_e(null);try{await Xd(t)}catch(k){throw K(C=>C-1),k}if(u!==It.current||!Pe(v)){K(k=>k-1);return}const y=k=>{er(C=>{if(!C||u!==It.current)return C;const le=C.hunks??[],ae=k===void 0?le.filter(Ae=>!(Ae.previewRevert?.cwd===t.cwd&&Ae.previewRevert.patch===t.patch)):[...le.filter(Ae=>Ae.filePath!==w.filePath),...k];return{...C,hunks:ae}})};y(),Vd({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!==It.current||!Pe(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const C=t.path.slice(t.cwd.length+1),le=w.filePath.slice(0,w.filePath.length-C.length);y((k.hunks??[]).map(ae=>({...ae,filePath:`${le}${ae.filePath}`,oldPath:ae.oldPath?`${le}${ae.oldPath}`:ae.oldPath,newPath:ae.newPath?`${le}${ae.newPath}`:ae.newPath})))}).catch(k=>{u===It.current&&Pe(v)&&!jr(k)&&_e(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>K(k=>k-1))},[ve,Pe,v,o]),so=a.useCallback((t,i,u)=>{if(i){if(t==="stage-all"){wt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}bn({kind:"stash-all",repoRoot:i,repoLabel:u})}},[wt,o]),Md=a.useCallback(t=>{Te(t),Na(""),Ca(""),Ea(""),ot(td(t)),dt||Dt("diff"),t&&Ka(it.get(t))},[Ka,td,dt,it,ot,Te,Dt]),$d=a.useCallback(t=>{const i=new Set([...qt.current.keys(),...Sn.current,...xr.current]);for(const u of i)u!==t&&(Kt.current.delete(u),qt.current.get(u)?.abort(),qt.current.delete(u),Rt(`right-sidebar-git-untracked:${u}`),Sn.current.delete(u),xr.current.delete(u))},[]),$m=a.useCallback(async t=>{const i=v;if(!i||(await V.getState().setNestedGitScanRoot(i,t),!Pe(i)))return;if(t){await _t(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}$d(i),Na(""),Ca(""),Ea(""),Ko(w=>w.filter(y=>y===i));const u=Vt;u&&xt(u,i)!==i&&ot(null),await _t(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[$d,Pe,_t,v,ot,Vt]),Pm=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Wn.trim();!t||t===de?.branch||await wt({action:"switch-branch",cwd:Ne,branch:t},o("rightSidebar.switchBranch"))},[de?.branch,Ne,et,wt,Wn,o]),Pd=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Ra.trim();if(!t)return;await wt({action:"commit",cwd:Ne,message:t},o("rightSidebar.commitChanges"))&&ac("")},[Ne,Ra,et,wt,o]),Am=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=vn.trim(),i=yn.trim();await wt({action:"push",cwd:Ne,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Ne,yn,vn,et,wt,o]),Lm=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=vn.trim(),i=yn.trim();await wt({action:"pull",cwd:Ne,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Ne,yn,vn,et,wt,o]);a.useEffect(()=>{if(!dt||!Ne||qe)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 Yd({cwd:Ne,action:u}).catch(()=>null);if(!w?.ok||w.status!=="running")continue;const y={action:u,cwd:Ne},k=i[u]??u;Ms({action:u});try{const C=await no(w,y,k);if(t||!Pe(v))return;const le=v?await Gi(v,void 0,{includeNested:Xs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(v)}).catch(()=>C.bundle):C.bundle;le&&Zn(le,{reloadDiff:!0,cacheOnly:!0})}catch(C){t||Gt(o("rightSidebar.gitActionFailed",{message:C instanceof Error?C.message:"Unknown error"}))}finally{t||Ms(null)}return}})(),()=>{t=!0}},[Ne,Zn,dt,Pe,v,qe,o,no]);const Fi=Hn?.action==="commit",_i=Hn?.action==="switch-branch",Bi=Hn?.action==="pull",Oi=Hn?.action==="push",ao=dt||Ah,Ui=Xa?o("rightSidebar.changeAuditScopeAll"):wr.length===1?wr[0].label:`${wr.length} repos`,Tm=wr.length>0,Ad=Us.length>0,Im=v?e.jsx(Ou,{open:Wo,onOpenChange:Go,showScopePicker:!0,selectedAll:Xa,repos:Yt,selectedRoots:Ya,onToggleRepo:xm,onGenerate:()=>km(Li?"regenerate":"generate"),disabled:!Tm,generateDisabled:!Ad,inserted:De?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ui,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Di()},secondaryDisabled:!Ad||ge,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:ge,loading:Jl.size>0,statusTitle:Jl.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:od.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:od.map(t=>t.label).join(_==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=it.get(t.root),u=os(t.root,rr[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(rr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const xe of i?.context?.branches??[])k(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const xe of i?.context?.remoteBranches??[])k(xe,o("rightSidebar.remoteBranch"));const C=[],le=new Set,ae=(xe,Ae)=>{!xe||le.has(xe)||(le.add(xe),C.push({value:xe,label:xe,meta:Ae}))};ae(Et[t.root],Et[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),ae(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const xe of i?.context?.remoteBranches??[])ae(xe,"remote");for(const xe of i?.context?.branches??[])ae(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:rr[t.root]||i?.context?.branch||"",options:w,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:xe=>{ya(Ae=>({...Ae,[t.root]:xe}))}}),e.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:C,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:xe=>{wa(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&&(mn[t.root]??!0),disabled:!u,onChange:xe=>qo(Ae=>({...Ae,[t.root]:xe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Ld=Zs(St.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),_),Dm=()=>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:()=>Xl(t=>{const i=!t;return At(Zi,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(da,{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:Ui})]}),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"),": ",Ui]}),Im]}),nt&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:nt}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[cn.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:()=>Sm(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")})]}),Zs(t.createdAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Zs(t.createdAt,_)})]}),e.jsx("button",{type:"button",onClick:()=>jm(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(yo,{size:12})})]},t.key)),is.length>0?is.slice(0,Math.max(0,8-cn.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:()=>Rm(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})]}),Zs(t.latestInjectedAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Zs(t.latestInjectedAt,_)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{gm(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(yo,{size:12})})]},t.key)):cn.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,Fm=()=>nr&&v&&Pn?e.jsxs("div",{className:ao?"overflow-visible":"overflow-hidden",children:[Dm(),e.jsxs("button",{type:"button",onClick:()=>{dt||Lh(t=>{const i=!t;return i&&Ne&&!Pn&&!xn&&xi(Ne),i})},"aria-expanded":ao,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${dt?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(kr,{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 ${$n.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[xn&&e.jsx(ft,{size:10,className:"animate-spin"}),$n.staged>0?o("rightSidebar.stagedCount",{count:$n.staged}):o("rightSidebar.noStagedChangesShort")]}),!dt&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${ao?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),ao&&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:nm})]})}),e.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:Ne??"",options:Ht,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!qe,onChange:t=>{Md(t||null)}}),et&&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:Wn!==Zc?Zc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Pm()},disabled:!hm,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 ${_i?"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:qe?.action==="switch-branch"||_i?"opacity-0":"",children:o("rightSidebar.switchBranch")}),qe?.action==="switch-branch"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),_i&&qe?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:Wn,options:om,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!qe,onChange:Na})]}),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:et?o("rightSidebar.selectRepositoryForGitActions"):$n.staged>0?o("rightSidebar.commitReadyHint",{count:$n.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Pd()},disabled:!!qe||et||$n.staged===0||!Ra.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 ${Fi?"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:et?o("rightSidebar.selectRepositoryForGitActions"):$n.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:qe?.action==="commit"||Fi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),qe?.action==="commit"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Fi&&qe?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ra,onChange:t=>ac(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Pd())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!qe,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:()=>js(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":Gr,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:[Wt&&e.jsx(ft,{size:12,className:"animate-spin text-muted-foreground"}),e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Gr?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),Gr&&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:Rs,onChange:t=>pr(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}),Rs&&e.jsx("button",{type:"button",onClick:()=>pr(""),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:sm,children:[re.length>0?re.map(t=>{const[i,...u]=t.split(/\s+/),w=u.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Nm(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}),hn[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${hn[i]==="ahead"?"bg-accent/10 text-accent":hn[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(hn[i]==="ahead"?"rightSidebar.commitAhead":hn[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),bt===i&&e.jsx(ft,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Wt?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):Ho?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),ba&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(ft,{size:12,className:"animate-spin"})}),zo&&!ba&&re.length>0&&e.jsx("button",{type:"button",onClick:()=>{Os({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")})]})]}),un&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:un}),Ho&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ho})]}),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:()=>{Lm()},disabled:!um,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 ${Bi?"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:qe?.action==="pull"||Bi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),qe?.action==="pull"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Bi&&qe?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Am()},disabled:!fm,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 ${Oi?"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:qe?.action==="push"||Oi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),qe?.action==="push"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Oi&&qe?.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] ${ld.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:ld.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 ${ad?"grid-cols-2":"grid-cols-1"}`,children:[ad&&e.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:vn,options:sd,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!qe,onChange:Ca}),e.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:yn,options:im,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!qe,onChange:Ea})]})]})]})]}):null,_m=a.useCallback(t=>{const i=xt(t,v);if(!i)return[];const u=cl(t),w=[];return t.canStage&&w.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{wt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),u)}}),t.canUnstage&&w.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{wt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),u)}}),t.canStash&&w.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{wt({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:()=>bn({kind:"restore",file:t,phrase:""})}),w},[v,wt,o]),Bm=a.useCallback(()=>{if(f){h?.();return}Lr(0),Ir.current?.slideTo(0),Ar(!1),Ct(null)},[h,f]),Td=a.useCallback(t=>{if(Y(""),Ft(t),ot(null),Ct(null),R(null),se){f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1);return}},[se,h,f,ot,Ft]);a.useEffect(()=>{if(!U||V.getState().pendingTerminalPath!==U)return;V.setState({pendingTerminalPath:null}),(()=>{const i=U,u=i.path;if(!u.startsWith("/"))return;Y(""),Ct(null),tn(null);const w=!!(v&&(u===v||u.startsWith(`${v}/`)));if(i.kind==="file"){const y=vo(u);Is(u),typeof i.line=="number"&&Number.isSafeInteger(i.line)&&i.line>0&&tn(i.line),Ft(w?null:y),R({path:u,nonce:++z.current});return}ot(null),w?(Ft(null),R({path:u,nonce:++z.current})):(R(null),Ft(u)),se&&(f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1))})()},[U,Is,se,h,f,v,ot,Ft]),a.useEffect(()=>{r||(zt(!1),Jt(!1))},[r]),a.useEffect(()=>{if(!lr&&!Cr)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(pa.current?.contains(i.target)||Fn.current?.contains(i.target))||(zt(!1),Jt(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[Cr,lr]);const Id=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:em,disabled:!Wa,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(Il,{size:14})}),e.jsx("button",{type:"button",onClick:Gc,disabled:!v||Kn===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(ru,{size:14})}),e.jsx("button",{type:"button",onClick:tm,disabled:!ie,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:oc?o("rightSidebar.fileWatchUnavailable",{message:oc}):o("rightSidebar.refreshFiles"),children:e.jsx(wo,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:ie??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:Qh}),La==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(nu,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>ie&&Ot(ie,Ut??void 0),disabled:!ie,...ie&&Ut?ji(Ua(ie),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||Re===Ut)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ut&&Re===Ut?"rightSidebar.copied":Ut&&De===Ut?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ut&&(De===Ut||Re===Ut)?e.jsx(Co,{size:13}):e.jsx(Eo,{size:13})}),e.jsx(kg,{rootPath:ie,disabled:!ie||!Fh||di,pressed:Aa,saving:di,onToggle:()=>{if(!ie||di)return;const t=ie;Sc(!0),ui(null),_h(t,!Aa).catch(()=>{const i=V.getState();(i.explorerRoot??i.rootPath)===t&&ui(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>Sc(!1))}}),e.jsxs("div",{ref:Fn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),Jt(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${Cr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":Cr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(No,{size:14})}),Cr&&e.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Jt(!1),rm()},disabled:!Ci,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${_s?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[_s?e.jsx(qi,{size:14}):e.jsx(lo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(_s?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Jt(!1),Ih()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${oi?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[oi?e.jsx(Yp,{size:14}):e.jsx(xl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(oi?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!ie,onClick:()=>{ie&&(Jt(!1),Dh(ie,La==="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:[La==="modified"?e.jsx(Ap,{size:14}):e.jsx(nu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(La==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),jc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:jc}),v&&(Ga.length>0||Zh)&&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:Gc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${ie===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(ru,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:st})]}),Ga.map(t=>{const i=t.path,u=t.kind==="file",w=u?at===i:ie===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):Ft(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(vl,{size:10,className:"shrink-0"}):e.jsx(lo,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:kt(i)})]}),e.jsx("button",{type:"button",onClick:()=>wn(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:kt(i)}),title:o("rightSidebar.unpinFolder",{name:kt(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"})]}),Hi=a.useMemo(()=>{if(zn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((ei-zn)/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)},[ei,zn]),oo="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",Dd=v&&!ts?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{$m(!ii)},"aria-checked":ii,title:o("rightSidebar.multiRepoScanTitle"),className:oo,children:[e.jsx(kr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),ii&&e.jsx(Co,{size:14,className:"shrink-0 text-primary"})]}):null,Fd=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Hi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Hi}),children:Hi}):null,e.jsx("button",{type:"button",onClick:()=>{es()},disabled:br,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(wo,{size:13,className:br?"animate-spin":""})})]}):null,Om=Pc?o("rightSidebar.changeAuditScopeAll"):Rn.length===1?Rn[0].relativeRoot==="."?st:Rn[0].relativeRoot||Rn[0].name:`${Rn.length} repos`,Um=t=>v?e.jsxs("div",{role:"none",children:[e.jsx(Ou,{menuItem:!0,open:ks,onOpenChange:i=>{sn(i),i&&t()},showScopePicker:An,selectedAll:Pc,repos:Bh,selectedRoots:ar,onToggleRepo:bm,onGenerate:()=>{t(),mm()},disabled:!v,inserted:De===Wc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Om,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:ws,error:!!nn,statusTitle:nn??(ws?o("rightSidebar.changeAuditLoading"):St.length>0?`${o("rightSidebar.changeAuditLoaded",{count:St.length})}${Ld?` · ${o("rightSidebar.changeAuditLoadedAt",{time:Ld})}`:""}`:void 0)}),St.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),pm()},disabled:ws||St.length===0,className:oo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(yo,{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:st}:null),_d=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(),so("stage-all",ls.root,ls.label)},disabled:!!qe,className:oo,children:[e.jsx(bp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),so("stash-all",ls.root,ls.label)},disabled:!!qe,className:oo,children:[e.jsx(Up,{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"}),Um(t),Dd&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Dd]}),io=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(kr,{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(Lp,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m,children:[ji.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Kh?"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:st}),(!se||Jo)&&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(kr,{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":We,onClick:()=>{Br(t=>!t),ne(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${We?"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(Tp,{size:14}),!We&&ct.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:dc,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:uc,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&Yh(i)}}),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(lo,{size:14})}),e.jsxs("div",{ref:pa,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Jt(!1),zt(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${lr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":lr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(No,{size:15})}),lr&&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":sr[t],onClick:()=>Vh(t,!sr[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(su,{size:14,className:"text-muted-foreground"}):e.jsx(Jd,{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 ${sr[t]?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${sr[t]?"left-3.5":"left-0.5"}`})})]},t)),e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qr,onClick:()=>Tc(!qr),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(Qd,{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 ${qr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${qr?"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),dc.current?.click()},disabled:_a,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:[_a?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Ip,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),uc.current?.click()},disabled:_a,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:[_a?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(tg,{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(lo,{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=W===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(oe==="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:()=>Cd("name"),"aria-pressed":oe==="name",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${oe==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Cd("content"),"aria-pressed":oe==="content",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${oe==="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(Dp,{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=>we(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:()=>we("."),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":be,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${be||As.length>0||Be||G||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(Fp,{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})]})]}),be&&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})})]}),oe==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Be,()=>Oe(t=>!t),qp,o("rightSidebar.matchCase")],[G,()=>je(t=>!t),ig,o("rightSidebar.matchWholeWord")],[ye,()=>Ue(t=>!t),ng,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(${(ts?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(qr)}, minmax(0, 1fr))`},children:[!ts&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>ss("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(kr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>ss("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(pf,{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=>ss("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(hl,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&e.jsxs("button",{type:"button",onClick:t=>ss("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] ${Nn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(su,{size:12}),o("architecture.tab")]}),sr.computer&&e.jsxs("button",{type:"button",onClick:t=>ss("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] ${ns?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Jd,{size:12}),o("rightSidebar.tabComputer")]}),qr&&e.jsxs("button",{type:"button",onClick:t=>ss("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(Qd,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),nc&&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:nc})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(ds,{active:dt,mounted:nr,fallback:e.jsx(ol,{slow:!1}),children:()=>ze?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(mu,{items:vm,diffViewType:ri,inlineMode:ur,viewControls:m?Hs():void 0,renderPathReference:(t,i)=>Ja(Tn(t,ze.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Rh,onSelect:xa,emptyText:o("rightSidebar.noChanges"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${ze.headRef??""}${ze.commits?.[0]?` · ${ze.commits[0]}`:""}`,onClose:()=>{Ge(null),xa(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:ro,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za})}):hr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(mu,{items:Ai,diffViewType:ri,inlineMode:ur,viewControls:m?Hs():void 0,renderPathReference:(t,i)=>{const u=ve?.comparisonRepos,w=u&&u.length>1?[...u].sort((k,C)=>C.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,y=w?t===w.label?w.repoRoot:Tn(t.slice(w.label.length+1),w.repoRoot):Tn(t,Gs?.repoRoot||v);return Ja(y,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Vo,onSelect:gn,emptyText:o(ve?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(ve?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Gs?`${Gs.repoLabel} · ${Gs.branchName??"HEAD"} → ${Gs.baseRef}`:void 0,onClose:()=>{++It.current,ke(!1),mr(!1),er(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:ro,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,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=>{Di({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:ve?.includeUncommitted?Mm:void 0,error:nt,actionsBusy:T>0,onRefresh:()=>{Di({refresh:!0})},refreshing:ge,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:ym,onWalkthroughNavigate:wm,initialDetailScrollTop:ve&&Qe?Ss[Qe]:void 0,onDetailScrollPositionChange:Cm,externalSwiperRef:se?Mc:void 0,onMobileSlideChange:se?Xo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&v&&Pn?e.jsx("div",{className:"px-3",children:Fm()}):br?e.jsx(ol,{slow:vc}):kn?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Gu(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(xo,{message:M.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{es()}}):v?e.jsx(ol,{slow:vc}):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:Ch||Dr,children:()=>se?e.jsxs(sf,{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(Yo,0)},onSlideChange:t=>{if(Lr(t.activeIndex),Ts.current===t.activeIndex){Ts.current=null;return}t.activeIndex===0&&(Ar(!1),Ct(null),h?.())},children:[e.jsx(ml,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Yn,onScroll:Ic,onDragOver:Ba,onDragEnter:Ba,onDragLeave:Fc,onDrop:_c,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[ic&&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()&&Id,e.jsx(au,{rootPath:ie??"",onFileSelect:Is,onPathReference:Ot,getReferenceText:Ua,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onDirectoryRoot:Kc,onSearchFromDirectory:qc,onDirectoryPinToggle:Vc,onFilePinToggle:Yc,pinnedPaths:En,selectedFilePath:at,query:Ye,searchRootPath:Rc,searchOptions:Nc,searchMode:oe,onContentMatchSelect:wi,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:O,canOpenInFileBrowser:lc,onOpenInFileBrowser:Dc})]})}),e.jsx(ml,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Fo,{filePath:Nh||Yo===1?at:null,active:r&&Dr&&Yo===1,onInsertReference:Ot,onInsertText:or,onInsertFeature:or,onReviewReference:Hc,onReferenceCopied:yr,onClose:Bm,onDirectoryLinkOpen:Td,isMobile:!0,lineRange:en,onLineRangeChange:Ct,insertedReferenceKey:De,copiedReferenceKey:Re,scrollToLine:Or,onScrollToLineHandled:()=>tn(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Yn,onScroll:Ic,onDragOver:Ba,onDragEnter:Ba,onDragLeave:Fc,onDrop:_c,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:ni},children:[ic&&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()&&Id,e.jsx(au,{rootPath:ie??"",onFileSelect:Is,onPathReference:Ot,getReferenceText:Ua,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onDirectoryRoot:Kc,onSearchFromDirectory:qc,onDirectoryPinToggle:Vc,onFilePinToggle:Yc,pinnedPaths:En,selectedFilePath:at,query:Ye,searchRootPath:Rc,searchOptions:Nc,searchMode:oe,onContentMatchSelect:wi,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:O,canOpenInFileBrowser:lc,onOpenInFileBrowser:Dc})]}),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:Oh,onPointerMove:Uh,onPointerUp:Lc,onPointerCancel:Lc,onDoubleClick:()=>{si(jl),At(ra,jl)},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(Fo,{filePath:at,active:r&&Dr,onInsertReference:Ot,onInsertText:or,onInsertFeature:or,onReviewReference:Hc,onReferenceCopied:yr,onDirectoryLinkOpen:Td,isMobile:!1,lineRange:en,onLineRangeChange:Ct,insertedReferenceKey:De,copiedReferenceKey:Re,scrollToLine:Or,onScrollToLineHandled:()=>tn(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})]})}),e.jsx(ds,{active:$t,mounted:Mh||$t,children:()=>vi?e.jsx(_p,{}):se?e.jsx(pl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:bi,onMobileSlideChange:Xo,groups:Xt.length>0?md():[],mode:zr,onModeChange:to,selectedKey:at,scrollToKey:vd,scrollToKeyNonce:Ma.nonce,compact:!1,collapsedDirectoryKeys:Ur,onToggleDirectory:kd,onSelectFile:t=>{const i=Ln.get(t.key);i&&eo(Sr(i))},renderLeading:pd,renderTrailing:t=>{const i=Ln.get(t.key);return i?fd(i):null},renderDirectoryTrailing:hd,renderSubtitle:t=>{const i=Ln.get(t.key);return i?ud(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:[io&&e.jsx("div",{className:"mb-2",children:io}),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:[Xt.length,"/",Fe.size]})]}),e.jsxs(uu,{actions:_d,children:[cd(),t,m&&Hs(),Fd]},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&&An&&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(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Va?(t=>wd(t)):void 0,emptyContent:vi?null:kn&&Fe.size===0?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Xt.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(la,{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&&Hs(),e.jsxs("button",{type:"button",onClick:ro,"aria-pressed":Tt,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 ${Tt?"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(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{es()},disabled:br,"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(wo,{size:14,className:br?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:gd,activePane:$t,wrap:Tt,diffViewType:ri,inlineMode:ur,diffOptions:Nd,reloadKey:xs,renderStreamBadge:t=>e.jsx(aa,{status:t}),onHunkGitAction:Ed,onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,onDetailScroll:Qa}):e.jsx(pl,{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:Xt.length>0?md():[],mode:zr,onModeChange:to,selectedKey:at,scrollToKey:vd,scrollToKeyNonce:Ma.nonce,compact:!0,collapsedDirectoryKeys:Ur,onToggleDirectory:kd,onSelectFile:t=>{const i=Ln.get(t.key);i&&eo(Sr(i))},renderLeading:pd,renderTrailing:t=>{const i=Ln.get(t.key);return i?fd(i):null},renderDirectoryTrailing:hd,renderSubtitle:t=>{const i=Ln.get(t.key);return i?ud(i):null},aiContent:Va?(t=>wd(t)):void 0,emptyContent:vi?null:kn&&Fe.size===0?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Xt.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:[io&&e.jsx("div",{className:"mb-2",children:io}),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:[Xt.length,"/",Fe.size]})})]}),e.jsxs(uu,{actions:_d,children:[cd(),t,Hs(),e.jsxs("button",{type:"button",onClick:ro,"aria-pressed":Tt,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 ${Tt?"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(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Fd]},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&&An&&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(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:gd,activePane:$t,wrap:Tt,diffViewType:Mr,inlineMode:ur,diffOptions:Nd,reloadKey:xs,renderStreamBadge:t=>e.jsx(aa,{status:t}),onHunkGitAction:Ed,onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,onDetailScroll:Qa})}),e.jsx(ds,{active:Nn,mounted:sr.architecture&&(Wh||r&&Nn),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(ex,{rootPath:v,active:r&&Nn,onInsertPrompt:(t,i)=>or(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(x0,{rootPath:v,file:t,active:r&&Nn,isMobile:se,onInsertReference:Ot,onInsertText:or,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(Dt("files"),Ft(null),wi(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(ds,{active:r&&ns,mounted:sr.computer&&(Hh||r&&ns),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(tx,{active:r&&ns})})}),e.jsx(ds,{active:rs,mounted:Zo&&qr,children:$h?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:o("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{Wi.getState().setDock(Ki,null),ta({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Bp,{sessionId:n??null,onCloseTab:()=>Tc(!1),onInsertPrompt:t=>Fr("android-deps",t),onInsertFile:Jh,onRecordingComplete:Xh})})]}),r&&Bt.task&&e.jsx(Xg,{task:Bt.task,onCancel:Bt.cancel,onRetry:()=>{Bt.retry()},onDismiss:Bt.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Bt.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Bt.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:Bt.task.files.length})}}),r&&We&&e.jsx(Gg,{value:ct,collapsed:H,autoCollapseAfterSend:Ce,focusRequest:Zr,insertError:gs?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{cr(!1),Nt(t)},onCollapsedChange:ne,onAutoCollapseAfterSendChange:lt,onDisable:()=>Br(!1),onClear:()=>Nt(""),onInsert:()=>zc(!1),onInsertAndSend:()=>zc(!0),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})}}),dm(),yt&&typeof document<"u"&&Rr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>bn(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:yt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:yt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:tf(yt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),yt.kind==="restore"&&e.jsx("input",{value:yt.phrase,onChange:t=>bn({...yt,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:()=>bn(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:!!qe||yt.kind==="restore"&&yt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(yt.kind==="restore"){const t=xt(yt.file,v);if(!t)return;wt({action:"restore-worktree-file",cwd:t,paths:[yt.file.path],confirm:{acknowledged:!0,phrase:yt.phrase}},o("rightSidebar.restoreFile"),cl(yt.file))}else{const t=yt.repoRoot??v;if(!t)return;wt({action:"stash-all",cwd:t},o("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${yt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(qe?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const P0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Fo,MarkdownImageLightbox:hh,MarkdownPreview:mh,RightSidebar:v0,__testParseMarkdownListBlock:Dx,buildMarkdownPreviewBlocks:Kx,buildMarkdownPreviewRenderResult:Gl,collectKnownGitRepoRoots:_f,computeMarkdownImageDisplayBox:Xf,getMarkdownHeadingOutline:fh,getMarkdownHeadingPathAtLine:uh,getNextMarkdownPreviewLineRange:Qx,isSvgImageSrc:ma,mountRightSidebarRepoPickerOverlay:Rf,replaceGitRepositorySnapshot:yh,resolveMarkdownLocalLinkTarget:Bl,resolveRightSidebarDiffViewType:Df,shouldCloseMarkdownImageLightboxDrag:lh,showsGitRepoGroupHeader:Rl},Symbol.toStringTag,{value:"Module"}));export{xl as E,P0 as R,ag as S,Yp as a,Kx as b,Sg as c,yg as i,vg as l,$0 as m};
|