termdock 1.4.238 → 1.4.240

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.
Files changed (319) hide show
  1. package/README.md +2 -0
  2. package/dist/client/assets/App-CmlGDKDj.js +155 -0
  3. package/dist/client/assets/App-CmlGDKDj.js.br +0 -0
  4. package/dist/client/assets/App-CmlGDKDj.js.gz +0 -0
  5. package/dist/client/assets/ChangeWalkthroughPanel-9whVVXTr.js +2 -0
  6. package/dist/client/assets/ChangeWalkthroughPanel-9whVVXTr.js.br +0 -0
  7. package/dist/client/assets/ChangeWalkthroughPanel-9whVVXTr.js.gz +0 -0
  8. package/dist/client/assets/{DagPlayground-BvnU5iIE.js → DagPlayground-y80OTTQj.js} +1 -1
  9. package/dist/client/assets/DagPlayground-y80OTTQj.js.br +0 -0
  10. package/dist/client/assets/DagPlayground-y80OTTQj.js.gz +0 -0
  11. package/dist/client/assets/{DiffLab-CSeMFrtl.js → DiffLab-BY2wbRtg.js} +1 -1
  12. package/dist/client/assets/DiffLab-BY2wbRtg.js.br +0 -0
  13. package/dist/client/assets/DiffLab-BY2wbRtg.js.gz +0 -0
  14. package/dist/client/assets/{DiffReview-D-5YkY_H.js → DiffReview-DLlDJbK1.js} +1 -1
  15. package/dist/client/assets/DiffReview-DLlDJbK1.js.br +0 -0
  16. package/dist/client/assets/DiffReview-DLlDJbK1.js.gz +0 -0
  17. package/dist/client/assets/{DiffReviewLab-CWjl-8Pe.js → DiffReviewLab-CEpa_B8I.js} +1 -1
  18. package/dist/client/assets/DiffReviewLab-CEpa_B8I.js.br +0 -0
  19. package/dist/client/assets/DiffReviewLab-CEpa_B8I.js.gz +0 -0
  20. package/dist/client/assets/{DiffViewer-BPsVQrjM.js → DiffViewer-GLkd1zMQ.js} +1 -1
  21. package/dist/client/assets/DiffViewer-GLkd1zMQ.js.br +0 -0
  22. package/dist/client/assets/DiffViewer-GLkd1zMQ.js.gz +0 -0
  23. package/dist/client/assets/{ModelPreview-BFycVhUy.js → ModelPreview-DB8tw45f.js} +1 -1
  24. package/dist/client/assets/ModelPreview-DB8tw45f.js.br +0 -0
  25. package/dist/client/assets/ModelPreview-DB8tw45f.js.gz +0 -0
  26. package/dist/client/assets/{RightSidebar-BX6rhGB4.js → RightSidebar-aoJjOQGX.js} +9 -9
  27. package/dist/client/assets/RightSidebar-aoJjOQGX.js.br +0 -0
  28. package/dist/client/assets/RightSidebar-aoJjOQGX.js.gz +0 -0
  29. package/dist/client/assets/{abnfDiagram-VCTEODGH-BTzZAuBK.js → abnfDiagram-VCTEODGH-RBGYciHa.js} +1 -1
  30. package/dist/client/assets/abnfDiagram-VCTEODGH-RBGYciHa.js.br +0 -0
  31. package/dist/client/assets/abnfDiagram-VCTEODGH-RBGYciHa.js.gz +0 -0
  32. package/dist/client/assets/{app-B6ME9Eob.js → app-Ctrh4Bku.js} +3 -3
  33. package/dist/client/assets/app-Ctrh4Bku.js.br +0 -0
  34. package/dist/client/assets/app-Ctrh4Bku.js.gz +0 -0
  35. package/dist/client/assets/{arc-DIV29t9b.js → arc-CzQsNCup.js} +1 -1
  36. package/dist/client/assets/arc-CzQsNCup.js.br +0 -0
  37. package/dist/client/assets/arc-CzQsNCup.js.gz +0 -0
  38. package/dist/client/assets/{architectureDiagram-5GKGNRK7-DgHv-608.js → architectureDiagram-5GKGNRK7-sDp6hSiy.js} +1 -1
  39. package/dist/client/assets/architectureDiagram-5GKGNRK7-sDp6hSiy.js.br +0 -0
  40. package/dist/client/assets/architectureDiagram-5GKGNRK7-sDp6hSiy.js.gz +0 -0
  41. package/dist/client/assets/{blockDiagram-I7D4REHJ-DwJbcw0g.js → blockDiagram-I7D4REHJ-C-AHqZPo.js} +1 -1
  42. package/dist/client/assets/blockDiagram-I7D4REHJ-C-AHqZPo.js.br +0 -0
  43. package/dist/client/assets/blockDiagram-I7D4REHJ-C-AHqZPo.js.gz +0 -0
  44. package/dist/client/assets/{c4Diagram-7LVT6UL2-I_d1HrDr.js → c4Diagram-7LVT6UL2-B8VGhLwN.js} +1 -1
  45. package/dist/client/assets/c4Diagram-7LVT6UL2-B8VGhLwN.js.br +0 -0
  46. package/dist/client/assets/c4Diagram-7LVT6UL2-B8VGhLwN.js.gz +0 -0
  47. package/dist/client/assets/channel-zK78er-R.js +1 -0
  48. package/dist/client/assets/{chunk-2Q5K7J3B-D8Up9_Qq.js → chunk-2Q5K7J3B-D56jCJTr.js} +1 -1
  49. package/dist/client/assets/{chunk-5VM5RSS4-Bqu4flXy.js → chunk-5VM5RSS4-cga3WKIM.js} +1 -1
  50. package/dist/client/assets/{chunk-F27PBJKO-BEx-OJOh.js → chunk-F27PBJKO-BNOR_7WA.js} +1 -1
  51. package/dist/client/assets/chunk-F27PBJKO-BNOR_7WA.js.br +0 -0
  52. package/dist/client/assets/chunk-F27PBJKO-BNOR_7WA.js.gz +0 -0
  53. package/dist/client/assets/{chunk-IMKFNOWR-DXRKd1hc.js → chunk-IMKFNOWR-Dk12DKtC.js} +1 -1
  54. package/dist/client/assets/chunk-IMKFNOWR-Dk12DKtC.js.br +0 -0
  55. package/dist/client/assets/chunk-IMKFNOWR-Dk12DKtC.js.gz +0 -0
  56. package/dist/client/assets/{chunk-JWPE2WC7-SPMqs5Ed.js → chunk-JWPE2WC7-CVqdLg0d.js} +1 -1
  57. package/dist/client/assets/{chunk-POPQ4Y6H-BP5FdWvP.js → chunk-POPQ4Y6H-Y6gEzK15.js} +1 -1
  58. package/dist/client/assets/{chunk-SVP7TREG-Cd1MiWuY.js → chunk-SVP7TREG-BIJtdFBL.js} +1 -1
  59. package/dist/client/assets/chunk-SVP7TREG-BIJtdFBL.js.br +0 -0
  60. package/dist/client/assets/chunk-SVP7TREG-BIJtdFBL.js.gz +0 -0
  61. package/dist/client/assets/{chunk-TICWLB2K-Bp824MdF.js → chunk-TICWLB2K-CS3jsxv7.js} +1 -1
  62. package/dist/client/assets/chunk-TICWLB2K-CS3jsxv7.js.br +0 -0
  63. package/dist/client/assets/chunk-TICWLB2K-CS3jsxv7.js.gz +0 -0
  64. package/dist/client/assets/{chunk-XXDRQBXY-BgSF02Yo.js → chunk-XXDRQBXY-BYgvxPrj.js} +1 -1
  65. package/dist/client/assets/classDiagram-ZZMXUADV-BMh5Sak3.js +1 -0
  66. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BMh5Sak3.js +1 -0
  67. package/dist/client/assets/{cose-bilkent-JH36ORCC-MIotlu8S.js → cose-bilkent-JH36ORCC-9udJiW7h.js} +1 -1
  68. package/dist/client/assets/cose-bilkent-JH36ORCC-9udJiW7h.js.br +0 -0
  69. package/dist/client/assets/cose-bilkent-JH36ORCC-9udJiW7h.js.gz +0 -0
  70. package/dist/client/assets/{cynefin-OW5HDTMX-Bx5fAwL9.js → cynefin-OW5HDTMX-D-6q-6N2.js} +1 -1
  71. package/dist/client/assets/cynefin-OW5HDTMX-D-6q-6N2.js.br +0 -0
  72. package/dist/client/assets/cynefin-OW5HDTMX-D-6q-6N2.js.gz +0 -0
  73. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Dq1IWXBH.js → cynefinDiagram-5FMLGOSQ-B5c37uFA.js} +1 -1
  74. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-B5c37uFA.js.br +0 -0
  75. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-B5c37uFA.js.gz +0 -0
  76. package/dist/client/assets/{dagre-GXQ25YYZ-1uJhB1J8.js → dagre-GXQ25YYZ-DoFMIka4.js} +1 -1
  77. package/dist/client/assets/dagre-GXQ25YYZ-DoFMIka4.js.br +0 -0
  78. package/dist/client/assets/dagre-GXQ25YYZ-DoFMIka4.js.gz +0 -0
  79. package/dist/client/assets/{diagram-S7CK7UJ4-immgVZRx.js → diagram-S7CK7UJ4-DrAwxGx7.js} +1 -1
  80. package/dist/client/assets/diagram-S7CK7UJ4-DrAwxGx7.js.br +0 -0
  81. package/dist/client/assets/diagram-S7CK7UJ4-DrAwxGx7.js.gz +0 -0
  82. package/dist/client/assets/{diagram-UQ7AKVKN-DY0SJCkK.js → diagram-UQ7AKVKN-DbWfEzKd.js} +1 -1
  83. package/dist/client/assets/diagram-UQ7AKVKN-DbWfEzKd.js.br +0 -0
  84. package/dist/client/assets/diagram-UQ7AKVKN-DbWfEzKd.js.gz +0 -0
  85. package/dist/client/assets/{diagram-VSXAHHWV-M6gBY9G0.js → diagram-VSXAHHWV-zKcVacRq.js} +1 -1
  86. package/dist/client/assets/diagram-VSXAHHWV-zKcVacRq.js.br +0 -0
  87. package/dist/client/assets/diagram-VSXAHHWV-zKcVacRq.js.gz +0 -0
  88. package/dist/client/assets/{diagram-VX7I27RA--S_w2OZo.js → diagram-VX7I27RA-BNAI-5sG.js} +1 -1
  89. package/dist/client/assets/diagram-VX7I27RA-BNAI-5sG.js.br +0 -0
  90. package/dist/client/assets/diagram-VX7I27RA-BNAI-5sG.js.gz +0 -0
  91. package/dist/client/assets/{diagram-Z3DM3KII-HEropZ-M.js → diagram-Z3DM3KII-ChB9ZeuK.js} +1 -1
  92. package/dist/client/assets/diagram-Z3DM3KII-ChB9ZeuK.js.br +0 -0
  93. package/dist/client/assets/diagram-Z3DM3KII-ChB9ZeuK.js.gz +0 -0
  94. package/dist/client/assets/{ebnfDiagram-PWID7BFC-DkeQP1kU.js → ebnfDiagram-PWID7BFC-Fe8VFmWJ.js} +1 -1
  95. package/dist/client/assets/ebnfDiagram-PWID7BFC-Fe8VFmWJ.js.br +0 -0
  96. package/dist/client/assets/ebnfDiagram-PWID7BFC-Fe8VFmWJ.js.gz +0 -0
  97. package/dist/client/assets/{erDiagram-RLTQ6QDP-1dq1ilk2.js → erDiagram-RLTQ6QDP-CC7DagoX.js} +1 -1
  98. package/dist/client/assets/erDiagram-RLTQ6QDP-CC7DagoX.js.br +0 -0
  99. package/dist/client/assets/erDiagram-RLTQ6QDP-CC7DagoX.js.gz +0 -0
  100. package/dist/client/assets/{flowDiagram-HODETNUW-CDX2AeEa.js → flowDiagram-HODETNUW-BBIgixMV.js} +1 -1
  101. package/dist/client/assets/flowDiagram-HODETNUW-BBIgixMV.js.br +0 -0
  102. package/dist/client/assets/flowDiagram-HODETNUW-BBIgixMV.js.gz +0 -0
  103. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-BF9-qd5G.js → ganttDiagram-EL5Y4UJY-CHRaIQ9P.js} +1 -1
  104. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHRaIQ9P.js.br +0 -0
  105. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHRaIQ9P.js.gz +0 -0
  106. package/dist/client/assets/{gestureArbiter-CahhrDMO.js → gestureArbiter-5c1oGojb.js} +1 -1
  107. package/dist/client/assets/gestureArbiter-5c1oGojb.js.br +0 -0
  108. package/dist/client/assets/gestureArbiter-5c1oGojb.js.gz +0 -0
  109. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-Dr4H-ZZx.js → gitGraphDiagram-WWUBYQGX-iJPivC9C.js} +1 -1
  110. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-iJPivC9C.js.br +0 -0
  111. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-iJPivC9C.js.gz +0 -0
  112. package/dist/client/assets/{infoDiagram-27XIBGKW-Bhu1F8ZQ.js → infoDiagram-27XIBGKW-CWjxPUb1.js} +1 -1
  113. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-D5U3zNlZ.js → ishikawaDiagram-5VMMS53U-2dN_H6WK.js} +1 -1
  114. package/dist/client/assets/ishikawaDiagram-5VMMS53U-2dN_H6WK.js.br +0 -0
  115. package/dist/client/assets/ishikawaDiagram-5VMMS53U-2dN_H6WK.js.gz +0 -0
  116. package/dist/client/assets/{journeyDiagram-3NMN7TZE-Cf3flu2q.js → journeyDiagram-3NMN7TZE-BqY-OLE2.js} +1 -1
  117. package/dist/client/assets/journeyDiagram-3NMN7TZE-BqY-OLE2.js.br +0 -0
  118. package/dist/client/assets/journeyDiagram-3NMN7TZE-BqY-OLE2.js.gz +0 -0
  119. package/dist/client/assets/{kanban-definition-UXKFOSKX-UtUZxvq0.js → kanban-definition-UXKFOSKX-CSOXhjNh.js} +1 -1
  120. package/dist/client/assets/kanban-definition-UXKFOSKX-CSOXhjNh.js.br +0 -0
  121. package/dist/client/assets/kanban-definition-UXKFOSKX-CSOXhjNh.js.gz +0 -0
  122. package/dist/client/assets/{layout-BtJol8tT.js → layout-BxIcRRf7.js} +1 -1
  123. package/dist/client/assets/layout-BxIcRRf7.js.br +0 -0
  124. package/dist/client/assets/{layout-BtJol8tT.js.gz → layout-BxIcRRf7.js.gz} +0 -0
  125. package/dist/client/assets/{linear-NTUDg_k8.js → linear-BYWiw-Yd.js} +1 -1
  126. package/dist/client/assets/linear-BYWiw-Yd.js.br +0 -0
  127. package/dist/client/assets/linear-BYWiw-Yd.js.gz +0 -0
  128. package/dist/client/assets/{mermaid.core-B2sd_0VA.js → mermaid.core-DhRpdkKn.js} +5 -5
  129. package/dist/client/assets/mermaid.core-DhRpdkKn.js.br +0 -0
  130. package/dist/client/assets/mermaid.core-DhRpdkKn.js.gz +0 -0
  131. package/dist/client/assets/{mindmap-definition-YA3MSWOX-BvnyWmZW.js → mindmap-definition-YA3MSWOX-DwBcGwTF.js} +1 -1
  132. package/dist/client/assets/mindmap-definition-YA3MSWOX-DwBcGwTF.js.br +0 -0
  133. package/dist/client/assets/mindmap-definition-YA3MSWOX-DwBcGwTF.js.gz +0 -0
  134. package/dist/client/assets/{passwordBootstrap-B-JP42Ue.js → passwordBootstrap-BkAa-DO2.js} +1 -1
  135. package/dist/client/assets/{passwordBootstrap-B-JP42Ue.js.br → passwordBootstrap-BkAa-DO2.js.br} +0 -0
  136. package/dist/client/assets/passwordBootstrap-BkAa-DO2.js.gz +0 -0
  137. package/dist/client/assets/{pegDiagram-XKGWAZYB-BEfaiRkj.js → pegDiagram-XKGWAZYB-D_04AQMs.js} +1 -1
  138. package/dist/client/assets/pegDiagram-XKGWAZYB-D_04AQMs.js.br +0 -0
  139. package/dist/client/assets/pegDiagram-XKGWAZYB-D_04AQMs.js.gz +0 -0
  140. package/dist/client/assets/{pieDiagram-E7YTZNPT-BJfWnKSk.js → pieDiagram-E7YTZNPT-DgHIGdDc.js} +1 -1
  141. package/dist/client/assets/pieDiagram-E7YTZNPT-DgHIGdDc.js.br +0 -0
  142. package/dist/client/assets/pieDiagram-E7YTZNPT-DgHIGdDc.js.gz +0 -0
  143. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BTvO0D46.js → quadrantDiagram-AXDQQJYC-BrxP_uCp.js} +1 -1
  144. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BrxP_uCp.js.br +0 -0
  145. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BrxP_uCp.js.gz +0 -0
  146. package/dist/client/assets/{railroadDiagram-O6MQD6OU-DBt4EfEX.js → railroadDiagram-O6MQD6OU-Bj8aV8et.js} +1 -1
  147. package/dist/client/assets/railroadDiagram-O6MQD6OU-Bj8aV8et.js.br +0 -0
  148. package/dist/client/assets/railroadDiagram-O6MQD6OU-Bj8aV8et.js.gz +0 -0
  149. package/dist/client/assets/{referenceLongPress-CJDSbgHQ.js → referenceLongPress-CG4k8F2W.js} +1 -1
  150. package/dist/client/assets/referenceLongPress-CG4k8F2W.js.br +0 -0
  151. package/dist/client/assets/referenceLongPress-CG4k8F2W.js.gz +0 -0
  152. package/dist/client/assets/{requirementDiagram-BXWQKSXE-lxRII39y.js → requirementDiagram-BXWQKSXE-DHOBnmaH.js} +1 -1
  153. package/dist/client/assets/requirementDiagram-BXWQKSXE-DHOBnmaH.js.br +0 -0
  154. package/dist/client/assets/requirementDiagram-BXWQKSXE-DHOBnmaH.js.gz +0 -0
  155. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-Dzx7pHhn.js → sankeyDiagram-P5KCCOFB-B46rNwzQ.js} +1 -1
  156. package/dist/client/assets/sankeyDiagram-P5KCCOFB-B46rNwzQ.js.br +0 -0
  157. package/dist/client/assets/sankeyDiagram-P5KCCOFB-B46rNwzQ.js.gz +0 -0
  158. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-A72IGdL2.js → sequenceDiagram-WJ2MYXX4-D8PnDgC6.js} +1 -1
  159. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-D8PnDgC6.js.br +0 -0
  160. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-D8PnDgC6.js.gz +0 -0
  161. package/dist/client/assets/{sizeCapture-INFHLROL-DBDKkK1y.js → sizeCapture-INFHLROL-CjofpSnZ.js} +1 -1
  162. package/dist/client/assets/sizeCapture-INFHLROL-CjofpSnZ.js.br +0 -0
  163. package/dist/client/assets/sizeCapture-INFHLROL-CjofpSnZ.js.gz +0 -0
  164. package/dist/client/assets/{sparkles-CWd8p2g-.js → sparkles-Zi8g0TMb.js} +1 -1
  165. package/dist/client/assets/{stateDiagram-D77RDMKH-CYH1Rw0N.js → stateDiagram-D77RDMKH-BX_StFJV.js} +1 -1
  166. package/dist/client/assets/stateDiagram-D77RDMKH-BX_StFJV.js.br +0 -0
  167. package/dist/client/assets/stateDiagram-D77RDMKH-BX_StFJV.js.gz +0 -0
  168. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CMG96YGj.js +1 -0
  169. package/dist/client/assets/{swimlanes-42K2YHIH-GvNJG8iK.js → swimlanes-42K2YHIH-bxGulCYh.js} +1 -1
  170. package/dist/client/assets/swimlanes-42K2YHIH-bxGulCYh.js.br +0 -0
  171. package/dist/client/assets/swimlanes-42K2YHIH-bxGulCYh.js.gz +0 -0
  172. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-sPKOywKp.js +8 -0
  173. package/dist/client/assets/{timeline-definition-24CTP7MA-CXGKAjVh.js → timeline-definition-24CTP7MA-DcHYPI0d.js} +1 -1
  174. package/dist/client/assets/timeline-definition-24CTP7MA-DcHYPI0d.js.br +0 -0
  175. package/dist/client/assets/timeline-definition-24CTP7MA-DcHYPI0d.js.gz +0 -0
  176. package/dist/client/assets/triangle-alert-BXXcxTk8.js +1 -0
  177. package/dist/client/assets/{vennDiagram-4TSXK5OY-DcjHEFq_.js → vennDiagram-4TSXK5OY-CjIGwkZf.js} +1 -1
  178. package/dist/client/assets/vennDiagram-4TSXK5OY-CjIGwkZf.js.br +0 -0
  179. package/dist/client/assets/vennDiagram-4TSXK5OY-CjIGwkZf.js.gz +0 -0
  180. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-DYHafp-J.js → wardleyDiagram-VM6X3IG4-B-WK3Fil.js} +1 -1
  181. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B-WK3Fil.js.br +0 -0
  182. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B-WK3Fil.js.gz +0 -0
  183. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-B6LMaSHZ.js → xychartDiagram-S5SC5T6Z-4RzKQfNK.js} +1 -1
  184. package/dist/client/assets/xychartDiagram-S5SC5T6Z-4RzKQfNK.js.br +0 -0
  185. package/dist/client/assets/xychartDiagram-S5SC5T6Z-4RzKQfNK.js.gz +0 -0
  186. package/dist/client/index.html +1 -1
  187. package/dist/client/index.html.br +0 -0
  188. package/dist/client/index.html.gz +0 -0
  189. package/dist/client/sw.js +1 -1
  190. package/dist/client/sw.js.br +0 -0
  191. package/dist/client/sw.js.gz +0 -0
  192. package/dist/server/agent/collaborationPrompt.js +31 -16
  193. package/dist/server/agent/collaborationStore.js +17 -3
  194. package/dist/server/certificateWatcher.js +7 -29
  195. package/dist/server/cli.js +2 -41
  196. package/dist/server/routes/filesystem.js +15 -11
  197. package/dist/server/utils/certificateNames.js +12 -0
  198. package/package.json +1 -1
  199. package/runtime-manifest.json +3 -3
  200. package/dist/client/assets/App-DIvCDJHZ.js +0 -155
  201. package/dist/client/assets/App-DIvCDJHZ.js.br +0 -0
  202. package/dist/client/assets/App-DIvCDJHZ.js.gz +0 -0
  203. package/dist/client/assets/ChangeWalkthroughPanel-BlM9ZAiG.js +0 -2
  204. package/dist/client/assets/ChangeWalkthroughPanel-BlM9ZAiG.js.br +0 -0
  205. package/dist/client/assets/ChangeWalkthroughPanel-BlM9ZAiG.js.gz +0 -0
  206. package/dist/client/assets/DagPlayground-BvnU5iIE.js.br +0 -0
  207. package/dist/client/assets/DagPlayground-BvnU5iIE.js.gz +0 -0
  208. package/dist/client/assets/DiffLab-CSeMFrtl.js.br +0 -0
  209. package/dist/client/assets/DiffLab-CSeMFrtl.js.gz +0 -0
  210. package/dist/client/assets/DiffReview-D-5YkY_H.js.br +0 -0
  211. package/dist/client/assets/DiffReview-D-5YkY_H.js.gz +0 -0
  212. package/dist/client/assets/DiffReviewLab-CWjl-8Pe.js.br +0 -0
  213. package/dist/client/assets/DiffReviewLab-CWjl-8Pe.js.gz +0 -0
  214. package/dist/client/assets/DiffViewer-BPsVQrjM.js.br +0 -0
  215. package/dist/client/assets/DiffViewer-BPsVQrjM.js.gz +0 -0
  216. package/dist/client/assets/ModelPreview-BFycVhUy.js.br +0 -0
  217. package/dist/client/assets/ModelPreview-BFycVhUy.js.gz +0 -0
  218. package/dist/client/assets/RightSidebar-BX6rhGB4.js.br +0 -0
  219. package/dist/client/assets/RightSidebar-BX6rhGB4.js.gz +0 -0
  220. package/dist/client/assets/abnfDiagram-VCTEODGH-BTzZAuBK.js.br +0 -0
  221. package/dist/client/assets/abnfDiagram-VCTEODGH-BTzZAuBK.js.gz +0 -0
  222. package/dist/client/assets/app-B6ME9Eob.js.br +0 -0
  223. package/dist/client/assets/app-B6ME9Eob.js.gz +0 -0
  224. package/dist/client/assets/arc-DIV29t9b.js.br +0 -0
  225. package/dist/client/assets/arc-DIV29t9b.js.gz +0 -0
  226. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgHv-608.js.br +0 -0
  227. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgHv-608.js.gz +0 -0
  228. package/dist/client/assets/blockDiagram-I7D4REHJ-DwJbcw0g.js.br +0 -0
  229. package/dist/client/assets/blockDiagram-I7D4REHJ-DwJbcw0g.js.gz +0 -0
  230. package/dist/client/assets/c4Diagram-7LVT6UL2-I_d1HrDr.js.br +0 -0
  231. package/dist/client/assets/c4Diagram-7LVT6UL2-I_d1HrDr.js.gz +0 -0
  232. package/dist/client/assets/channel-BOGwCQT3.js +0 -1
  233. package/dist/client/assets/chunk-F27PBJKO-BEx-OJOh.js.br +0 -0
  234. package/dist/client/assets/chunk-F27PBJKO-BEx-OJOh.js.gz +0 -0
  235. package/dist/client/assets/chunk-IMKFNOWR-DXRKd1hc.js.br +0 -0
  236. package/dist/client/assets/chunk-IMKFNOWR-DXRKd1hc.js.gz +0 -0
  237. package/dist/client/assets/chunk-SVP7TREG-Cd1MiWuY.js.br +0 -0
  238. package/dist/client/assets/chunk-SVP7TREG-Cd1MiWuY.js.gz +0 -0
  239. package/dist/client/assets/chunk-TICWLB2K-Bp824MdF.js.br +0 -0
  240. package/dist/client/assets/chunk-TICWLB2K-Bp824MdF.js.gz +0 -0
  241. package/dist/client/assets/classDiagram-ZZMXUADV--MBMAd-k.js +0 -1
  242. package/dist/client/assets/classDiagram-v2-VYDZK3BY--MBMAd-k.js +0 -1
  243. package/dist/client/assets/cose-bilkent-JH36ORCC-MIotlu8S.js.br +0 -0
  244. package/dist/client/assets/cose-bilkent-JH36ORCC-MIotlu8S.js.gz +0 -0
  245. package/dist/client/assets/cynefin-OW5HDTMX-Bx5fAwL9.js.br +0 -0
  246. package/dist/client/assets/cynefin-OW5HDTMX-Bx5fAwL9.js.gz +0 -0
  247. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dq1IWXBH.js.br +0 -0
  248. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dq1IWXBH.js.gz +0 -0
  249. package/dist/client/assets/dagre-GXQ25YYZ-1uJhB1J8.js.br +0 -0
  250. package/dist/client/assets/dagre-GXQ25YYZ-1uJhB1J8.js.gz +0 -0
  251. package/dist/client/assets/diagram-S7CK7UJ4-immgVZRx.js.br +0 -0
  252. package/dist/client/assets/diagram-S7CK7UJ4-immgVZRx.js.gz +0 -0
  253. package/dist/client/assets/diagram-UQ7AKVKN-DY0SJCkK.js.br +0 -0
  254. package/dist/client/assets/diagram-UQ7AKVKN-DY0SJCkK.js.gz +0 -0
  255. package/dist/client/assets/diagram-VSXAHHWV-M6gBY9G0.js.br +0 -0
  256. package/dist/client/assets/diagram-VSXAHHWV-M6gBY9G0.js.gz +0 -0
  257. package/dist/client/assets/diagram-VX7I27RA--S_w2OZo.js.br +0 -0
  258. package/dist/client/assets/diagram-VX7I27RA--S_w2OZo.js.gz +0 -0
  259. package/dist/client/assets/diagram-Z3DM3KII-HEropZ-M.js.br +0 -0
  260. package/dist/client/assets/diagram-Z3DM3KII-HEropZ-M.js.gz +0 -0
  261. package/dist/client/assets/ebnfDiagram-PWID7BFC-DkeQP1kU.js.br +0 -0
  262. package/dist/client/assets/ebnfDiagram-PWID7BFC-DkeQP1kU.js.gz +0 -0
  263. package/dist/client/assets/erDiagram-RLTQ6QDP-1dq1ilk2.js.br +0 -0
  264. package/dist/client/assets/erDiagram-RLTQ6QDP-1dq1ilk2.js.gz +0 -0
  265. package/dist/client/assets/flowDiagram-HODETNUW-CDX2AeEa.js.br +0 -0
  266. package/dist/client/assets/flowDiagram-HODETNUW-CDX2AeEa.js.gz +0 -0
  267. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BF9-qd5G.js.br +0 -0
  268. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BF9-qd5G.js.gz +0 -0
  269. package/dist/client/assets/gestureArbiter-CahhrDMO.js.br +0 -0
  270. package/dist/client/assets/gestureArbiter-CahhrDMO.js.gz +0 -0
  271. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Dr4H-ZZx.js.br +0 -0
  272. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Dr4H-ZZx.js.gz +0 -0
  273. package/dist/client/assets/ishikawaDiagram-5VMMS53U-D5U3zNlZ.js.br +0 -0
  274. package/dist/client/assets/ishikawaDiagram-5VMMS53U-D5U3zNlZ.js.gz +0 -0
  275. package/dist/client/assets/journeyDiagram-3NMN7TZE-Cf3flu2q.js.br +0 -0
  276. package/dist/client/assets/journeyDiagram-3NMN7TZE-Cf3flu2q.js.gz +0 -0
  277. package/dist/client/assets/kanban-definition-UXKFOSKX-UtUZxvq0.js.br +0 -0
  278. package/dist/client/assets/kanban-definition-UXKFOSKX-UtUZxvq0.js.gz +0 -0
  279. package/dist/client/assets/layout-BtJol8tT.js.br +0 -0
  280. package/dist/client/assets/linear-NTUDg_k8.js.br +0 -0
  281. package/dist/client/assets/linear-NTUDg_k8.js.gz +0 -0
  282. package/dist/client/assets/mermaid.core-B2sd_0VA.js.br +0 -0
  283. package/dist/client/assets/mermaid.core-B2sd_0VA.js.gz +0 -0
  284. package/dist/client/assets/mindmap-definition-YA3MSWOX-BvnyWmZW.js.br +0 -0
  285. package/dist/client/assets/mindmap-definition-YA3MSWOX-BvnyWmZW.js.gz +0 -0
  286. package/dist/client/assets/passwordBootstrap-B-JP42Ue.js.gz +0 -0
  287. package/dist/client/assets/pegDiagram-XKGWAZYB-BEfaiRkj.js.br +0 -0
  288. package/dist/client/assets/pegDiagram-XKGWAZYB-BEfaiRkj.js.gz +0 -0
  289. package/dist/client/assets/pieDiagram-E7YTZNPT-BJfWnKSk.js.br +0 -0
  290. package/dist/client/assets/pieDiagram-E7YTZNPT-BJfWnKSk.js.gz +0 -0
  291. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BTvO0D46.js.br +0 -0
  292. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BTvO0D46.js.gz +0 -0
  293. package/dist/client/assets/railroadDiagram-O6MQD6OU-DBt4EfEX.js.br +0 -0
  294. package/dist/client/assets/railroadDiagram-O6MQD6OU-DBt4EfEX.js.gz +0 -0
  295. package/dist/client/assets/referenceLongPress-CJDSbgHQ.js.br +0 -0
  296. package/dist/client/assets/referenceLongPress-CJDSbgHQ.js.gz +0 -0
  297. package/dist/client/assets/requirementDiagram-BXWQKSXE-lxRII39y.js.br +0 -0
  298. package/dist/client/assets/requirementDiagram-BXWQKSXE-lxRII39y.js.gz +0 -0
  299. package/dist/client/assets/sankeyDiagram-P5KCCOFB-Dzx7pHhn.js.br +0 -0
  300. package/dist/client/assets/sankeyDiagram-P5KCCOFB-Dzx7pHhn.js.gz +0 -0
  301. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-A72IGdL2.js.br +0 -0
  302. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-A72IGdL2.js.gz +0 -0
  303. package/dist/client/assets/sizeCapture-INFHLROL-DBDKkK1y.js.br +0 -0
  304. package/dist/client/assets/sizeCapture-INFHLROL-DBDKkK1y.js.gz +0 -0
  305. package/dist/client/assets/stateDiagram-D77RDMKH-CYH1Rw0N.js.br +0 -0
  306. package/dist/client/assets/stateDiagram-D77RDMKH-CYH1Rw0N.js.gz +0 -0
  307. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-ClPva5pp.js +0 -1
  308. package/dist/client/assets/swimlanes-42K2YHIH-GvNJG8iK.js.br +0 -0
  309. package/dist/client/assets/swimlanes-42K2YHIH-GvNJG8iK.js.gz +0 -0
  310. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-D0YOfmzt.js +0 -8
  311. package/dist/client/assets/timeline-definition-24CTP7MA-CXGKAjVh.js.br +0 -0
  312. package/dist/client/assets/timeline-definition-24CTP7MA-CXGKAjVh.js.gz +0 -0
  313. package/dist/client/assets/triangle-alert--V4KOVlD.js +0 -1
  314. package/dist/client/assets/vennDiagram-4TSXK5OY-DcjHEFq_.js.br +0 -0
  315. package/dist/client/assets/vennDiagram-4TSXK5OY-DcjHEFq_.js.gz +0 -0
  316. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DYHafp-J.js.br +0 -0
  317. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DYHafp-J.js.gz +0 -0
  318. package/dist/client/assets/xychartDiagram-S5SC5T6Z-B6LMaSHZ.js.br +0 -0
  319. package/dist/client/assets/xychartDiagram-S5SC5T6Z-B6LMaSHZ.js.gz +0 -0
@@ -1,16 +1,16 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-BFycVhUy.js","assets/app-B6ME9Eob.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-BzglvLj5.css","assets/App-DIvCDJHZ.js","assets/gestureArbiter-CahhrDMO.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert--V4KOVlD.js","assets/referenceLongPress-CJDSbgHQ.js","assets/DiffReview-D-5YkY_H.js","assets/sparkles-CWd8p2g-.js","assets/DiffViewer-BPsVQrjM.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-BlM9ZAiG.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-B2sd_0VA.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
2
- import{a3 as Mt,a0 as uh,bb as e,cD as yt,cN as xt,bt as tt,a as Ns,aK as fh,C as bi,c as Ms,X as Ut,cA as hh,a$ as mh,y as gs,ak as ph,cH as te,b3 as gh,b5 as Ui,b6 as bh,b7 as Td,b4 as bs,ax as xh,E as vh,i as yh,b2 as wh,bv as kh,bx as Sh,by as jh,aW as Rh,bw as Oc,x as bt,f as Ch,L as vt,u as Nh,b as Mh,aV as Uc,at as Hc,ap as $h,aB as Ca,aC as zc,cO as Ss,ag as xs,aD as Eh,cB as Yo,bn as Lh,cm as Wc,av as Ah,cy as Ph,bY as Th,aG as Ih,N as Gc,K as Dh,aq as Fh,au as _h,az as qc,b_ as Bh,r as Oh,d as Na,g as xi,v as Id,ac as Uh,_ as $s,bS as Hh,cL as zh,bi as Wh,ae as Gh}from"./app-B6ME9Eob.js";import{x as qh,g as Kh,p as Ba,e as Vh,P as Yh,k as Xh,R as vi,q as Dd,r as Jh,S as Vn,D as Qh,c as Fd,a as Zh,w as _d,u as Ma,s as em,t as tm,v as rm,T as Kc,d as Vc,j as Xo,i as $a,b as nm,m as sm,h as am,f as om,n as im,F as Yc,C as lm,G as cm}from"./App-DIvCDJHZ.js";import{b as o,r as Gr}from"./dnd-BCFAPC0L.js";import{a as dm,S as um,b as Bd,c as yi,F as fm}from"./gestureArbiter-CahhrDMO.js";import{D as wi,C as js,L as Od,f as hm,n as mm}from"./DiffReview-D-5YkY_H.js";import{T as pm,L as za,G as Rr}from"./triangle-alert--V4KOVlD.js";import{S as Es}from"./sparkles-CWd8p2g-.js";import{C as Ud,a as Hd,M as zd}from"./ChangeWalkthroughPanel-BlM9ZAiG.js";import{r as Wd,s as Gd,l as qd,u as gm,h as Kd}from"./DiffViewer-BPsVQrjM.js";import{u as Vd,G as Yd}from"./referenceLongPress-CJDSbgHQ.js";const bm=[["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"}]],xm=Mt("case-sensitive",bm);const vm=[["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"}]],ym=Mt("eye-off",vm);const wm=[["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"}]],ki=Mt("eye",wm);const km=[["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"}]],Si=Mt("file-text",km);const Sm=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Xc=Mt("house",Sm);const jm=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Rm=Mt("image-plus",jm);const Cm=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Nm=Mt("maximize",Cm);const Mm=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],$m=Mt("minimize",Mm);const Em=[["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"}]],Lm=Mt("regex",Em);const Am=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Pm=Mt("rotate-cw",Am);const Tm=[["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"}]],Im=Mt("scan",Tm);const Dm=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Jc=Mt("send",Dm);const Fm=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],_m=Mt("upload",Fm);const Bm=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],Om=Mt("whole-word",Bm);async function Um(t){let n;try{await Promise.race([t(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function Hm({active:t,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){o.useEffect(()=>{if(!t||!n||s||d.current===n)return;const h=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(h)},[t,n,s,l,d,c])}function zm(t,n,s){try{const l=t instanceof HTMLImageElement?t.naturalWidth:t.width,d=t instanceof HTMLImageElement?t.naturalHeight:t.height;if(!l||!d)return Promise.resolve(null);const c=t instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(l*c)),h.height=Math.max(1,Math.round(d*c));const m=h.getContext("2d");if(!m)return Promise.resolve(null);const g=getComputedStyle(document.documentElement);if(m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,h.height),m.drawImage(t,0,0,h.width,h.height),s){const p=Math.max(10,Math.min(16,h.width/35));m.font=`${p}px sans-serif`;const f=[];let k="";for(const y of s.split(" "))k&&m.measureText(`${k} ${y}`).width>h.width-20?(f.push(k),k=y):k=k?`${k} ${y}`:y;k&&f.push(k),m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(p+4)+12),m.fillStyle=g.getPropertyValue("--foreground").trim()||"black",f.forEach((y,N)=>m.fillText(y,10,8+p+N*(p+4)))}if(n){const p=n.xPercent*h.width/100,f=n.yPercent*h.height/100,k=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),y=k*1.6;m.strokeStyle=g.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,k/3),m.beginPath(),m.arc(p,f,k,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(p-y,f),m.lineTo(p+y,f),m.moveTo(p,f-y),m.lineTo(p,f+y),m.stroke()}return new Promise(p=>h.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function Wm(t,n,s,l){return[t.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-DB8tw45f.js","assets/app-Ctrh4Bku.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-BzglvLj5.css","assets/App-CmlGDKDj.js","assets/gestureArbiter-5c1oGojb.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-BXXcxTk8.js","assets/referenceLongPress-CG4k8F2W.js","assets/DiffReview-DLlDJbK1.js","assets/sparkles-Zi8g0TMb.js","assets/DiffViewer-GLkd1zMQ.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-9whVVXTr.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-DhRpdkKn.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
2
+ import{a3 as Mt,a0 as uh,bb as e,cD as yt,cN as xt,bt as tt,a as Ns,aK as fh,C as bi,c as Ms,X as Ut,cA as hh,a$ as mh,y as gs,ak as ph,cH as te,b3 as gh,b5 as Ui,b6 as bh,b7 as Td,b4 as bs,ax as xh,E as vh,i as yh,b2 as wh,bv as kh,bx as Sh,by as jh,aW as Rh,bw as Oc,x as bt,f as Ch,L as vt,u as Nh,b as Mh,aV as Uc,at as Hc,ap as $h,aB as Ca,aC as zc,cO as Ss,ag as xs,aD as Eh,cB as Yo,bn as Lh,cm as Wc,av as Ah,cy as Ph,bY as Th,aG as Ih,N as Gc,K as Dh,aq as Fh,au as _h,az as qc,b_ as Bh,r as Oh,d as Na,g as xi,v as Id,ac as Uh,_ as $s,bS as Hh,cL as zh,bi as Wh,ae as Gh}from"./app-Ctrh4Bku.js";import{x as qh,g as Kh,p as Ba,e as Vh,P as Yh,k as Xh,R as vi,q as Dd,r as Jh,S as Vn,D as Qh,c as Fd,a as Zh,w as _d,u as Ma,s as em,t as tm,v as rm,T as Kc,d as Vc,j as Xo,i as $a,b as nm,m as sm,h as am,f as om,n as im,F as Yc,C as lm,G as cm}from"./App-CmlGDKDj.js";import{b as o,r as Gr}from"./dnd-BCFAPC0L.js";import{a as dm,S as um,b as Bd,c as yi,F as fm}from"./gestureArbiter-5c1oGojb.js";import{D as wi,C as js,L as Od,f as hm,n as mm}from"./DiffReview-DLlDJbK1.js";import{T as pm,L as za,M as Ud,G as Rr}from"./triangle-alert-BXXcxTk8.js";import{S as Es}from"./sparkles-Zi8g0TMb.js";import{C as Hd,M as zd}from"./ChangeWalkthroughPanel-9whVVXTr.js";import{r as Wd,s as Gd,l as qd,u as gm,h as Kd}from"./DiffViewer-GLkd1zMQ.js";import{u as Vd,G as Yd}from"./referenceLongPress-CG4k8F2W.js";const bm=[["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"}]],xm=Mt("case-sensitive",bm);const vm=[["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"}]],ym=Mt("eye-off",vm);const wm=[["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"}]],ki=Mt("eye",wm);const km=[["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"}]],Si=Mt("file-text",km);const Sm=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Xc=Mt("house",Sm);const jm=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Rm=Mt("image-plus",jm);const Cm=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Nm=Mt("maximize",Cm);const Mm=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],$m=Mt("minimize",Mm);const Em=[["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"}]],Lm=Mt("regex",Em);const Am=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Pm=Mt("rotate-cw",Am);const Tm=[["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"}]],Im=Mt("scan",Tm);const Dm=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Jc=Mt("send",Dm);const Fm=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],_m=Mt("upload",Fm);const Bm=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],Om=Mt("whole-word",Bm);async function Um(t){let n;try{await Promise.race([t(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function Hm({active:t,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){o.useEffect(()=>{if(!t||!n||s||d.current===n)return;const h=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(h)},[t,n,s,l,d,c])}function zm(t,n,s){try{const l=t instanceof HTMLImageElement?t.naturalWidth:t.width,d=t instanceof HTMLImageElement?t.naturalHeight:t.height;if(!l||!d)return Promise.resolve(null);const c=t instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(l*c)),h.height=Math.max(1,Math.round(d*c));const m=h.getContext("2d");if(!m)return Promise.resolve(null);const g=getComputedStyle(document.documentElement);if(m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,h.height),m.drawImage(t,0,0,h.width,h.height),s){const p=Math.max(10,Math.min(16,h.width/35));m.font=`${p}px sans-serif`;const f=[];let k="";for(const y of s.split(" "))k&&m.measureText(`${k} ${y}`).width>h.width-20?(f.push(k),k=y):k=k?`${k} ${y}`:y;k&&f.push(k),m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(p+4)+12),m.fillStyle=g.getPropertyValue("--foreground").trim()||"black",f.forEach((y,N)=>m.fillText(y,10,8+p+N*(p+4)))}if(n){const p=n.xPercent*h.width/100,f=n.yPercent*h.height/100,k=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),y=k*1.6;m.strokeStyle=g.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,k/3),m.beginPath(),m.arc(p,f,k,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(p-y,f),m.lineTo(p+y,f),m.moveTo(p,f-y),m.lineTo(p,f+y),m.stroke()}return new Promise(p=>h.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function Wm(t,n,s,l){return[t.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
3
3
  `)}function Db(t,n,s){const l=n*Math.PI/360,d=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(t,1e-6)/Math.sin(d)*1.15}async function Gm(t,n,s,l){if(!s?.snapshot){l.isCurrent()&&l.insert(t,n);return}const d=new Date().toISOString(),c=new AbortController;let h,m;try{m=await Promise.race([(async()=>{const g=await s.snapshot;if(!(!g||c.signal.aborted||!l.isCurrent()))return l.upload(new File([g],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(g=>{h=setTimeout(()=>{c.abort(),g(void 0)},3e3)})])}catch{}finally{clearTimeout(h),c.abort()}l.isCurrent()&&l.insert(m?Wm(t,"",d,m):t,n)}function qm(t){let n=1,s="terminal";for(;;){let l=!1;for(const d of t.values())if(d.name===s){l=!0;break}if(!l)break;s=`terminal-${n}`,n++}return s}const Qc=uh((t,n)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:s=>{const l=qh(),d=Date.now(),c=n().sessions,h=qm(c),m={id:l,cwd:s,sessionId:null,name:h,customName:!1,createdAt:d,lastActivity:d};return t(g=>{const p=new Map(g.sessions);return p.set(l,m),{sessions:p,activeSessionId:g.activeSessionId??l,nextSessionNumber:g.nextSessionNumber+1}}),l},closeSession:s=>{t(l=>{const d=new Map(l.sessions),c=l.activeSessionId===s;d.delete(s);let h=l.activeSessionId;if(c){const m=Array.from(d.keys());h=m.length>0?m[0]:null}return{sessions:d,activeSessionId:h}})},switchSession:s=>{t(l=>l.sessions.has(s)?{activeSessionId:s}:l)},updateSession:(s,l)=>{t(d=>{const c=d.sessions.get(s);if(!c)return d;const h=new Map(d.sessions);return h.set(s,{...c,...l,lastActivity:Date.now()}),{sessions:h}})},setTerminalSession:(s,l)=>{n().updateSession(s,{sessionId:l.sessionId})},getActiveSession:()=>{const s=n();if(s.activeSessionId)return s.sessions.get(s.activeSessionId)},getSessionCount:()=>n().sessions.size,clearAllSessions:()=>{t({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}}));function Km(t,n){return t===n||n.endsWith(`/${t}`)||t.endsWith(`/${n}`)}function Zc(t,n){return`${t??""}\0${n}`}function Vm(t,n,s){if(!t||t.length===0||!s)return{explained:0,stale:0};const l=Zc(n,s);let d=0,c=0;for(const h of t){const m=[h.filePath,h.newPath,h.oldPath].filter(p=>typeof p=="string"&&p.length>0);(m.some(p=>Zc(h.repoRoot,p)===l)||m.some(p=>Km(p,s)))&&(d+=1)}return{explained:d,stale:c}}function Ym({status:t}){if(!t)return null;const n=t.stale>0&&t.explained===0;if(!(t.explained>0||t.stale>0))return null;const l=n?"AI audit explanation is stale":"AI audit explanation available";return e.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${n?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:l,"aria-label":l,children:n?e.jsx(pm,{size:10}):e.jsx(Es,{size:10})})}function ji({changeStatus:t,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(t),e.jsx(Ym,{status:n})]})}const Xd="termdock:right-sidebar:diff-change-list-mode:v1";function Xm(t){return t==="list"||t==="tree"}function Jm(){return tt(Xd,Xm)??"tree"}function Qm(t){for(const l of t){const d=l.hunk;if(d.oldPath&&d.newPath&&d.oldPath!==d.newPath)return"renamed";if(!d.oldPath&&d.newPath)return"added";if(d.oldPath&&!d.newPath)return"deleted"}const n=t.some(l=>l.hunk.additions>0),s=t.some(l=>l.hunk.deletions>0);return n&&!s?"added":!n&&s?"deleted":"modified"}function Zm(t){const n=new Map;for(const l of t){const d=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(l),d.additions+=l.hunk.additions,d.deletions+=l.hunk.deletions,l.current&&(d.explained+=1),l.stale&&(d.stale+=1),n.set(l.hunk.filePath,d)}const s=Array.from(n.values()).sort((l,d)=>l.filePath.localeCompare(d.filePath));for(const l of s)l.changeType=Qm(l.items);return s}function ep(t){const n=t.filePath.split("/").pop()??t.filePath;return{key:t.key,path:t.filePath,displayName:n,displayDir:t.filePath.includes("/")?t.filePath.slice(0,-n.length-1):"",status:t.changeType,title:t.filePath}}function tp(t,n){const s=t.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],d=new Set;for(const[c,h]of s.entries()){const m=h.split(`
4
4
  `),g=m.findIndex(k=>k.startsWith("@@ "));if(g<0){l.push(...m);continue}c===0&&l.push(...m.slice(0,g));const p=n[c];let f=g;for(;f>=0&&f<m.length;){const k=m.findIndex((E,$)=>$>f&&E.startsWith("@@ ")),y=k>=0?k:m.length,N=m.slice(f,y),I=N[0]??"",F=p?I===p:!0,B=I||p||N.join(`
5
5
  `);F&&!d.has(B)&&(l.push(...N),d.add(B)),f=k}}return l.join(`
6
- `)}function rp({groups:t,onInsertDiffReference:n}){return t.map(s=>{const l=tp(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),d=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"";return{key:s.key,path:s.filePath,absolutePath:d[0]?.repoRoot?`${d[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:d[0]?.repoRoot??null,displayName:c,displayDir:h,diffOverride:l,auditRecords:d,onInsertDiffReference:n}})}function np(t,n,s){const l=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=t.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const p of l){const f=p.getBoundingClientRect();if(f.bottom<c)continue;const k=Math.abs(f.top-c);k<m&&(h=p,m=k)}const g=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!g||g===n||s(g),g}function ed({items:t,selectedKey:n,onSelect:s,emptyText:l,mobile:d=!1,backLabel:c="Back",headerTitle:h,headerMeta:m,onClose:g,closeLabel:p="Back",wrap:f=!0,onToggleWrap:k,wrapTitle:y,wrapOnLabel:N="Wrap on",wrapOffLabel:I="Wrap off",desktopLayout:F="split",onInsertDiffReference:B,onReferenceCopied:E,insertedReferenceKey:$,copiedReferenceKey:L,onClearAuditRecord:P,walkthroughs:U=[],onWalkthroughNavigate:D,initialDetailScrollTop:a,onDetailScrollPositionChange:w,scrollToKey:O,scrollToKeyNonce:j,externalSwiperRef:X,onMobileSlideChange:ne}){const{t:se}=yt(),fe=o.useMemo(()=>Zm(t),[t]),G=o.useMemo(()=>new Map(fe.map(le=>[le.key,le])),[fe]),[J,M]=o.useState(()=>Jm()),[_,K]=o.useState(()=>new Set),[re,oe]=o.useState({key:null,nonce:0}),he=fe.find(le=>le.explained>0||le.stale>0)?.key??fe[0]?.key??null,me=n&&fe.some(le=>le.key===n)?n:he,je=o.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:fe.map(ep)}],[fe]),C=o.useMemo(()=>rp({groups:fe,onInsertDiffReference:B}),[fe,B]),Z=o.useRef(he),ue=o.useRef(s);Z.current=he,ue.current=s,o.useEffect(()=>{!n&&Z.current&&ue.current(Z.current)},[n]);const Ee=k?e.jsxs("button",{type:"button",onClick:k,"aria-pressed":f,title:y,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]}):null,Ge=le=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[h&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),m&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:m})]}),g&&e.jsxs("button",{type:"button",onClick:g,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(Ns,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[le,Ee]})]});if(t.length===0){const le=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!h&&!g?le:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ge(null),le]})}const Fe=k?({slideToList:le})=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:le,children:[e.jsx(Ns,{size:14}),c]}),e.jsxs("button",{type:"button",onClick:k,"aria-pressed":f,title:y,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]})]}):void 0;return e.jsx(wi,{mobile:d,desktopLayout:F,backLabel:c,groups:je,selectedKey:me,mode:J,onModeChange:le=>{M(le),le!=="ai"&&xt(Xd,le)},compact:d,collapsedDirectoryKeys:_,onToggleDirectory:le=>{K(ae=>{const S=new Set(ae);return S.has(le)?S.delete(le):S.add(le),S})},onSelectFile:le=>{s(le.key),oe(ae=>({key:le.key,nonce:ae.nonce+1}))},renderLeading:le=>{const ae=G.get(le.key);return e.jsx(ji,{changeStatus:le.status,auditStatus:ae,renderChangeBadge:S=>e.jsx(js,{status:S})})},renderTrailing:le=>{const ae=G.get(le.key);return ae?e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",ae.additions," -",ae.deletions]}):null},renderListHeader:Ge,aiContent:({slideToDetail:le,fullscreen:ae,toggleFullscreen:S})=>U.length>0&&D?e.jsx(Ud,{walkthroughs:U,repoRoot:U[0]?.repoRoot,fullscreen:ae,onToggleFullscreen:S,onNavigate:V=>{d&&window.requestAnimationFrame(le),D(V)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:se("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Fe,externalSwiperRef:X,onMobileSlideChange:ne,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:a,scrollToKey:O??re.key,scrollToKeyNonce:O==null?re.nonce:j,onDetailScroll:le=>{np(le,me,s),w?.(le.scrollTop)},files:C,activePane:!0,wrap:f,renderStreamBadge:(le,ae)=>{const S=G.get(ae.key);return e.jsx(ji,{changeStatus:le,auditStatus:S,renderChangeBadge:V=>e.jsx(js,{status:V})})},onInsertDiffReference:B,onReferenceCopied:E,insertedReferenceKey:$,copiedReferenceKey:L,onClearAuditRecord:P,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function sp(t){return t.replace(/\/+$/,"")||"/"}function ap(t){return[...new Set(Array.from(t,sp))].sort((n,s)=>n.localeCompare(s))}function op(t){return t==="event-storm"||t==="reconnected"||t==="directory-rescan"||t==="polling-fallback"}function ip(t){let n=null;return{applicableEvents:t.filter(l=>{const d=l.type==="rescan-required"&&!op(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const lp=1400,cp=1200,Jd=44,dp=.7;function Jo(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ri(t){return`termdock:right-sidebar:context-draft-height:${t}:v1`}function up(t){try{const n=window.localStorage.getItem(Ri(t)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Jd?s:null}catch{return null}}function td(t,n){try{n===null?window.localStorage.removeItem(Ri(t)):window.localStorage.setItem(Ri(t),String(n))}catch{}}function Ea(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function fp({value:t,collapsed:n,labels:s,focusRequest:l,insertError:d,autoCollapseAfterSend:c,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:g,onDisable:p,onClear:f,onInsert:k,onInsertAndSend:y}){const[N,I]=o.useState(null),[F,B]=o.useState(!1),[E,$]=o.useState(()=>up(Jo())),L=o.useRef(E),P=o.useRef(null),U=o.useRef(null),D=o.useRef(t),a=o.useRef(null),w=o.useRef(null),O=!!t.trim(),j=t.trim().split(`
6
+ `)}function rp({groups:t,onInsertDiffReference:n}){return t.map(s=>{const l=tp(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),d=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"";return{key:s.key,path:s.filePath,absolutePath:d[0]?.repoRoot?`${d[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:d[0]?.repoRoot??null,displayName:c,displayDir:h,diffOverride:l,auditRecords:d,onInsertDiffReference:n}})}function np(t,n,s){const l=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=t.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const p of l){const f=p.getBoundingClientRect();if(f.bottom<c)continue;const k=Math.abs(f.top-c);k<m&&(h=p,m=k)}const g=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!g||g===n||s(g),g}function ed({items:t,selectedKey:n,onSelect:s,emptyText:l,mobile:d=!1,backLabel:c="Back",headerTitle:h,headerMeta:m,onClose:g,closeLabel:p="Back",wrap:f=!0,onToggleWrap:k,wrapTitle:y,wrapOnLabel:N="Wrap on",wrapOffLabel:I="Wrap off",desktopLayout:F="split",onInsertDiffReference:B,onReferenceCopied:E,insertedReferenceKey:$,copiedReferenceKey:L,onClearAuditRecord:P,walkthroughs:U=[],onWalkthroughNavigate:D,initialDetailScrollTop:a,onDetailScrollPositionChange:w,scrollToKey:O,scrollToKeyNonce:j,externalSwiperRef:X,onMobileSlideChange:ne}){const{t:se}=yt(),fe=o.useMemo(()=>Zm(t),[t]),G=o.useMemo(()=>new Map(fe.map(le=>[le.key,le])),[fe]),[J,M]=o.useState(()=>Jm()),[_,K]=o.useState(()=>new Set),[re,oe]=o.useState({key:null,nonce:0}),he=fe.find(le=>le.explained>0||le.stale>0)?.key??fe[0]?.key??null,me=n&&fe.some(le=>le.key===n)?n:he,je=o.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:fe.map(ep)}],[fe]),C=o.useMemo(()=>rp({groups:fe,onInsertDiffReference:B}),[fe,B]),Z=o.useRef(he),ue=o.useRef(s);Z.current=he,ue.current=s,o.useEffect(()=>{!n&&Z.current&&ue.current(Z.current)},[n]);const Ee=k?e.jsxs("button",{type:"button",onClick:k,"aria-pressed":f,title:y,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]}):null,Ge=le=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[h&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),m&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:m})]}),g&&e.jsxs("button",{type:"button",onClick:g,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(Ns,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[le,Ee]})]});if(t.length===0){const le=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!h&&!g?le:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ge(null),le]})}const Fe=k?({slideToList:le})=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:le,children:[e.jsx(Ns,{size:14}),c]}),e.jsxs("button",{type:"button",onClick:k,"aria-pressed":f,title:y,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]})]}):void 0;return e.jsx(wi,{mobile:d,desktopLayout:F,backLabel:c,groups:je,selectedKey:me,mode:J,onModeChange:le=>{M(le),le!=="ai"&&xt(Xd,le)},compact:d,collapsedDirectoryKeys:_,onToggleDirectory:le=>{K(ae=>{const S=new Set(ae);return S.has(le)?S.delete(le):S.add(le),S})},onSelectFile:le=>{s(le.key),oe(ae=>({key:le.key,nonce:ae.nonce+1}))},renderLeading:le=>{const ae=G.get(le.key);return e.jsx(ji,{changeStatus:le.status,auditStatus:ae,renderChangeBadge:S=>e.jsx(js,{status:S})})},renderTrailing:le=>{const ae=G.get(le.key);return ae?e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",ae.additions," -",ae.deletions]}):null},renderListHeader:Ge,aiContent:({slideToDetail:le,fullscreen:ae,toggleFullscreen:S})=>U.length>0&&D?e.jsx(Hd,{walkthroughs:U,repoRoot:U[0]?.repoRoot,fullscreen:ae,onToggleFullscreen:S,onNavigate:V=>{d&&window.requestAnimationFrame(le),D(V)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:se("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Fe,externalSwiperRef:X,onMobileSlideChange:ne,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:a,scrollToKey:O??re.key,scrollToKeyNonce:O==null?re.nonce:j,onDetailScroll:le=>{np(le,me,s),w?.(le.scrollTop)},files:C,activePane:!0,wrap:f,renderStreamBadge:(le,ae)=>{const S=G.get(ae.key);return e.jsx(ji,{changeStatus:le,auditStatus:S,renderChangeBadge:V=>e.jsx(js,{status:V})})},onInsertDiffReference:B,onReferenceCopied:E,insertedReferenceKey:$,copiedReferenceKey:L,onClearAuditRecord:P,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function sp(t){return t.replace(/\/+$/,"")||"/"}function ap(t){return[...new Set(Array.from(t,sp))].sort((n,s)=>n.localeCompare(s))}function op(t){return t==="event-storm"||t==="reconnected"||t==="directory-rescan"||t==="polling-fallback"}function ip(t){let n=null;return{applicableEvents:t.filter(l=>{const d=l.type==="rescan-required"&&!op(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const lp=1400,cp=1200,Jd=44,dp=.7;function Jo(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ri(t){return`termdock:right-sidebar:context-draft-height:${t}:v1`}function up(t){try{const n=window.localStorage.getItem(Ri(t)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Jd?s:null}catch{return null}}function td(t,n){try{n===null?window.localStorage.removeItem(Ri(t)):window.localStorage.setItem(Ri(t),String(n))}catch{}}function Ea(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function fp({value:t,collapsed:n,labels:s,focusRequest:l,insertError:d,autoCollapseAfterSend:c,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:g,onDisable:p,onClear:f,onInsert:k,onInsertAndSend:y}){const[N,I]=o.useState(null),[F,B]=o.useState(!1),[E,$]=o.useState(()=>up(Jo())),L=o.useRef(E),P=o.useRef(null),U=o.useRef(null),D=o.useRef(t),a=o.useRef(null),w=o.useRef(null),O=!!t.trim(),j=t.trim().split(`
7
7
  `)[0]??"",X=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";o.useEffect(()=>()=>{P.current!==null&&window.clearTimeout(P.current),U.current!==null&&window.clearTimeout(U.current)},[]),o.useEffect(()=>{let C=!1;const Z=Jo();return fh().then(ue=>{if(C)return;const Ee=ue.contextDraftHeight?.[Z]??null;td(Z,Ee),L.current=Ee,$(Ee)}).catch(()=>{}),()=>{C=!0}},[]),o.useEffect(()=>{if(l!==void 0&&l>0){const C=a.current;if(!C)return;Ea()||C.focus(),C.setSelectionRange(C.value.length,C.value.length),C.scrollTop=C.scrollHeight}},[l]),o.useEffect(()=>{const C=D.current;D.current=t,!(!n||t.length<=C.length)&&(B(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,B(!1)},cp))},[t,n]),o.useEffect(()=>{if(n)return;const C=a.current;C&&(C.style.height=E!==null?`${E}px`:"")},[t,n,E]),o.useEffect(()=>{if(n)return;const C=a.current;!C||document.activeElement===C||(C.scrollTop=C.scrollHeight)},[t,n]),o.useEffect(()=>{if(n||Ea())return;const C=a.current;!C||document.activeElement===C||(C.focus(),C.setSelectionRange(C.value.length,C.value.length))},[n]);const ne=o.useRef(null);o.useLayoutEffect(()=>{if(!Ea())return;const C=window.visualViewport;if(!C)return;const Z=()=>{const ue=ne.current;if(!ue)return;if(C.height>=window.innerHeight*.75){ue.style.transform="";return}const Ee=ue.getBoundingClientRect(),Ge=Math.round(C.height-Ee.bottom);ue.style.transform=Ge!==0?`translateY(${Ge}px)`:""};return Z(),C.addEventListener("resize",Z),C.addEventListener("scroll",Z),()=>{C.removeEventListener("resize",Z),C.removeEventListener("scroll",Z),ne.current&&(ne.current.style.transform="")}},[n]);const se=C=>{I(C),P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,I(null)},lp)},fe=C=>{m(!1),Ea()&&window.requestAnimationFrame(()=>{const Z=a.current;if(!Z)return;Z.focus();const ue=Z.value.length;Z.setSelectionRange(ue,ue),window.requestAnimationFrame(()=>{Z.setSelectionRange(ue,ue)})})},G=()=>{k(),se("inserted")},J=()=>{O&&(y(),se("sent"))},M=C=>{if(C.key==="Escape"){C.preventDefault(),m(!0);return}C.key!=="Enter"||!C.metaKey&&!C.ctrlKey||(C.preventDefault(),J())},_=C=>{C.preventDefault()},K=C=>{C.preventDefault();const Z=a.current;Z&&(w.current={startY:C.clientY,startHeight:Z.getBoundingClientRect().height},C.currentTarget.setPointerCapture?.(C.pointerId))},re=C=>{const Z=w.current;if(!Z)return;const ue=window.visualViewport?.height??window.innerHeight,Ee=Math.round(Math.min(Math.max(Z.startHeight+(Z.startY-C.clientY),Jd),ue*dp));L.current=Ee,$(Ee)},oe=C=>{const Z=Jo();td(Z,C),hh({contextDraftHeight:{[Z]:C}}).catch(()=>{})},he=()=>{w.current&&(w.current=null,L.current!==null&&oe(L.current))},me=()=>{L.current=null,$(null),oe(null)},je=t.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(t.length)});return n?e.jsx("section",{ref:ne,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:()=>fe(),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(Kh,{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":F?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(F?s.appended:O?j:s.title)})]}),je,e.jsx("button",{type:"button",onClick:J,disabled:!O,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:N==="sent"?e.jsx(bi,{size:12}):e.jsx(Jc,{size:12})})]})}):e.jsxs("section",{ref:ne,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:K,onPointerMove:re,onPointerUp:he,onPointerCancel:he,onDoubleClick:me,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:_,onClick:()=>m(!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(Ms,{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}),je]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:_,onClick:()=>g(!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:_,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(Ut,{size:11})})]}),e.jsx("div",{className:"px-2 pb-2",children:e.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[e.jsx("textarea",{ref:a,value:t,onChange:C=>h(C.target.value),onKeyDown:M,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:_,onClick:f,disabled:!O,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(Ba,{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:_,onClick:G,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[e.jsx(Vh,{size:11}),e.jsx("span",{children:N==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:_,onClick:J,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${X}`,children:[N==="sent"?e.jsx(bi,{size:11}):e.jsx(Jc,{size:11}),e.jsx("span",{children:N==="sent"?s.sent:s.send})]})]})]})})]})}function hp(t,n){const s=n.trim();if(!s)return t;if(!t.trim())return s;const l=t.endsWith(`
8
8
 
9
9
  `)?"":t.endsWith(`
10
10
  `)?`
11
11
  `:`
12
12
 
13
- `;return`${t}${l}${s}`}function mp(t,n){const s=t.trim();return s?n?`${s}\r`:/\s$/.test(t)?t:`${s} `:""}const Ci="termdock:right-sidebar:html-view-mode-by-file:v1";function pp(t){return t==="preview"||t==="source"}function Qd(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(pp)}function Zd(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function rd(t,n){const s=Zd(t,n);return s?tt(Ci,Qd)?.[s]??"source":"source"}function gp(t,n,s){const l=Zd(t,n);if(!l)return;const d=tt(Ci,Qd)??{};xt(Ci,{...d,[l]:s})}function nd(t){try{return new URL(t,location.href).pathname.startsWith("/api/")}catch{return!1}}function Ja(t,n){const[s,l]=o.useState(()=>!!navigator.serviceWorker?.controller);return o.useEffect(()=>{if(!nd(t)||s)return;const d=navigator.serviceWorker,c=()=>l(!!d?.controller);d?.addEventListener("controllerchange",c),c();const h=window.setTimeout(()=>{d?.controller||n?.()},1e4);return()=>{d?.removeEventListener("controllerchange",c),window.clearTimeout(h)}},[t,s,n]),nd(t)&&!s?void 0:t}function Qo(t){const n=Number.isFinite(t)&&t>0?Math.floor(t):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),d=n%60,c=String(l).padStart(2,"0"),h=String(d).padStart(2,"0");return s>0?`${s}:${c}:${h}`:`${c}:${h}`}function bp(t,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(t-n.left)/n.width))*s}const xp=350,vp=12,yp=90;function wp({url:t,onLoadError:n}){const s=Ja(t,n),{t:l}=yt(),d=o.useRef(null),c=o.useRef(null),h=o.useRef(null),m=o.useRef(null),g=o.useRef(!1),p=o.useRef(null),f=o.useRef(null),k=o.useRef(0),y=o.useRef(!1),N=o.useRef(!1),I=o.useRef(!1),F=o.useRef(null),B=o.useRef(null),E=o.useRef(!1),$=o.useRef(1),L=o.useRef(!1),[P,U]=o.useState(0),[D,a]=o.useState(0),[w,O]=o.useState(!1),[j,X]=o.useState(!1),[ne,se]=o.useState(null),[fe,G]=o.useState(!1),[J,M]=o.useState(0),[_,K]=o.useState(!1),[re,oe]=o.useState({width:0,height:0}),he=o.useCallback(()=>{F.current!==null&&(clearTimeout(F.current),F.current=null)},[]),me=o.useCallback(()=>{if(he(),B.current=null,!E.current)return!1;const W=h.current;return W&&(W.playbackRate=$.current),E.current=!1,G(!1),!0},[he]);o.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),f.current!==null&&clearTimeout(f.current),he();const W=h.current;W&&E.current&&(W.playbackRate=$.current)},[he]),o.useEffect(()=>{const W=c.current;if(!W||typeof ResizeObserver>"u")return;const q=new ResizeObserver(([Se])=>{Se&&oe({width:Se.contentRect.width,height:Se.contentRect.height})});return q.observe(W),()=>q.disconnect()},[]),o.useEffect(()=>{const W=()=>K(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const je=o.useCallback((W,q=!1)=>{const Se=h.current;if(!Se)return!1;const Re=Number.isFinite(Se.duration)?Se.duration:W,lt=Math.min(Math.max(W,0),Re);if(a(lt),Math.abs(Se.currentTime-lt)<1/120)return!1;const Qe=Se.fastSeek;return q&&typeof Qe=="function"?Qe.call(Se,lt):Se.currentTime=lt,!0},[]),C=o.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const W=h.current;if(!W||!y.current||N.current||W.seeking)return;const q=I.current;I.current=!1,N.current=je(k.current,!q)}))},[je]),Z=o.useCallback(W=>{const q=m.current,Se=h.current;if(!q||!Se)return;const Re=q.getBoundingClientRect(),lt=bp(W,Re,Se.duration);k.current=lt,se(lt),I.current=!1,C(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,I.current=!0,C()},yp)},[C]),ue=o.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),I.current=!1,N.current=!1,je(k.current)},[je]),Ee=o.useCallback(W=>{const q=h.current;if(!(!q||!Number.isFinite(q.duration)||q.duration<=0)){g.current=!q.paused,q.pause(),y.current=!0,X(!0);try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}Z(W.clientX)}},[Z]),Ge=o.useCallback(()=>{y.current=!1,ue(),X(!1),se(null);const W=h.current;W&&g.current&&!W.ended&&W.play().catch(()=>{}),g.current=!1},[ue]),Fe=o.useCallback(()=>{const W=h.current;if(W){if(L.current){L.current=!1;return}W.paused?W.play().catch(()=>{}):W.pause()}},[]),le=o.useCallback(W=>{const q=h.current;!q||q.paused||W.button!==0||(he(),B.current={id:W.pointerId,x:W.clientX,y:W.clientY},F.current=setTimeout(()=>{F.current=null,$.current=q.playbackRate,q.playbackRate=2,E.current=!0,G(!0)},xp))},[he]),ae=o.useCallback(W=>{const q=B.current;!q||q.id!==W.pointerId||E.current||Math.hypot(W.clientX-q.x,W.clientY-q.y)>vp&&(he(),B.current=null)},[he]),S=o.useCallback(()=>{me()&&(L.current=!0)},[me]);o.useEffect(()=>(window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S),()=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),window.removeEventListener("blur",S)}),[S]);const V=o.useCallback(async()=>{const W=d.current,q=h.current;if(!(!W||!q))try{document.fullscreenElement===W?await document.exitFullscreen():W.requestFullscreen?await W.requestFullscreen():q.webkitEnterFullscreen?.()}catch{q.webkitEnterFullscreen?.()}},[]),ye=o.useCallback(()=>M(W=>(W+90)%360),[]),be=o.useCallback(W=>{const q=h.current;if(!q||!Number.isFinite(q.duration))return;const Se=W.shiftKey?10:5;let Re=null;W.key==="ArrowLeft"?Re=q.currentTime-Se:W.key==="ArrowRight"?Re=q.currentTime+Se:W.key==="Home"?Re=0:W.key==="End"&&(Re=q.duration),Re!==null&&(W.preventDefault(),je(Re))},[je]),Oe=j&&ne!==null?ne:D,ce=P>0?Math.min(1,Math.max(0,Oe/P)):0,Le=(J===90||J===270)&&re.width>0&&re.height>0?{width:`${re.height}px`,height:`${re.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":J,children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:h,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...Le,transform:`translate(-50%, -50%) rotate(${J}deg)`},src:s,preload:"auto",playsInline:!0,onClick:Fe,onPointerDown:le,onPointerMove:ae,onPointerUp:S,onPointerCancel:S,onContextMenu:W=>{E.current&&W.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:W=>a(W.currentTarget.currentTime),onSeeked:W=>{const q=W.currentTarget;if(a(q.currentTime),N.current=!1,!y.current)return;const Se=q.requestVideoFrameCallback;typeof Se=="function"?Se.call(q,()=>{y.current&&C()}):requestAnimationFrame(()=>{y.current&&C()})},onLoadedMetadata:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onDurationChange:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),fe&&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")}),j&&ne!==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:`${ce*100}%`},"data-testid":"file-preview-video-scrub-time",children:Qo(ne)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${dm}`,[um]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Fe,"aria-label":l(w?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(w?"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:w?e.jsx(Yh,{size:14}):e.jsx(Xh,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(P),"aria-valuenow":Math.floor(Oe),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:Ee,onPointerMove:W=>{j&&Z(W.clientX)},onPointerUp:Ge,onPointerCancel:Ge,onKeyDown:be,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:`${ce*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:`${ce*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Qo(Oe)," / ",Qo(P)]}),e.jsx("button",{type:"button",onClick:ye,"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(Pm,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{V()},"aria-label":l(_?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(_?"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:_?e.jsx($m,{size:14}):e.jsx(Nm,{size:14})})]})})]})}function kp(t){const n=Math.max(0,Math.min(100,t.xPercent)),s=Math.max(0,Math.min(100,t.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function Qa({anchor:t,children:n,disabled:s=!1,onClick:l,title:d}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l()},title:d,style:kp(t),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(za,{size:11}),n]})}function Sp(t,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const d=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(d)||d<=0)return null;const c=l.width*d,h=l.height*d,m=s.left+(s.width-c)/2,g=s.top+(s.height-h)/2,p=t-m,f=n-g;if(p<0||f<0||p>c||f>h)return null;const k=p/c*100,y=f/h*100;return{x:l.x+l.width*k/100,y:l.y+l.height*y/100,xPercent:k,yPercent:y}}function jp(t,n,s){const l=[`SVG标注: ${t}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function Rp(t){const n=new DOMParser().parseFromString(t,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const d of Array.from(l.attributes)){const c=d.name.toLowerCase(),h=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function Cp(t,n,s){let l=null;for(const d of Array.from(t.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const h=Number(d.getAttribute("x")),m=Number(d.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const g=Math.hypot(h-n,m-s);(!l||g<l.distance)&&(l={text:c,distance:g})}return l?.text.slice(0,120)}function eu({blobUrl:t,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=o.useRef(null),c=o.useRef(null),[h,m]=o.useState(null),[g,p]=o.useState(null),[f,k]=o.useState(1),[y,N]=o.useState(!1),[I,F]=o.useState(null),B=o.useRef(new Map),E=o.useRef(null),$=o.useRef(!1),L=o.useRef(null),P=o.useRef(f);P.current=f,o.useEffect(()=>{const M=new AbortController;return m(null),p(null),F(null),k(1),fetch(t,{signal:M.signal}).then(_=>_.text()).then(_=>m(Rp(_))).catch(_=>{M.signal.aborted||p(_ instanceof Error?_.message:"SVG preview failed")}),()=>M.abort()},[t]),o.useEffect(()=>{if(!y)return;const M=_=>{_.key==="Escape"&&N(!1)};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[y]),o.useLayoutEffect(()=>{const M=c.current,_=M?.querySelector("[data-svg-document] > svg");if(!M||!_)return;let K;try{K=_.getBBox()}catch{return}if(!K.width||!K.height)return;const re=Math.max(2,Math.min(K.width,K.height)*.025);_.setAttribute("viewBox",`${K.x-re} ${K.y-re} ${K.width+2*re} ${K.height+2*re}`),_.style.width=`${f*100}%`,_.style.height=`${f*100}%`,_.style.minWidth=`${f*100}%`,_.style.minHeight=`${f*100}%`,_.style.display="block"},[h,f]);const U=o.useMemo(()=>I?jp(n,s,I):null,[n,I,s]),D=M=>{if($.current){$.current=!1;return}const _=c.current,K=_?.querySelector("[data-svg-document] > svg"),re=d.current;if(!_||!K||!re)return;const oe=K.viewBox.baseVal,he=Sp(M.clientX,M.clientY,K.getBoundingClientRect(),oe);if(!he)return;const me=re.getBoundingClientRect();F({...he,nearestText:Cp(K,he.x,he.y),stageX:M.clientX-me.left,stageY:M.clientY-me.top,stageXPercent:(M.clientX-me.left)/me.width*100,stageYPercent:(M.clientY-me.top)/me.height*100})},a=M=>Math.max(1,Math.min(12,M)),w=(M,_)=>{const K=a(_),re=M.querySelector("[data-svg-document] > svg");if(!re)return K;const oe=`${K*100}%`;return re.style.width=oe,re.style.height=oe,re.style.minWidth=oe,re.style.minHeight=oe,P.current=K,K},O=(M,_,K,re)=>{const oe=P.current,he=M.getBoundingClientRect(),me=K-he.left,je=re-he.top,C=(M.scrollLeft+me)/oe,Z=(M.scrollTop+je)/oe,ue=w(M,_);return M.scrollLeft=C*ue-me,M.scrollTop=Z*ue-je,ue},j=()=>{const M=Array.from(B.current.values());return M.length>=2?Math.hypot(M[0].x-M[1].x,M[0].y-M[1].y):0},X=M=>{if(M.pointerType==="mouse"&&M.button!==0)return;const _=c.current;_&&(B.current.set(M.pointerId,{x:M.clientX,y:M.clientY}),_.setPointerCapture?.(M.pointerId),B.current.size>=2?(E.current={kind:"pinch",startX:M.clientX,startY:M.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startDistance:j(),startZoom:P.current,moved:!1},$.current=!0):P.current>1&&(E.current={kind:"pan",startX:M.clientX,startY:M.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:P.current,moved:!1}))},ne=M=>{if(!B.current.has(M.pointerId))return;B.current.set(M.pointerId,{x:M.clientX,y:M.clientY});const _=c.current,K=E.current;if(!(!_||!K)){if(B.current.size>=2&&K.kind==="pinch"){const re=j();if(!K.startDistance||!re)return;const oe=a(K.startZoom*re/K.startDistance);if(Math.abs(oe-P.current)<.01)return;const he=Array.from(B.current.values()),me=(he[0].x+he[1].x)/2,je=(he[0].y+he[1].y)/2;K.moved=!0,$.current=!0,O(_,oe,me,je),M.preventDefault();return}if(K.kind==="pan"&&B.current.size===1){const re=M.clientX-K.startX,oe=M.clientY-K.startY;if(!K.moved&&Math.hypot(re,oe)<6)return;K.moved=!0,$.current=!0,_.scrollLeft=K.startScrollLeft-re,_.scrollTop=K.startScrollTop-oe,M.preventDefault()}}},se=M=>{const _=c.current,K=E.current,re=B.current.size===1&&!K?.moved;B.current.delete(M.pointerId);try{_?.releasePointerCapture?.(M.pointerId)}catch{}if(B.current.size===1&&K?.kind==="pinch"){const me=Array.from(B.current.values())[0];E.current=_?{kind:"pan",startX:me.x,startY:me.y,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:P.current,moved:!1}:null;return}if(B.current.size>0||(E.current=null,K?.kind==="pinch"&&k(P.current),!re||$.current))return;const oe=Date.now(),he=L.current;he&&oe-he.time<350&&Math.hypot(M.clientX-he.x,M.clientY-he.y)<24?(L.current=null,$.current=!0,k(me=>me>1?1:2.5)):L.current={time:oe,x:M.clientX,y:M.clientY}},fe=M=>{if(!M.ctrlKey&&!M.metaKey)return;const _=c.current;if(!_)return;M.preventDefault();const K=O(_,P.current*Math.exp(-M.deltaY*.01),M.clientX,M.clientY);k(K)},G=()=>{k(1),P.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},J=e.jsxs("div",{className:y?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:D,onDoubleClick:M=>{M.preventDefault(),k(_=>_>1?1:2.5)},onPointerDown:X,onPointerMove:ne,onPointerUp:se,onPointerCancel:se,onWheel:fe,onScroll:()=>F(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:g?e.jsx("div",{className:"p-4 text-sm text-destructive",children:g}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),I&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:I.stageX,top:I.stageY}}),I&&U&&e.jsx(Qa,{anchor:{xPercent:I.stageXPercent,yPercent:I.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${I.x.toFixed(2)}:${I.y.toFixed(2)}`),F(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:M=>{M.stopPropagation(),G()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(Im,{size:14})}),e.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:M=>{M.stopPropagation(),N(_=>!_)},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:y?e.jsx(Hd,{size:14}):e.jsx(zd,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:I?`SVG (${I.x.toFixed(2)}, ${I.y.toFixed(2)}) · ${I.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?Gr.createPortal(J,document.body):J}function Oa(t){switch(t){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function Np(t,n,s,l){const d=[`电子标注: ${t}`,`视图: ${Oa(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 Mp({blobUrl:t,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:h,interactive3d:m}){const{t:g}=yt(),p=o.useRef(null),f=o.useRef(null),k=o.useRef(null),[y,N]=o.useState(null),[I,F]=o.useState(!1);o.useEffect(()=>(k.current?.abort(),N(null),F(!1),()=>k.current?.abort()),[t,s]);const B=o.useMemo(()=>y?Np(n,s,y,y.inspection):null,[n,y,s]),E=L=>{const P=p.current,U=f.current;if(!P||!U||!U.naturalWidth||!U.naturalHeight)return;const D=P.getBoundingClientRect(),a=U.getBoundingClientRect(),w=Math.min(a.width/U.naturalWidth,a.height/U.naturalHeight),O=U.naturalWidth*w,j=U.naturalHeight*w,X=a.left+(a.width-O)/2,ne=a.top+(a.height-j)/2,se=L.clientX-X,fe=L.clientY-ne;if(se<0||fe<0||se>O||fe>j)return;const G={xPercent:Math.max(0,Math.min(100,se/O*100)),yPercent:Math.max(0,Math.min(100,fe/j*100)),stageXPercent:(L.clientX-D.left)/D.width*100,stageYPercent:(L.clientY-D.top)/D.height*100,inspecting:l&&s!=="pcb-3d"};if(N(G),k.current?.abort(),!G.inspecting)return;const J=new AbortController;k.current=J,mh(n,s,G.xPercent,G.yPercent,J.signal).then(M=>N(_=>_===G?{..._,inspection:M,inspecting:!1}:_)).catch(()=>{J.signal.aborted||N(M=>M===G?{...M,inspection:{available:!1},inspecting:!1}:M)})},$=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:$.map(L=>e.jsx("button",{type:"button",onClick:()=>d(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Oa(L)},L))}),e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:g("rightSidebar.edaRefresh"),"aria-label":g("rightSidebar.edaRefresh"),children:e.jsx(vi,{size:13})})]}),l&&m?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:m}):null,l?s==="pcb-3d"?m?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:E,onKeyDown:L=>{L.key!=="Enter"&&L.key!==" "||(L.preventDefault(),N({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:g("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:t,alt:`${n} ${Oa(s)}`,onLoad:()=>F(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${I?"opacity-100":"opacity-0"}`}),y&&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:`${y.stageXPercent}%`,top:`${y.stageYPercent}%`}}),y&&B&&e.jsx(Qa,{anchor:{xPercent:y.stageXPercent,yPercent:y.stageYPercent},disabled:y.inspecting,title:g("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(B,`eda:${s}:${y.xPercent.toFixed(1)}:${y.yPercent.toFixed(1)}`,{snapshot:f.current?zm(f.current,y):Promise.resolve(null)}),N(null)},children:g("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:y?y.inspecting?g("rightSidebar.edaInspecting"):y.inspection?.available?g("rightSidebar.edaPickedBoardPosition",{x:y.inspection.xMm?.toFixed(2)??"—",y:y.inspection.yMm?.toFixed(2)??"—",object:y.inspection.nearest?.label??g("rightSidebar.edaNoNearbyObject")}):g("rightSidebar.edaPickedPosition",{x:y.xPercent.toFixed(1),y:y.yPercent.toFixed(1)}):g("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(eu,{blobUrl:t,filePath:n,viewLabel:Oa(s),onInsertAnnotation:c})})]})}function $p(t){const n=[];let s=[],l="",d=!1;for(let c=0;c<t.length;c+=1){const h=t[c];d?h==='"'&&t[c+1]==='"'?(l+='"',c+=1):h==='"'?d=!1:l+=h:h==='"'?d=!0:h===","?(s.push(l),l=""):h===`
13
+ `;return`${t}${l}${s}`}function mp(t,n){const s=t.trim();return s?n?`${s}\r`:/\s$/.test(t)?t:`${s} `:""}const Ci="termdock:right-sidebar:html-view-mode-by-file:v1";function pp(t){return t==="preview"||t==="source"}function Qd(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(pp)}function Zd(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function rd(t,n){const s=Zd(t,n);return s?tt(Ci,Qd)?.[s]??"source":"source"}function gp(t,n,s){const l=Zd(t,n);if(!l)return;const d=tt(Ci,Qd)??{};xt(Ci,{...d,[l]:s})}function nd(t){try{return new URL(t,location.href).pathname.startsWith("/api/")}catch{return!1}}function Ja(t,n){const[s,l]=o.useState(()=>!!navigator.serviceWorker?.controller);return o.useEffect(()=>{if(!nd(t)||s)return;const d=navigator.serviceWorker,c=()=>l(!!d?.controller);d?.addEventListener("controllerchange",c),c();const h=window.setTimeout(()=>{d?.controller||n?.()},1e4);return()=>{d?.removeEventListener("controllerchange",c),window.clearTimeout(h)}},[t,s,n]),nd(t)&&!s?void 0:t}function Qo(t){const n=Number.isFinite(t)&&t>0?Math.floor(t):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),d=n%60,c=String(l).padStart(2,"0"),h=String(d).padStart(2,"0");return s>0?`${s}:${c}:${h}`:`${c}:${h}`}function bp(t,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(t-n.left)/n.width))*s}const xp=350,vp=12,yp=90;function wp({url:t,onLoadError:n}){const s=Ja(t,n),{t:l}=yt(),d=o.useRef(null),c=o.useRef(null),h=o.useRef(null),m=o.useRef(null),g=o.useRef(!1),p=o.useRef(null),f=o.useRef(null),k=o.useRef(0),y=o.useRef(!1),N=o.useRef(!1),I=o.useRef(!1),F=o.useRef(null),B=o.useRef(null),E=o.useRef(!1),$=o.useRef(1),L=o.useRef(!1),[P,U]=o.useState(0),[D,a]=o.useState(0),[w,O]=o.useState(!1),[j,X]=o.useState(!1),[ne,se]=o.useState(null),[fe,G]=o.useState(!1),[J,M]=o.useState(0),[_,K]=o.useState(!1),[re,oe]=o.useState({width:0,height:0}),he=o.useCallback(()=>{F.current!==null&&(clearTimeout(F.current),F.current=null)},[]),me=o.useCallback(()=>{if(he(),B.current=null,!E.current)return!1;const W=h.current;return W&&(W.playbackRate=$.current),E.current=!1,G(!1),!0},[he]);o.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),f.current!==null&&clearTimeout(f.current),he();const W=h.current;W&&E.current&&(W.playbackRate=$.current)},[he]),o.useEffect(()=>{const W=c.current;if(!W||typeof ResizeObserver>"u")return;const q=new ResizeObserver(([Se])=>{Se&&oe({width:Se.contentRect.width,height:Se.contentRect.height})});return q.observe(W),()=>q.disconnect()},[]),o.useEffect(()=>{const W=()=>K(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const je=o.useCallback((W,q=!1)=>{const Se=h.current;if(!Se)return!1;const Re=Number.isFinite(Se.duration)?Se.duration:W,lt=Math.min(Math.max(W,0),Re);if(a(lt),Math.abs(Se.currentTime-lt)<1/120)return!1;const Qe=Se.fastSeek;return q&&typeof Qe=="function"?Qe.call(Se,lt):Se.currentTime=lt,!0},[]),C=o.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const W=h.current;if(!W||!y.current||N.current||W.seeking)return;const q=I.current;I.current=!1,N.current=je(k.current,!q)}))},[je]),Z=o.useCallback(W=>{const q=m.current,Se=h.current;if(!q||!Se)return;const Re=q.getBoundingClientRect(),lt=bp(W,Re,Se.duration);k.current=lt,se(lt),I.current=!1,C(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,I.current=!0,C()},yp)},[C]),ue=o.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),I.current=!1,N.current=!1,je(k.current)},[je]),Ee=o.useCallback(W=>{const q=h.current;if(!(!q||!Number.isFinite(q.duration)||q.duration<=0)){g.current=!q.paused,q.pause(),y.current=!0,X(!0);try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}Z(W.clientX)}},[Z]),Ge=o.useCallback(()=>{y.current=!1,ue(),X(!1),se(null);const W=h.current;W&&g.current&&!W.ended&&W.play().catch(()=>{}),g.current=!1},[ue]),Fe=o.useCallback(()=>{const W=h.current;if(W){if(L.current){L.current=!1;return}W.paused?W.play().catch(()=>{}):W.pause()}},[]),le=o.useCallback(W=>{const q=h.current;!q||q.paused||W.button!==0||(he(),B.current={id:W.pointerId,x:W.clientX,y:W.clientY},F.current=setTimeout(()=>{F.current=null,$.current=q.playbackRate,q.playbackRate=2,E.current=!0,G(!0)},xp))},[he]),ae=o.useCallback(W=>{const q=B.current;!q||q.id!==W.pointerId||E.current||Math.hypot(W.clientX-q.x,W.clientY-q.y)>vp&&(he(),B.current=null)},[he]),S=o.useCallback(()=>{me()&&(L.current=!0)},[me]);o.useEffect(()=>(window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S),()=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),window.removeEventListener("blur",S)}),[S]);const V=o.useCallback(async()=>{const W=d.current,q=h.current;if(!(!W||!q))try{document.fullscreenElement===W?await document.exitFullscreen():W.requestFullscreen?await W.requestFullscreen():q.webkitEnterFullscreen?.()}catch{q.webkitEnterFullscreen?.()}},[]),ye=o.useCallback(()=>M(W=>(W+90)%360),[]),be=o.useCallback(W=>{const q=h.current;if(!q||!Number.isFinite(q.duration))return;const Se=W.shiftKey?10:5;let Re=null;W.key==="ArrowLeft"?Re=q.currentTime-Se:W.key==="ArrowRight"?Re=q.currentTime+Se:W.key==="Home"?Re=0:W.key==="End"&&(Re=q.duration),Re!==null&&(W.preventDefault(),je(Re))},[je]),Oe=j&&ne!==null?ne:D,ce=P>0?Math.min(1,Math.max(0,Oe/P)):0,Le=(J===90||J===270)&&re.width>0&&re.height>0?{width:`${re.height}px`,height:`${re.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":J,children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:h,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...Le,transform:`translate(-50%, -50%) rotate(${J}deg)`},src:s,preload:"auto",playsInline:!0,onClick:Fe,onPointerDown:le,onPointerMove:ae,onPointerUp:S,onPointerCancel:S,onContextMenu:W=>{E.current&&W.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:W=>a(W.currentTarget.currentTime),onSeeked:W=>{const q=W.currentTarget;if(a(q.currentTime),N.current=!1,!y.current)return;const Se=q.requestVideoFrameCallback;typeof Se=="function"?Se.call(q,()=>{y.current&&C()}):requestAnimationFrame(()=>{y.current&&C()})},onLoadedMetadata:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onDurationChange:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),fe&&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")}),j&&ne!==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:`${ce*100}%`},"data-testid":"file-preview-video-scrub-time",children:Qo(ne)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${dm}`,[um]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Fe,"aria-label":l(w?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(w?"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:w?e.jsx(Yh,{size:14}):e.jsx(Xh,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(P),"aria-valuenow":Math.floor(Oe),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:Ee,onPointerMove:W=>{j&&Z(W.clientX)},onPointerUp:Ge,onPointerCancel:Ge,onKeyDown:be,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:`${ce*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:`${ce*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Qo(Oe)," / ",Qo(P)]}),e.jsx("button",{type:"button",onClick:ye,"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(Pm,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{V()},"aria-label":l(_?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(_?"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:_?e.jsx($m,{size:14}):e.jsx(Nm,{size:14})})]})})]})}function kp(t){const n=Math.max(0,Math.min(100,t.xPercent)),s=Math.max(0,Math.min(100,t.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function Qa({anchor:t,children:n,disabled:s=!1,onClick:l,title:d}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l()},title:d,style:kp(t),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(za,{size:11}),n]})}function Sp(t,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const d=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(d)||d<=0)return null;const c=l.width*d,h=l.height*d,m=s.left+(s.width-c)/2,g=s.top+(s.height-h)/2,p=t-m,f=n-g;if(p<0||f<0||p>c||f>h)return null;const k=p/c*100,y=f/h*100;return{x:l.x+l.width*k/100,y:l.y+l.height*y/100,xPercent:k,yPercent:y}}function jp(t,n,s){const l=[`SVG标注: ${t}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function Rp(t){const n=new DOMParser().parseFromString(t,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const d of Array.from(l.attributes)){const c=d.name.toLowerCase(),h=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function Cp(t,n,s){let l=null;for(const d of Array.from(t.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const h=Number(d.getAttribute("x")),m=Number(d.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const g=Math.hypot(h-n,m-s);(!l||g<l.distance)&&(l={text:c,distance:g})}return l?.text.slice(0,120)}function eu({blobUrl:t,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=o.useRef(null),c=o.useRef(null),[h,m]=o.useState(null),[g,p]=o.useState(null),[f,k]=o.useState(1),[y,N]=o.useState(!1),[I,F]=o.useState(null),B=o.useRef(new Map),E=o.useRef(null),$=o.useRef(!1),L=o.useRef(null),P=o.useRef(f);P.current=f,o.useEffect(()=>{const M=new AbortController;return m(null),p(null),F(null),k(1),fetch(t,{signal:M.signal}).then(_=>_.text()).then(_=>m(Rp(_))).catch(_=>{M.signal.aborted||p(_ instanceof Error?_.message:"SVG preview failed")}),()=>M.abort()},[t]),o.useEffect(()=>{if(!y)return;const M=_=>{_.key==="Escape"&&N(!1)};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[y]),o.useLayoutEffect(()=>{const M=c.current,_=M?.querySelector("[data-svg-document] > svg");if(!M||!_)return;let K;try{K=_.getBBox()}catch{return}if(!K.width||!K.height)return;const re=Math.max(2,Math.min(K.width,K.height)*.025);_.setAttribute("viewBox",`${K.x-re} ${K.y-re} ${K.width+2*re} ${K.height+2*re}`),_.style.width=`${f*100}%`,_.style.height=`${f*100}%`,_.style.minWidth=`${f*100}%`,_.style.minHeight=`${f*100}%`,_.style.display="block"},[h,f]);const U=o.useMemo(()=>I?jp(n,s,I):null,[n,I,s]),D=M=>{if($.current){$.current=!1;return}const _=c.current,K=_?.querySelector("[data-svg-document] > svg"),re=d.current;if(!_||!K||!re)return;const oe=K.viewBox.baseVal,he=Sp(M.clientX,M.clientY,K.getBoundingClientRect(),oe);if(!he)return;const me=re.getBoundingClientRect();F({...he,nearestText:Cp(K,he.x,he.y),stageX:M.clientX-me.left,stageY:M.clientY-me.top,stageXPercent:(M.clientX-me.left)/me.width*100,stageYPercent:(M.clientY-me.top)/me.height*100})},a=M=>Math.max(1,Math.min(12,M)),w=(M,_)=>{const K=a(_),re=M.querySelector("[data-svg-document] > svg");if(!re)return K;const oe=`${K*100}%`;return re.style.width=oe,re.style.height=oe,re.style.minWidth=oe,re.style.minHeight=oe,P.current=K,K},O=(M,_,K,re)=>{const oe=P.current,he=M.getBoundingClientRect(),me=K-he.left,je=re-he.top,C=(M.scrollLeft+me)/oe,Z=(M.scrollTop+je)/oe,ue=w(M,_);return M.scrollLeft=C*ue-me,M.scrollTop=Z*ue-je,ue},j=()=>{const M=Array.from(B.current.values());return M.length>=2?Math.hypot(M[0].x-M[1].x,M[0].y-M[1].y):0},X=M=>{if(M.pointerType==="mouse"&&M.button!==0)return;const _=c.current;_&&(B.current.set(M.pointerId,{x:M.clientX,y:M.clientY}),_.setPointerCapture?.(M.pointerId),B.current.size>=2?(E.current={kind:"pinch",startX:M.clientX,startY:M.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startDistance:j(),startZoom:P.current,moved:!1},$.current=!0):P.current>1&&(E.current={kind:"pan",startX:M.clientX,startY:M.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:P.current,moved:!1}))},ne=M=>{if(!B.current.has(M.pointerId))return;B.current.set(M.pointerId,{x:M.clientX,y:M.clientY});const _=c.current,K=E.current;if(!(!_||!K)){if(B.current.size>=2&&K.kind==="pinch"){const re=j();if(!K.startDistance||!re)return;const oe=a(K.startZoom*re/K.startDistance);if(Math.abs(oe-P.current)<.01)return;const he=Array.from(B.current.values()),me=(he[0].x+he[1].x)/2,je=(he[0].y+he[1].y)/2;K.moved=!0,$.current=!0,O(_,oe,me,je),M.preventDefault();return}if(K.kind==="pan"&&B.current.size===1){const re=M.clientX-K.startX,oe=M.clientY-K.startY;if(!K.moved&&Math.hypot(re,oe)<6)return;K.moved=!0,$.current=!0,_.scrollLeft=K.startScrollLeft-re,_.scrollTop=K.startScrollTop-oe,M.preventDefault()}}},se=M=>{const _=c.current,K=E.current,re=B.current.size===1&&!K?.moved;B.current.delete(M.pointerId);try{_?.releasePointerCapture?.(M.pointerId)}catch{}if(B.current.size===1&&K?.kind==="pinch"){const me=Array.from(B.current.values())[0];E.current=_?{kind:"pan",startX:me.x,startY:me.y,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:P.current,moved:!1}:null;return}if(B.current.size>0||(E.current=null,K?.kind==="pinch"&&k(P.current),!re||$.current))return;const oe=Date.now(),he=L.current;he&&oe-he.time<350&&Math.hypot(M.clientX-he.x,M.clientY-he.y)<24?(L.current=null,$.current=!0,k(me=>me>1?1:2.5)):L.current={time:oe,x:M.clientX,y:M.clientY}},fe=M=>{if(!M.ctrlKey&&!M.metaKey)return;const _=c.current;if(!_)return;M.preventDefault();const K=O(_,P.current*Math.exp(-M.deltaY*.01),M.clientX,M.clientY);k(K)},G=()=>{k(1),P.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},J=e.jsxs("div",{className:y?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:D,onDoubleClick:M=>{M.preventDefault(),k(_=>_>1?1:2.5)},onPointerDown:X,onPointerMove:ne,onPointerUp:se,onPointerCancel:se,onWheel:fe,onScroll:()=>F(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:g?e.jsx("div",{className:"p-4 text-sm text-destructive",children:g}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),I&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:I.stageX,top:I.stageY}}),I&&U&&e.jsx(Qa,{anchor:{xPercent:I.stageXPercent,yPercent:I.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${I.x.toFixed(2)}:${I.y.toFixed(2)}`),F(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:M=>{M.stopPropagation(),G()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(Im,{size:14})}),e.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:M=>{M.stopPropagation(),N(_=>!_)},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:y?e.jsx(zd,{size:14}):e.jsx(Ud,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:I?`SVG (${I.x.toFixed(2)}, ${I.y.toFixed(2)}) · ${I.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?Gr.createPortal(J,document.body):J}function Oa(t){switch(t){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function Np(t,n,s,l){const d=[`电子标注: ${t}`,`视图: ${Oa(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 Mp({blobUrl:t,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:h,interactive3d:m}){const{t:g}=yt(),p=o.useRef(null),f=o.useRef(null),k=o.useRef(null),[y,N]=o.useState(null),[I,F]=o.useState(!1);o.useEffect(()=>(k.current?.abort(),N(null),F(!1),()=>k.current?.abort()),[t,s]);const B=o.useMemo(()=>y?Np(n,s,y,y.inspection):null,[n,y,s]),E=L=>{const P=p.current,U=f.current;if(!P||!U||!U.naturalWidth||!U.naturalHeight)return;const D=P.getBoundingClientRect(),a=U.getBoundingClientRect(),w=Math.min(a.width/U.naturalWidth,a.height/U.naturalHeight),O=U.naturalWidth*w,j=U.naturalHeight*w,X=a.left+(a.width-O)/2,ne=a.top+(a.height-j)/2,se=L.clientX-X,fe=L.clientY-ne;if(se<0||fe<0||se>O||fe>j)return;const G={xPercent:Math.max(0,Math.min(100,se/O*100)),yPercent:Math.max(0,Math.min(100,fe/j*100)),stageXPercent:(L.clientX-D.left)/D.width*100,stageYPercent:(L.clientY-D.top)/D.height*100,inspecting:l&&s!=="pcb-3d"};if(N(G),k.current?.abort(),!G.inspecting)return;const J=new AbortController;k.current=J,mh(n,s,G.xPercent,G.yPercent,J.signal).then(M=>N(_=>_===G?{..._,inspection:M,inspecting:!1}:_)).catch(()=>{J.signal.aborted||N(M=>M===G?{...M,inspection:{available:!1},inspecting:!1}:M)})},$=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:$.map(L=>e.jsx("button",{type:"button",onClick:()=>d(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Oa(L)},L))}),e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:g("rightSidebar.edaRefresh"),"aria-label":g("rightSidebar.edaRefresh"),children:e.jsx(vi,{size:13})})]}),l&&m?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:m}):null,l?s==="pcb-3d"?m?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:E,onKeyDown:L=>{L.key!=="Enter"&&L.key!==" "||(L.preventDefault(),N({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:g("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:t,alt:`${n} ${Oa(s)}`,onLoad:()=>F(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${I?"opacity-100":"opacity-0"}`}),y&&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:`${y.stageXPercent}%`,top:`${y.stageYPercent}%`}}),y&&B&&e.jsx(Qa,{anchor:{xPercent:y.stageXPercent,yPercent:y.stageYPercent},disabled:y.inspecting,title:g("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(B,`eda:${s}:${y.xPercent.toFixed(1)}:${y.yPercent.toFixed(1)}`,{snapshot:f.current?zm(f.current,y):Promise.resolve(null)}),N(null)},children:g("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:y?y.inspecting?g("rightSidebar.edaInspecting"):y.inspection?.available?g("rightSidebar.edaPickedBoardPosition",{x:y.inspection.xMm?.toFixed(2)??"—",y:y.inspection.yMm?.toFixed(2)??"—",object:y.inspection.nearest?.label??g("rightSidebar.edaNoNearbyObject")}):g("rightSidebar.edaPickedPosition",{x:y.xPercent.toFixed(1),y:y.yPercent.toFixed(1)}):g("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(eu,{blobUrl:t,filePath:n,viewLabel:Oa(s),onInsertAnnotation:c})})]})}function $p(t){const n=[];let s=[],l="",d=!1;for(let c=0;c<t.length;c+=1){const h=t[c];d?h==='"'&&t[c+1]==='"'?(l+='"',c+=1):h==='"'?d=!1:l+=h:h==='"'?d=!0:h===","?(s.push(l),l=""):h===`
14
14
  `?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=h}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function Ep(t,n,s,l,d){const c=n[d]||`第${d+1}列`,h=s[d]??"",m=n.map((g,p)=>`${g||`第${p+1}列`}=${s[p]??""}`).join(";");return`"表格标注: ${t} / 数据行: ${l+1} / 列: ${c} / 值: ${h} / 记录: ${m}"`}function Lp({content:t,filePath:n,onInsertAnnotation:s}){const{t:l}=yt(),d=o.useMemo(()=>$p(t),[t]),c=d[0]??[],h=d.slice(1),m=o.useRef(null),[g,p]=o.useState(null),f=g?h[g.row]:null,k=g&&f?Ep(n,c,f,g.row+1,g.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:m,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((y,N)=>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:y||l("rightSidebar.csvUnnamedColumn",{index:N+1})},`${y}:${N}`))]})}),e.jsx("tbody",{children:h.map((y,N)=>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:N+1}),c.map((I,F)=>{const B=g?.row===N&&g.column===F;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${B?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:E=>{const $=m.current?.getBoundingClientRect(),L=E.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const P=E.clientX||L.left+L.width/2,U=E.clientY||L.top+L.height/2;p({row:N,column:F,xPercent:(P-$.left)/$.width*100,yPercent:(U-$.top)/$.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:y[F]||" "})},`cell:${N}:${F}`)})]},`row:${N}`))})]})}),g&&k&&e.jsx(Qa,{anchor:{xPercent:g.xPercent,yPercent:g.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(k,`csv:${n}:${g.row+1}:${g.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:g&&f?l("rightSidebar.csvSelectedCell",{row:g.row+1,column:c[g.column]||g.column+1}):l("rightSidebar.csvPickHint",{rows:h.length,columns:c.length})})})]})}function Wn(t,n){let s=t;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function Ap(t,n){const s=JSON.parse(t),l=Wn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(Wn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Wn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Wn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=Wn(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=Wn(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(h)?h.length:0)}]}function Pp(t,n){return`"KiCad项目标注: ${t} / 项: ${n.label} / 值: ${n.value}"`}function Tp({content:t,filePath:n,localState:s,onInsertAnnotation:l}){const{t:d}=yt(),c=o.useRef(null),[h,m]=o.useState(null),g=o.useMemo(()=>{try{return{items:Ap(t,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[t,s]),p=h===null?null:g.items[h.index];return g.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:t}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:d("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[e.jsx("div",{className:"divide-y divide-border/15",children:g.items.map((f,k)=>e.jsxs("button",{type:"button",onClick:y=>{const N=c.current?.getBoundingClientRect(),I=y.currentTarget.getBoundingClientRect();if(!N?.width||!N.height)return;const F=y.clientX||I.left+I.width/2,B=y.clientY||I.top+I.height/2;m({index:k,xPercent:(F-N.left)/N.width*100,yPercent:(B-N.top)/N.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${h?.index===k?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:f.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:f.value})]},f.label))}),e.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:d("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:t})]})]}),p&&h&&e.jsx(Qa,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(Pp(n,p),`kicad-project:${n}:${p.label}`),m(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 Ip=`/** ES Module Shims Wasm @version 2.8.4 */
15
15
  (function () {
16
16
 
@@ -1634,13 +1634,13 @@ function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
1634
1634
  }
1635
1635
  `,La="/api/terminal/fs/preview/",Fp=8*1024*1024,_p=32*1024*1024,Bp=128,Op="data:,";function Nt(t){throw new Error(t)}function Up(t){return JSON.stringify(t).replace(/</g,"\\u003c")}async function sd(t,n,s){let l="",d=0;for(const c of t.matchAll(n))l+=t.slice(d,c.index)+await s(c),d=c.index+c[0].length;return l+t.slice(d)}async function tu(t,n){const s=n.origin??location.origin,l=new URL(t,s);(l.origin!==s||!gs(l.pathname)?.startsWith(La))&&Nt("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,h=[],m=G=>{!h.includes(G)&&h.length<20&&h.push(G)},g=new Set,p=[],f=new Set,k=new Map,y=new Map;let N=0,I=!1;const F=new Set,B=()=>{I=!0;for(const G of[...F])G();g.clear(),p.length=0};async function E(G){G.ok||Nt(`预览资源读取失败(${G.status})`);const J=G.body?.getReader(),M=[];let _=0;try{if(J)for(;;){const oe=await J.read();if(oe.done)break;_+=oe.value.byteLength,N+=oe.value.byteLength,(_>Fp||N>_p)&&Nt("预览资源超出大小限制"),M.push(oe.value)}}catch(oe){throw await J?.cancel().catch(()=>{}),oe}finally{J?.releaseLock()}const K=new Uint8Array(_);let re=0;for(const oe of M)K.set(oe,re),re+=oe.length;return{bytes:K,type:G.headers.get("content-type")??"application/octet-stream",status:G.status}}let $=l,L;for(let G=0;G<4;G++){const J=await n.fetch($.pathname+$.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(J.status)){L=J;break}const M=J.headers.get("location");await J.body?.cancel(),M||Nt("预览重定向缺少目标");const _=new URL(M,$);(_.origin!==s||!gs(_.pathname)?.startsWith(La))&&Nt("预览重定向越出文件范围"),$=_}L||Nt("预览重定向次数过多");const P=gs($.pathname),U=P.slice(La.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||Nt("服务未提供有效的预览资源授权");const D=gs(l.pathname).slice(La.length).split("/");/^[a-f0-9]{32}$/.test(D[0])&&D.shift(),D.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&Nt("预览重定向改变了文件范围");const a=P.endsWith("/")?P:P.slice(0,P.lastIndexOf("/")+1),w=new URL($.pathname.endsWith("/")?$.pathname:$.pathname.slice(0,$.pathname.lastIndexOf("/")+1),s);function O(G,J){const M=new URL(G,J);return M.origin!==s?null:(gs(M.pathname)?.startsWith(a)||Nt("已阻止预览访问目录之外的资源"),M)}function j(G){const J=new URL(G,c);(J.origin!==new URL(c).origin||!J.pathname.startsWith(new URL(c).pathname))&&Nt("已阻止预览访问服务接口或目录之外的资源");const M=J.pathname.slice(new URL(c).pathname.length)+J.search;return O(M,w)??Nt("预览资源无效")}function X(G){const J=G.pathname+G.search,M=k.get(J);if(M)return M;if(I||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(k.size>=Bp)return Promise.reject(new Error("预览资源数量超出限制"));const _=n.fetch(J,{signal:n.signal,redirect:"manual"}).then(E);return k.set(J,_),_}function ne(G,J){I&&Nt("预览已关闭");const M=`termdock-resource-${d}-${p.length}`;return p.push({token:M,data:G,type:J}),g.add(M),M}async function se(G,J,M,_=new Set){if(!G||G.startsWith("#")||/^data:(?:image|font)\//i.test(G)&&M==="resource")return G;try{const K=O(G,J);if(!K){const je=new URL(G,J);return(je.protocol!=="https:"||je.username||je.password||je.origin===new URL(c).origin)&&Nt("已阻止不安全的外部资源"),f.add(je.origin),je.href}const re=`${M}:${K.href}`;(_.has(re)||_.size>=8)&&Nt("预览资源存在循环或过深引用");const oe=y.get(re);if(oe)return oe;const he=new Set(_);he.add(re);const me=(async()=>{const je=await X(K);return M==="css"?ne(await fe(new TextDecoder().decode(je.bytes),K,he),"text/css"):M==="script"?ne(je.bytes,"text/javascript"):ne(je.bytes,je.type)})();return y.set(re,me),await me}catch(K){return m(K instanceof Error?K.message:"部分预览资源未能加载"),Op}}async function fe(G,J,M){return G=await sd(G,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async _=>`@import url("${await se(_[1],J,"css",M)}")${_[2]};`),sd(G,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async _=>{const K=(_[1]??_[2]??_[3]).trim();return g.has(K)?_[0]:`url("${await se(K,J,"resource",M)}")`})}try{const G=await E(L),J=ne(Ip,"text/javascript"),M=new DOMParser().parseFromString(new TextDecoder().decode(G.bytes),"text/html");M.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(C=>C.remove());for(const C of M.querySelectorAll("*")){if(C.removeAttribute("ping"),C.removeAttribute("srcdoc"),C.hasAttribute("style")&&C.setAttribute("style",await fe(C.getAttribute("style"),$,new Set)),C.tagName==="STYLE"&&(C.textContent=await fe(C.textContent??"",$,new Set)),C.tagName==="A"||C.tagName==="AREA"){const Z=C.getAttribute("href");try{if(Z&&!Z.startsWith("#")){const ue=O(Z,$);if(ue)C.setAttribute("href",new URL(ue.pathname.slice(w.pathname.length)+ue.search+ue.hash,c).href);else{const Ee=new URL(Z,$);if(Ee.protocol!=="https:"){C.removeAttribute("href");continue}f.add(Ee.origin),C.setAttribute("href",Ee.href)}}}catch(ue){C.removeAttribute("href"),m(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const Z of["data","manifest"])C.removeAttribute(Z);if(C.tagName==="SCRIPT"&&C.getAttribute("type")==="module"){C.setAttribute("type","module-shim");const Z=C.getAttribute("src");if(Z){const ue=O(Z,$);if(ue)C.setAttribute("src",new URL(ue.pathname.slice(w.pathname.length)+ue.search,c).href);else{const Ee=new URL(Z,$);if(Ee.protocol!=="https:"){C.remove();continue}f.add(Ee.origin),C.setAttribute("src",Ee.href)}}continue}if(C.tagName==="SCRIPT"&&C.getAttribute("type")==="importmap"){C.setAttribute("type","importmap-shim");continue}if(C.tagName==="LINK"){const Z=(C.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(Z)){C.remove();continue}const ue=C.getAttribute("href");ue&&C.setAttribute("href",await se(ue,$,Z==="stylesheet"?"css":"resource"))}if(C.hasAttribute("src")&&C.setAttribute("src",await se(C.getAttribute("src"),$,C.tagName==="SCRIPT"?"script":"resource")),C.hasAttribute("poster")&&C.setAttribute("poster",await se(C.getAttribute("poster"),$,"resource")),C.hasAttribute("srcset")){const Z=C.getAttribute("srcset");/data:/i.test(Z)?(C.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):C.setAttribute("srcset",(await Promise.all(Z.split(",").map(async ue=>{const[Ee,...Ge]=ue.trim().split(/\s+/);return`${await se(Ee,$,"resource")} ${Ge.join(" ")}`}))).join(", "))}C.setAttribute("referrerpolicy","no-referrer"),C.removeAttribute("integrity"),C.removeAttribute("crossorigin")}const _=[...f].join(" "),K=M.createElement("meta");K.httpEquiv="Content-Security-Policy",K.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${_}; style-src 'unsafe-inline' blob: ${_}; img-src blob: data: ${_}; font-src blob: data: ${_}; media-src blob: data: ${_}; connect-src blob: ${_} ${[...f].map(C=>C.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const re=M.createElement("base");re.href=c;const oe=M.createElement("meta");oe.name="referrer",oe.content="no-referrer";const he=M.createElement("script");he.textContent=Dp+`
1636
1636
  installPreviewRuntime(`+[d,c,[...f],J].map(Up).join(",")+");";const me=M.createElement("script");me.src=J,M.head.prepend(K,oe,re,he,me);const je=`<!doctype html>
1637
- `+M.documentElement.outerHTML;return{html:je,shellUrl:`/preview-shell.html#${d}`,errors:h,attach(C,Z){const ue=new Set,Ee=Fe=>{if(Fe.source!==C.contentWindow||Fe.data?.capability!==d)return;if(Fe.data.type==="preview-ready"){C.contentWindow?.postMessage({type:"preview-init",capability:d,html:je,resources:p},"*");return}if(Fe.data.type==="preview-error"){Z("部分动态内容被安全预览限制");return}if(Fe.data.type==="preview-navigate"){(async()=>{const ae=j(String(Fe.data.url)),S=await tu(ae.pathname+ae.search,n);if(I){S.dispose();return}const V=S.attach(C,Z);F.add(()=>{V(),S.dispose()}),C.src=S.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ae=>Z(ae instanceof Error?ae.message:"无法打开预览页面"));return}if(Fe.data.type==="preview-external"){try{const ae=new URL(String(Fe.data.url));ae.protocol==="https:"&&f.has(ae.origin)&&window.open(ae.href,"_blank","noopener,noreferrer")}catch{}return}if(Fe.data.type!=="preview-fetch"||Fe.ports.length!==1)return;const le=Fe.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(Fe.data.method)){le.postMessage({error:"预览仅允许读取已授权目录资源"}),le.close();return}ue.add(le),(async()=>{const ae=j(String(Fe.data.url)),S=await X(ae);if(!ue.has(le)||I)return;const V=Fe.data.method==="HEAD"?new Uint8Array:S.bytes.slice();le.postMessage({status:S.status,headers:{"content-type":S.type},data:V.buffer},[V.buffer])})().catch(()=>{le.postMessage({error:"预览资源不在授权范围或无法加载"}),Z("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(le),le.close()})};window.addEventListener("message",Ee);const Ge=()=>{window.removeEventListener("message",Ee);for(const Fe of ue)Fe.close();ue.clear(),F.delete(Ge)};return F.add(Ge),Ge},dispose:B}}catch(G){throw B(),G}}const Hp=o.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const h=o.useRef(null),[m,g]=o.useState(null),[p,f]=o.useState(),[k,y]=o.useState("");o.useEffect(()=>{const P=new AbortController;let U;return f(void 0),y(""),(async()=>{const D=await ph();if(U=await tu(n,{fetch:(a,w)=>D.fetch(a,w),signal:P.signal}),P.signal.aborted){U.dispose();return}f(U),U.errors.length&&y(U.errors.join(";"))})().catch(D=>{P.signal.aborted||y(D instanceof Error?D.message:"安全预览加载失败")}),()=>{P.abort(),U?.dispose()}},[n]),o.useEffect(()=>{if(!(!p||!m))return p.attach(m,y)},[p,m]);const[N,I]=o.useState(!1),[F,B]=o.useState(!1),E=N||F;o.useEffect(()=>{d?.(E)},[E,d]),o.useEffect(()=>{const P=()=>{I(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",P),()=>document.removeEventListener("fullscreenchange",P)},[]),o.useEffect(()=>{if(!F)return;const P=U=>{U.key==="Escape"&&B(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[F]);const $=o.useCallback(async()=>{const P=h.current;if(P){if(F){B(!1);return}if(document.fullscreenElement===P){await document.exitFullscreen();return}if(P.requestFullscreen&&document.fullscreenEnabled!==!1)try{await P.requestFullscreen();return}catch{}B(!0)}},[F]);o.useImperativeHandle(c,()=>({toggleFullscreen:$}),[$]);const L=e.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:E?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[E&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{$()},"aria-label":l,title:`${l} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:e.jsx(Hd,{size:15})})]}),k&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:k}),!p&&!k&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:g,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 F?Gr.createPortal(L,document.body):L}),ru="termdock-file-search-match",Ni="termdock-file-search-current";function zp(t){const n=t.metaKey||t.ctrlKey,s=t.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||t.key==="F3"?t.shiftKey?"previous":"next":t.key==="Escape"?"close":null}function Wp(t){return t.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Gp(t,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const h=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const k=Wp(f);if(!k)continue;c&&c!==k&&(d+=`
1638
- `);const y=d.length;d+=f.data,l.push({node:f,start:y,end:d.length,group:k}),c=k}const m=d.toLocaleLowerCase(),g=[];let p=0;for(;p<=m.length-s.length;){const f=m.indexOf(s,p);if(f<0)break;const k=f+s.length,y=l.find(I=>I.start<=f&&I.end>f),N=l.find(I=>I.start<k&&I.end>=k);if(y&&N&&y.group===N.group){const I=document.createRange();I.setStart(y.node,f-y.start),I.setEnd(N.node,k-N.start),g.push(I)}p=f+Math.max(s.length,1)}return g}function nu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Aa(){const t=nu();t?.delete(ru),t?.delete(Ni)}function ad(t,n){const s=nu();if(!s||typeof Highlight>"u")return;s.set(ru,new Highlight(...t));const l=t[n];l?s.set(Ni,new Highlight(l)):s.delete(Ni)}function od(t){t?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function qp(t){return Array.from(new Set(t.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Kp(t,n){const s=n.trim();return!s||s==="."?t:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${t.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Vp(t,n){if(n===t)return".";const s=`${t.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function su(t,n,s){return n?t:Gr.createPortal(t,s)}const Hi="termdock:right-sidebar:file-tree-scroll:v1",zi="termdock:right-sidebar:file-preview-reading-state:v1",ws="termdock:right-sidebar:file-tree-width:v1",au="termdock:right-sidebar:markdown-view-mode:v1",ou="termdock:right-sidebar:diff-change-list-mode:v1",iu="termdock:right-sidebar:diff-wrap:v1",lu="termdock:diff-viewer:view-type:v1",cu="termdock:right-sidebar:file-search-mode:v1",Zo="termdock:right-sidebar:collapsed-git-repo-groups:v1",id="termdock:right-sidebar:collapsed-diff-directories:v1",ei="termdock:right-sidebar:branch-audit-module-open:v1",du="termdock:right-sidebar:branch-audit-module:v1",Yp=150,uu="termdock:right-sidebar:active-git-repo:v1",ld="termdock:right-sidebar:context-draft-enabled:v1",cd="termdock:right-sidebar:context-draft-collapsed:v1",dd="termdock:right-sidebar:context-draft-auto-collapse:v1",ti="termdock:right-sidebar:context-draft-text:v1",Xp=300,Jp=20,Qp=120,Zp=250,eg=250,tg=120,rg=700,ri=600;function Gn(t){return!!(t&&te.getState().nestedGitScanRoots[t])}const ud=[2e3,5e3,15e3,3e4],ng=320,sg=500,ag=20,og=12e3,Mi=300,fd=240,ig=560,fu="border-r px-2 py-1.5 sm:px-3 sm:py-2",Wa="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",hu=`${fu} border-b border-border/15 font-semibold last:border-r-0`,mu=`${fu} border-border/10 align-top text-muted-foreground last:border-r-0`,Wi="termdock-file-preview-horizontal-scroll",hd=o.lazy(()=>$s(()=>import("./ModelPreview-BFycVhUy.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),pu=`${Wi} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function gu(t,n,s){return t&&!n?"unified":s}const lg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function cg(t){return t==="preview"||t==="source"}function dg(t){return t==="list"||t==="tree"||t==="ai"}function md(){return tt(au,cg)??"preview"}function ug(){return tt(ou,dg)??"tree"}function ks(t){return typeof t=="boolean"}function fg(t){return typeof t=="string"}function hg(){return tt(iu,ks)??!0}function mg(t){return t==="unified"||t==="split"}function pg(){return tt(lu,mg)??"unified"}function gg(t){return t==="name"||t==="content"||t==="regex"}function bg(){return tt(cu,gg)??"name"}function bu(t){return t.repositories??(t.context?.root?[{id:t.context.root,root:t.context.root,relativeRoot:".",name:ft(t.context.root)||t.context.root,depth:0,nested:!1,available:t.available,files:t.files,context:t.context,error:t.error}]:[])}function xg(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(n=>n===null||typeof n=="string")}function xu(){return tt(uu,xg)??{}}function pd(t){if(!t)return;const n=xu();return Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}function ni(t,n){t&&xt(uu,{...xu(),[t]:n})}function vg(t,n){if(!n)return null;const s=new Set((t.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(t.repositories??[]).some(l=>l.root===n)?n:null}function $i(t){return!t.activeGitRepoRoot&&(t.groupCount>1||t.label!==t.rootName)}function vu(...t){const n=new Set;for(const s of t)for(const l of s)n.add(l.root);return n}function Ei(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function gd(t){const n=tt(t,Ei);return n?new Set(n):new Set}function si(t,n){xt(t,[...n])}function yg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function wg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Ei(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(yg))&&(n.commits===void 0||Ei(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 kg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.key=="string"&&wg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function Sg(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(kg))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function bd(){return tt(du,Sg)??{}}function xd(t){return[t.repoRoot,t.baseRef,t.branchName??"",t.headRef??"",t.diffFingerprint??""].join("\0")}function vd(t){const n=t?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function yu(t,n){const s=t?.trim(),l=n?.trim();return!s||!l?!1:s===l||vd(s)===vd(l)}function yd(t){const n=t?.branch??null;return[t?.upstream,...t?.remoteBranches??[],...t?.branches??[]].find(l=>l&&!yu(l,n))??""}function Li(t,n){const s=Math.max(fd,n-320),l=Math.min(ig,s);return Math.min(l,Math.max(fd,t))}function jg(t){return typeof t=="number"&&Number.isFinite(t)}function Rg(t){return Li(tt(ws,jg)??Mi,t)}function wu(t){const n=t.split(/[\\/]/).pop()??t,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function vs(t){return lg.has(wu(t))}function ku(t){const n=t.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Ai(t){const n=t.trim();return/^#{1,6}\s+/.test(n)||ku(t)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Su(t){const n=t.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const ju=o.createContext(null);function Ua(t){return t.trim().replace(/\s+/g," ").toLowerCase()}function Ru(t){return t.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Cu(t){return t.replace(/\s+#+\s*$/,"").trim()}function Pi(t,n){const l=Ru(t).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function wd(t){return Ru(t)||t.trim()}function Ga(t){const n=t.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Ii(n[2]);return s?{id:Ua(n[1]),definition:{href:s.href,title:s.title}}:null}function Cg(t){const n=new Map;for(const s of t){const l=Ga(s);l&&n.set(l.id,l.definition)}return n}function Nu(t){return t.trim().toLowerCase()}function Mu(t){const n=t.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Nu(n[1]),text:n[2]}:null}function Ng(t){const n=new Map;let s=null;for(const l of t){const d=Mu(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 $u(t){const n=new Set;let s=!1;return t.forEach((l,d)=>{if(Mu(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function Mg(t){const n=[...t];let s=0;const l=t[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<t.length&&t[s].trim()!==l;)n[s]="",s+=1;s<t.length&&(n[s]="",s+=1)}for(;s<t.length;){const d=t[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<t.length&&!t[s].includes("-->");)n[s]="",s+=1;s<t.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Eu(t){const n=t.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function Rs(t){const n=t.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Gi(t,n,s){const l=t.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,h=d>=0?l.slice(d+1):"",m=c.split("?",1)[0];if(!m)return null;let g,p=null;try{g=decodeURIComponent(m),p=h?decodeURIComponent(h):null}catch{return null}const f=s?Rs(s):null;let k;if(g.startsWith("/")){const y=f&&(g===f||g.startsWith(`${f}/`));k=Rs(f&&!y?`${f}/${g.slice(1)}`:g)}else{if(!n)return null;k=Rs(`${Eu(n)}/${g}`)}return f&&k!==f&&!k.startsWith(`${f}/`)?null:{path:k,fragment:p,directory:/\/$/.test(m)}}function qi(t,n,s,l,d){const c=t.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 h;if(c.startsWith("/")){const m=s&&(c===s||c.startsWith(`${s}/`));h=Rs(s&&!m?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;h=Rs(`${Eu(n)}/${c}`)}return d(h)}function $g(t,n,s){return qi(t,n,s,Ui,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Eg(t,n,s){return qi(t,n,s,Td,Id)}const Ti=128,Lg=360,ai=480;function Za(t){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(t))}catch{return!1}}function Lu(t,n,s,l,d=0){if(!n||!s)return null;let c,h;return d>0?(c=l>0?Math.min(d,l):d,h=s*c/n):Za(t)?(h=Math.min(Math.max(s,Ti),Lg),c=n*h/s):(c=n,h=s),l>0&&c>l&&(h=h*l/c,c=l),h>ai&&(c=c*ai/h,h=ai),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(h))}}function Ag(t){if(!t.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(t.slice(t.indexOf("?"))).get("path")}catch{return null}}function Au(t){const n=Ag(t),s=te(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${t}&v=${s}`:t}function Pg({src:t,alt:n,title:s,requestedWidthPx:l}){const d=Za(t),c=Au(t),h=Ja(c),m=o.useRef(null),[g,p]=o.useState(!1),[f,k]=o.useState(0),[y,N]=o.useState({status:"loading"}),[I,F]=o.useState(null);o.useLayoutEffect(()=>{const $=m.current,L=$?.parentElement?.parentElement??$?.parentElement;if(!L)return;const P=()=>k(L.clientWidth);if(P(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(P);return U.observe(L),()=>U.disconnect()},[]),o.useEffect(()=>{if(g)return;const $=m.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const L=new IntersectionObserver(P=>{P.some(U=>U.isIntersecting)&&(p(!0),L.disconnect())},{rootMargin:"400px"});return L.observe($),()=>L.disconnect()},[g]),o.useEffect(()=>{if(!g)return;const $=new AbortController;let L=null;N({status:"loading"});const P=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Gh(c,{signal:$.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const D=Number(U.headers.get("X-Image-Width"))||0,a=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:D,height:a}}).then(({blob:U,width:D,height:a})=>{$.signal.aborted||(L=URL.createObjectURL(U),D>0&&a>0&&F({width:D,height:a}),N({status:"ready",objectUrl:L}))}).catch(()=>{const U=$.signal.reason;$.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||N({status:"fallback"})}).finally(()=>{window.clearTimeout(P)}),()=>{window.clearTimeout(P),$.abort(),L&&URL.revokeObjectURL(L)}},[g,c]);const B=Lu(t,I?.width??0,I?.height??0,f,l??0),E=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:Ti*2,height:Ti});return e.jsx("div",{ref:m,className:"block max-w-full",style:B?{width:B.width,height:B.height}:void 0,children:y.status==="ready"?e.jsx("img",{src:y.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):y.status==="fallback"?e.jsx("img",{src:h,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:E.width,height:E.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Cs(t,n,s,l,d,c){const h=$g(s,d.markdownFilePath,d.rootPath);if(!h)return c?.fallbackText??`![${n}](${s})`;const m=d.images.length;d.images.push({kind:"image",src:h,alt:n,title:l});const g=e.jsx(Pg,{src:h,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?.(m)},children:g},t):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:g},t)}function oi(t){let n=t,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function kd(t){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(t)}function Ii(t){const n=t.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const Pu="",Tg=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Ig(t){return t.replace(Tg,(n,s)=>`${Pu}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Sd(t){return t.replace(new RegExp(`${Pu}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Dg(t){const n=t.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Tu={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 Pa=null;function Iu(){return Pa||(Pa=$s(()=>import("./purify.es-4eNOHKSq.js"),[]).then(t=>t.default??t).catch(t=>{throw Pa=null,t})),Pa}function Du({html:t}){const{t:n}=yt(),[s,l]=o.useState(null);return o.useEffect(()=>{let d=!1;return l(null),Iu().then(c=>{d||l(c.sanitize(t,Tu))}).catch(()=>{d||l("")}),()=>{d=!0}},[t]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function Fg({html:t}){const[n,s]=o.useState(null);return o.useEffect(()=>{let l=!1;return s(null),Iu().then(d=>{l||s(d.sanitize(t,Tu))}).catch(()=>{l||s("")}),()=>{l=!0}},[t]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):t}function Fu(t){const n=t.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(t)}}let Ta=null;function _g(){return Ta||(Ta=Promise.all([$s(()=>import("./katex-DnlPpQZa.js"),[]),$s(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([t])=>t.default??t).catch(t=>{throw Ta=null,t})),Ta}function Ls({tex:t,display:n=!1}){const[s,l]=o.useState(null),[d,c]=o.useState(!1);if(o.useEffect(()=>{let m=!1;return l(null),c(!1),_g().then(g=>{m||l(g.renderToString(t,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||c(!0)}),()=>{m=!0}},[n,t]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${t}$$`:`$${t}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":t});const h=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:h,dangerouslySetInnerHTML:{__html:s}})}function Ki(t){const n=new Map;for(const s of t.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 jd(t){const n=Ki(t),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 Bg(t){const n=t.indexOf(">"),s=n<0?t:t.slice(0,n+1),l=Ki(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),m=n<0?"":t.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:m,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function Og({url:t,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=yt(),[c,h]=o.useState(!1),m=Ja(t,()=>h(!0));return m?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:m,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function Ug(t,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(t)){const h=t.slice(0,t.indexOf(">")+1),m=Ki(h).get("href")?.trim()??"",g=t.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:f,title:k,widthPx:y}=jd(g);if(!p)return null;const N=qi(p,s.markdownFilePath,s.rootPath,Ui,$=>$);if(!N)return null;const I=m?Gi(m,s.markdownFilePath,s.rootPath):null,B=!!!(I&&I.path===N)&&m?Su(m):null,E=Cs(n,f??"",p,k,s,{requestedWidthPx:y,interactive:B?!1:void 0});return B?e.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:E},n):E}if(/^<\s*img\b[^>]*>$/i.test(t)){const{src:h,alt:m,title:g,widthPx:p}=jd(t);return h?Cs(n,m??"",h,g,s,{fallbackText:t,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(t)){const{src:h,fallbackText:m,widthPx:g,controls:p}=Bg(t);if(!h)return null;const f=Eg(h,s.markdownFilePath,s.rootPath);return f?e.jsx(Og,{url:f,fallbackText:m,widthPx:g,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(t))return e.jsx("br",{},n);const l=t.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(t)?e.jsx(Fg,{html:t},n):null;const d=l[1].toLowerCase(),c=rt(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 rt(t,n,s=!0,l){const d=Ig(t),c=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<\s*img\b[^>]*>|<\s*video\b[^>]*>[\s\S]*?<\/video\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let m=0,g;for(;(g=c.exec(d))!==null;){g.index>m&&h.push(Sd(d.slice(m,g.index)));const p=g[0],f=`${n}-${g.index}`,k=p.startsWith("<")?Ug(p,f,l):null;if(k)h.push(k);else if(p.startsWith("\\(")&&p.endsWith("\\)"))h.push(e.jsx(Ls,{tex:p.slice(2,-2)},f));else if(p.startsWith("$")&&p.endsWith("$"))h.push(e.jsx(Ls,{tex:p.slice(1,-1)},f));else if(p.startsWith("`")){const y=p.match(/^`+/)?.[0].length??1;h.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Dg(p.slice(y,-y))},f))}else if(p.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:rt(p.slice(2,-2),`${f}-del`,s,l)},f));else if(p.startsWith("**")||p.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:rt(p.slice(2,-2),`${f}-strong`,s,l)},f));else if(p.startsWith("*")||p.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:rt(p.slice(1,-1),`${f}-em`,s,l)},f));else if(p.startsWith("![")){const y=p.match(/^!\[([^\]]*)\]\((.*)\)$/),N=p.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),I=p.match(/^!\[([^\]]+)\]$/);if(y){const F=Ii(y[2]);h.push(F?Cs(f,y[1],F.href,F.title,l):p)}else if(N){const F=N[2]||N[1],B=l.referenceDefinitions.get(Ua(F));h.push(B?Cs(f,N[1],B.href,B.title,l):p)}else if(I){const F=l.referenceDefinitions.get(Ua(I[1]));h.push(F?Cs(f,I[1],F.href,F.title,l):p)}else h.push(p)}else if(p.startsWith("[^")){const y=Nu(p.slice(2,-1)),N=l.footnoteDefinitions.get(y);h.push(N?e.jsx("sup",{id:`fnref-${N.id}`,title:N.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${N.id}`,className:"text-primary no-underline",children:N.index})},f):p)}else if(p.startsWith("<http")){const y=p.slice(1,-1);h.push(e.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f))}else if(p.startsWith("<")&&p.endsWith(">")&&kd(p.slice(1,-1))){const y=p.slice(1,-1);h.push(e.jsx("a",{href:`mailto:${y}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f))}else if(kd(oi(p).linkText)){const{linkText:y,suffix:N}=oi(p);h.push(e.jsx("a",{href:`mailto:${y}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else if(p.startsWith("http")||p.startsWith("www.")){const{linkText:y,suffix:N}=oi(p),I=y.startsWith("www.")?`https://${y}`:y;h.push(e.jsx("a",{href:I,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else{const y=p.match(/^\[([^\]]+)\]\((.*)\)$/),N=p.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),I=p.match(/^\[([^\]]+)\]$/),F=N?N[2]||N[1]:I?.[1]??null,B=F?l.referenceDefinitions.get(Ua(F)):null,E=y?Ii(y[2]):null,$=E?.href??B?.href??null,L=$?Su($):null,P=y?.[1]??N?.[1]??I?.[1]??"";h.push(L?e.jsx("a",{href:L,title:E?.title??B?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:rt(P,`${f}-link`,s,l)},f):p)}m=c.lastIndex}return m<d.length&&h.push(Sd(d.slice(m))),h.length>0?h:[t]}function _u(t){return/(?: {2,}|\\)$/.test(t)}function Bu(t){return t.replace(/(?: {2,}|\\)$/,"")}function qa(t){return/^(?: {4}|\t)/.test(t)}function Ou(t){return t.startsWith(" ")?t.slice(1):t.replace(/^ {4}/,"")}function Uu(t,n,s){const l=[];return t.forEach((d,c)=>{const h=_u(d);l.push(...rt(Bu(d),`${n}-${c}`,!0,s)),c<t.length-1&&l.push(h?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Di(t,n,s){const l=[],d=[];return t.forEach((c,h)=>{d.push(_u(c)),l.push(rt(Bu(c),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:d}}function Fi(t,n,s,l,d){const c=[];return t.forEach((h,m)=>{const g=s[m]??0,p=!!(d&&g>=d.start&&g<=d.end);c.push(e.jsx("span",{"data-md-ref-start":g,"data-md-ref-end":g,"data-selected":p?"true":void 0,children:h},`${l}-ref-${m}`)),m<t.length-1&&c.push(n[m]?e.jsx("br",{},`${l}-${m}-br`):" ")}),c}function As(t){const n=t.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,h=0;for(let m=0;m<n.length;m+=1){const g=n[m];if(d){l+=g,d=!1;continue}if(g==="\\"){d=!0;continue}if(g==="`"){const p=m;for(;m+1<n.length&&n[m+1]==="`";)m+=1;const f=m-p+1;l+="`".repeat(f),c===0?c=f:c===f&&(c=0);continue}if(c===0&&g==="["?h+=1:c===0&&g==="]"&&h>0&&(h-=1),g==="|"&&c===0&&h===0){s.push(l.trim()),l="";continue}l+=g}return d&&(l+="\\"),s.push(l.trim()),s}function Hu(t){return As(t).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Ka(t){return t==="center"?"text-center":t==="right"?"text-right":"text-left"}function Va(t){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(t.trim())}function zu(t,n){return t>96||t>44&&n>.35}function eo(t){return(t.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Ps(t){const n=t.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function Vi(t,n,s,l,d,c=new Set){const h=[],m=[];let g=n;for(;g<t.length;){const p=t[g];if(d&&(Ga(p)||c.has(g))){g+=1;continue}const f=Ps(p),k=eo(p);if(!f){if(k>s&&m.length>0){([...m].reverse().find(F=>F.indent<k)?.item??m[m.length-1].item).paragraphs.push(p.trim());for(const F of m)F.item.lineEnd=g+1;g+=1;continue}break}if(k<s||k===s&&f.ordered!==l)break;const y={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:g+1,lineEnd:g+1};for(;m.length>0&&m[m.length-1].indent>=k;)m.pop();const N=m[m.length-1]?.item??null;N?N.children.push(y):h.push(y),m.push({indent:k,item:y});for(const I of m)I.item.lineEnd=g+1;g+=1}return{items:h,nextIndex:g}}function Hg(t){const n=t.find(l=>Ps(l));if(!n)return[];const s=Ps(n);return s?Vi(t,0,eo(n),s.ordered,!0,$u(t)).items:[]}function Yi(t,n,s,l=0){return t.map((d,c)=>{const h=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!h,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[h?e.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,rt(h?.[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((m,g)=>e.jsx("p",{children:rt(m,`li-${n}-${c}-p-${g}`,!0,s)},`paragraph-${g}`))})]}),groups:zg(d.children,`${n}-${c}`,s,l)}})}function zg(t,n,s,l=0){const d=[];for(const c of t){const h=d[d.length-1];h&&h.ordered===c.ordered?h.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,h)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:Yi(c.items,`${n}-g${h}`,s,l)}))}function Xi(t,n){return t.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&Wg(s.groups,n)]},s.key)})}function Wg(t,n){return t.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Xi(s.items,n)},`nested-${l}`)})}function Gg(t){const n=Array.from(t.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:t.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[rt(s.text,`footnote-${s.id}`,!0,t)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":t.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function qg(t,n,s,l){const d=[];let c=0;const h=m=>l?.[m]??m+1;for(;c<t.length;){const m=t[c],g=m.trim();if(!g){c+=1;continue}if(/^<details>\s*$/i.test(g)){const E=c;let $="Details";const L=[];for(c+=1;c<t.length&&!/^<\/details>\s*$/i.test(t[c].trim());){const P=t[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?$=P[1].trim()||$:L.push(t[c].trimStart()),c+=1}c<t.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:rt($,`${n}-details-${E}-summary`,!0,s)}),L.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Uu(L,`${n}-details-${E}`,s)})]},`${n}-details-${E}`)});continue}const p=Fu(m);if(p){const E=[m],$=c;for(c+=1;c<t.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(t[c]);)E.push(t[c]),c+=1;c<t.length&&!p.selfContained&&(E.push(t[c]),c+=1),d.push({kind:"static",node:e.jsx(Du,{html:E.join(`
1637
+ `+M.documentElement.outerHTML;return{html:je,shellUrl:`/preview-shell.html#${d}`,errors:h,attach(C,Z){const ue=new Set,Ee=Fe=>{if(Fe.source!==C.contentWindow||Fe.data?.capability!==d)return;if(Fe.data.type==="preview-ready"){C.contentWindow?.postMessage({type:"preview-init",capability:d,html:je,resources:p},"*");return}if(Fe.data.type==="preview-error"){Z("部分动态内容被安全预览限制");return}if(Fe.data.type==="preview-navigate"){(async()=>{const ae=j(String(Fe.data.url)),S=await tu(ae.pathname+ae.search,n);if(I){S.dispose();return}const V=S.attach(C,Z);F.add(()=>{V(),S.dispose()}),C.src=S.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ae=>Z(ae instanceof Error?ae.message:"无法打开预览页面"));return}if(Fe.data.type==="preview-external"){try{const ae=new URL(String(Fe.data.url));ae.protocol==="https:"&&f.has(ae.origin)&&window.open(ae.href,"_blank","noopener,noreferrer")}catch{}return}if(Fe.data.type!=="preview-fetch"||Fe.ports.length!==1)return;const le=Fe.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(Fe.data.method)){le.postMessage({error:"预览仅允许读取已授权目录资源"}),le.close();return}ue.add(le),(async()=>{const ae=j(String(Fe.data.url)),S=await X(ae);if(!ue.has(le)||I)return;const V=Fe.data.method==="HEAD"?new Uint8Array:S.bytes.slice();le.postMessage({status:S.status,headers:{"content-type":S.type},data:V.buffer},[V.buffer])})().catch(()=>{le.postMessage({error:"预览资源不在授权范围或无法加载"}),Z("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(le),le.close()})};window.addEventListener("message",Ee);const Ge=()=>{window.removeEventListener("message",Ee);for(const Fe of ue)Fe.close();ue.clear(),F.delete(Ge)};return F.add(Ge),Ge},dispose:B}}catch(G){throw B(),G}}const Hp=o.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const h=o.useRef(null),[m,g]=o.useState(null),[p,f]=o.useState(),[k,y]=o.useState("");o.useEffect(()=>{const P=new AbortController;let U;return f(void 0),y(""),(async()=>{const D=await ph();if(U=await tu(n,{fetch:(a,w)=>D.fetch(a,w),signal:P.signal}),P.signal.aborted){U.dispose();return}f(U),U.errors.length&&y(U.errors.join(";"))})().catch(D=>{P.signal.aborted||y(D instanceof Error?D.message:"安全预览加载失败")}),()=>{P.abort(),U?.dispose()}},[n]),o.useEffect(()=>{if(!(!p||!m))return p.attach(m,y)},[p,m]);const[N,I]=o.useState(!1),[F,B]=o.useState(!1),E=N||F;o.useEffect(()=>{d?.(E)},[E,d]),o.useEffect(()=>{const P=()=>{I(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",P),()=>document.removeEventListener("fullscreenchange",P)},[]),o.useEffect(()=>{if(!F)return;const P=U=>{U.key==="Escape"&&B(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[F]);const $=o.useCallback(async()=>{const P=h.current;if(P){if(F){B(!1);return}if(document.fullscreenElement===P){await document.exitFullscreen();return}if(P.requestFullscreen&&document.fullscreenEnabled!==!1)try{await P.requestFullscreen();return}catch{}B(!0)}},[F]);o.useImperativeHandle(c,()=>({toggleFullscreen:$}),[$]);const L=e.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:E?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[E&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{$()},"aria-label":l,title:`${l} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:e.jsx(zd,{size:15})})]}),k&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:k}),!p&&!k&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:g,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 F?Gr.createPortal(L,document.body):L}),ru="termdock-file-search-match",Ni="termdock-file-search-current";function zp(t){const n=t.metaKey||t.ctrlKey,s=t.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||t.key==="F3"?t.shiftKey?"previous":"next":t.key==="Escape"?"close":null}function Wp(t){return t.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Gp(t,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const h=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const k=Wp(f);if(!k)continue;c&&c!==k&&(d+=`
1638
+ `);const y=d.length;d+=f.data,l.push({node:f,start:y,end:d.length,group:k}),c=k}const m=d.toLocaleLowerCase(),g=[];let p=0;for(;p<=m.length-s.length;){const f=m.indexOf(s,p);if(f<0)break;const k=f+s.length,y=l.find(I=>I.start<=f&&I.end>f),N=l.find(I=>I.start<k&&I.end>=k);if(y&&N&&y.group===N.group){const I=document.createRange();I.setStart(y.node,f-y.start),I.setEnd(N.node,k-N.start),g.push(I)}p=f+Math.max(s.length,1)}return g}function nu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Aa(){const t=nu();t?.delete(ru),t?.delete(Ni)}function ad(t,n){const s=nu();if(!s||typeof Highlight>"u")return;s.set(ru,new Highlight(...t));const l=t[n];l?s.set(Ni,new Highlight(l)):s.delete(Ni)}function od(t){t?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function qp(t){return Array.from(new Set(t.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Kp(t,n){const s=n.trim();return!s||s==="."?t:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${t.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Vp(t,n){if(n===t)return".";const s=`${t.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function su(t,n,s){return n?t:Gr.createPortal(t,s)}const Hi="termdock:right-sidebar:file-tree-scroll:v1",zi="termdock:right-sidebar:file-preview-reading-state:v1",ws="termdock:right-sidebar:file-tree-width:v1",au="termdock:right-sidebar:markdown-view-mode:v1",ou="termdock:right-sidebar:diff-change-list-mode:v1",iu="termdock:right-sidebar:diff-wrap:v1",lu="termdock:diff-viewer:view-type:v1",cu="termdock:right-sidebar:file-search-mode:v1",Zo="termdock:right-sidebar:collapsed-git-repo-groups:v1",id="termdock:right-sidebar:collapsed-diff-directories:v1",ei="termdock:right-sidebar:branch-audit-module-open:v1",du="termdock:right-sidebar:branch-audit-module:v1",Yp=150,uu="termdock:right-sidebar:active-git-repo:v1",ld="termdock:right-sidebar:context-draft-enabled:v1",cd="termdock:right-sidebar:context-draft-collapsed:v1",dd="termdock:right-sidebar:context-draft-auto-collapse:v1",ti="termdock:right-sidebar:context-draft-text:v1",Xp=300,Jp=20,Qp=120,Zp=250,eg=250,tg=120,rg=700,ri=600;function Gn(t){return!!(t&&te.getState().nestedGitScanRoots[t])}const ud=[2e3,5e3,15e3,3e4],ng=320,sg=500,ag=20,og=12e3,Mi=300,fd=240,ig=560,fu="border-r px-2 py-1.5 sm:px-3 sm:py-2",Wa="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",hu=`${fu} border-b border-border/15 font-semibold last:border-r-0`,mu=`${fu} border-border/10 align-top text-muted-foreground last:border-r-0`,Wi="termdock-file-preview-horizontal-scroll",hd=o.lazy(()=>$s(()=>import("./ModelPreview-DB8tw45f.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),pu=`${Wi} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function gu(t,n,s){return t&&!n?"unified":s}const lg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function cg(t){return t==="preview"||t==="source"}function dg(t){return t==="list"||t==="tree"||t==="ai"}function md(){return tt(au,cg)??"preview"}function ug(){return tt(ou,dg)??"tree"}function ks(t){return typeof t=="boolean"}function fg(t){return typeof t=="string"}function hg(){return tt(iu,ks)??!0}function mg(t){return t==="unified"||t==="split"}function pg(){return tt(lu,mg)??"unified"}function gg(t){return t==="name"||t==="content"||t==="regex"}function bg(){return tt(cu,gg)??"name"}function bu(t){return t.repositories??(t.context?.root?[{id:t.context.root,root:t.context.root,relativeRoot:".",name:ft(t.context.root)||t.context.root,depth:0,nested:!1,available:t.available,files:t.files,context:t.context,error:t.error}]:[])}function xg(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(n=>n===null||typeof n=="string")}function xu(){return tt(uu,xg)??{}}function pd(t){if(!t)return;const n=xu();return Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}function ni(t,n){t&&xt(uu,{...xu(),[t]:n})}function vg(t,n){if(!n)return null;const s=new Set((t.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(t.repositories??[]).some(l=>l.root===n)?n:null}function $i(t){return!t.activeGitRepoRoot&&(t.groupCount>1||t.label!==t.rootName)}function vu(...t){const n=new Set;for(const s of t)for(const l of s)n.add(l.root);return n}function Ei(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function gd(t){const n=tt(t,Ei);return n?new Set(n):new Set}function si(t,n){xt(t,[...n])}function yg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function wg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Ei(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(yg))&&(n.commits===void 0||Ei(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 kg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.key=="string"&&wg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function Sg(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(kg))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function bd(){return tt(du,Sg)??{}}function xd(t){return[t.repoRoot,t.baseRef,t.branchName??"",t.headRef??"",t.diffFingerprint??""].join("\0")}function vd(t){const n=t?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function yu(t,n){const s=t?.trim(),l=n?.trim();return!s||!l?!1:s===l||vd(s)===vd(l)}function yd(t){const n=t?.branch??null;return[t?.upstream,...t?.remoteBranches??[],...t?.branches??[]].find(l=>l&&!yu(l,n))??""}function Li(t,n){const s=Math.max(fd,n-320),l=Math.min(ig,s);return Math.min(l,Math.max(fd,t))}function jg(t){return typeof t=="number"&&Number.isFinite(t)}function Rg(t){return Li(tt(ws,jg)??Mi,t)}function wu(t){const n=t.split(/[\\/]/).pop()??t,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function vs(t){return lg.has(wu(t))}function ku(t){const n=t.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Ai(t){const n=t.trim();return/^#{1,6}\s+/.test(n)||ku(t)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Su(t){const n=t.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const ju=o.createContext(null);function Ua(t){return t.trim().replace(/\s+/g," ").toLowerCase()}function Ru(t){return t.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Cu(t){return t.replace(/\s+#+\s*$/,"").trim()}function Pi(t,n){const l=Ru(t).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function wd(t){return Ru(t)||t.trim()}function Ga(t){const n=t.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Ii(n[2]);return s?{id:Ua(n[1]),definition:{href:s.href,title:s.title}}:null}function Cg(t){const n=new Map;for(const s of t){const l=Ga(s);l&&n.set(l.id,l.definition)}return n}function Nu(t){return t.trim().toLowerCase()}function Mu(t){const n=t.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Nu(n[1]),text:n[2]}:null}function Ng(t){const n=new Map;let s=null;for(const l of t){const d=Mu(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 $u(t){const n=new Set;let s=!1;return t.forEach((l,d)=>{if(Mu(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function Mg(t){const n=[...t];let s=0;const l=t[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<t.length&&t[s].trim()!==l;)n[s]="",s+=1;s<t.length&&(n[s]="",s+=1)}for(;s<t.length;){const d=t[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<t.length&&!t[s].includes("-->");)n[s]="",s+=1;s<t.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Eu(t){const n=t.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function Rs(t){const n=t.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Gi(t,n,s){const l=t.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,h=d>=0?l.slice(d+1):"",m=c.split("?",1)[0];if(!m)return null;let g,p=null;try{g=decodeURIComponent(m),p=h?decodeURIComponent(h):null}catch{return null}const f=s?Rs(s):null;let k;if(g.startsWith("/")){const y=f&&(g===f||g.startsWith(`${f}/`));k=Rs(f&&!y?`${f}/${g.slice(1)}`:g)}else{if(!n)return null;k=Rs(`${Eu(n)}/${g}`)}return f&&k!==f&&!k.startsWith(`${f}/`)?null:{path:k,fragment:p,directory:/\/$/.test(m)}}function qi(t,n,s,l,d){const c=t.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 h;if(c.startsWith("/")){const m=s&&(c===s||c.startsWith(`${s}/`));h=Rs(s&&!m?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;h=Rs(`${Eu(n)}/${c}`)}return d(h)}function $g(t,n,s){return qi(t,n,s,Ui,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Eg(t,n,s){return qi(t,n,s,Td,Id)}const Ti=128,Lg=360,ai=480;function Za(t){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(t))}catch{return!1}}function Lu(t,n,s,l,d=0){if(!n||!s)return null;let c,h;return d>0?(c=l>0?Math.min(d,l):d,h=s*c/n):Za(t)?(h=Math.min(Math.max(s,Ti),Lg),c=n*h/s):(c=n,h=s),l>0&&c>l&&(h=h*l/c,c=l),h>ai&&(c=c*ai/h,h=ai),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(h))}}function Ag(t){if(!t.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(t.slice(t.indexOf("?"))).get("path")}catch{return null}}function Au(t){const n=Ag(t),s=te(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${t}&v=${s}`:t}function Pg({src:t,alt:n,title:s,requestedWidthPx:l}){const d=Za(t),c=Au(t),h=Ja(c),m=o.useRef(null),[g,p]=o.useState(!1),[f,k]=o.useState(0),[y,N]=o.useState({status:"loading"}),[I,F]=o.useState(null);o.useLayoutEffect(()=>{const $=m.current,L=$?.parentElement?.parentElement??$?.parentElement;if(!L)return;const P=()=>k(L.clientWidth);if(P(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(P);return U.observe(L),()=>U.disconnect()},[]),o.useEffect(()=>{if(g)return;const $=m.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const L=new IntersectionObserver(P=>{P.some(U=>U.isIntersecting)&&(p(!0),L.disconnect())},{rootMargin:"400px"});return L.observe($),()=>L.disconnect()},[g]),o.useEffect(()=>{if(!g)return;const $=new AbortController;let L=null;N({status:"loading"});const P=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Gh(c,{signal:$.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const D=Number(U.headers.get("X-Image-Width"))||0,a=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:D,height:a}}).then(({blob:U,width:D,height:a})=>{$.signal.aborted||(L=URL.createObjectURL(U),D>0&&a>0&&F({width:D,height:a}),N({status:"ready",objectUrl:L}))}).catch(()=>{const U=$.signal.reason;$.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||N({status:"fallback"})}).finally(()=>{window.clearTimeout(P)}),()=>{window.clearTimeout(P),$.abort(),L&&URL.revokeObjectURL(L)}},[g,c]);const B=Lu(t,I?.width??0,I?.height??0,f,l??0),E=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:Ti*2,height:Ti});return e.jsx("div",{ref:m,className:"block max-w-full",style:B?{width:B.width,height:B.height}:void 0,children:y.status==="ready"?e.jsx("img",{src:y.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):y.status==="fallback"?e.jsx("img",{src:h,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:E.width,height:E.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Cs(t,n,s,l,d,c){const h=$g(s,d.markdownFilePath,d.rootPath);if(!h)return c?.fallbackText??`![${n}](${s})`;const m=d.images.length;d.images.push({kind:"image",src:h,alt:n,title:l});const g=e.jsx(Pg,{src:h,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?.(m)},children:g},t):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:g},t)}function oi(t){let n=t,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function kd(t){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(t)}function Ii(t){const n=t.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const Pu="",Tg=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Ig(t){return t.replace(Tg,(n,s)=>`${Pu}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Sd(t){return t.replace(new RegExp(`${Pu}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Dg(t){const n=t.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Tu={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 Pa=null;function Iu(){return Pa||(Pa=$s(()=>import("./purify.es-4eNOHKSq.js"),[]).then(t=>t.default??t).catch(t=>{throw Pa=null,t})),Pa}function Du({html:t}){const{t:n}=yt(),[s,l]=o.useState(null);return o.useEffect(()=>{let d=!1;return l(null),Iu().then(c=>{d||l(c.sanitize(t,Tu))}).catch(()=>{d||l("")}),()=>{d=!0}},[t]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function Fg({html:t}){const[n,s]=o.useState(null);return o.useEffect(()=>{let l=!1;return s(null),Iu().then(d=>{l||s(d.sanitize(t,Tu))}).catch(()=>{l||s("")}),()=>{l=!0}},[t]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):t}function Fu(t){const n=t.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(t)}}let Ta=null;function _g(){return Ta||(Ta=Promise.all([$s(()=>import("./katex-DnlPpQZa.js"),[]),$s(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([t])=>t.default??t).catch(t=>{throw Ta=null,t})),Ta}function Ls({tex:t,display:n=!1}){const[s,l]=o.useState(null),[d,c]=o.useState(!1);if(o.useEffect(()=>{let m=!1;return l(null),c(!1),_g().then(g=>{m||l(g.renderToString(t,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||c(!0)}),()=>{m=!0}},[n,t]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${t}$$`:`$${t}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":t});const h=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:h,dangerouslySetInnerHTML:{__html:s}})}function Ki(t){const n=new Map;for(const s of t.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 jd(t){const n=Ki(t),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 Bg(t){const n=t.indexOf(">"),s=n<0?t:t.slice(0,n+1),l=Ki(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),m=n<0?"":t.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:m,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function Og({url:t,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=yt(),[c,h]=o.useState(!1),m=Ja(t,()=>h(!0));return m?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:m,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function Ug(t,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(t)){const h=t.slice(0,t.indexOf(">")+1),m=Ki(h).get("href")?.trim()??"",g=t.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:f,title:k,widthPx:y}=jd(g);if(!p)return null;const N=qi(p,s.markdownFilePath,s.rootPath,Ui,$=>$);if(!N)return null;const I=m?Gi(m,s.markdownFilePath,s.rootPath):null,B=!!!(I&&I.path===N)&&m?Su(m):null,E=Cs(n,f??"",p,k,s,{requestedWidthPx:y,interactive:B?!1:void 0});return B?e.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:E},n):E}if(/^<\s*img\b[^>]*>$/i.test(t)){const{src:h,alt:m,title:g,widthPx:p}=jd(t);return h?Cs(n,m??"",h,g,s,{fallbackText:t,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(t)){const{src:h,fallbackText:m,widthPx:g,controls:p}=Bg(t);if(!h)return null;const f=Eg(h,s.markdownFilePath,s.rootPath);return f?e.jsx(Og,{url:f,fallbackText:m,widthPx:g,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(t))return e.jsx("br",{},n);const l=t.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(t)?e.jsx(Fg,{html:t},n):null;const d=l[1].toLowerCase(),c=rt(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 rt(t,n,s=!0,l){const d=Ig(t),c=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<\s*img\b[^>]*>|<\s*video\b[^>]*>[\s\S]*?<\/video\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let m=0,g;for(;(g=c.exec(d))!==null;){g.index>m&&h.push(Sd(d.slice(m,g.index)));const p=g[0],f=`${n}-${g.index}`,k=p.startsWith("<")?Ug(p,f,l):null;if(k)h.push(k);else if(p.startsWith("\\(")&&p.endsWith("\\)"))h.push(e.jsx(Ls,{tex:p.slice(2,-2)},f));else if(p.startsWith("$")&&p.endsWith("$"))h.push(e.jsx(Ls,{tex:p.slice(1,-1)},f));else if(p.startsWith("`")){const y=p.match(/^`+/)?.[0].length??1;h.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Dg(p.slice(y,-y))},f))}else if(p.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:rt(p.slice(2,-2),`${f}-del`,s,l)},f));else if(p.startsWith("**")||p.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:rt(p.slice(2,-2),`${f}-strong`,s,l)},f));else if(p.startsWith("*")||p.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:rt(p.slice(1,-1),`${f}-em`,s,l)},f));else if(p.startsWith("![")){const y=p.match(/^!\[([^\]]*)\]\((.*)\)$/),N=p.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),I=p.match(/^!\[([^\]]+)\]$/);if(y){const F=Ii(y[2]);h.push(F?Cs(f,y[1],F.href,F.title,l):p)}else if(N){const F=N[2]||N[1],B=l.referenceDefinitions.get(Ua(F));h.push(B?Cs(f,N[1],B.href,B.title,l):p)}else if(I){const F=l.referenceDefinitions.get(Ua(I[1]));h.push(F?Cs(f,I[1],F.href,F.title,l):p)}else h.push(p)}else if(p.startsWith("[^")){const y=Nu(p.slice(2,-1)),N=l.footnoteDefinitions.get(y);h.push(N?e.jsx("sup",{id:`fnref-${N.id}`,title:N.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${N.id}`,className:"text-primary no-underline",children:N.index})},f):p)}else if(p.startsWith("<http")){const y=p.slice(1,-1);h.push(e.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f))}else if(p.startsWith("<")&&p.endsWith(">")&&kd(p.slice(1,-1))){const y=p.slice(1,-1);h.push(e.jsx("a",{href:`mailto:${y}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f))}else if(kd(oi(p).linkText)){const{linkText:y,suffix:N}=oi(p);h.push(e.jsx("a",{href:`mailto:${y}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else if(p.startsWith("http")||p.startsWith("www.")){const{linkText:y,suffix:N}=oi(p),I=y.startsWith("www.")?`https://${y}`:y;h.push(e.jsx("a",{href:I,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else{const y=p.match(/^\[([^\]]+)\]\((.*)\)$/),N=p.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),I=p.match(/^\[([^\]]+)\]$/),F=N?N[2]||N[1]:I?.[1]??null,B=F?l.referenceDefinitions.get(Ua(F)):null,E=y?Ii(y[2]):null,$=E?.href??B?.href??null,L=$?Su($):null,P=y?.[1]??N?.[1]??I?.[1]??"";h.push(L?e.jsx("a",{href:L,title:E?.title??B?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:rt(P,`${f}-link`,s,l)},f):p)}m=c.lastIndex}return m<d.length&&h.push(Sd(d.slice(m))),h.length>0?h:[t]}function _u(t){return/(?: {2,}|\\)$/.test(t)}function Bu(t){return t.replace(/(?: {2,}|\\)$/,"")}function qa(t){return/^(?: {4}|\t)/.test(t)}function Ou(t){return t.startsWith(" ")?t.slice(1):t.replace(/^ {4}/,"")}function Uu(t,n,s){const l=[];return t.forEach((d,c)=>{const h=_u(d);l.push(...rt(Bu(d),`${n}-${c}`,!0,s)),c<t.length-1&&l.push(h?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Di(t,n,s){const l=[],d=[];return t.forEach((c,h)=>{d.push(_u(c)),l.push(rt(Bu(c),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:d}}function Fi(t,n,s,l,d){const c=[];return t.forEach((h,m)=>{const g=s[m]??0,p=!!(d&&g>=d.start&&g<=d.end);c.push(e.jsx("span",{"data-md-ref-start":g,"data-md-ref-end":g,"data-selected":p?"true":void 0,children:h},`${l}-ref-${m}`)),m<t.length-1&&c.push(n[m]?e.jsx("br",{},`${l}-${m}-br`):" ")}),c}function As(t){const n=t.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,h=0;for(let m=0;m<n.length;m+=1){const g=n[m];if(d){l+=g,d=!1;continue}if(g==="\\"){d=!0;continue}if(g==="`"){const p=m;for(;m+1<n.length&&n[m+1]==="`";)m+=1;const f=m-p+1;l+="`".repeat(f),c===0?c=f:c===f&&(c=0);continue}if(c===0&&g==="["?h+=1:c===0&&g==="]"&&h>0&&(h-=1),g==="|"&&c===0&&h===0){s.push(l.trim()),l="";continue}l+=g}return d&&(l+="\\"),s.push(l.trim()),s}function Hu(t){return As(t).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Ka(t){return t==="center"?"text-center":t==="right"?"text-right":"text-left"}function Va(t){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(t.trim())}function zu(t,n){return t>96||t>44&&n>.35}function eo(t){return(t.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Ps(t){const n=t.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function Vi(t,n,s,l,d,c=new Set){const h=[],m=[];let g=n;for(;g<t.length;){const p=t[g];if(d&&(Ga(p)||c.has(g))){g+=1;continue}const f=Ps(p),k=eo(p);if(!f){if(k>s&&m.length>0){([...m].reverse().find(F=>F.indent<k)?.item??m[m.length-1].item).paragraphs.push(p.trim());for(const F of m)F.item.lineEnd=g+1;g+=1;continue}break}if(k<s||k===s&&f.ordered!==l)break;const y={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:g+1,lineEnd:g+1};for(;m.length>0&&m[m.length-1].indent>=k;)m.pop();const N=m[m.length-1]?.item??null;N?N.children.push(y):h.push(y),m.push({indent:k,item:y});for(const I of m)I.item.lineEnd=g+1;g+=1}return{items:h,nextIndex:g}}function Hg(t){const n=t.find(l=>Ps(l));if(!n)return[];const s=Ps(n);return s?Vi(t,0,eo(n),s.ordered,!0,$u(t)).items:[]}function Yi(t,n,s,l=0){return t.map((d,c)=>{const h=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!h,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[h?e.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,rt(h?.[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((m,g)=>e.jsx("p",{children:rt(m,`li-${n}-${c}-p-${g}`,!0,s)},`paragraph-${g}`))})]}),groups:zg(d.children,`${n}-${c}`,s,l)}})}function zg(t,n,s,l=0){const d=[];for(const c of t){const h=d[d.length-1];h&&h.ordered===c.ordered?h.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,h)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:Yi(c.items,`${n}-g${h}`,s,l)}))}function Xi(t,n){return t.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&Wg(s.groups,n)]},s.key)})}function Wg(t,n){return t.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Xi(s.items,n)},`nested-${l}`)})}function Gg(t){const n=Array.from(t.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:t.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[rt(s.text,`footnote-${s.id}`,!0,t)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":t.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function qg(t,n,s,l){const d=[];let c=0;const h=m=>l?.[m]??m+1;for(;c<t.length;){const m=t[c],g=m.trim();if(!g){c+=1;continue}if(/^<details>\s*$/i.test(g)){const E=c;let $="Details";const L=[];for(c+=1;c<t.length&&!/^<\/details>\s*$/i.test(t[c].trim());){const P=t[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?$=P[1].trim()||$:L.push(t[c].trimStart()),c+=1}c<t.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:rt($,`${n}-details-${E}-summary`,!0,s)}),L.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Uu(L,`${n}-details-${E}`,s)})]},`${n}-details-${E}`)});continue}const p=Fu(m);if(p){const E=[m],$=c;for(c+=1;c<t.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(t[c]);)E.push(t[c]),c+=1;c<t.length&&!p.selfContained&&(E.push(t[c]),c+=1),d.push({kind:"static",node:e.jsx(Du,{html:E.join(`
1639
1639
  `)},`${n}-html-${$}`)});continue}const f=g.match(/^(```|~~~)\s*(.*)$/);if(f){const E=[],$=f[1],L=f[2]?.trim(),P=c;for(c+=1;c<t.length&&!t[c].trim().startsWith($);)E.push(t[c]),c+=1;c<t.length&&(c+=1),L.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(Gu,{code:E.join(`
1640
1640
  `),blockKey:`${n}-code-${P}`},`${n}-code-${P}`)}):["math","latex","tex"].includes(L.toLowerCase())?d.push({kind:"static",node:e.jsx(Ls,{tex:E.join(`
1641
1641
  `),display:!0},`${n}-code-${P}`)}):d.push({kind:"code",key:`${n}-code-${P}`,code:E.join(`
1642
1642
  `),lang:L,blockKey:`${n}-code-${P}`,codeStartLine:h(P)+1});continue}if(qa(m)){const E=[],$=c;for(;c<t.length&&(qa(t[c])||!t[c].trim());)E.push(t[c].trim()?Ou(t[c]):""),c+=1;d.push({kind:"code",key:`${n}-indented-code-${$}`,code:E.join(`
1643
- `).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${$}`,codeStartLine:h($)});continue}const k=g.match(/^(#{1,6})\s+(.+)$/);if(k){const $=`h${Math.min(6,k[1].length+1)}`,L=Cu(k[2]),P=Pi(L,s);d.push({kind:"static",node:e.jsx($,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:rt(L,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<t.length&&m.includes("|")&&Va(t[c+1])){const E=As(m),$=Hu(t[c+1]),L=[],P=c;for(c+=2;c<t.length&&t[c].includes("|")&&t[c].trim();)L.push(As(t[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:pu,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:E.map((U,D)=>e.jsx("th",{className:`${hu} ${Ka($[D]??null)}`,children:e.jsx("div",{className:Wa,children:rt(U,`${n}-th-${P}-${D}`,!0,s)})},`h-${D}`))})}),e.jsx("tbody",{children:L.map((U,D)=>e.jsx("tr",{className:"border-t border-border/10",children:E.map((a,w)=>e.jsx("td",{className:`${mu} ${Ka($[w]??null)}`,children:e.jsx("div",{className:Wa,children:rt(U[w]??"",`${n}-td-${P}-${D}-${w}`,!0,s)})},`c-${w}`))},`r-${D}`))})]})},`${n}-table-${P}`)});continue}const y=Ps(m);if(y){const E=y.ordered,$=eo(m),L=y.start,P=c,U=Vi(t,c,$,E,!1);c=U.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${P}`,ordered:E,start:E?L:void 0,renders:Yi(U.items,`${n}-list-${P}`,s,h(0)-1)});continue}const N=[m.trimStart()],I=[h(c)],F=c;for(c+=1;c<t.length&&t[c].trim()&&!Ai(t[c])&&!(c+1<t.length&&t[c].includes("|")&&Va(t[c+1]));)N.push(t[c].trimStart()),I.push(h(c)),c+=1;const B=Di(N,`${n}-p-${F}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${F}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:I})}return d}function Kg(t,n){return t.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:Fi(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:Xi(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Ya,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Ia=null,Rd=!1;const Da=16,Wu=192;function Vg(){return Ia||(Ia=$s(()=>import("./mermaid.core-B2sd_0VA.js").then(t=>t.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(t=>t.default??t).catch(t=>{throw Ia=null,t})),Ia}function Yg(t){Rd||(t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),Rd=!0)}function Xg(t){const n=t.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return t;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=l;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return t;const h=Math.max(Wu,Math.ceil(d)),m=Math.ceil(h/d*c);return t.replace(/<svg\b([^>]*)>/i,(g,p)=>`<svg${p.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function Jg(t){const n=t?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-Da,d=s.y-Da,c=s.width+Da*2,h=s.height+Da*2,m=Math.max(Wu,Math.ceil(c)),g=Math.ceil(m/c*h);n.setAttribute("viewBox",`${l} ${d} ${c} ${h}`),n.setAttribute("width",String(m)),n.setAttribute("height",String(g)),n.removeAttribute("style")}function Qg(t){const n=t.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return Wd(`code.${s}`)??s}function Gu({code:t,blockKey:n}){const{t:s}=yt(),[l,d]=o.useState(null),[c,h]=o.useState(!1),m=o.useRef(null),g=o.useContext(ju);o.useEffect(()=>{let f=!1;return d(null),h(!1),Vg().then(async k=>{Yg(k);const y=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:N}=await k.render(y,t);f||d(Xg(N))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[n,t]),o.useLayoutEffect(()=>{l&&Jg(m.current)},[l]);const p=o.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??l;f&&g?.(f)},[g,l]);return c?e.jsx(Ya,{code:t,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),p()},children:e.jsx("span",{ref:m,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 Ya({code:t,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Qg(n),[h,m]=o.useState(null);o.useEffect(()=>{if(!c||!Gd(t)){m(null);return}let p=!1;return qd().then(f=>{if(p||!f.registered(c)){p||m(null);return}try{m(Kd(f,t,c))}catch{p||m(null)}}).catch(()=>{p||m(null)}),()=>{p=!0}},[s,t,c]);const g=h??(t||" ").split(`
1643
+ `).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${$}`,codeStartLine:h($)});continue}const k=g.match(/^(#{1,6})\s+(.+)$/);if(k){const $=`h${Math.min(6,k[1].length+1)}`,L=Cu(k[2]),P=Pi(L,s);d.push({kind:"static",node:e.jsx($,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:rt(L,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<t.length&&m.includes("|")&&Va(t[c+1])){const E=As(m),$=Hu(t[c+1]),L=[],P=c;for(c+=2;c<t.length&&t[c].includes("|")&&t[c].trim();)L.push(As(t[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:pu,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:E.map((U,D)=>e.jsx("th",{className:`${hu} ${Ka($[D]??null)}`,children:e.jsx("div",{className:Wa,children:rt(U,`${n}-th-${P}-${D}`,!0,s)})},`h-${D}`))})}),e.jsx("tbody",{children:L.map((U,D)=>e.jsx("tr",{className:"border-t border-border/10",children:E.map((a,w)=>e.jsx("td",{className:`${mu} ${Ka($[w]??null)}`,children:e.jsx("div",{className:Wa,children:rt(U[w]??"",`${n}-td-${P}-${D}-${w}`,!0,s)})},`c-${w}`))},`r-${D}`))})]})},`${n}-table-${P}`)});continue}const y=Ps(m);if(y){const E=y.ordered,$=eo(m),L=y.start,P=c,U=Vi(t,c,$,E,!1);c=U.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${P}`,ordered:E,start:E?L:void 0,renders:Yi(U.items,`${n}-list-${P}`,s,h(0)-1)});continue}const N=[m.trimStart()],I=[h(c)],F=c;for(c+=1;c<t.length&&t[c].trim()&&!Ai(t[c])&&!(c+1<t.length&&t[c].includes("|")&&Va(t[c+1]));)N.push(t[c].trimStart()),I.push(h(c)),c+=1;const B=Di(N,`${n}-p-${F}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${F}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:I})}return d}function Kg(t,n){return t.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:Fi(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:Xi(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Ya,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Ia=null,Rd=!1;const Da=16,Wu=192;function Vg(){return Ia||(Ia=$s(()=>import("./mermaid.core-DhRpdkKn.js").then(t=>t.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(t=>t.default??t).catch(t=>{throw Ia=null,t})),Ia}function Yg(t){Rd||(t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),Rd=!0)}function Xg(t){const n=t.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return t;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=l;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return t;const h=Math.max(Wu,Math.ceil(d)),m=Math.ceil(h/d*c);return t.replace(/<svg\b([^>]*)>/i,(g,p)=>`<svg${p.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function Jg(t){const n=t?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-Da,d=s.y-Da,c=s.width+Da*2,h=s.height+Da*2,m=Math.max(Wu,Math.ceil(c)),g=Math.ceil(m/c*h);n.setAttribute("viewBox",`${l} ${d} ${c} ${h}`),n.setAttribute("width",String(m)),n.setAttribute("height",String(g)),n.removeAttribute("style")}function Qg(t){const n=t.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return Wd(`code.${s}`)??s}function Gu({code:t,blockKey:n}){const{t:s}=yt(),[l,d]=o.useState(null),[c,h]=o.useState(!1),m=o.useRef(null),g=o.useContext(ju);o.useEffect(()=>{let f=!1;return d(null),h(!1),Vg().then(async k=>{Yg(k);const y=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:N}=await k.render(y,t);f||d(Xg(N))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[n,t]),o.useLayoutEffect(()=>{l&&Jg(m.current)},[l]);const p=o.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??l;f&&g?.(f)},[g,l]);return c?e.jsx(Ya,{code:t,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),p()},children:e.jsx("span",{ref:m,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 Ya({code:t,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Qg(n),[h,m]=o.useState(null);o.useEffect(()=>{if(!c||!Gd(t)){m(null);return}let p=!1;return qd().then(f=>{if(p||!f.registered(c)){p||m(null);return}try{m(Kd(f,t,c))}catch{p||m(null)}}).catch(()=>{p||m(null)}),()=>{p=!0}},[s,t,c]);const g=h??(t||" ").split(`
1644
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:`${Wi} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:g.map((p,f)=>{const k=l!=null?l+f:null,y=!!(d&&k!=null&&k>=d.start&&k<=d.end);return e.jsxs("span",{"data-md-ref-start":k??void 0,"data-md-ref-end":k??void 0,"data-selected":y?"true":void 0,children:[p,f<g.length-1?`
1645
1645
  `:null]},`${s}-line-${f}`)})})})]})}function Ji(t,n,s,l,d){t=Mg(t);const c=Cg(t),h=$u(t),m=[],g={markdownFilePath:n,rootPath:s,referenceDefinitions:c,footnoteDefinitions:Ng(t),headingSlugCounts:new Map,images:m,onImageOpen:l,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(y=>`Back to footnote ${y}`)},p=[];let f=0;for(;f<t.length;){const y=t[f],N=y.trim();if(Ga(y)||h.has(f)){f+=1;continue}if(!N){f+=1;continue}if(/^<details>\s*$/i.test(N)){const D=f;let a="Details";const w=[];for(f+=1;f<t.length&&!/^<\/details>\s*$/i.test(t[f].trim());){const O=t[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);O?a=O[1].trim()||a:w.push(t[f].trimStart()),f+=1}f<t.length&&(f+=1),p.push({key:`details-${D}`,startLine:D+1,endLine:f,content:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:rt(a,`details-${D}-summary`,!0,g)}),w.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Uu(w,`details-${D}`,g)})]})});continue}const I=Fu(y);if(I){const D=[y],a=f;for(f+=1;f<t.length&&!I.selfContained&&!new RegExp(`</${I.tag}>`,"i").test(t[f]);)D.push(t[f]),f+=1;f<t.length&&!I.selfContained&&(D.push(t[f]),f+=1),p.push({key:`html-${a}`,startLine:a+1,endLine:f,content:e.jsx(Du,{html:D.join(`
1646
1646
  `)})});continue}const F=N.match(/^(```|~~~)\s*(.*)$/);if(F){const D=[],a=F[1],w=F[2]?.trim(),O=f;for(f+=1;f<t.length&&!t[f].trim().startsWith(a);)D.push(t[f]),f+=1;f<t.length&&(f+=1),p.push({key:`code-${O}`,startLine:O+1,endLine:f,fineGrained:w.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(w.toLowerCase()),content:w.toLowerCase()==="mermaid"?e.jsx(Gu,{code:D.join(`
@@ -1656,7 +1656,7 @@ ${ie}${z}
1656
1656
  ${T.join(`
1657
1657
  `)}
1658
1658
  ${ie}
1659
- `})(),Lr=`path:${Ie}`,Pt=E?`path:${Ie}:${E.start}-${E.end}`:Lr,Xr=L===Lr,Jr=L===Pt,Fs=P===Lr,Ar=P===Pt,hr=Jr||Ar,mr=E?E.start===E.end?`L${E.start}`:`L${E.start}-${E.end}`:null,kn=T=>{const z=re.current;if(!z)return;const ie=z.getBoundingClientRect(),xe=T.currentTarget.getBoundingClientRect(),Ue=T.clientX||xe.left+xe.width/2,ze=(T.clientY||xe.top+xe.height/2)-ie.top+z.scrollTop,_e=g?116:132,nt=z.scrollLeft+Math.max(8,z.clientWidth-_e),at=Math.min(Math.max(8,Ue-ie.left+z.scrollLeft+10),nt);he({top:ze,left:at})},Sn=(T,z)=>{Bi()||(kn(T),$(ie=>{const xe=_i(ie,z,z);return xe||he(null),xe}))},pr=(T,z,ie)=>{kn(T),$(xe=>{const Ue=_i(xe,z,ie);return Ue||he(null),Ue})},Zt=(T,z,ie,xe)=>{xe==="end"&&kn(T),$({start:z,end:ie})},Me=T=>{const{scrollTop:z,scrollLeft:ie}=T.currentTarget;S(z),ii(w,n,{top:z,left:ie,markdownTop:z})},er=T=>{if(T.directory){m?.(T.path);return}if(T.path===Ie||j.kind==="text"&&T.path===j.sourcePath){T.fragment&&Xn(T.fragment);return}ye(z=>[...z,Ie]),ce.current=T.path,Oe(T.fragment),$(null),O(T.path)},Qr=()=>{const T=V[V.length-1];T&&(ye(z=>z.slice(0,-1)),ce.current=T,Oe(null),$(null),O(T))},es=T=>{const{scrollTop:z,scrollLeft:ie}=T.currentTarget;ii(w,n,{top:z,left:ie})},jn=()=>{if(t){t(Er,Pt);return}E&&l(Er,Pt)},Rn=async()=>{if(!(!Ie||q.status==="pending")&&!(j.kind==="loading"||j.kind==="error")){Se({status:"pending"});try{await Uh(Ie),Se({status:"idle"})}catch(T){Se({status:"error",message:T instanceof Error?T.message:a("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Ht.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${g&&(Vr||fr)?"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:[g&&h&&e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":a("rightSidebar.backToFileList"),title:a("rightSidebar.backToFileList"),children:e.jsx(Od,{size:16})}),V.length>0&&e.jsxs("button",{type:"button",onClick:Qr,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 ${g?"w-9":"px-2.5"}`,"aria-label":a("rightSidebar.backToPreviousPreview"),title:a("rightSidebar.backToPreviousPreview"),children:[e.jsx(Ns,{size:15}),!g&&e.jsx("span",{className:"text-[11px] font-medium",children:a("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ie,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Gt.name}),Gt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Gt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Wt&&e.jsx("button",{type:"button",onClick:Re?Kr:kt,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":a("rightSidebar.findInFile"),title:`${a("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Vn,{size:14})}),Is&&j.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{p&&y?.(),je(T=>{const z=T==="preview"?"source":"preview";return xt(au,z),z}),$(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${g?"w-9 px-0":"px-3"}`,"aria-label":a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:g?me==="preview"?e.jsx(Si,{size:14}):e.jsx(ki,{size:14}):a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Jn&&j.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{Z(T=>{const z=T==="preview"?"source":"preview";return gp(w,n,z),z}),$(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${g?"w-9 px-0":"px-3"}`,"aria-label":a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:g?C==="preview"?e.jsx(Si,{size:14}):e.jsx(ki,{size:14}):a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),fr&&e.jsx("button",{type:"button",onClick:()=>{ue.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(zd,{size:15})}),!g&&e.jsx("button",{type:"button",onClick:()=>s(Ie,Lr),...Ht(Mr,Lr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Xr||Fs?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:a("rightSidebar.insertReference",{reference:Mr}),children:a(Fs?"rightSidebar.copied":Xr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Mr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:a("rightSidebar.copyReference",{reference:Mr}),"aria-label":a("rightSidebar.copyFileRef"),children:e.jsx(Ch,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{Rn()},disabled:q.status==="pending"||j.kind==="loading"||j.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:q.status==="error"?q.message??a("rightSidebar.downloadFailed"):a("rightSidebar.downloadFile"),"aria-label":a("rightSidebar.downloadFile"),children:q.status==="pending"?e.jsx(vt,{size:13,className:"animate-spin"}):e.jsx(Qh,{size:14})})]})]}),Re&&Wt&&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(Vn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:wt,type:"search",value:Qe,onChange:T=>vn(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Nr(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:a("rightSidebar.findInFilePlaceholder"),"aria-label":a("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:ht.length>0?`${Xt+1}/${ht.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Nr(-1),disabled:ht.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":a("rightSidebar.previousSearchMatch"),title:`${a("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Fd,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Nr(1),disabled:ht.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":a("rightSidebar.nextSearchMatch"),title:`${a("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Zh,{size:13})}),e.jsx("button",{type:"button",onClick:Kr,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":a("rightSidebar.closeFileSearch"),title:`${a("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Ut,{size:13})})]}),St&&!(g&&(Vr||fr))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[St.size!==null&&e.jsx("span",{children:a("rightSidebar.byteCount",{count:St.size.toLocaleString()})}),"truncated"in St&&St.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:a("rightSidebar.previewTruncated")}),"mimeType"in St&&e.jsx("span",{children:St.mimeType}),"dimensions"in j&&j.dimensions&&e.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(g&&(Vr||fr))&&!jt&&j.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:Qn?a("rightSidebar.edaPickHint"):$t?a("rightSidebar.csvTablePreview"):Ds||Qt?a("rightSidebar.kicadProjectPickHint"):Yr?a("rightSidebar.videoPreviewHint"):ro?a("rightSidebar.imagePreviewHint"):Vr?E?a("rightSidebar.selectedLineHint",{lineLabel:mr??""}):a("rightSidebar.markdownPreviewHint"):fr?a("rightSidebar.htmlPreviewHint"):E?a("rightSidebar.selectedLineHint",{lineLabel:mr??""}):a("rightSidebar.multiLineHint")})})]}),j.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:j.mode==="eda"?a("rightSidebar.edaLoading"):j.mode==="image"?a("rightSidebar.loadingImage"):j.mode==="model3d"?a("rightSidebar.model3dLoading"):j.mode==="video"?a("rightSidebar.loadingVideo"):"Loading file…"}):j.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:j.message}),e.jsx("button",{type:"button",onClick:wn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:a("common.retry")})]}):j.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:a("rightSidebar.binaryPreviewHint")})}):j.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:j.meta.mimeType==="image/svg+xml"?e.jsx(eu,{blobUrl:j.objectUrl,filePath:Ie,viewLabel:"SVG 文件",onInsertAnnotation:d}):e.jsx(of,{src:j.objectUrl,alt:Gt.name,vector:!1,onLoad:T=>{const z=T.currentTarget;X(ie=>ie.kind==="image"?{...ie,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:ie)},onError:()=>X({kind:"error",message:a("rightSidebar.imageLoadFailed")})})}):j.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(wp,{url:j.url,onLoadError:()=>X({kind:"error",message:a("rightSidebar.videoLoadFailed")})})}):j.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Mp,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:Ie.toLowerCase().endsWith(".kicad_pcb"),onViewChange:se,onInsertAnnotation:t??d,onRefresh:wn,interactive3d:fe?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(hd,{blobUrl:fe.objectUrl,ext:".glb",fileName:Gt.name,filePath:fe.sourcePath,features:null,onInsertFeature:t??d,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:j.view==="pcb-3d"})}):void 0})}):j.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(hd,{blobUrl:j.objectUrl,ext:j.ext,fileName:Gt.name,filePath:j.sourcePath,features:M,onInsertFeature:t??d,onRefresh:wn})})}):j.kind==="text"&&$t?e.jsx(Lp,{content:j.content,filePath:Ie,onInsertAnnotation:t??d},Ie):j.kind==="text"&&(Ds||Qt)?e.jsx(Tp,{content:j.content,filePath:Ie,localState:Qt,onInsertAnnotation:t??d},Ie):Vr?e.jsxs("div",{ref:re,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:Me,style:{touchAction:"pan-x pan-y"},children:[e.jsx(Yu,{content:j.content,filePath:j.sourcePath,rootPath:w,lineRange:E,onLineRangeClick:pr,onLineRangeDrag:Zt,scrollTop:ae,outlineOpen:p,outlineCloseSignal:f,onOutlineOpen:k,onOutlineClose:y,lightboxOpen:N,lightboxCloseSignal:I,onLightboxOpen:F,onLightboxClose:B,onLocalLinkOpen:er}),E&&oe&&e.jsxs("button",{type:"button",onClick:jn,...Ht(Er,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:Md(g,hr),title:`Insert markdown reference: ${$r}`,children:[e.jsx(za,{size:g?13:11}),Ar?a("rightSidebar.copied"):Jr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:mr??""})]})]}):fr?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Hp,{ref:ue,src:Nh(Ie),title:`${Gt.name} preview`,exitFullscreenLabel:a("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ge},`${Ie}:${Jt}:${zt}`)}):j.kind==="text"?e.jsxs("div",{ref:re,onScroll:es,className:`${Wi} 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:[ur.length>0?e.jsx("div",{className:"min-w-full",children:ur.map((T,z)=>{const ie=z+1,xe=!!(E&&ie>=E.start&&ie<=E.end),Ue=Le&&Le.length===ur.length?Le[z]:null;return e.jsxs("div",{ref:$e=>{$e?K.current.set(ie,$e):K.current.delete(ie)},role:"button","data-file-preview-line":ie,tabIndex:0,onClick:$e=>Sn($e,ie),onKeyDown:$e=>{$e.key!=="Enter"&&$e.key!==" "||($e.preventDefault(),Sn($e,ie))},style:{gridTemplateColumns:`${to}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${xe?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Mr}:${ie}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${xe?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ie}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ue??(T||" ")})]},z)})}):"Empty file.",E&&oe&&e.jsxs("button",{type:"button",onClick:jn,...Ht(Er,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:Md(g,hr),title:`Insert code reference: ${$r}`,children:[e.jsx(za,{size:g?13:11}),Ar?a("rightSidebar.copied"):Jr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:mr??""})]})]}):null]})}function Rb({isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c=!1,onTogglePinned:h,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:g,onOpenRightSidebarFilePreview:p,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:k=!1,rightSidebarRepoPickerCloseSignal:y,onOpenRightSidebarRepoPicker:N,onCloseRightSidebarRepoPicker:I,markdownOutlineOpen:F=!1,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L=!1,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D}){const{t:a,locale:w}=yt(),[O,j]=o.useState(""),[X,ne]=o.useState(null),se=te(r=>r.rightSearchOpen),fe=te(r=>r.setRightSearchOpen),G=te(r=>r.rightSidebarLayoutPreference),J=te(r=>r.setRightSidebarLayoutPreference),[M,_]=o.useState(()=>bg()),[K,re]=o.useState("."),[oe,he]=o.useState(""),[me,je]=o.useState(!1),[C,Z]=o.useState(!1),[ue,Ee]=o.useState(!1),[Ge,Fe]=o.useState(!1),le=o.useDeferredValue(O),[ae,S]=o.useState(null),[V,ye]=o.useState([]),[be,Oe]=o.useState([]),[ce,Je]=o.useState(null),[Le,W]=o.useState(null),[q,Se]=o.useState(null),[Re,lt]=o.useState(null),[Qe,vn]=o.useState(()=>tt(ld,ks)??!1),[ht,lr]=o.useState(()=>tt(cd,ks)??!1),[Xt,yn]=o.useState(()=>tt(dd,ks)??!1),[wt,Ht]=o.useState(()=>tt(ti,fg)??""),[qr,cr]=o.useState(0),[Jt,At]=o.useState(!1),[dr,zt]=o.useState(!1),Ts=o.useRef(null),wn=o.useRef(null),[Xn,Wt]=o.useState(!1),[Kr,kt]=o.useState(null),[Nr,Ie]=o.useState(null),[Gt,Mr]=o.useState(()=>gd(Zo)),[ur,to]=o.useState(()=>gd(id)),[St,Is]=o.useState(()=>ug()),[$t,Ds]=o.useState(()=>hg()),[Qt,Vr]=o.useState(()=>pg()),Jn="words",[fr,ro]=o.useState(0),[jt,Yr]=o.useState([]),[Qn,Zn]=o.useState([]),[$r,Er]=o.useState(!1),[Lr,Pt]=o.useState(null),[Xr,Jr]=o.useState([]),[Fs,Ar]=o.useState(!1),[hr,mr]=o.useState([]),[kn,Sn]=o.useState([]),[pr,Zt]=o.useState(!1),[Me,er]=o.useState(null),[Qr,es]=o.useState([]),[jn,Rn]=o.useState({}),[T,z]=o.useState(!1),[ie,xe]=o.useState(null),[Ue,$e]=o.useState(null),[ze,_e]=o.useState(null),[nt,at]=o.useState(null),[tr,gr]=o.useState(!1),[Cn,Zr]=o.useState(""),ts=o.useDeferredValue(Cn),[rr,rs]=o.useState({}),[en,Pr]=o.useState([]),[Q,Be]=o.useState(!1),[Tt,br]=o.useState(!1),[el,Nn]=o.useState(null),[no,Mn]=o.useState(!1),nr=o.useRef(null),Tr=o.useRef(0),tl=o.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[lf,_s]=o.useState(null),[ns,rl]=o.useState(()=>tt(ei,ks)??!1),[so,ao]=o.useState(!1),[Bs,oo]=o.useState([]),[xr,Os]=o.useState({}),[Rt,Us]=o.useState({}),[Ir,nl]=o.useState(!0),[sl,al]=o.useState(()=>new Set),[Ze,tn]=o.useState(null),[io,rn]=o.useState(null),[cf,vr]=o.useState(!1),[ol,yr]=o.useState(0),[,lo]=o.useState(0),[co,Hs]=o.useState(!1),[sr,uo]=o.useState(!1),[df,il]=o.useState(()=>te.getState().rightTab==="diff"),[Ae,ss]=o.useState(null),[$n,as]=o.useState(null),[ct,Dr]=o.useState(null),[ll,dt]=o.useState(null),[En,cl]=o.useState(null),[fo,uf]=o.useState(()=>Date.now()),[ff,hf]=o.useState(!1),[nn,zs]=o.useState(!1),[Ws,dl]=o.useState(""),[Ln,Gs]=o.useState(""),[sn,qs]=o.useState(""),[an,Ks]=o.useState(""),[ul,An]=o.useState(null),[Vs,Ys]=o.useState(!1),[fl,ho]=o.useState(!1),[hl,ml]=o.useState(!1),[Xs,mf]=o.useState({key:null,nonce:0}),pl=o.useRef(null),gl=o.useRef(null),ee=Hh(n,c,G),pf=gu(ee,c,Qt),[mo,po]=o.useState(()=>Rg(n)),go=te(r=>r.rightTab),on=te(r=>r.setRightTab),b=te(r=>r.rootPath),Pn=te(r=>r.explorerRoot),bl=te(r=>r.pinnedExplorerRootsCache),xl=te(r=>r.hydratePinnedExplorerRoots),vl=te(r=>r.syncPinnedExplorerRoots),It=te(r=>r.setExplorerRoot),yl=te(r=>r.resetExplorerToProject),Tn=te(r=>r.pinExplorerRoot),ln=te(r=>r.unpinExplorerRoot),Ve=te(r=>r.selectedFilePath),Ye=te(r=>r.selectFile),bo=te(r=>r.showHiddenFiles),gf=te(r=>r.toggleShowHiddenFiles),xo=te(r=>!!(b&&r.nestedGitScanRoots[b])),we=te(r=>r.changedFiles),Js=te(r=>r.setChangedFiles),Qs=te(r=>r.invalidateDirectoryCache),bf=te(r=>r.setDirectorySortMode),wl=te(r=>r.applyFileWatchEvents),kl=te(r=>r.reconcileDirectoryCache),Sl=te(r=>r.bumpFileWatchEpoch),Fr=te(r=>r.gitBundleLoading),jl=te(r=>r.gitBundleSlow),cn=te(r=>r.gitBundleError),In=te(r=>r.gitBundleLastLoadedAt),Rl=te(r=>r.beginGitBundleLoading),Cl=te(r=>r.setGitBundleSlowFor),vo=te(r=>r.finishGitBundleLoading),Zs=te(r=>r.resetGitBundleLoading),yo=te(r=>r.setGitBundleError),Nl=te(r=>r.markGitBundleLoaded),pe=Pn??b,Ml=o.useMemo(()=>pe?Kp(pe,K):"",[pe,K]),os=o.useMemo(()=>qp(oe),[oe]),$l=o.useMemo(()=>({excludePatterns:os,caseSensitive:C,wholeWord:ue,regex:Ge}),[C,os,Ge,ue]),ea=te(r=>pe?r.fileSortModes[pe]??"name":"name"),El=te(r=>!!(pe&&r.directoryCache.has(pe))),Dn=o.useRef(null),mt=o.useRef(0),[Ll]=o.useState(()=>++vb),wr=o.useRef(null),_r=o.useRef(null),ta=o.useRef(0),Dt=o.useRef(new Map),Ft=o.useRef(new Map),ar=o.useRef(new Set),dn=o.useRef(new Set),un=o.useRef(0),Br=o.useRef(null),Fn=o.useRef(0),_n=o.useRef(null),Bn=o.useRef(0),Or=o.useRef(null),wo=o.useRef(new Set),ko=o.useRef(null),So=o.useRef(null),ra=o.useRef(null),jo=o.useRef(null);o.useEffect(()=>{if(En===null)return;const r=Math.max(0,Date.now()-En),i=r<6e4?1e3:r<36e5?6e4:r<864e5?36e5:864e5,u=Math.max(50,i-r%i),x=window.setTimeout(()=>uf(Date.now()),u);return()=>window.clearTimeout(x)},[fo,En]);const na=o.useRef(null),kr=o.useRef(null),sa=o.useRef(null),is=o.useRef(null),ke=o.useCallback(r=>te.getState().rootPath===r,[]);o.useEffect(()=>{if(!t||typeof window>"u")return;const r=i=>{const u=Sb(i.target);u&&_a("global_change_row_event",{...jb(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:te.getState().selectedFilePath,rightTab:te.getState().rightTab,activeGitRepoRoot:ce,changedFiles:te.getState().changedFiles.size})};return window.addEventListener("pointerdown",r,{capture:!0}),window.addEventListener("click",r,{capture:!0}),()=>{window.removeEventListener("pointerdown",r,{capture:!0}),window.removeEventListener("click",r,{capture:!0})}},[ce,t]);const Al=o.useCallback(async(r=b??void 0)=>{if(!r)return null;if(ar.current.has(r)||dn.current.has(r))return et("untracked_skip_cached",{cwd:r,rootPath:b,completed:ar.current.has(r),running:dn.current.has(r)}),null;const i=b,u=ta.current+1;ta.current=u,Dt.current.set(r,u);const x=`right-sidebar-git-untracked:${r}`,v=new AbortController;Ft.current.set(r,v),dn.current.add(r),et("untracked_start",{requestId:u,cwd:r,rootPath:b});try{let R=await Uc(r,v.signal,x),A=0;for(;R.status==="running"&&A<120;){if(Dt.current.get(r)!==u||v.signal.aborted)return et("untracked_stale_result",{requestId:u,activeRequestId:Dt.current.get(r),cwd:r,status:R.status}),null;if(!ke(i))return et("untracked_root_changed",{requestId:u,cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath}),null;await new Promise(Y=>window.setTimeout(Y,A<10?1e3:3e3)),A+=1,R=await Uc(r,v.signal,x)}if(Dt.current.get(r)!==u||!ke(i))return et("untracked_stale_result",{requestId:u,activeRequestId:Dt.current.get(r),cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath,files:R.files.length,status:R.status}),null;if(R.status==="done")return Js(Zu(te.getState().changedFiles,R.files)),R.files.length>0&&ye(Y=>{const He=new Map(Y.map(Ne=>[Ne.root,Ne])).get(r);if(!He)return Y;const Pe=ib(He.files,R.files),De=Y.map(Ne=>Ne.root===r?{...Ne,files:Pe,context:Ne.context?{...Ne.context,changedFiles:Pe.map(qe=>({path:qe.path,absolutePath:qe.absolutePath,status:qe.status})),truncated:!1}:Ne.context,untrackedDeferred:!1}:Ne);Oe(ef(De,b));const ge=De.find(Ne=>Ne.root===b);return ge?.context&&S(Ne=>Ne?.root===ge.root?{...Ne,...ge.context}:Ne),De}),ar.current.add(r),et("untracked_apply",{requestId:u,cwd:r,files:R.files.length}),R;const H=R.error||(R.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return ar.current.add(r),et("untracked_error",{requestId:u,cwd:r,message:H,code:R.code,status:R.status}),null}catch(R){if(Dt.current.get(r)!==u||!ke(i)||Cr(R))return et("untracked_aborted",{requestId:u,activeRequestId:Dt.current.get(r),cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath,message:R instanceof Error?R.message:String(R)}),null;const A=R instanceof Error?R.message:"Failed to scan untracked files";return ar.current.add(r),et("untracked_error",{requestId:u,cwd:r,message:A}),null}finally{Ft.current.get(r)===v&&Ft.current.delete(r),Dt.current.get(r)===u&&Dt.current.delete(r),dn.current.delete(r)}},[ae,ke,b,Js]),qt=o.useMemo(()=>{const r=new Set(be.map(u=>u.root)),i=Xr.filter(u=>r.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Xr,be]),Pl=qt.length===0,fn=o.useMemo(()=>qt.map(r=>V.find(i=>i.root===r)).filter(r=>!!r),[qt,V]),xf=o.useMemo(()=>be.map(r=>({root:r.root,label:r.label,branch:r.branch??null})),[be]),or=o.useCallback(async()=>{if(!b){Yr([]),Zn([]);return}const r=b,i=Fn.current+1;Fn.current=i,_n.current?.abort();const u=new AbortController;_n.current=u,Er(jt.length===0),Pt(null);try{const x=qt.length>0?await Promise.all(qt.map(v=>Hc({workspaceRoot:b,repoRoot:v},u.signal))).then(v=>({records:v.flatMap(R=>R.records),walkthroughs:v.flatMap(R=>R.walkthroughs??[])})):await Hc({workspaceRoot:b},u.signal);if(Fn.current!==i||!ke(r))return;Yr(x.records),Zn(x.walkthroughs??[])}catch(x){if(Fn.current!==i||!ke(r)||Cr(x))return;Pt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{_n.current===u&&(_n.current=null),Fn.current===i&&ke(r)&&Er(!1)}},[jt.length,qt,ke,b]),aa=o.useCallback(async(r,i,u)=>{if(!r&&!b){mr([]),Sn([]);return}const x=b,v=Bn.current+1;Bn.current=v,Or.current?.abort();const R=new AbortController;Or.current=R;try{const A=r?[r]:Array.from(new Set([b,...V.map(Y=>Y.root)].filter(Y=>!!Y))),H=await Promise.all(A.map(Y=>$h({repoRoot:Y,baseRef:i,branchName:u},R.signal))).then(Y=>{const Ce=new Map,He=new Map;for(const Pe of Y){for(const De of Pe.records)Ce.set(De.id,De);for(const De of Pe.walkthroughs??[])He.set(De.id,De)}return{records:Array.from(Ce.values()),walkthroughs:Array.from(He.values())}});if(Bn.current!==v||!ke(x))return;mr(H.records),Sn(H.walkthroughs??[])}catch(A){if(Bn.current!==v||!ke(x)||Cr(A))return;console.warn("[RightSidebar] Failed to load branch explanations",A)}finally{Or.current===R&&(Or.current=null)}},[V,ke,b]),Ur=o.useCallback((r,i={})=>{if(!ke(b)){et("apply_skipped_root_changed",{expectedRootPath:b,currentRootPath:te.getState().rootPath,bundleRoot:r.context?.root,files:r.files.length});return}et(r.files.length===0?"empty_bundle":"apply",{rootPath:b,available:r.available,files:r.files.length,repositories:r.repositories?.map(ge=>({root:ge.root,relativeRoot:ge.relativeRoot,files:ge.files.length,available:ge.available,error:ge.error})),repoFilters:r.repoFilters?.map(ge=>({root:ge.root,label:ge.label,count:ge.count})),cached:r.cached,stale:r.stale,cacheAgeMs:r.cacheAgeMs,untrackedDeferred:r.untrackedDeferred,error:r.error});let u=bu(r),x=r.repoFilters??[],v=r.files;const R=te.getState().changedFiles;if(!!(i.cacheOnly&&!r.cached&&r.files.length===0&&u.length===0)&&(R.size>0||V.length>0||ae)){et("cache_only_apply_skipped_empty_backend_cache",{rootPath:b,currentFiles:R.size,currentRepositories:V.length});return}const H=u.some(ge=>ge.deferred);if(H&&!i.replaceWorkspace){const ge=new Set(u.filter(qe=>!qe.deferred||qe.root===b).map(qe=>qe.root));v=[...Array.from(R.values()).filter(qe=>!ge.has(it(qe,b)??"")),...r.files]}const Y=$d(R.values(),b),Ce=$d(r.files,b),He=u.some(ge=>ge.root!==b);if(!!(i.background&&!H&&!i.replaceWorkspace&&R.size>0&&(r.files.length===0&&!r.error||Y>0&&Ce===0&&!He))){et("background_apply_skipped_degraded_bundle",{rootPath:b,currentFiles:R.size,nextFiles:r.files.length,currentNestedCount:Y,nextNestedCount:Ce,nextRepositories:u.map(ge=>({root:ge.root,relativeRoot:ge.relativeRoot,files:ge.files.length})),cached:r.cached,stale:r.stale,error:r.error});return}if(i.replaceRepoRoot){const ge=tf(R.values(),V,r,i.replaceRepoRoot,b);v=ge.files,u=ge.repositories,x=ge.repoFilters}if(Js(Qu(v)),ye(u),Oe(x),i.syncActiveRepo!==!1){const ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:ce??pd(b),Ne=vg({...r,repositories:u,repoFilters:x},ge);Je(Ne),ni(b,Ne)}typeof r.cacheUpdatedAt=="number"&&cl(r.cacheUpdatedAt),S(ge=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==b)return ge;if(!r.context)return null;const Ne=ge?.root??b;return!ge?.available||Ne!==(r.context.root??b)?r.context:{...ge,...r.context}}),i.reloadDiff&&ro(ge=>ge+1);const De=te.getState().selectedFilePath;if(De&&!De.startsWith("/")&&!v.some(ge=>ge.path===De||ge.absolutePath===De)&&Ye(null),Mr(ge=>{const Ne=new Set(v.map(Yt=>it(Yt,b)).filter(Boolean)),qe=new Set;for(const Yt of ge)Ne.has(Yt)&&qe.add(Yt);return si(Zo,qe),qe}),i.loadDeferred!==!1){const ge=u.filter(Ne=>Ne.untrackedDeferred&&Ne.root).map(Ne=>Ne.root);for(const Ne of ge)Al(Ne)}i.loadAudit!==!1&&or()},[ce,ke,or,Al,b,Ye,Js]);o.useEffect(()=>{Zs(),ko.current=null,So.current=b;const r=[],i=[],x=pd(b);mt.current+=1,un.current+=1,ta.current+=1,wr.current?.abort(),bt(Kn(_r.current?.cwd??b??void 0)),_r.current=null,wr.current=null,Br.current?.abort(),bt("right-sidebar-git-details"),Br.current=null;for(const Y of Ft.current.values())Y.abort();for(const Y of Ft.current.keys())bt(`right-sidebar-git-untracked:${Y}`);Ft.current.clear(),Dt.current.clear(),Fn.current+=1,_n.current?.abort(),_n.current=null,Bn.current+=1,Or.current?.abort(),Or.current=null,Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,Yr([]),Zn([]),Er(!1),Pt(null),Jr([]),Ar(!1),mr([]),Sn([]),Zt(!1),er(null),z(!1),xe(null),$e(null),_e(null),at(null),gr(!1),Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1),_s(null),tn(null),rn(null),rl(!1),xt(ei,!1),ao(!1);const v=b?bd()[b]:null,R=v?.previewEntries??[],A=v?.selectedPreviewKey??null,H=A?R.find(Y=>Y.key===A)??null:null;oo(v?.selectedRepoRoots??[]),Os(v?.repoTargetBranches??{}),Us(v?.repoBaseBranches??{}),es(R),Rn(v?.previewScrollTops??{}),H&&v?.previewDetailOpen&&(H.diff.hunks?.length??0)>0&&(er(H.diff),tn(H.key),rn(v.selectedPreviewFileKey??(H.diff.hunks?.[0]?`${H.diff.hunks[0].filePath}\0${H.diff.hunks[0].hunkHeader}\0${H.diff.hunks[0].hunkIndex}`:null)),Zt(!0)),nl(v?.includeUncommitted??!0),ko.current=b,zs(!1),Je(x??null),ar.current.clear(),dn.current.clear(),ss(null),as(null),Dr(null),dt(null),cl(null),ye(r),Oe(i),S(null),jo.current=null},[Zs,b]);const Kt=o.useCallback(async(r=b??void 0,i={})=>{if(!r)return null;const u=b,x=mt.current;if(await Um(te.getState().hydrateNestedGitScanRoots),mt.current!==x||!ke(u))return null;const v=r===b&&Gn(b),R=i.includeNested??v,A=i.refresh??i.reloadDiff??!1,H=i.cacheOnly??!1,Y=i.background??!1,Ce=R&&(i.discoverOnly??!1);A&&ar.current.clear();const He=_r.current;if(He&&He.cwd===r&&He.includeNested===R&&He.refresh===A&&He.cacheOnly===H&&He.discoverOnly===Ce)return et("reuse_pending",{cwd:r,includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce}),He.promise;const Pe=mt.current+1;mt.current=Pe;const De=`right-sidebar:${Ll}:${Pe}`;wr.current?.abort();const ge=Kn(r);bt(ge);const Ne=new AbortController;wr.current=Ne;let qe=null;Y||Rl(De),yo(null),et("start",{requestId:Pe,cwd:r,rootPath:b,requestSlotId:ge,includeNested:R,refresh:A,cacheOnly:H,background:Y,existingChanges:we.size,lastLoadedAt:In}),!Y&&typeof window<"u"&&(qe=window.setTimeout(()=>{mt.current===Pe&&Cl(De,!0)},rg));const Yt=(async()=>{const Te=await Ca(r,Ne.signal,{includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce,action:A?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:ge,requestTimeoutMs:A?null:void 0});if(db(Te)){if(et("cancelled_result_ignored",{requestId:Pe,activeRequestId:mt.current,cwd:r,error:Te.error??Te.context?.error}),Ne.signal.aborted)return null;throw new Error(Te.error??Te.context?.error??"Failed to load Git changes")}return mt.current!==Pe||!ke(u)?(et("stale_result",{requestId:Pe,activeRequestId:mt.current,cwd:r,expectedRootPath:u,currentRootPath:te.getState().rootPath,files:Te.files.length,repositories:Te.repositories?.length??0}),null):(Ur(Te,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:R,background:Y,cacheOnly:H,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),Te)})();_r.current={cwd:r,includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce,promise:Yt};try{const Te=await Yt;return mt.current===Pe&&Te&&ke(u)?Nl({cached:Te.cached,stale:Te.stale,cacheAgeMs:Te.cacheAgeMs,nestedDeferred:!R||Te.nestedDeferred,untrackedDeferred:Te.untrackedDeferred}):mt.current===Pe&&ke(u)&&vo(De),Te}catch(Te){return mt.current!==Pe||!ke(u)||Ne.signal.aborted?(et("aborted",{requestId:Pe,activeRequestId:mt.current,cwd:r,expectedRootPath:u,currentRootPath:te.getState().rootPath,message:Te instanceof Error?Te.message:String(Te)}),null):(et("error",{requestId:Pe,cwd:r,includeNested:R,refresh:A,background:Y,message:Te instanceof Error?Te.message:String(Te)}),Y||(S(null),yo(Te instanceof Error?Te.message:"Failed to load Git changes")),null)}finally{qe!==null&&window.clearTimeout(qe),wr.current===Ne&&(wr.current=null),_r.current?.promise===Yt&&(_r.current=null),!Y&&mt.current===Pe&&ke(u)&&vo(De)}},[Ur,Rl,we.size,vo,Ll,In,ke,Nl,b,yo,Cl]),ls=o.useCallback(async()=>{b&&await Kt(b,{reloadDiff:!0,refresh:!0})},[Kt,b]),Ro=o.useCallback(async(r=b??void 0)=>{if(!r)return null;const i=b,u=un.current+1;un.current=u,Br.current?.abort(),bt("right-sidebar-git-details");const x=new AbortController;Br.current=x,zs(!0);try{const v=await zc(r,x.signal,"load_git_details","right-sidebar-git-details");return un.current!==u||!ke(i)?null:(ye(R=>R.map(A=>A.root===v.root?{...A,available:v.available,context:v,error:v.error}:A)),S(R=>R?.root&&v.root&&R.root!==v.root?R:!R?.available||!v.available?v:{...R,...v}),v)}catch(v){return Cr(v)||!ke(i)||un.current===u&&dt(v instanceof Error?v.message:"Failed to load Git details"),null}finally{Br.current===x&&(Br.current=null),un.current===u&&ke(i)&&zs(!1)}},[ke,b]);o.useEffect(()=>{if(!t){mt.current+=1,Zs(),jo.current=null,un.current+=1,ta.current+=1,wr.current?.abort(),bt(Kn(_r.current?.cwd??b??void 0)),_r.current=null,wr.current=null,Br.current?.abort(),bt("right-sidebar-git-details"),Br.current=null;for(const r of Ft.current.values())r.abort();for(const r of Ft.current.keys())bt(`right-sidebar-git-untracked:${r}`);Ft.current.clear(),Dt.current.clear(),Bn.current+=1,Or.current?.abort(),Or.current=null,Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,zs(!1),z(!1),xe(null),$e(null),_e(null),at(null),gr(!1),Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1),j(""),fe(!1),kt(null),uo(!1),ee&&il(!1)}},[ee,t,Zs,fe]),o.useEffect(()=>{if(!se)return;const r=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(r)},[se]),o.useEffect(()=>{ee||vr(!1)},[ee]);const cs=o.useCallback(r=>{lo(r);const i=sa.current;i&&(i.update(),i.slideTo(r,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(r,0)}))},[]);o.useEffect(()=>{if(ee)if(vr(m),m&&Ve){yr(1);const r=kr.current;r&&(r.update(),r.activeIndex!==1&&(is.current=1,r.slideTo(1,0)))}else{yr(0);const r=kr.current;r&&r.activeIndex!==0&&(is.current=0,r.slideTo(0,0)),kt(null)}},[ee,m,b,Ve]),o.useEffect(()=>{if(g!==void 0&&!m){yr(0);const r=kr.current;r&&r.activeIndex!==0&&(is.current=0,r.slideTo(0,0)),vr(!1),kt(null)}},[g,m]),o.useEffect(()=>{y!==void 0&&W(null)},[y]),o.useEffect(()=>{!ee&&m&&f?.()},[ee,f,m]),o.useEffect(()=>{po(r=>Li(r,n))},[n]);const vf=o.useCallback(r=>{ee||(r.preventDefault(),na.current={startX:r.clientX,startWidth:mo,pointerId:r.pointerId},r.currentTarget.setPointerCapture(r.pointerId))},[mo,ee]),yf=o.useCallback(r=>{const i=na.current;if(!i||i.pointerId!==r.pointerId)return;const u=Li(i.startWidth+r.clientX-i.startX,n);po(u),Ss(ws,u,tg)},[n]),Tl=o.useCallback(r=>{const i=na.current;if(!(!i||i.pointerId!==r.pointerId)){na.current=null,xs(ws);try{r.currentTarget.releasePointerCapture(r.pointerId)}catch{}}},[]),ds=!!(b&&In!==null&&Ad(ae)),Co=!!(b&&!cn&&we.size===0&&In===null),Hr=ds?"files":go,Xe=Hr==="git",On=Hr==="files",pt=Hr==="diff";o.useEffect(()=>{if(!ee){Hs(!0);return}if(!t){const i=window.setTimeout(()=>{Hs(!1)},sg);return()=>window.clearTimeout(i)}Hs(!1);const r=window.setTimeout(()=>{Hs(!0)},ng);return()=>window.clearTimeout(r)},[ee,t]),o.useEffect(()=>{if(!ee||!pt)return;const r=sa.current;if(!r)return;const i=window.requestAnimationFrame(()=>{r.update()});return()=>window.cancelAnimationFrame(i)},[pt,ee]),o.useEffect(()=>{if(!ds||!b||Fr)return;const r=window.setTimeout(()=>{Kt(b,{background:!0})},3e3);return()=>window.clearTimeout(r)},[ds,b,Fr,Kt]);const wf=o.useCallback(r=>{Kt(r,{discoverOnly:!0})},[Kt]);Hm({active:t&&(Xe||pt),rootPath:b,loading:Fr,delay:Xe&&!ee?0:ri,lastStartedRoot:jo,load:wf}),o.useEffect(()=>{!t||!Xe||(!ee||co)&&uo(!0)},[Xe,ee,t,co]),o.useEffect(()=>{if(!t||Xe)return;const r=window.setTimeout(()=>{uo(!0)},ri);return()=>window.clearTimeout(r)},[Xe,t]),o.useEffect(()=>{pt&&il(!0)},[pt]);const Il=o.useCallback(r=>{pe&&rb(pe,r.currentTarget.scrollTop)},[pe]);o.useEffect(()=>()=>{wr.current?.abort(),xs(Hi),xs(zi),xs(ws),xs(ti)},[]),o.useEffect(()=>{if(!pe||!El)return;const r=Xu()[pe]?.top;if(typeof r!="number")return;let i=window.requestAnimationFrame(()=>{Dn.current&&(Dn.current.scrollTop=r),i=window.requestAnimationFrame(()=>{Dn.current&&(Dn.current.scrollTop=r)})});return()=>window.cancelAnimationFrame(i)},[pe,El]),o.useEffect(()=>{if(!t)return;const r=new AbortController;return Eh(r.signal).then(i=>ml(!!i.available)).catch(()=>ml(!1)),()=>r.abort()},[t]);const us=o.useCallback(r=>{if(ne(null),Ye(r),kt(null),ee){vr(!0),yr(1),kr.current?.slideTo(1),p?.();return}},[ee,p,Ye]),Dl=o.useCallback((r,i)=>{if(ne(null),Ye(r),Ie(i),ee){vr(!0),yr(1),kr.current?.slideTo(1),p?.();return}},[ee,p,Ye]),fs=o.useCallback(async(r,i)=>{const u=i||Pn||b;if(!(!u||r.length===0)){Ys(!0);try{await Yo(u,r),Qs(u,!1)}catch(x){dt(x instanceof Error?x.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>dt(null),4e3)}finally{Ys(!1)}}},[Pn,b,Qs,a]),Fl=o.useCallback(async r=>{try{await Lh(r)}catch(i){dt(i instanceof Error?i.message:a("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>dt(null),4e3)}},[a]),oa=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),r.dataTransfer.types.includes("Files")&&ho(!0)},[]),_l=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),ho(!1)},[]),Bl=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),ho(!1);const i=r.dataTransfer.files;i.length>0&&fs(Array.from(i))},[fs]),No=o.useCallback(r=>{Se(r),window.setTimeout(()=>Se(i=>i===r?null:i),1400)},[]),Sr=o.useCallback(r=>{lt(r),window.setTimeout(()=>lt(i=>i===r?null:i),1400)},[]);o.useEffect(()=>{xt(ld,Qe)},[Qe]),o.useEffect(()=>{xt(cd,ht)},[ht]),o.useEffect(()=>{xt(dd,Xt)},[Xt]),o.useEffect(()=>{Ss(ti,wt,Xp)},[wt]),o.useEffect(()=>(xl().catch(()=>{}),Wc(r=>{r.type==="pinned-explorer-roots"&&vl(r.pinnedExplorerRoots)})),[xl,vl]);const Ol=o.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ia=o.useRef(null),hn=o.useRef(null),[Ul,Mo]=o.useState(!1);o.useEffect(()=>{if(!t)return;Mo(!1);let r=!1;Ah().then(u=>{r||(ia.current=u.text,Ht(x=>u.text&&u.text!==x?u.text:x),Mo(!0))}).catch(()=>{r||Mo(!0)});const i=Wc(u=>{u.type==="context-draft"&&u.origin!==Ol.current&&(ia.current=u.text,Ht(u.text))});return()=>{r=!0,i(),hn.current!==null&&(window.clearTimeout(hn.current),hn.current=null)}},[t]),o.useEffect(()=>{if(!Ul||ia.current===wt)return;hn.current!==null&&window.clearTimeout(hn.current);const r=wt;hn.current=window.setTimeout(()=>{hn.current=null,Ph(r,Ol.current).then(()=>{ia.current=r}).catch(()=>{})},500)},[wt,Ul]);const Un=o.useCallback((r,i,u)=>{if(r){if(Th(u?r+u:r)){No(i);return}Qe?(Ht(x=>hp(x,r)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(lr(!1),cr(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?r+u:r,focus:!0}})),No(i)}},[Qe,No]),la=o.useCallback(r=>{const i=Ma(r,b);return em(i,b)},[b]),$o=Vd(Sr),zr=o.useCallback((r,i)=>{const u=Ma(r,b);Un(tm(u,b),i??`path:${u}`)},[b,Un]),kf=o.useCallback(async r=>{Ys(!0);try{await rm(r,Yo,i=>{zr(i,`path:${i}`)}),ee&&!Qe&&s()}catch(i){dt(i instanceof Error?i.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>dt(null),4e3)}finally{Ys(!1)}},[Qe,zr,ee,s,a]),jr=o.useCallback((r,i)=>{if(!r)return;const u=r.includes(`
1659
+ `})(),Lr=`path:${Ie}`,Pt=E?`path:${Ie}:${E.start}-${E.end}`:Lr,Xr=L===Lr,Jr=L===Pt,Fs=P===Lr,Ar=P===Pt,hr=Jr||Ar,mr=E?E.start===E.end?`L${E.start}`:`L${E.start}-${E.end}`:null,kn=T=>{const z=re.current;if(!z)return;const ie=z.getBoundingClientRect(),xe=T.currentTarget.getBoundingClientRect(),Ue=T.clientX||xe.left+xe.width/2,ze=(T.clientY||xe.top+xe.height/2)-ie.top+z.scrollTop,_e=g?116:132,nt=z.scrollLeft+Math.max(8,z.clientWidth-_e),at=Math.min(Math.max(8,Ue-ie.left+z.scrollLeft+10),nt);he({top:ze,left:at})},Sn=(T,z)=>{Bi()||(kn(T),$(ie=>{const xe=_i(ie,z,z);return xe||he(null),xe}))},pr=(T,z,ie)=>{kn(T),$(xe=>{const Ue=_i(xe,z,ie);return Ue||he(null),Ue})},Zt=(T,z,ie,xe)=>{xe==="end"&&kn(T),$({start:z,end:ie})},Me=T=>{const{scrollTop:z,scrollLeft:ie}=T.currentTarget;S(z),ii(w,n,{top:z,left:ie,markdownTop:z})},er=T=>{if(T.directory){m?.(T.path);return}if(T.path===Ie||j.kind==="text"&&T.path===j.sourcePath){T.fragment&&Xn(T.fragment);return}ye(z=>[...z,Ie]),ce.current=T.path,Oe(T.fragment),$(null),O(T.path)},Qr=()=>{const T=V[V.length-1];T&&(ye(z=>z.slice(0,-1)),ce.current=T,Oe(null),$(null),O(T))},es=T=>{const{scrollTop:z,scrollLeft:ie}=T.currentTarget;ii(w,n,{top:z,left:ie})},jn=()=>{if(t){t(Er,Pt);return}E&&l(Er,Pt)},Rn=async()=>{if(!(!Ie||q.status==="pending")&&!(j.kind==="loading"||j.kind==="error")){Se({status:"pending"});try{await Uh(Ie),Se({status:"idle"})}catch(T){Se({status:"error",message:T instanceof Error?T.message:a("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Ht.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${g&&(Vr||fr)?"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:[g&&h&&e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":a("rightSidebar.backToFileList"),title:a("rightSidebar.backToFileList"),children:e.jsx(Od,{size:16})}),V.length>0&&e.jsxs("button",{type:"button",onClick:Qr,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 ${g?"w-9":"px-2.5"}`,"aria-label":a("rightSidebar.backToPreviousPreview"),title:a("rightSidebar.backToPreviousPreview"),children:[e.jsx(Ns,{size:15}),!g&&e.jsx("span",{className:"text-[11px] font-medium",children:a("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ie,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Gt.name}),Gt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Gt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Wt&&e.jsx("button",{type:"button",onClick:Re?Kr:kt,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":a("rightSidebar.findInFile"),title:`${a("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Vn,{size:14})}),Is&&j.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{p&&y?.(),je(T=>{const z=T==="preview"?"source":"preview";return xt(au,z),z}),$(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${g?"w-9 px-0":"px-3"}`,"aria-label":a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:g?me==="preview"?e.jsx(Si,{size:14}):e.jsx(ki,{size:14}):a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Jn&&j.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{Z(T=>{const z=T==="preview"?"source":"preview";return gp(w,n,z),z}),$(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${g?"w-9 px-0":"px-3"}`,"aria-label":a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:g?C==="preview"?e.jsx(Si,{size:14}):e.jsx(ki,{size:14}):a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),fr&&e.jsx("button",{type:"button",onClick:()=>{ue.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(Ud,{size:15})}),!g&&e.jsx("button",{type:"button",onClick:()=>s(Ie,Lr),...Ht(Mr,Lr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Xr||Fs?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:a("rightSidebar.insertReference",{reference:Mr}),children:a(Fs?"rightSidebar.copied":Xr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Mr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:a("rightSidebar.copyReference",{reference:Mr}),"aria-label":a("rightSidebar.copyFileRef"),children:e.jsx(Ch,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{Rn()},disabled:q.status==="pending"||j.kind==="loading"||j.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:q.status==="error"?q.message??a("rightSidebar.downloadFailed"):a("rightSidebar.downloadFile"),"aria-label":a("rightSidebar.downloadFile"),children:q.status==="pending"?e.jsx(vt,{size:13,className:"animate-spin"}):e.jsx(Qh,{size:14})})]})]}),Re&&Wt&&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(Vn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:wt,type:"search",value:Qe,onChange:T=>vn(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Nr(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:a("rightSidebar.findInFilePlaceholder"),"aria-label":a("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:ht.length>0?`${Xt+1}/${ht.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Nr(-1),disabled:ht.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":a("rightSidebar.previousSearchMatch"),title:`${a("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Fd,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Nr(1),disabled:ht.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":a("rightSidebar.nextSearchMatch"),title:`${a("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Zh,{size:13})}),e.jsx("button",{type:"button",onClick:Kr,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":a("rightSidebar.closeFileSearch"),title:`${a("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Ut,{size:13})})]}),St&&!(g&&(Vr||fr))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[St.size!==null&&e.jsx("span",{children:a("rightSidebar.byteCount",{count:St.size.toLocaleString()})}),"truncated"in St&&St.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:a("rightSidebar.previewTruncated")}),"mimeType"in St&&e.jsx("span",{children:St.mimeType}),"dimensions"in j&&j.dimensions&&e.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(g&&(Vr||fr))&&!jt&&j.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:Qn?a("rightSidebar.edaPickHint"):$t?a("rightSidebar.csvTablePreview"):Ds||Qt?a("rightSidebar.kicadProjectPickHint"):Yr?a("rightSidebar.videoPreviewHint"):ro?a("rightSidebar.imagePreviewHint"):Vr?E?a("rightSidebar.selectedLineHint",{lineLabel:mr??""}):a("rightSidebar.markdownPreviewHint"):fr?a("rightSidebar.htmlPreviewHint"):E?a("rightSidebar.selectedLineHint",{lineLabel:mr??""}):a("rightSidebar.multiLineHint")})})]}),j.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:j.mode==="eda"?a("rightSidebar.edaLoading"):j.mode==="image"?a("rightSidebar.loadingImage"):j.mode==="model3d"?a("rightSidebar.model3dLoading"):j.mode==="video"?a("rightSidebar.loadingVideo"):"Loading file…"}):j.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:j.message}),e.jsx("button",{type:"button",onClick:wn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:a("common.retry")})]}):j.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:a("rightSidebar.binaryPreviewHint")})}):j.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:j.meta.mimeType==="image/svg+xml"?e.jsx(eu,{blobUrl:j.objectUrl,filePath:Ie,viewLabel:"SVG 文件",onInsertAnnotation:d}):e.jsx(of,{src:j.objectUrl,alt:Gt.name,vector:!1,onLoad:T=>{const z=T.currentTarget;X(ie=>ie.kind==="image"?{...ie,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:ie)},onError:()=>X({kind:"error",message:a("rightSidebar.imageLoadFailed")})})}):j.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(wp,{url:j.url,onLoadError:()=>X({kind:"error",message:a("rightSidebar.videoLoadFailed")})})}):j.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Mp,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:Ie.toLowerCase().endsWith(".kicad_pcb"),onViewChange:se,onInsertAnnotation:t??d,onRefresh:wn,interactive3d:fe?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(hd,{blobUrl:fe.objectUrl,ext:".glb",fileName:Gt.name,filePath:fe.sourcePath,features:null,onInsertFeature:t??d,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:j.view==="pcb-3d"})}):void 0})}):j.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(hd,{blobUrl:j.objectUrl,ext:j.ext,fileName:Gt.name,filePath:j.sourcePath,features:M,onInsertFeature:t??d,onRefresh:wn})})}):j.kind==="text"&&$t?e.jsx(Lp,{content:j.content,filePath:Ie,onInsertAnnotation:t??d},Ie):j.kind==="text"&&(Ds||Qt)?e.jsx(Tp,{content:j.content,filePath:Ie,localState:Qt,onInsertAnnotation:t??d},Ie):Vr?e.jsxs("div",{ref:re,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:Me,style:{touchAction:"pan-x pan-y"},children:[e.jsx(Yu,{content:j.content,filePath:j.sourcePath,rootPath:w,lineRange:E,onLineRangeClick:pr,onLineRangeDrag:Zt,scrollTop:ae,outlineOpen:p,outlineCloseSignal:f,onOutlineOpen:k,onOutlineClose:y,lightboxOpen:N,lightboxCloseSignal:I,onLightboxOpen:F,onLightboxClose:B,onLocalLinkOpen:er}),E&&oe&&e.jsxs("button",{type:"button",onClick:jn,...Ht(Er,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:Md(g,hr),title:`Insert markdown reference: ${$r}`,children:[e.jsx(za,{size:g?13:11}),Ar?a("rightSidebar.copied"):Jr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:mr??""})]})]}):fr?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Hp,{ref:ue,src:Nh(Ie),title:`${Gt.name} preview`,exitFullscreenLabel:a("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ge},`${Ie}:${Jt}:${zt}`)}):j.kind==="text"?e.jsxs("div",{ref:re,onScroll:es,className:`${Wi} 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:[ur.length>0?e.jsx("div",{className:"min-w-full",children:ur.map((T,z)=>{const ie=z+1,xe=!!(E&&ie>=E.start&&ie<=E.end),Ue=Le&&Le.length===ur.length?Le[z]:null;return e.jsxs("div",{ref:$e=>{$e?K.current.set(ie,$e):K.current.delete(ie)},role:"button","data-file-preview-line":ie,tabIndex:0,onClick:$e=>Sn($e,ie),onKeyDown:$e=>{$e.key!=="Enter"&&$e.key!==" "||($e.preventDefault(),Sn($e,ie))},style:{gridTemplateColumns:`${to}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${xe?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Mr}:${ie}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${xe?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ie}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ue??(T||" ")})]},z)})}):"Empty file.",E&&oe&&e.jsxs("button",{type:"button",onClick:jn,...Ht(Er,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:Md(g,hr),title:`Insert code reference: ${$r}`,children:[e.jsx(za,{size:g?13:11}),Ar?a("rightSidebar.copied"):Jr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:mr??""})]})]}):null]})}function Rb({isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c=!1,onTogglePinned:h,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:g,onOpenRightSidebarFilePreview:p,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:k=!1,rightSidebarRepoPickerCloseSignal:y,onOpenRightSidebarRepoPicker:N,onCloseRightSidebarRepoPicker:I,markdownOutlineOpen:F=!1,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L=!1,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D}){const{t:a,locale:w}=yt(),[O,j]=o.useState(""),[X,ne]=o.useState(null),se=te(r=>r.rightSearchOpen),fe=te(r=>r.setRightSearchOpen),G=te(r=>r.rightSidebarLayoutPreference),J=te(r=>r.setRightSidebarLayoutPreference),[M,_]=o.useState(()=>bg()),[K,re]=o.useState("."),[oe,he]=o.useState(""),[me,je]=o.useState(!1),[C,Z]=o.useState(!1),[ue,Ee]=o.useState(!1),[Ge,Fe]=o.useState(!1),le=o.useDeferredValue(O),[ae,S]=o.useState(null),[V,ye]=o.useState([]),[be,Oe]=o.useState([]),[ce,Je]=o.useState(null),[Le,W]=o.useState(null),[q,Se]=o.useState(null),[Re,lt]=o.useState(null),[Qe,vn]=o.useState(()=>tt(ld,ks)??!1),[ht,lr]=o.useState(()=>tt(cd,ks)??!1),[Xt,yn]=o.useState(()=>tt(dd,ks)??!1),[wt,Ht]=o.useState(()=>tt(ti,fg)??""),[qr,cr]=o.useState(0),[Jt,At]=o.useState(!1),[dr,zt]=o.useState(!1),Ts=o.useRef(null),wn=o.useRef(null),[Xn,Wt]=o.useState(!1),[Kr,kt]=o.useState(null),[Nr,Ie]=o.useState(null),[Gt,Mr]=o.useState(()=>gd(Zo)),[ur,to]=o.useState(()=>gd(id)),[St,Is]=o.useState(()=>ug()),[$t,Ds]=o.useState(()=>hg()),[Qt,Vr]=o.useState(()=>pg()),Jn="words",[fr,ro]=o.useState(0),[jt,Yr]=o.useState([]),[Qn,Zn]=o.useState([]),[$r,Er]=o.useState(!1),[Lr,Pt]=o.useState(null),[Xr,Jr]=o.useState([]),[Fs,Ar]=o.useState(!1),[hr,mr]=o.useState([]),[kn,Sn]=o.useState([]),[pr,Zt]=o.useState(!1),[Me,er]=o.useState(null),[Qr,es]=o.useState([]),[jn,Rn]=o.useState({}),[T,z]=o.useState(!1),[ie,xe]=o.useState(null),[Ue,$e]=o.useState(null),[ze,_e]=o.useState(null),[nt,at]=o.useState(null),[tr,gr]=o.useState(!1),[Cn,Zr]=o.useState(""),ts=o.useDeferredValue(Cn),[rr,rs]=o.useState({}),[en,Pr]=o.useState([]),[Q,Be]=o.useState(!1),[Tt,br]=o.useState(!1),[el,Nn]=o.useState(null),[no,Mn]=o.useState(!1),nr=o.useRef(null),Tr=o.useRef(0),tl=o.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[lf,_s]=o.useState(null),[ns,rl]=o.useState(()=>tt(ei,ks)??!1),[so,ao]=o.useState(!1),[Bs,oo]=o.useState([]),[xr,Os]=o.useState({}),[Rt,Us]=o.useState({}),[Ir,nl]=o.useState(!0),[sl,al]=o.useState(()=>new Set),[Ze,tn]=o.useState(null),[io,rn]=o.useState(null),[cf,vr]=o.useState(!1),[ol,yr]=o.useState(0),[,lo]=o.useState(0),[co,Hs]=o.useState(!1),[sr,uo]=o.useState(!1),[df,il]=o.useState(()=>te.getState().rightTab==="diff"),[Ae,ss]=o.useState(null),[$n,as]=o.useState(null),[ct,Dr]=o.useState(null),[ll,dt]=o.useState(null),[En,cl]=o.useState(null),[fo,uf]=o.useState(()=>Date.now()),[ff,hf]=o.useState(!1),[nn,zs]=o.useState(!1),[Ws,dl]=o.useState(""),[Ln,Gs]=o.useState(""),[sn,qs]=o.useState(""),[an,Ks]=o.useState(""),[ul,An]=o.useState(null),[Vs,Ys]=o.useState(!1),[fl,ho]=o.useState(!1),[hl,ml]=o.useState(!1),[Xs,mf]=o.useState({key:null,nonce:0}),pl=o.useRef(null),gl=o.useRef(null),ee=Hh(n,c,G),pf=gu(ee,c,Qt),[mo,po]=o.useState(()=>Rg(n)),go=te(r=>r.rightTab),on=te(r=>r.setRightTab),b=te(r=>r.rootPath),Pn=te(r=>r.explorerRoot),bl=te(r=>r.pinnedExplorerRootsCache),xl=te(r=>r.hydratePinnedExplorerRoots),vl=te(r=>r.syncPinnedExplorerRoots),It=te(r=>r.setExplorerRoot),yl=te(r=>r.resetExplorerToProject),Tn=te(r=>r.pinExplorerRoot),ln=te(r=>r.unpinExplorerRoot),Ve=te(r=>r.selectedFilePath),Ye=te(r=>r.selectFile),bo=te(r=>r.showHiddenFiles),gf=te(r=>r.toggleShowHiddenFiles),xo=te(r=>!!(b&&r.nestedGitScanRoots[b])),we=te(r=>r.changedFiles),Js=te(r=>r.setChangedFiles),Qs=te(r=>r.invalidateDirectoryCache),bf=te(r=>r.setDirectorySortMode),wl=te(r=>r.applyFileWatchEvents),kl=te(r=>r.reconcileDirectoryCache),Sl=te(r=>r.bumpFileWatchEpoch),Fr=te(r=>r.gitBundleLoading),jl=te(r=>r.gitBundleSlow),cn=te(r=>r.gitBundleError),In=te(r=>r.gitBundleLastLoadedAt),Rl=te(r=>r.beginGitBundleLoading),Cl=te(r=>r.setGitBundleSlowFor),vo=te(r=>r.finishGitBundleLoading),Zs=te(r=>r.resetGitBundleLoading),yo=te(r=>r.setGitBundleError),Nl=te(r=>r.markGitBundleLoaded),pe=Pn??b,Ml=o.useMemo(()=>pe?Kp(pe,K):"",[pe,K]),os=o.useMemo(()=>qp(oe),[oe]),$l=o.useMemo(()=>({excludePatterns:os,caseSensitive:C,wholeWord:ue,regex:Ge}),[C,os,Ge,ue]),ea=te(r=>pe?r.fileSortModes[pe]??"name":"name"),El=te(r=>!!(pe&&r.directoryCache.has(pe))),Dn=o.useRef(null),mt=o.useRef(0),[Ll]=o.useState(()=>++vb),wr=o.useRef(null),_r=o.useRef(null),ta=o.useRef(0),Dt=o.useRef(new Map),Ft=o.useRef(new Map),ar=o.useRef(new Set),dn=o.useRef(new Set),un=o.useRef(0),Br=o.useRef(null),Fn=o.useRef(0),_n=o.useRef(null),Bn=o.useRef(0),Or=o.useRef(null),wo=o.useRef(new Set),ko=o.useRef(null),So=o.useRef(null),ra=o.useRef(null),jo=o.useRef(null);o.useEffect(()=>{if(En===null)return;const r=Math.max(0,Date.now()-En),i=r<6e4?1e3:r<36e5?6e4:r<864e5?36e5:864e5,u=Math.max(50,i-r%i),x=window.setTimeout(()=>uf(Date.now()),u);return()=>window.clearTimeout(x)},[fo,En]);const na=o.useRef(null),kr=o.useRef(null),sa=o.useRef(null),is=o.useRef(null),ke=o.useCallback(r=>te.getState().rootPath===r,[]);o.useEffect(()=>{if(!t||typeof window>"u")return;const r=i=>{const u=Sb(i.target);u&&_a("global_change_row_event",{...jb(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:te.getState().selectedFilePath,rightTab:te.getState().rightTab,activeGitRepoRoot:ce,changedFiles:te.getState().changedFiles.size})};return window.addEventListener("pointerdown",r,{capture:!0}),window.addEventListener("click",r,{capture:!0}),()=>{window.removeEventListener("pointerdown",r,{capture:!0}),window.removeEventListener("click",r,{capture:!0})}},[ce,t]);const Al=o.useCallback(async(r=b??void 0)=>{if(!r)return null;if(ar.current.has(r)||dn.current.has(r))return et("untracked_skip_cached",{cwd:r,rootPath:b,completed:ar.current.has(r),running:dn.current.has(r)}),null;const i=b,u=ta.current+1;ta.current=u,Dt.current.set(r,u);const x=`right-sidebar-git-untracked:${r}`,v=new AbortController;Ft.current.set(r,v),dn.current.add(r),et("untracked_start",{requestId:u,cwd:r,rootPath:b});try{let R=await Uc(r,v.signal,x),A=0;for(;R.status==="running"&&A<120;){if(Dt.current.get(r)!==u||v.signal.aborted)return et("untracked_stale_result",{requestId:u,activeRequestId:Dt.current.get(r),cwd:r,status:R.status}),null;if(!ke(i))return et("untracked_root_changed",{requestId:u,cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath}),null;await new Promise(Y=>window.setTimeout(Y,A<10?1e3:3e3)),A+=1,R=await Uc(r,v.signal,x)}if(Dt.current.get(r)!==u||!ke(i))return et("untracked_stale_result",{requestId:u,activeRequestId:Dt.current.get(r),cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath,files:R.files.length,status:R.status}),null;if(R.status==="done")return Js(Zu(te.getState().changedFiles,R.files)),R.files.length>0&&ye(Y=>{const He=new Map(Y.map(Ne=>[Ne.root,Ne])).get(r);if(!He)return Y;const Pe=ib(He.files,R.files),De=Y.map(Ne=>Ne.root===r?{...Ne,files:Pe,context:Ne.context?{...Ne.context,changedFiles:Pe.map(qe=>({path:qe.path,absolutePath:qe.absolutePath,status:qe.status})),truncated:!1}:Ne.context,untrackedDeferred:!1}:Ne);Oe(ef(De,b));const ge=De.find(Ne=>Ne.root===b);return ge?.context&&S(Ne=>Ne?.root===ge.root?{...Ne,...ge.context}:Ne),De}),ar.current.add(r),et("untracked_apply",{requestId:u,cwd:r,files:R.files.length}),R;const H=R.error||(R.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return ar.current.add(r),et("untracked_error",{requestId:u,cwd:r,message:H,code:R.code,status:R.status}),null}catch(R){if(Dt.current.get(r)!==u||!ke(i)||Cr(R))return et("untracked_aborted",{requestId:u,activeRequestId:Dt.current.get(r),cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath,message:R instanceof Error?R.message:String(R)}),null;const A=R instanceof Error?R.message:"Failed to scan untracked files";return ar.current.add(r),et("untracked_error",{requestId:u,cwd:r,message:A}),null}finally{Ft.current.get(r)===v&&Ft.current.delete(r),Dt.current.get(r)===u&&Dt.current.delete(r),dn.current.delete(r)}},[ae,ke,b,Js]),qt=o.useMemo(()=>{const r=new Set(be.map(u=>u.root)),i=Xr.filter(u=>r.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Xr,be]),Pl=qt.length===0,fn=o.useMemo(()=>qt.map(r=>V.find(i=>i.root===r)).filter(r=>!!r),[qt,V]),xf=o.useMemo(()=>be.map(r=>({root:r.root,label:r.label,branch:r.branch??null})),[be]),or=o.useCallback(async()=>{if(!b){Yr([]),Zn([]);return}const r=b,i=Fn.current+1;Fn.current=i,_n.current?.abort();const u=new AbortController;_n.current=u,Er(jt.length===0),Pt(null);try{const x=qt.length>0?await Promise.all(qt.map(v=>Hc({workspaceRoot:b,repoRoot:v},u.signal))).then(v=>({records:v.flatMap(R=>R.records),walkthroughs:v.flatMap(R=>R.walkthroughs??[])})):await Hc({workspaceRoot:b},u.signal);if(Fn.current!==i||!ke(r))return;Yr(x.records),Zn(x.walkthroughs??[])}catch(x){if(Fn.current!==i||!ke(r)||Cr(x))return;Pt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{_n.current===u&&(_n.current=null),Fn.current===i&&ke(r)&&Er(!1)}},[jt.length,qt,ke,b]),aa=o.useCallback(async(r,i,u)=>{if(!r&&!b){mr([]),Sn([]);return}const x=b,v=Bn.current+1;Bn.current=v,Or.current?.abort();const R=new AbortController;Or.current=R;try{const A=r?[r]:Array.from(new Set([b,...V.map(Y=>Y.root)].filter(Y=>!!Y))),H=await Promise.all(A.map(Y=>$h({repoRoot:Y,baseRef:i,branchName:u},R.signal))).then(Y=>{const Ce=new Map,He=new Map;for(const Pe of Y){for(const De of Pe.records)Ce.set(De.id,De);for(const De of Pe.walkthroughs??[])He.set(De.id,De)}return{records:Array.from(Ce.values()),walkthroughs:Array.from(He.values())}});if(Bn.current!==v||!ke(x))return;mr(H.records),Sn(H.walkthroughs??[])}catch(A){if(Bn.current!==v||!ke(x)||Cr(A))return;console.warn("[RightSidebar] Failed to load branch explanations",A)}finally{Or.current===R&&(Or.current=null)}},[V,ke,b]),Ur=o.useCallback((r,i={})=>{if(!ke(b)){et("apply_skipped_root_changed",{expectedRootPath:b,currentRootPath:te.getState().rootPath,bundleRoot:r.context?.root,files:r.files.length});return}et(r.files.length===0?"empty_bundle":"apply",{rootPath:b,available:r.available,files:r.files.length,repositories:r.repositories?.map(ge=>({root:ge.root,relativeRoot:ge.relativeRoot,files:ge.files.length,available:ge.available,error:ge.error})),repoFilters:r.repoFilters?.map(ge=>({root:ge.root,label:ge.label,count:ge.count})),cached:r.cached,stale:r.stale,cacheAgeMs:r.cacheAgeMs,untrackedDeferred:r.untrackedDeferred,error:r.error});let u=bu(r),x=r.repoFilters??[],v=r.files;const R=te.getState().changedFiles;if(!!(i.cacheOnly&&!r.cached&&r.files.length===0&&u.length===0)&&(R.size>0||V.length>0||ae)){et("cache_only_apply_skipped_empty_backend_cache",{rootPath:b,currentFiles:R.size,currentRepositories:V.length});return}const H=u.some(ge=>ge.deferred);if(H&&!i.replaceWorkspace){const ge=new Set(u.filter(qe=>!qe.deferred||qe.root===b).map(qe=>qe.root));v=[...Array.from(R.values()).filter(qe=>!ge.has(it(qe,b)??"")),...r.files]}const Y=$d(R.values(),b),Ce=$d(r.files,b),He=u.some(ge=>ge.root!==b);if(!!(i.background&&!H&&!i.replaceWorkspace&&R.size>0&&(r.files.length===0&&!r.error||Y>0&&Ce===0&&!He))){et("background_apply_skipped_degraded_bundle",{rootPath:b,currentFiles:R.size,nextFiles:r.files.length,currentNestedCount:Y,nextNestedCount:Ce,nextRepositories:u.map(ge=>({root:ge.root,relativeRoot:ge.relativeRoot,files:ge.files.length})),cached:r.cached,stale:r.stale,error:r.error});return}if(i.replaceRepoRoot){const ge=tf(R.values(),V,r,i.replaceRepoRoot,b);v=ge.files,u=ge.repositories,x=ge.repoFilters}if(Js(Qu(v)),ye(u),Oe(x),i.syncActiveRepo!==!1){const ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:ce??pd(b),Ne=vg({...r,repositories:u,repoFilters:x},ge);Je(Ne),ni(b,Ne)}typeof r.cacheUpdatedAt=="number"&&cl(r.cacheUpdatedAt),S(ge=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==b)return ge;if(!r.context)return null;const Ne=ge?.root??b;return!ge?.available||Ne!==(r.context.root??b)?r.context:{...ge,...r.context}}),i.reloadDiff&&ro(ge=>ge+1);const De=te.getState().selectedFilePath;if(De&&!De.startsWith("/")&&!v.some(ge=>ge.path===De||ge.absolutePath===De)&&Ye(null),Mr(ge=>{const Ne=new Set(v.map(Yt=>it(Yt,b)).filter(Boolean)),qe=new Set;for(const Yt of ge)Ne.has(Yt)&&qe.add(Yt);return si(Zo,qe),qe}),i.loadDeferred!==!1){const ge=u.filter(Ne=>Ne.untrackedDeferred&&Ne.root).map(Ne=>Ne.root);for(const Ne of ge)Al(Ne)}i.loadAudit!==!1&&or()},[ce,ke,or,Al,b,Ye,Js]);o.useEffect(()=>{Zs(),ko.current=null,So.current=b;const r=[],i=[],x=pd(b);mt.current+=1,un.current+=1,ta.current+=1,wr.current?.abort(),bt(Kn(_r.current?.cwd??b??void 0)),_r.current=null,wr.current=null,Br.current?.abort(),bt("right-sidebar-git-details"),Br.current=null;for(const Y of Ft.current.values())Y.abort();for(const Y of Ft.current.keys())bt(`right-sidebar-git-untracked:${Y}`);Ft.current.clear(),Dt.current.clear(),Fn.current+=1,_n.current?.abort(),_n.current=null,Bn.current+=1,Or.current?.abort(),Or.current=null,Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,Yr([]),Zn([]),Er(!1),Pt(null),Jr([]),Ar(!1),mr([]),Sn([]),Zt(!1),er(null),z(!1),xe(null),$e(null),_e(null),at(null),gr(!1),Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1),_s(null),tn(null),rn(null),rl(!1),xt(ei,!1),ao(!1);const v=b?bd()[b]:null,R=v?.previewEntries??[],A=v?.selectedPreviewKey??null,H=A?R.find(Y=>Y.key===A)??null:null;oo(v?.selectedRepoRoots??[]),Os(v?.repoTargetBranches??{}),Us(v?.repoBaseBranches??{}),es(R),Rn(v?.previewScrollTops??{}),H&&v?.previewDetailOpen&&(H.diff.hunks?.length??0)>0&&(er(H.diff),tn(H.key),rn(v.selectedPreviewFileKey??(H.diff.hunks?.[0]?`${H.diff.hunks[0].filePath}\0${H.diff.hunks[0].hunkHeader}\0${H.diff.hunks[0].hunkIndex}`:null)),Zt(!0)),nl(v?.includeUncommitted??!0),ko.current=b,zs(!1),Je(x??null),ar.current.clear(),dn.current.clear(),ss(null),as(null),Dr(null),dt(null),cl(null),ye(r),Oe(i),S(null),jo.current=null},[Zs,b]);const Kt=o.useCallback(async(r=b??void 0,i={})=>{if(!r)return null;const u=b,x=mt.current;if(await Um(te.getState().hydrateNestedGitScanRoots),mt.current!==x||!ke(u))return null;const v=r===b&&Gn(b),R=i.includeNested??v,A=i.refresh??i.reloadDiff??!1,H=i.cacheOnly??!1,Y=i.background??!1,Ce=R&&(i.discoverOnly??!1);A&&ar.current.clear();const He=_r.current;if(He&&He.cwd===r&&He.includeNested===R&&He.refresh===A&&He.cacheOnly===H&&He.discoverOnly===Ce)return et("reuse_pending",{cwd:r,includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce}),He.promise;const Pe=mt.current+1;mt.current=Pe;const De=`right-sidebar:${Ll}:${Pe}`;wr.current?.abort();const ge=Kn(r);bt(ge);const Ne=new AbortController;wr.current=Ne;let qe=null;Y||Rl(De),yo(null),et("start",{requestId:Pe,cwd:r,rootPath:b,requestSlotId:ge,includeNested:R,refresh:A,cacheOnly:H,background:Y,existingChanges:we.size,lastLoadedAt:In}),!Y&&typeof window<"u"&&(qe=window.setTimeout(()=>{mt.current===Pe&&Cl(De,!0)},rg));const Yt=(async()=>{const Te=await Ca(r,Ne.signal,{includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce,action:A?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:ge,requestTimeoutMs:A?null:void 0});if(db(Te)){if(et("cancelled_result_ignored",{requestId:Pe,activeRequestId:mt.current,cwd:r,error:Te.error??Te.context?.error}),Ne.signal.aborted)return null;throw new Error(Te.error??Te.context?.error??"Failed to load Git changes")}return mt.current!==Pe||!ke(u)?(et("stale_result",{requestId:Pe,activeRequestId:mt.current,cwd:r,expectedRootPath:u,currentRootPath:te.getState().rootPath,files:Te.files.length,repositories:Te.repositories?.length??0}),null):(Ur(Te,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:R,background:Y,cacheOnly:H,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),Te)})();_r.current={cwd:r,includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce,promise:Yt};try{const Te=await Yt;return mt.current===Pe&&Te&&ke(u)?Nl({cached:Te.cached,stale:Te.stale,cacheAgeMs:Te.cacheAgeMs,nestedDeferred:!R||Te.nestedDeferred,untrackedDeferred:Te.untrackedDeferred}):mt.current===Pe&&ke(u)&&vo(De),Te}catch(Te){return mt.current!==Pe||!ke(u)||Ne.signal.aborted?(et("aborted",{requestId:Pe,activeRequestId:mt.current,cwd:r,expectedRootPath:u,currentRootPath:te.getState().rootPath,message:Te instanceof Error?Te.message:String(Te)}),null):(et("error",{requestId:Pe,cwd:r,includeNested:R,refresh:A,background:Y,message:Te instanceof Error?Te.message:String(Te)}),Y||(S(null),yo(Te instanceof Error?Te.message:"Failed to load Git changes")),null)}finally{qe!==null&&window.clearTimeout(qe),wr.current===Ne&&(wr.current=null),_r.current?.promise===Yt&&(_r.current=null),!Y&&mt.current===Pe&&ke(u)&&vo(De)}},[Ur,Rl,we.size,vo,Ll,In,ke,Nl,b,yo,Cl]),ls=o.useCallback(async()=>{b&&await Kt(b,{reloadDiff:!0,refresh:!0})},[Kt,b]),Ro=o.useCallback(async(r=b??void 0)=>{if(!r)return null;const i=b,u=un.current+1;un.current=u,Br.current?.abort(),bt("right-sidebar-git-details");const x=new AbortController;Br.current=x,zs(!0);try{const v=await zc(r,x.signal,"load_git_details","right-sidebar-git-details");return un.current!==u||!ke(i)?null:(ye(R=>R.map(A=>A.root===v.root?{...A,available:v.available,context:v,error:v.error}:A)),S(R=>R?.root&&v.root&&R.root!==v.root?R:!R?.available||!v.available?v:{...R,...v}),v)}catch(v){return Cr(v)||!ke(i)||un.current===u&&dt(v instanceof Error?v.message:"Failed to load Git details"),null}finally{Br.current===x&&(Br.current=null),un.current===u&&ke(i)&&zs(!1)}},[ke,b]);o.useEffect(()=>{if(!t){mt.current+=1,Zs(),jo.current=null,un.current+=1,ta.current+=1,wr.current?.abort(),bt(Kn(_r.current?.cwd??b??void 0)),_r.current=null,wr.current=null,Br.current?.abort(),bt("right-sidebar-git-details"),Br.current=null;for(const r of Ft.current.values())r.abort();for(const r of Ft.current.keys())bt(`right-sidebar-git-untracked:${r}`);Ft.current.clear(),Dt.current.clear(),Bn.current+=1,Or.current?.abort(),Or.current=null,Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,zs(!1),z(!1),xe(null),$e(null),_e(null),at(null),gr(!1),Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1),j(""),fe(!1),kt(null),uo(!1),ee&&il(!1)}},[ee,t,Zs,fe]),o.useEffect(()=>{if(!se)return;const r=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(r)},[se]),o.useEffect(()=>{ee||vr(!1)},[ee]);const cs=o.useCallback(r=>{lo(r);const i=sa.current;i&&(i.update(),i.slideTo(r,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(r,0)}))},[]);o.useEffect(()=>{if(ee)if(vr(m),m&&Ve){yr(1);const r=kr.current;r&&(r.update(),r.activeIndex!==1&&(is.current=1,r.slideTo(1,0)))}else{yr(0);const r=kr.current;r&&r.activeIndex!==0&&(is.current=0,r.slideTo(0,0)),kt(null)}},[ee,m,b,Ve]),o.useEffect(()=>{if(g!==void 0&&!m){yr(0);const r=kr.current;r&&r.activeIndex!==0&&(is.current=0,r.slideTo(0,0)),vr(!1),kt(null)}},[g,m]),o.useEffect(()=>{y!==void 0&&W(null)},[y]),o.useEffect(()=>{!ee&&m&&f?.()},[ee,f,m]),o.useEffect(()=>{po(r=>Li(r,n))},[n]);const vf=o.useCallback(r=>{ee||(r.preventDefault(),na.current={startX:r.clientX,startWidth:mo,pointerId:r.pointerId},r.currentTarget.setPointerCapture(r.pointerId))},[mo,ee]),yf=o.useCallback(r=>{const i=na.current;if(!i||i.pointerId!==r.pointerId)return;const u=Li(i.startWidth+r.clientX-i.startX,n);po(u),Ss(ws,u,tg)},[n]),Tl=o.useCallback(r=>{const i=na.current;if(!(!i||i.pointerId!==r.pointerId)){na.current=null,xs(ws);try{r.currentTarget.releasePointerCapture(r.pointerId)}catch{}}},[]),ds=!!(b&&In!==null&&Ad(ae)),Co=!!(b&&!cn&&we.size===0&&In===null),Hr=ds?"files":go,Xe=Hr==="git",On=Hr==="files",pt=Hr==="diff";o.useEffect(()=>{if(!ee){Hs(!0);return}if(!t){const i=window.setTimeout(()=>{Hs(!1)},sg);return()=>window.clearTimeout(i)}Hs(!1);const r=window.setTimeout(()=>{Hs(!0)},ng);return()=>window.clearTimeout(r)},[ee,t]),o.useEffect(()=>{if(!ee||!pt)return;const r=sa.current;if(!r)return;const i=window.requestAnimationFrame(()=>{r.update()});return()=>window.cancelAnimationFrame(i)},[pt,ee]),o.useEffect(()=>{if(!ds||!b||Fr)return;const r=window.setTimeout(()=>{Kt(b,{background:!0})},3e3);return()=>window.clearTimeout(r)},[ds,b,Fr,Kt]);const wf=o.useCallback(r=>{Kt(r,{discoverOnly:!0})},[Kt]);Hm({active:t&&(Xe||pt),rootPath:b,loading:Fr,delay:Xe&&!ee?0:ri,lastStartedRoot:jo,load:wf}),o.useEffect(()=>{!t||!Xe||(!ee||co)&&uo(!0)},[Xe,ee,t,co]),o.useEffect(()=>{if(!t||Xe)return;const r=window.setTimeout(()=>{uo(!0)},ri);return()=>window.clearTimeout(r)},[Xe,t]),o.useEffect(()=>{pt&&il(!0)},[pt]);const Il=o.useCallback(r=>{pe&&rb(pe,r.currentTarget.scrollTop)},[pe]);o.useEffect(()=>()=>{wr.current?.abort(),xs(Hi),xs(zi),xs(ws),xs(ti)},[]),o.useEffect(()=>{if(!pe||!El)return;const r=Xu()[pe]?.top;if(typeof r!="number")return;let i=window.requestAnimationFrame(()=>{Dn.current&&(Dn.current.scrollTop=r),i=window.requestAnimationFrame(()=>{Dn.current&&(Dn.current.scrollTop=r)})});return()=>window.cancelAnimationFrame(i)},[pe,El]),o.useEffect(()=>{if(!t)return;const r=new AbortController;return Eh(r.signal).then(i=>ml(!!i.available)).catch(()=>ml(!1)),()=>r.abort()},[t]);const us=o.useCallback(r=>{if(ne(null),Ye(r),kt(null),ee){vr(!0),yr(1),kr.current?.slideTo(1),p?.();return}},[ee,p,Ye]),Dl=o.useCallback((r,i)=>{if(ne(null),Ye(r),Ie(i),ee){vr(!0),yr(1),kr.current?.slideTo(1),p?.();return}},[ee,p,Ye]),fs=o.useCallback(async(r,i)=>{const u=i||Pn||b;if(!(!u||r.length===0)){Ys(!0);try{await Yo(u,r),Qs(u,!1)}catch(x){dt(x instanceof Error?x.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>dt(null),4e3)}finally{Ys(!1)}}},[Pn,b,Qs,a]),Fl=o.useCallback(async r=>{try{await Lh(r)}catch(i){dt(i instanceof Error?i.message:a("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>dt(null),4e3)}},[a]),oa=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),r.dataTransfer.types.includes("Files")&&ho(!0)},[]),_l=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),ho(!1)},[]),Bl=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),ho(!1);const i=r.dataTransfer.files;i.length>0&&fs(Array.from(i))},[fs]),No=o.useCallback(r=>{Se(r),window.setTimeout(()=>Se(i=>i===r?null:i),1400)},[]),Sr=o.useCallback(r=>{lt(r),window.setTimeout(()=>lt(i=>i===r?null:i),1400)},[]);o.useEffect(()=>{xt(ld,Qe)},[Qe]),o.useEffect(()=>{xt(cd,ht)},[ht]),o.useEffect(()=>{xt(dd,Xt)},[Xt]),o.useEffect(()=>{Ss(ti,wt,Xp)},[wt]),o.useEffect(()=>(xl().catch(()=>{}),Wc(r=>{r.type==="pinned-explorer-roots"&&vl(r.pinnedExplorerRoots)})),[xl,vl]);const Ol=o.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ia=o.useRef(null),hn=o.useRef(null),[Ul,Mo]=o.useState(!1);o.useEffect(()=>{if(!t)return;Mo(!1);let r=!1;Ah().then(u=>{r||(ia.current=u.text,Ht(x=>u.text&&u.text!==x?u.text:x),Mo(!0))}).catch(()=>{r||Mo(!0)});const i=Wc(u=>{u.type==="context-draft"&&u.origin!==Ol.current&&(ia.current=u.text,Ht(u.text))});return()=>{r=!0,i(),hn.current!==null&&(window.clearTimeout(hn.current),hn.current=null)}},[t]),o.useEffect(()=>{if(!Ul||ia.current===wt)return;hn.current!==null&&window.clearTimeout(hn.current);const r=wt;hn.current=window.setTimeout(()=>{hn.current=null,Ph(r,Ol.current).then(()=>{ia.current=r}).catch(()=>{})},500)},[wt,Ul]);const Un=o.useCallback((r,i,u)=>{if(r){if(Th(u?r+u:r)){No(i);return}Qe?(Ht(x=>hp(x,r)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(lr(!1),cr(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?r+u:r,focus:!0}})),No(i)}},[Qe,No]),la=o.useCallback(r=>{const i=Ma(r,b);return em(i,b)},[b]),$o=Vd(Sr),zr=o.useCallback((r,i)=>{const u=Ma(r,b);Un(tm(u,b),i??`path:${u}`)},[b,Un]),kf=o.useCallback(async r=>{Ys(!0);try{await rm(r,Yo,i=>{zr(i,`path:${i}`)}),ee&&!Qe&&s()}catch(i){dt(i instanceof Error?i.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>dt(null),4e3)}finally{Ys(!1)}},[Qe,zr,ee,s,a]),jr=o.useCallback((r,i)=>{if(!r)return;const u=r.includes(`
1660
1660
  `)?`
1661
1661
  `:void 0;Un(r.endsWith(`
1662
1662
  `)||r.endsWith(" ")?r:`${r} `,i,u)},[Un]),Hl=o.useRef(jr);Hl.current=jr;const Eo=o.useRef(!0);o.useEffect(()=>(Eo.current=!0,()=>{Eo.current=!1}),[]);const Lo=o.useRef(new Set),zl=o.useCallback((r,i,u)=>{if(Lo.current.has(i))return;const x=Qc.getState().activeSessionId;Lo.current.add(i),Gm(r,i,u,{insert:jr,upload:async(v,R)=>(await Yo("/tmp",[v],R)).files[0]?.path,isCurrent:()=>Eo.current&&Hl.current===jr&&x===Qc.getState().activeSessionId}).finally(()=>Lo.current.delete(i))},[jr]),Wr=o.useCallback((r,i,u)=>{i&&Un(i.endsWith(" ")?i:`${i} `,u??`context:${r}`,`
@@ -1675,4 +1675,4 @@ ${ie}
1675
1675
  `)},[Ir,Vt,Rt,xr,b]),Kf=o.useCallback((r="generate")=>{const i=r==="generate"?Ho:[r==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ho].join(`
1676
1676
  `);Wr(a("rightSidebar.branchAuditShort"),i,`context:branch-audit-scope:${r}`),d||s()},[Ho,Wr,s,d,a]),Vf=o.useCallback(async()=>{if(!b||Vt.length===0)return;const r=b;z(!0),xe(null),er(null),$e(null);try{const i=await Promise.all(Vt.map(async H=>{const Y=Rt[H.root]?.trim();if(!Y)throw new Error(a("rightSidebar.branchAuditMissingBase",{repo:H.label}));const Ce=(xr[H.root]||H.branch||"").trim();return Fh({cwd:b,repoRoot:H.root,base:Y,head:Ce&&Ce!==H.branch?Ce:null,includeUncommitted:Ir,requestSlotId:`right-sidebar-branch-preview:${H.root}`})}));if(!ke(r))return;const u=i.find(H=>!H.available);if(u){xe(u.error??"Branch diff is unavailable");return}const x=i.length===1?i[0]:{available:!0,workspaceRoot:b,repoRoot:b,baseRef:i.map(H=>H.baseRef??H.baseBranch).filter(Boolean).join(", "),currentBranch:i.map(H=>H.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:i.map(H=>H.headRef).filter(Boolean).join(", "),diffFingerprint:i.map(H=>H.diffFingerprint).filter(Boolean).join("+"),stat:i.map(H=>H.stat).filter(Boolean).join(`
1677
1677
  `),files:i.flatMap((H,Y)=>{const Ce=Vt[Y];return(H.files??[]).map(He=>`${Ce?.label??H.repoRoot??"repo"}/${He}`)}),hunks:i.flatMap((H,Y)=>{const He=Vt[Y]?.label??H.repoRoot??"repo";return(H.hunks??[]).map(Pe=>({...Pe,filePath:`${He}/${Pe.filePath}`,oldPath:Pe.oldPath?`${He}/${Pe.oldPath}`:Pe.oldPath,newPath:Pe.newPath?`${He}/${Pe.newPath}`:Pe.newPath}))}),commits:i.flatMap(H=>H.commits??[]),commitCount:i.reduce((H,Y)=>H+(Y.commitCount??Y.commits?.length??0),0),diff:i.map(H=>H.diff).filter(Boolean).join(`
1678
- `),truncated:i.some(H=>H.truncated)};if((x.hunks??[]).length===0){xe(a("rightSidebar.branchAuditDiffEmpty"));return}const v=Date.now(),R=["preview",x.repoRoot??b,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??v].join("\0"),A=Vt.length===1?Vt[0].label:`${Vt.length} repos`;er(x),es(H=>[{key:R,diff:x,repoLabel:A,createdAt:v},...H.filter(Y=>Y.key!==R)].slice(0,8)),Rn(H=>H[R]===void 0?H:{...H,[R]:0}),tn(R),rn(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),Zt(!0)}catch(i){if(!ke(r)||Cr(i))return;xe(i instanceof Error?i.message:"Failed to load branch diff")}finally{ke(r)&&z(!1)}},[Ir,Vt,Rt,xr,ke,b,a]),Yf=o.useCallback(r=>{er(r.diff),xe(null),tn(r.key),rn(r.diff.hunks?.[0]?`${r.diff.hunks[0].filePath}\0${r.diff.hunks[0].hunkHeader}\0${r.diff.hunks[0].hunkIndex}`:null),Zt(!0)},[]),Xf=o.useCallback(r=>{es(i=>i.filter(u=>u.key!==r)),Rn(i=>{if(!(r in i))return i;const u={...i};return delete u[r],u}),Ze===r&&(tn(null),er(null),Zt(!1))},[Ze]),Jf=o.useCallback(r=>{const i=zn.find(u=>u.key===r);i&&(er(null),xe(null),tn(r),rn(i.records[0]?.filePath??null),Zt(!0))},[zn]),Qf=o.useCallback(async r=>{if(!b||!ve)return;const[i]=r.split(/\s+/);if(i){_e(i),at(null),$e(null);try{const u=await _h({cwd:b,repoRoot:ve,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){at(u.error??"Commit diff is unavailable");return}$e(u);const x=u.hunks?.[0];_s(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){at(u instanceof Error?u.message:"Failed to load commit diff")}finally{_e(null)}}},[ve,b]),Zf=o.useCallback(r=>{if(!Me||!Ze)return;const i=Math.max(0,Math.round(r));Rn(u=>Math.abs((u[Ze]??0)-i)<24?u:{...u,[Ze]:i})},[Me,Ze]);o.useEffect(()=>{!ee||!pr||!Me||cs(1)},[pr,Me,ee,cs]);const xc=o.useCallback(r=>{r&&mf(i=>mm(i,r))},[]),vc=Xs.key===Ve?Xs.key:null,va=o.useCallback(r=>{const i=te.getState(),u=kb();_a("select_diff_file",{interactionId:u,path:r,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),Ye(r),on("diff"),ee&&r&&cs(1),xc(r),queueMicrotask(()=>{const x=te.getState();_a("select_diff_file_after",{interactionId:u,requestedPath:r,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:ce})})},[ce,ee,xc,Ye,on,cs]),yc=o.useCallback(r=>{const i=Array.from(we.values()).find(u=>{const x=it(u,b),v=ut(u);return u.path===r.filePath||v===r.filePath||u.absolutePath===r.filePath||(x?`${x}/${u.path}`===r.filePath:!1)||r.repoRoot&&x===r.repoRoot&&u.path===r.filePath});if(i){va(ut(i)),window.setTimeout(()=>xn(r),90),window.setTimeout(()=>xn(r),320),window.setTimeout(()=>xn(r),760);return}xn(r)},[we,b,va]),wc=o.useCallback(({slideToDetail:r,fullscreen:i,toggleFullscreen:u}={})=>Qn.length>0?e.jsx(Ud,{walkthroughs:Qn,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:x=>{ee&&window.requestAnimationFrame(()=>r?.()),yc(x)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(Es,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),a("rightSidebar.changeWalkthroughEmpty")]}),[ce,Qn,yc,ee,a]),eh=o.useCallback(r=>{r&&Mr(i=>{const u=new Set(i);return u.has(r)?u.delete(r):u.add(r),si(Zo,u),u})},[]),kc=o.useCallback(r=>{to(i=>{const u=new Set(i);return u.has(r)?u.delete(r):u.add(r),si(id,u),u})},[]),ya=o.useCallback(r=>{Is(r),xt(ou,r)},[]);o.useEffect(()=>{fa||St!=="ai"||ya("tree")},[St,ya,fa]);const wa=o.useCallback(()=>{Ds(r=>{const i=!r;return xt(iu,i),i})},[]),Sc=o.useCallback(r=>{Vr(r),xt(lu,r)},[]),{whitespace:jc,context:Rc}=gm(),Cc=o.useMemo(()=>({algorithm:"histogram",whitespace:jc,context:Rc}),[jc,Rc]),Nc=o.useCallback(r=>{_(r),xt(cu,r)},[]),ka=o.useCallback(async(r,i,u,x)=>{let v=r;for(;v.ok&&v.status==="running";)await new Promise(A=>window.setTimeout(A,1500)),v=await qc({jobId:v.jobId,cwd:i.cwd,action:i.action});if(!v.ok)throw new Error("Git action status is unavailable");if(v.status==="error")throw new Error(v.error||v.message||"Git action failed");const R={action:i.action,path:x,label:u};return as(R),window.setTimeout(()=>as(A=>A?.action===R.action&&A.path===R.path?null:A),1400),v},[]),ot=o.useCallback(async(r,i,u)=>{const x=b;b&&ar.current.delete(b),dt(null),as(null),ss({action:r.action,path:u});try{const v=await Bh({...r,includeNested:Gn(b)}),R=await ka(v,r,i,u);if(!ke(x))return!1;const A=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>R.bundle):R.bundle;return ke(x)?(A&&Ur(A,{reloadDiff:!0,cacheOnly:!0}),Dr(null),!0):!1}catch(v){return as(null),dt(a("rightSidebar.gitActionFailed",{message:v instanceof Error?v.message:"Unknown error"})),!1}finally{ke(x)&&ss(null)}},[Ur,ke,b,a,ka]),Mc=o.useCallback(async r=>{const i=b,u=await Oh({...r,includeNested:Gn(b)});if(!ke(i))return;const x=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>u.bundle):u.bundle;ke(i)&&x&&Ur(x,{reloadDiff:!0,cacheOnly:!0})},[Ur,ke,b]),Sa=o.useCallback((r,i,u)=>{if(i){if(r==="stage-all"){ot({action:"stage-all",cwd:i},a("rightSidebar.stageAll"),`repo:${i}`);return}Dr({kind:"stash-all",repoRoot:i,repoLabel:u})}},[ot,a]),$c=o.useCallback(r=>{Je(r),ni(b,r),Gs(""),qs(""),Ks(""),Ye(tc(r)),Xe||on("diff"),r&&r!==b&&V.find(u=>u.root===r)?.deferred&&Kt(r,{includeNested:!1,background:!0,replaceRepoRoot:r})},[tc,Xe,V,Kt,b,Ye,on]),Ec=o.useCallback(r=>{const i=new Set([...Ft.current.keys(),...dn.current,...ar.current]);for(const u of i)u!==r&&(Dt.current.delete(u),Ft.current.get(u)?.abort(),Ft.current.delete(u),bt(`right-sidebar-git-untracked:${u}`),dn.current.delete(u),ar.current.delete(u))},[]),th=o.useCallback(async r=>{const i=b;if(!i||(await te.getState().setNestedGitScanRoot(i,r),!ke(i)))return;if(r){await Kt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Ec(i),Gs(""),qs(""),Ks(""),oo(x=>x.filter(v=>v===i));const u=_t;u&&it(u,i)!==i&&Ye(null),await Kt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Ec,ke,Kt,b,Ye,_t]),rh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Ln.trim();!r||r===de?.branch||await ot({action:"switch-branch",cwd:ve,branch:r},a("rightSidebar.switchBranch"))},[de?.branch,ve,We,ot,Ln,a]),Lc=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Ws.trim();if(!r)return;await ot({action:"commit",cwd:ve,message:r},a("rightSidebar.commitChanges"))&&dl("")},[ve,Ws,We,ot,a]),nh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=sn.trim(),i=an.trim();await ot({action:"push",cwd:ve,...r?{remote:r}:{},...i?{branch:i}:{}},a("rightSidebar.pushChanges"))},[ve,an,sn,We,ot,a]),sh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=sn.trim(),i=an.trim();await ot({action:"pull",cwd:ve,...r?{remote:r}:{},...i?{branch:i}:{}},a("rightSidebar.pullChanges"))},[ve,an,sn,We,ot,a]);o.useEffect(()=>{if(!Xe||!ve||Ae)return;let r=!1;const i={push:a("rightSidebar.pushChanges"),pull:a("rightSidebar.pullChanges"),commit:a("rightSidebar.commitChanges"),"switch-branch":a("rightSidebar.switchBranch"),"stage-all":a("rightSidebar.stageAll"),"stash-all":a("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(r)return;const x=await qc({cwd:ve,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const v={action:u,cwd:ve},R=i[u]??u;ss({action:u});try{const A=await ka(x,v,R);if(r||!ke(b))return;const H=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>A.bundle):A.bundle;H&&Ur(H,{reloadDiff:!0,cacheOnly:!0})}catch(A){r||dt(a("rightSidebar.gitActionFailed",{message:A instanceof Error?A.message:"Unknown error"}))}finally{r||ss(null)}return}})(),()=>{r=!0}},[ve,Ur,Xe,ke,b,Ae,a,ka]);const zo=$n?.action==="commit",Wo=$n?.action==="switch-branch",Go=$n?.action==="pull",qo=$n?.action==="push",ja=Xe||ff,Ko=ma?a("rightSidebar.changeAuditScopeAll"):ir.length===1?ir[0].label:`${ir.length} repos`,ah=ir.length>0,Ac=Vt.length>0,oh=b?e.jsx(Cd,{open:so,onOpenChange:ao,showScopePicker:!0,selectedAll:ma,repos:Bt,selectedRoots:ha,onToggleRepo:zf,onGenerate:()=>Kf(Oo?"regenerate":"generate"),disabled:!ah,generateDisabled:!Ac,inserted:q?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:a(Oo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.branchAuditGenerateTitle"),ariaLabel:a("rightSidebar.branchAuditShort"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ko,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a(Oo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Vf()},secondaryDisabled:!Ac||T,secondaryLabel:a("rightSidebar.branchAuditViewDiff"),secondaryTitle:a("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:T,loading:sl.size>0,statusTitle:sl.size>0?a("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsxs("label",{className:"flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:a("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:a("rightSidebar.includeUncommittedHint")})]}),e.jsx("input",{type:"checkbox",checked:Ir,onChange:r=>nl(r.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),oc.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:a("rightSidebar.missingBaseReposSkipped",{repositories:oc.map(r=>r.label).join(w==="zh"?"、":", ")})})]}),renderRepoExtra:r=>{const i=gt.get(r.root),u=[],x=new Set,v=(Y,Ce)=>{!Y||x.has(Y)||(x.add(Y),u.push({value:Y,label:Y,meta:Ce}))};v(xr[r.root]||i?.context?.branch,a("rightSidebar.pushCurrentBranchBadge"));for(const Y of i?.context?.branches??[])v(Y,Y===i?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):a("rightSidebar.localBranch"));for(const Y of i?.context?.remoteBranches??[])v(Y,a("rightSidebar.remoteBranch"));const R=[],A=new Set,H=(Y,Ce)=>{!Y||A.has(Y)||(A.add(Y),R.push({value:Y,label:Y,meta:Ce}))};H(Rt[r.root],Rt[r.root]?a("rightSidebar.pushUpstreamBadge"):void 0),H(i?.context?.upstream,i?.context?.upstream?a("rightSidebar.pushUpstreamBadge"):void 0);for(const Y of i?.context?.remoteBranches??[])H(Y,"remote");for(const Y of i?.context?.branches??[])H(Y,Y===i?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(qn,{label:a("rightSidebar.currentBranchLabel"),value:xr[r.root]||i?.context?.branch||"",options:u,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),onChange:Y=>{Os(Ce=>({...Ce,[r.root]:Y}))}}),e.jsx(qn,{label:a("rightSidebar.branchAuditBaseLabel"),value:Rt[r.root]||"",options:R,placeholder:a("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:a("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:a("rightSidebar.branchAuditBaseEmpty"),onChange:Y=>{Us(Ce=>({...Ce,[r.root]:Y}))}})]})}}):null,Pc=ys(jt.reduce((r,i)=>Math.max(r,i.injectedAt??0),0),w),ih=b?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>rl(r=>{const i=!r;return xt(ei,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":ns,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(Es,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Ko})]}),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 ${ns?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]}),ns&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[a("rightSidebar.changeAuditScopeLabel"),": ",Ko]}),oh]}),ie&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ie}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Qr.map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===r.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Yf(r),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diff.baseRef??r.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:a("rightSidebar.branchAuditViewDiff")})]}),ys(r.createdAt,w)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:ys(r.createdAt,w)})]}),e.jsx("button",{type:"button",onClick:()=>Xf(r.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:a("common.delete"),"aria-label":a("common.delete"),children:e.jsx(Ba,{size:12})})]},r.key)),zn.length>0?zn.slice(0,Math.max(0,8-Qr.length)).map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===r.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Jf(r.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.baseRef}),r.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diffFingerprint})]}),ys(r.latestInjectedAt,w)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:a("rightSidebar.branchAuditGeneratedAt",{time:ys(r.latestInjectedAt,w)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{Uf(r)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:a("rightSidebar.branchAuditClearTitle"),"aria-label":a("rightSidebar.branchAuditClearTitle"),children:e.jsx(Ba,{size:12})})]},r.key)):Qr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Tc=sr&&b&&Hn?e.jsxs("div",{className:ja?"overflow-visible":"overflow-hidden",children:[ih,e.jsxs("button",{type:"button",onClick:()=>{Xe||hf(r=>{const i=!r;return i&&ve&&!Hn&&!nn&&Ro(ve),i})},"aria-expanded":ja,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${Xe?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(Rr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${gn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[nn&&e.jsx(vt,{size:10,className:"animate-spin"}),gn.staged>0?a("rightSidebar.stagedCount",{count:gn.staged}):a("rightSidebar.noStagedChangesShort")]}),!Xe&&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 ${ja?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]})]}),ja&&e.jsxs("div",{className:"space-y-0",children:[Lt.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:a("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Mf})]})}),e.jsx(qn,{label:a("rightSidebar.gitRepositoryLabel"),value:ve??"",options:Lt,placeholder:a("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:a("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:a("rightSidebar.gitRepositoryEmpty"),disabled:!!Ae,onChange:r=>{$c(r||null)}}),We&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:a("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/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:a("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:Ln!==ec?ec:null})]}),e.jsxs("button",{type:"button",onClick:()=>{rh()},disabled:!_f,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 ${Wo?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Ae?.action==="switch-branch"||Wo?"opacity-0":"",children:a("rightSidebar.switchBranch")}),Ae?.action==="switch-branch"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),Wo&&Ae?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(qn,{label:a("rightSidebar.currentBranchLabel"),value:Ln,options:Lf,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),disabled:!!Ae,onChange:Gs})]}),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:a("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:We?a("rightSidebar.selectRepositoryForGitActions"):gn.staged>0?a("rightSidebar.commitReadyHint",{count:gn.staged}):a("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Lc()},disabled:!!Ae||We||gn.staged===0||!Ws.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 ${zo?"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:We?a("rightSidebar.selectRepositoryForGitActions"):gn.staged===0?a("rightSidebar.commitNeedsStaged"):a("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Ae?.action==="commit"||zo?"opacity-0":"",children:a("rightSidebar.commitChanges")}),Ae?.action==="commit"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),zo&&Ae?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ws,onChange:r=>dl(r.target.value),onKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),Lc())},placeholder:a("rightSidebar.commitMessagePlaceholder"),disabled:!!Ae,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:()=>gr(r=>!r),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":tr,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:a("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Q&&e.jsx(vt,{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 ${tr?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]})]}),tr&&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(Vn,{size:12,className:"shrink-0"}),e.jsx("input",{value:Cn,onChange:r=>Zr(r.target.value),placeholder:a("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),Cn&&e.jsx("button",{type:"button",onClick:()=>Zr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Ut,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:$f,children:[en.length>0?en.map(r=>{const[i,...u]=r.split(/\s+/),x=u.join(" ")||r;return e.jsxs("button",{type:"button",onClick:()=>{Qf(r)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:x,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),rr[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${rr[i]==="ahead"?"bg-accent/10 text-accent":rr[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:a(rr[i]==="ahead"?"rightSidebar.commitAhead":rr[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),ze===i&&e.jsx(vt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},r)}):Q?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:a("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.recentCommitsEmpty")}),Tt&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(vt,{size:12,className:"animate-spin"})}),no&&!Tt&&en.length>0&&e.jsx("button",{type:"button",onClick:()=>{ms({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:a("rightSidebar.recentCommitsLoadMore")})]})]}),nt&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:nt}),el&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:el})]}),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:a("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{sh()},disabled:!Df,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 ${Go?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Ae?.action==="pull"||Go?"opacity-0":"",children:a("rightSidebar.pullChanges")}),Ae?.action==="pull"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),Go&&Ae?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{nh()},disabled:!Ff,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 ${qo?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Ae?.action==="push"||qo?"opacity-0":"",children:a("rightSidebar.pushChanges")}),Ae?.action==="push"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),qo&&Ae?.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] ${lc.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:lc.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 ${ac?"grid-cols-2":"grid-cols-1"}`,children:[ac&&e.jsx(qn,{label:a("rightSidebar.pushRemoteLabel"),value:sn,options:sc,placeholder:a("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:a("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:a("rightSidebar.pushNoRemotes"),disabled:!!Ae,onChange:qs}),e.jsx(qn,{label:a("rightSidebar.pushBranchLabel"),value:an,options:Af,placeholder:a("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:a("rightSidebar.pushBranchSearchPlaceholder"),emptyText:a("rightSidebar.pushNoBranches"),disabled:!!Ae,onChange:Ks})]})]})]})]}):null,lh=o.useCallback(r=>{const i=it(r,b);if(!i)return[];const u=hi(r),x=[];return r.canStage&&x.push({key:"stage-file",label:a("rightSidebar.stageFile"),onClick:()=>{ot({action:"stage-file",cwd:i,paths:[r.path]},a("rightSidebar.stageFile"),u)}}),r.canUnstage&&x.push({key:"unstage-file",label:a("rightSidebar.unstageFile"),onClick:()=>{ot({action:"unstage-file",cwd:i,paths:[r.path]},a("rightSidebar.unstageFile"),u)}}),r.canStash&&x.push({key:"stash-file",label:a("rightSidebar.stashFile"),onClick:()=>{ot({action:"stash-file",cwd:i,paths:[r.path]},a("rightSidebar.stashFile"),u)}}),r.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:a("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Dr({kind:"restore",file:r,phrase:""})}),x},[b,ot,a]),ch=o.useCallback(()=>{if(m){f?.();return}yr(0),kr.current?.slideTo(0),vr(!1),kt(null)},[f,m]),Ic=o.useCallback(r=>{if(j(""),It(r),Ye(null),kt(null),ne(null),ee){m&&f?.(),yr(0),kr.current?.slideTo(0),vr(!1);return}},[ee,f,m,Ye,It]);o.useEffect(()=>{const r=i=>{const u=i.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;j(""),kt(null),Ie(null);const v=!!(b&&(x===b||x.startsWith(`${b}/`)));if(u.kind==="file"){const R=di(x);us(x),typeof u.line=="number"&&Number.isSafeInteger(u.line)&&u.line>0&&Ie(u.line),It(v?null:R),ne(A=>({path:x,nonce:(A?.nonce??0)+1}));return}Ye(null),v?(It(null),ne(R=>({path:x,nonce:(R?.nonce??0)+1}))):(ne(null),It(x)),ee&&(m&&f?.(),yr(0),kr.current?.slideTo(0),vr(!1))};return window.addEventListener(Kc,r),()=>window.removeEventListener(Kc,r)},[us,ee,f,m,b,Ye,It]),o.useEffect(()=>{t||(At(!1),zt(!1))},[t]),o.useEffect(()=>{if(!Jt&&!dr)return;const r=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(Ts.current?.contains(i.target)||wn.current?.contains(i.target))||(At(!1),zt(!1))};return window.addEventListener("mousedown",r),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",r)}},[dr,Jt]);const Dc=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:Rf,disabled:!ca,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.parentFolder"),title:a("rightSidebar.parentFolder"),children:e.jsx(Fd,{size:14})}),e.jsx("button",{type:"button",onClick:ql,disabled:!b||Pn===b,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.backToProjectRoot"),title:a("rightSidebar.backToProjectRoot"),children:e.jsx(Xc,{size:14})}),e.jsx("button",{type:"button",onClick:Cf,disabled:!pe,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.refreshFiles"),title:ul?a("rightSidebar.fileWatchUnavailable",{message:ul}):a("rightSidebar.refreshFiles"),children:e.jsx(vi,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:pe??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:Sf}),ea==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:a("fileTree.sortedByModified"),"aria-label":a("fileTree.sortedByModified"),children:e.jsx(Vc,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>pe&&zr(pe,Et??void 0),disabled:!pe,...pe&&Et?$o(la(pe),Et):{},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 ${Et&&(q===Et||Re===Et)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":a(Et&&Re===Et?"rightSidebar.copied":Et&&q===Et?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:a("rightSidebar.insertCurrentFolder"),children:Et&&(q===Et||Re===Et)?e.jsx(bi,{size:13}):e.jsx(za,{size:13})}),e.jsxs("div",{ref:wn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{At(!1),zt(r=>!r)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${dr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":dr,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(xi,{size:14})}),dr&&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:()=>{zt(!1),Nf()},disabled:!Ao,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${hs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[hs?e.jsx(Xo,{size:14}):e.jsx($a,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(hs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),gf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${bo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[bo?e.jsx(ym,{size:14}):e.jsx(ki,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(bo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!pe,onClick:()=>{pe&&(zt(!1),bf(pe,ea==="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:[ea==="modified"?e.jsx(nm,{size:14}):e.jsx(Vc,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ea==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),b&&(da.length>0||jf)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:ql,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 ${pe===b?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:b,children:[e.jsx(Xc,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:Ke})]}),da.map(r=>{const i=r.path,u=r.kind==="file",x=u?Ve===i:pe===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?us(i):It(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(Si,{size:10,className:"shrink-0"}):e.jsx($a,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ft(i)})]}),e.jsx("button",{type:"button",onClick:()=>ln(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":a("rightSidebar.unpinFolder",{name:ft(i)}),title:a("rightSidebar.unpinFolder",{name:ft(i)}),children:e.jsx(Ut,{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"})]}),Vo=o.useMemo(()=>{if(En===null)return null;const r=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((fo-En)/1e3)),u=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),[x,v]=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(x,v)},[fo,En]),Fc=b&&!ds?e.jsx("button",{type:"button",onClick:()=>{th(!xo)},"aria-pressed":xo,title:a("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${xo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:a("rightSidebar.multiRepoScan")}):null,_c=b?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Vo?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:a("rightSidebar.gitLastUpdated",{time:Vo}),children:Vo}):null,e.jsx("button",{type:"button",onClick:()=>{ls()},disabled:Fr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":a("rightSidebar.refreshGit"),title:a("rightSidebar.refreshGit"),children:e.jsx(vi,{size:13,className:Fr?"animate-spin":""})})]}):null,dh=Pl?a("rightSidebar.changeAuditScopeAll"):fn.length===1?fn[0].relativeRoot==="."?Ke:fn[0].relativeRoot||fn[0].name:`${fn.length} repos`,Bc=b?e.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[e.jsx(Cd,{open:Fs,onOpenChange:Ar,showScopePicker:bn,selectedAll:Pl,repos:xf,selectedRoots:qt,onToggleRepo:Hf,onGenerate:()=>Bf(),disabled:!b,inserted:q===Gl,buttonLabel:a("rightSidebar.changeAuditShort"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:a("rightSidebar.insertChangeAuditPrompt"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:dh,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a("rightSidebar.changeAuditShort"),loading:$r,error:!!Lr,statusTitle:Lr??($r?a("rightSidebar.changeAuditLoading"):jt.length>0?`${a("rightSidebar.changeAuditLoaded",{count:jt.length})}${Pc?` · ${a("rightSidebar.changeAuditLoadedAt",{time:Pc})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{Of()},disabled:$r||jt.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${jt.length>0?"":"invisible"}`,title:a("rightSidebar.clearChangeAuditTitle"),"aria-label":a("rightSidebar.clearChangeAudit"),children:e.jsx(Ba,{size:12})})]}):null,Ra=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:[ae?.available&&ae.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:ae.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ae.branch})]}),st.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[st.modified,"M"]}),st.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",st.added]}),st.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",st.deleted]}),st.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[st.renamed,"R"]}),st.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[st.copied,"C"]}),st.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[st.untracked,"U"]}),st.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[st.conflicted,"!"]}),st.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[st.other,"?"]}),st.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:a("rightSidebar.stagedCountShort",{count:st.staged})}),ae?.available&&b&&we.size>0&&V.length<=1&&e.jsx("button",{type:"button",onClick:()=>{ot({action:"stage-all",cwd:b},a("rightSidebar.stageAll"))},disabled:!!Ae,className:"rounded-md bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),ae?.available&&b&&we.size>0&&V.length<=1&&e.jsx("button",{type:"button",onClick:()=>Dr({kind:"stash-all",repoRoot:b,repoLabel:Ke}),disabled:!!Ae,className:"rounded-md bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]});return e.jsxs(sm,{side:"right",isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c,children:[$o.popoverNode,e.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:b??void 0,children:Ke}),(!ee||co)&&ae?.available&&ae.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:ae.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:ae.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const r=!se;fe(r),r?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):j("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${se?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleSearch"),title:a("common.search"),children:e.jsx(Vn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Qe,onClick:()=>{vn(r=>!r),lr(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Qe?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleContextDraft"),title:a("rightSidebar.contextDraftTitle"),children:[e.jsx(am,{size:14}),!Qe&&wt.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:pl,type:"file",multiple:!0,className:"hidden",onChange:r=>{const i=r.target.files;!i||i.length===0||(fs(Array.from(i)),r.target.value="")}}),e.jsx("input",{ref:gl,type:"file",accept:"image/*",className:"hidden",onChange:r=>{const i=r.target.files?.[0];r.target.value="",i&&kf(i)}}),h&&e.jsx("button",{type:"button",onClick:h,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${c?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:c?e.jsx(Xo,{size:14}):e.jsx($a,{size:14})}),e.jsxs("div",{ref:Ts,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),At(r=>!r)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Jt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Jt,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(xi,{size:15})}),Jt&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),pl.current?.click()},disabled:Vs,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:[Vs?e.jsx(vt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(_m,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),gl.current?.click()},disabled:Vs,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:[Vs?e.jsx(vt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Rm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.insertLocalImage")})]}),h&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),h()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${c?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[c?e.jsx(Xo,{size:14}):e.jsx($a,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),c&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":a("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:a("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",a("rightSidebar.layoutModeAuto")],["narrow",a("rightSidebar.layoutModeNarrow")],["wide",a("rightSidebar.layoutModeWide")]].map(([r,i])=>{const u=G===r;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(r),At(!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},r)})})]})]})]}),e.jsx("button",{type:"button",onClick:s,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":a("rightSidebar.close"),children:e.jsx(Ut,{size:14})})]}),se&&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(Vn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:O,onChange:r=>j(r.target.value),placeholder:a(M==="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 ${ee?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Nc("name"),"aria-pressed":M==="name",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${M==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Nc("content"),"aria-pressed":M==="content",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${M==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeContent")})]}),O&&e.jsx("button",{type:"button",onClick:()=>j(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Ut,{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(om,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:K,onChange:r=>re(r.target.value),onKeyDown:r=>{r.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchScopePlaceholder"),"aria-label":a("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),K!=="."&&e.jsx("button",{type:"button",onClick:()=>re("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.resetSearchScope"),children:e.jsx(Ut,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>je(r=>!r),"aria-expanded":me,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${me||os.length>0||C||ue||Ge?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:a("rightSidebar.searchOptions"),"aria-label":a("rightSidebar.searchOptions"),children:[e.jsx(im,{size:13}),os.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:os.length})]})]}),me&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:oe,onChange:r=>he(r.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchExcludePlaceholder"),"aria-label":a("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),oe&&e.jsx("button",{type:"button",onClick:()=>he(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":a("rightSidebar.clearSearchExclude"),children:e.jsx(Ut,{size:11})})]}),M==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":a("rightSidebar.contentSearchOptions"),children:[[C,()=>Z(r=>!r),xm,a("rightSidebar.matchCase")],[ue,()=>Ee(r=>!r),Om,a("rightSidebar.matchWholeWord")],[Ge,()=>Fe(r=>!r),Lm,a("rightSidebar.useRegex")]].map(([r,i,u,x])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":r,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${r?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),x]},x))})]})]}),ds?null:e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>on("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Rr,{size:12}),a("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:()=>on("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Yd,{size:12}),a("rightSidebar.tabChanges"),we.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:we.size}):null]}),e.jsxs("button",{type:"button",onClick:()=>on("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(fm,{size:12}),a("rightSidebar.tabFiles")]})]}),e.jsx("div",{className:"h-2"}),ll&&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:ll})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(li,{active:Xe,mounted:sr,fallback:e.jsx(ci,{slow:!1}),children:Ue?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(ed,{items:Wf,selectedKey:lf,onSelect:_s,emptyText:a("rightSidebar.noChanges"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a("rightSidebar.recentCommitsTitle"),headerMeta:`${Ue.headRef??""}${Ue.commits?.[0]?` · ${Ue.commits[0]}`:""}`,onClose:()=>{$e(null),_s(null)},closeLabel:a("common.back"),wrap:$t,onToggleWrap:ee?wa:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba})}):pr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(ed,{items:Bo,selectedKey:io,onSelect:rn,emptyText:a(Me?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a(Me?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:xa?`${xa.repoLabel} · ${xa.branchName??"HEAD"} → ${xa.baseRef}`:void 0,onClose:()=>{Zt(!1),er(null)},closeLabel:a("common.back"),wrap:$t,onToggleWrap:ee?wa:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,walkthroughs:Gf,onWalkthroughNavigate:qf,initialDetailScrollTop:Me&&Ze?jn[Ze]:void 0,onDetailScrollPositionChange:Zf,externalSwiperRef:ee?sa:void 0,onMobileSlideChange:ee?lo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:Tc?e.jsx("div",{className:"px-3",children:Tc}):Fr?e.jsx(ci,{slow:jl}):cn?e.jsx(Fa,{message:cn,onRetry:()=>{ls()}}):Ad(ae)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):ae?.available===!1?e.jsx(Fa,{message:ae.error??a("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ls()}}):b?e.jsx(ci,{slow:jl}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(li,{active:On,children:ee?e.jsxs(Bd,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:r=>{kr.current=r,r.slideTo(ol,0)},onSlideChange:r=>{if(yr(r.activeIndex),is.current===r.activeIndex){is.current=null;return}r.activeIndex===0&&(vr(!1),kt(null),f?.())},children:[e.jsx(yi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Dn,onScroll:Il,onDragOver:oa,onDragEnter:oa,onDragLeave:_l,onDrop:Bl,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[fl&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:a("rightSidebar.dropToUpload")})}),!O.trim()&&Dc,e.jsx(Yc,{rootPath:pe??"",onFileSelect:us,onPathReference:zr,getReferenceText:la,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onDirectoryRoot:Kl,onSearchFromDirectory:Vl,onDirectoryPinToggle:Yl,onFilePinToggle:Xl,pinnedPaths:mn,selectedFilePath:Ve,query:le,searchRootPath:Ml,searchOptions:$l,searchMode:M,onContentMatchSelect:Dl,onDirectoryDropFiles:(r,i)=>fs(i,r),revealDirectory:X,canOpenInFileBrowser:hl,onOpenInFileBrowser:Fl})]})}),e.jsx(yi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Oi,{filePath:On&&(cf||ol===1)?Ve:null,onInsertReference:zr,onInsertText:jr,onInsertFeature:jr,onReviewReference:zl,onReferenceCopied:Sr,onClose:ch,onDirectoryLinkOpen:Ic,isMobile:!0,lineRange:Kr,onLineRangeChange:kt,insertedReferenceKey:q,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Dn,onScroll:Il,onDragOver:oa,onDragEnter:oa,onDragLeave:_l,onDrop:Bl,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:mo},children:[fl&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:a("rightSidebar.dropToUpload")})}),!O.trim()&&Dc,e.jsx(Yc,{rootPath:pe??"",onFileSelect:us,onPathReference:zr,getReferenceText:la,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onDirectoryRoot:Kl,onSearchFromDirectory:Vl,onDirectoryPinToggle:Yl,onFilePinToggle:Xl,pinnedPaths:mn,selectedFilePath:Ve,query:le,searchRootPath:Ml,searchOptions:$l,searchMode:M,onContentMatchSelect:Dl,onDirectoryDropFiles:(r,i)=>fs(i,r),revealDirectory:X,canOpenInFileBrowser:hl,onOpenInFileBrowser:Fl})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("rightSidebar.resizeFileTree"),title:a("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:vf,onPointerMove:yf,onPointerUp:Tl,onPointerCancel:Tl,onDoubleClick:()=>{po(Mi),xt(ws,Mi)},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(Oi,{filePath:On?Ve:null,onInsertReference:zr,onInsertText:jr,onInsertFeature:jr,onReviewReference:zl,onReferenceCopied:Sr,onDirectoryLinkOpen:Ic,isMobile:!1,lineRange:Kr,onLineRangeChange:kt,insertedReferenceKey:q,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D})})]})}),e.jsx(li,{active:pt,mounted:df||pt,children:()=>Co?e.jsx(lm,{}):ee?e.jsx(wi,{mobile:!0,backLabel:a("rightSidebar.backToChangeList"),externalSwiperRef:sa,onMobileSlideChange:lo,groups:Ot.length>0?pc():[],mode:St,onModeChange:ya,selectedKey:Ve,scrollToKey:vc,scrollToKeyNonce:Xs.nonce,compact:!1,collapsedDirectoryKeys:ur,onToggleDirectory:kc,onSelectFile:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);i&&va(ut(i))},renderLeading:bc,renderTrailing:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?hc(i):null},renderDirectoryTrailing:mc,renderSubtitle:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?uc(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:r=>b&&e.jsxs("div",{className:"px-0 py-0",children:[Ra&&e.jsx("div",{className:"mb-2",children:Ra}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Ot.length,"/",we.size]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[cc(),Fc,r,c&&Fo(),Bc,_c]}),Ct&&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:Ct.label}),Ct.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:Ct.branch})]}),!Ct&&bn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:fa?(r=>wc(r)):void 0,emptyContent:Co?null:cn&&we.size===0?e.jsx(Fa,{message:cn,onRetry:()=>{ls()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ot.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>cs(0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:a("rightSidebar.backToChangeList"),children:[e.jsx(Ns,{size:14}),a("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[c&&Fo(),e.jsxs("button",{type:"button",onClick:wa,"aria-pressed":$t,title:a("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${$t?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:a($t?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:gc(),activePane:pt,wrap:$t,diffViewType:pf,inlineMode:Jn,diffOptions:Cc,reloadKey:fr,renderStreamBadge:r=>e.jsx(js,{status:r}),onHunkGitAction:Mc,onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,onDetailScroll:pa}):e.jsx(wi,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:a("rightSidebar.backToChangeList"),groups:Ot.length>0?pc():[],mode:St,onModeChange:ya,selectedKey:Ve,scrollToKey:vc,scrollToKeyNonce:Xs.nonce,compact:!0,collapsedDirectoryKeys:ur,onToggleDirectory:kc,onSelectFile:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);i&&va(ut(i))},renderLeading:bc,renderTrailing:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?hc(i):null},renderDirectoryTrailing:mc,renderSubtitle:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?uc(i):null},aiContent:fa?(r=>wc(r)):void 0,emptyContent:Co?null:cn&&we.size===0?e.jsx(Fa,{message:cn,onRetry:()=>{ls()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ot.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderListHeader:r=>b&&e.jsxs("div",{className:"px-0 py-0",children:[Ra&&e.jsx("div",{className:"mb-2",children:Ra}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Ot.length,"/",we.size]})})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[cc(),Fc,r,Fo(),e.jsxs("button",{type:"button",onClick:wa,"aria-pressed":$t,title:a("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 ${$t?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:a($t?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Bc,_c]}),Ct&&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:Ct.label}),Ct.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:Ct.branch}),e.jsx("button",{type:"button",onClick:()=>Sa("stage-all",Ct.root,Ct.label),disabled:!!Ae,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>Sa("stash-all",Ct.root,Ct.label),disabled:!!Ae,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}),!Ct&&bn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),files:gc(),activePane:pt,wrap:$t,diffViewType:Qt,inlineMode:Jn,diffOptions:Cc,reloadKey:fr,renderStreamBadge:r=>e.jsx(js,{status:r}),onHunkGitAction:Mc,onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,onDetailScroll:pa})})]}),t&&Qe&&e.jsx(fp,{value:wt,collapsed:ht,autoCollapseAfterSend:Xt,focusRequest:qr,insertError:Xn?a("rightSidebar.contextDraftInsertFailed"):null,onChange:r=>{Wt(!1),Ht(r)},onCollapsedChange:lr,onAutoCollapseAfterSendChange:yn,onDisable:()=>vn(!1),onClear:()=>Ht(""),onInsert:()=>Wl(!1),onInsertAndSend:()=>Wl(!0),labels:{title:a("rightSidebar.contextDraftTitle"),hint:a("rightSidebar.contextDraftHint"),placeholder:a("rightSidebar.contextDraftPlaceholder"),collapse:a("rightSidebar.contextDraftCollapse"),expand:a("rightSidebar.contextDraftExpand"),disable:a("rightSidebar.contextDraftDisable"),clear:a("rightSidebar.contextDraftClear"),insert:a("rightSidebar.contextDraftInsert"),insertAndSend:a("rightSidebar.contextDraftInsertAndSend"),inserted:a("rightSidebar.contextDraftInserted"),sent:a("rightSidebar.contextDraftSent"),send:a("rightSidebar.contextDraftSend"),appended:a("rightSidebar.contextDraftAppended"),resize:a("rightSidebar.contextDraftResize"),autoCollapseAfterSend:a("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:r=>a("rightSidebar.contextDraftCharacterCount",{count:r})}}),If(),ct&&typeof document<"u"&&Gr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Dr(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:r=>r.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:ct.kind==="restore"?a("rightSidebar.confirmRestoreTitle"):a("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:ct.kind==="restore"?a("rightSidebar.confirmRestoreDescription",{path:Dd(ct.file.absolutePath,b)}):a("rightSidebar.confirmStashAllDescription")}),ct.kind==="restore"&&e.jsx("input",{value:ct.phrase,onChange:r=>Dr({...ct,phrase:r.target.value}),placeholder:a("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Dr(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:a("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Ae||ct.kind==="restore"&&ct.phrase.trim()!==a("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(ct.kind==="restore"){const r=it(ct.file,b);if(!r)return;ot({action:"restore-worktree-file",cwd:r,paths:[ct.file.path],confirm:{acknowledged:!0,phrase:ct.phrase}},a("rightSidebar.restoreFile"),hi(ct.file))}else{const r=ct.repoRoot??b;if(!r)return;ot({action:"stash-all",cwd:r},a("rightSidebar.stashAll"),`repo:${r}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${ct.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:a(Ae?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const Fb=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Oi,MarkdownImageLightbox:Vu,MarkdownPreview:Yu,RightSidebar:Rb,__testParseMarkdownListBlock:Hg,buildMarkdownPreviewBlocks:Zg,buildMarkdownPreviewRenderResult:Ji,collectKnownGitRepoRoots:vu,computeMarkdownImageDisplayBox:Lu,getMarkdownHeadingOutline:Ku,getMarkdownHeadingPathAtLine:qu,getNextMarkdownPreviewLineRange:ab,isSvgImageSrc:Za,mountRightSidebarRepoPickerOverlay:su,replaceGitRepositorySnapshot:tf,resolveMarkdownLocalLinkTarget:Gi,resolveRightSidebarDiffViewType:gu,shouldCloseMarkdownImageLightboxDrag:zu,showsGitRepoGroupHeader:$i},Symbol.toStringTag,{value:"Module"}));export{ki as E,Xc as H,Nm as M,Fb as R,ym as a,$m as b,zm as c,Db as m};
1678
+ `),truncated:i.some(H=>H.truncated)};if((x.hunks??[]).length===0){xe(a("rightSidebar.branchAuditDiffEmpty"));return}const v=Date.now(),R=["preview",x.repoRoot??b,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??v].join("\0"),A=Vt.length===1?Vt[0].label:`${Vt.length} repos`;er(x),es(H=>[{key:R,diff:x,repoLabel:A,createdAt:v},...H.filter(Y=>Y.key!==R)].slice(0,8)),Rn(H=>H[R]===void 0?H:{...H,[R]:0}),tn(R),rn(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),Zt(!0)}catch(i){if(!ke(r)||Cr(i))return;xe(i instanceof Error?i.message:"Failed to load branch diff")}finally{ke(r)&&z(!1)}},[Ir,Vt,Rt,xr,ke,b,a]),Yf=o.useCallback(r=>{er(r.diff),xe(null),tn(r.key),rn(r.diff.hunks?.[0]?`${r.diff.hunks[0].filePath}\0${r.diff.hunks[0].hunkHeader}\0${r.diff.hunks[0].hunkIndex}`:null),Zt(!0)},[]),Xf=o.useCallback(r=>{es(i=>i.filter(u=>u.key!==r)),Rn(i=>{if(!(r in i))return i;const u={...i};return delete u[r],u}),Ze===r&&(tn(null),er(null),Zt(!1))},[Ze]),Jf=o.useCallback(r=>{const i=zn.find(u=>u.key===r);i&&(er(null),xe(null),tn(r),rn(i.records[0]?.filePath??null),Zt(!0))},[zn]),Qf=o.useCallback(async r=>{if(!b||!ve)return;const[i]=r.split(/\s+/);if(i){_e(i),at(null),$e(null);try{const u=await _h({cwd:b,repoRoot:ve,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){at(u.error??"Commit diff is unavailable");return}$e(u);const x=u.hunks?.[0];_s(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){at(u instanceof Error?u.message:"Failed to load commit diff")}finally{_e(null)}}},[ve,b]),Zf=o.useCallback(r=>{if(!Me||!Ze)return;const i=Math.max(0,Math.round(r));Rn(u=>Math.abs((u[Ze]??0)-i)<24?u:{...u,[Ze]:i})},[Me,Ze]);o.useEffect(()=>{!ee||!pr||!Me||cs(1)},[pr,Me,ee,cs]);const xc=o.useCallback(r=>{r&&mf(i=>mm(i,r))},[]),vc=Xs.key===Ve?Xs.key:null,va=o.useCallback(r=>{const i=te.getState(),u=kb();_a("select_diff_file",{interactionId:u,path:r,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),Ye(r),on("diff"),ee&&r&&cs(1),xc(r),queueMicrotask(()=>{const x=te.getState();_a("select_diff_file_after",{interactionId:u,requestedPath:r,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:ce})})},[ce,ee,xc,Ye,on,cs]),yc=o.useCallback(r=>{const i=Array.from(we.values()).find(u=>{const x=it(u,b),v=ut(u);return u.path===r.filePath||v===r.filePath||u.absolutePath===r.filePath||(x?`${x}/${u.path}`===r.filePath:!1)||r.repoRoot&&x===r.repoRoot&&u.path===r.filePath});if(i){va(ut(i)),window.setTimeout(()=>xn(r),90),window.setTimeout(()=>xn(r),320),window.setTimeout(()=>xn(r),760);return}xn(r)},[we,b,va]),wc=o.useCallback(({slideToDetail:r,fullscreen:i,toggleFullscreen:u}={})=>Qn.length>0?e.jsx(Hd,{walkthroughs:Qn,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:x=>{ee&&window.requestAnimationFrame(()=>r?.()),yc(x)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(Es,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),a("rightSidebar.changeWalkthroughEmpty")]}),[ce,Qn,yc,ee,a]),eh=o.useCallback(r=>{r&&Mr(i=>{const u=new Set(i);return u.has(r)?u.delete(r):u.add(r),si(Zo,u),u})},[]),kc=o.useCallback(r=>{to(i=>{const u=new Set(i);return u.has(r)?u.delete(r):u.add(r),si(id,u),u})},[]),ya=o.useCallback(r=>{Is(r),xt(ou,r)},[]);o.useEffect(()=>{fa||St!=="ai"||ya("tree")},[St,ya,fa]);const wa=o.useCallback(()=>{Ds(r=>{const i=!r;return xt(iu,i),i})},[]),Sc=o.useCallback(r=>{Vr(r),xt(lu,r)},[]),{whitespace:jc,context:Rc}=gm(),Cc=o.useMemo(()=>({algorithm:"histogram",whitespace:jc,context:Rc}),[jc,Rc]),Nc=o.useCallback(r=>{_(r),xt(cu,r)},[]),ka=o.useCallback(async(r,i,u,x)=>{let v=r;for(;v.ok&&v.status==="running";)await new Promise(A=>window.setTimeout(A,1500)),v=await qc({jobId:v.jobId,cwd:i.cwd,action:i.action});if(!v.ok)throw new Error("Git action status is unavailable");if(v.status==="error")throw new Error(v.error||v.message||"Git action failed");const R={action:i.action,path:x,label:u};return as(R),window.setTimeout(()=>as(A=>A?.action===R.action&&A.path===R.path?null:A),1400),v},[]),ot=o.useCallback(async(r,i,u)=>{const x=b;b&&ar.current.delete(b),dt(null),as(null),ss({action:r.action,path:u});try{const v=await Bh({...r,includeNested:Gn(b)}),R=await ka(v,r,i,u);if(!ke(x))return!1;const A=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>R.bundle):R.bundle;return ke(x)?(A&&Ur(A,{reloadDiff:!0,cacheOnly:!0}),Dr(null),!0):!1}catch(v){return as(null),dt(a("rightSidebar.gitActionFailed",{message:v instanceof Error?v.message:"Unknown error"})),!1}finally{ke(x)&&ss(null)}},[Ur,ke,b,a,ka]),Mc=o.useCallback(async r=>{const i=b,u=await Oh({...r,includeNested:Gn(b)});if(!ke(i))return;const x=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>u.bundle):u.bundle;ke(i)&&x&&Ur(x,{reloadDiff:!0,cacheOnly:!0})},[Ur,ke,b]),Sa=o.useCallback((r,i,u)=>{if(i){if(r==="stage-all"){ot({action:"stage-all",cwd:i},a("rightSidebar.stageAll"),`repo:${i}`);return}Dr({kind:"stash-all",repoRoot:i,repoLabel:u})}},[ot,a]),$c=o.useCallback(r=>{Je(r),ni(b,r),Gs(""),qs(""),Ks(""),Ye(tc(r)),Xe||on("diff"),r&&r!==b&&V.find(u=>u.root===r)?.deferred&&Kt(r,{includeNested:!1,background:!0,replaceRepoRoot:r})},[tc,Xe,V,Kt,b,Ye,on]),Ec=o.useCallback(r=>{const i=new Set([...Ft.current.keys(),...dn.current,...ar.current]);for(const u of i)u!==r&&(Dt.current.delete(u),Ft.current.get(u)?.abort(),Ft.current.delete(u),bt(`right-sidebar-git-untracked:${u}`),dn.current.delete(u),ar.current.delete(u))},[]),th=o.useCallback(async r=>{const i=b;if(!i||(await te.getState().setNestedGitScanRoot(i,r),!ke(i)))return;if(r){await Kt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Ec(i),Gs(""),qs(""),Ks(""),oo(x=>x.filter(v=>v===i));const u=_t;u&&it(u,i)!==i&&Ye(null),await Kt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Ec,ke,Kt,b,Ye,_t]),rh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Ln.trim();!r||r===de?.branch||await ot({action:"switch-branch",cwd:ve,branch:r},a("rightSidebar.switchBranch"))},[de?.branch,ve,We,ot,Ln,a]),Lc=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Ws.trim();if(!r)return;await ot({action:"commit",cwd:ve,message:r},a("rightSidebar.commitChanges"))&&dl("")},[ve,Ws,We,ot,a]),nh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=sn.trim(),i=an.trim();await ot({action:"push",cwd:ve,...r?{remote:r}:{},...i?{branch:i}:{}},a("rightSidebar.pushChanges"))},[ve,an,sn,We,ot,a]),sh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=sn.trim(),i=an.trim();await ot({action:"pull",cwd:ve,...r?{remote:r}:{},...i?{branch:i}:{}},a("rightSidebar.pullChanges"))},[ve,an,sn,We,ot,a]);o.useEffect(()=>{if(!Xe||!ve||Ae)return;let r=!1;const i={push:a("rightSidebar.pushChanges"),pull:a("rightSidebar.pullChanges"),commit:a("rightSidebar.commitChanges"),"switch-branch":a("rightSidebar.switchBranch"),"stage-all":a("rightSidebar.stageAll"),"stash-all":a("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(r)return;const x=await qc({cwd:ve,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const v={action:u,cwd:ve},R=i[u]??u;ss({action:u});try{const A=await ka(x,v,R);if(r||!ke(b))return;const H=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>A.bundle):A.bundle;H&&Ur(H,{reloadDiff:!0,cacheOnly:!0})}catch(A){r||dt(a("rightSidebar.gitActionFailed",{message:A instanceof Error?A.message:"Unknown error"}))}finally{r||ss(null)}return}})(),()=>{r=!0}},[ve,Ur,Xe,ke,b,Ae,a,ka]);const zo=$n?.action==="commit",Wo=$n?.action==="switch-branch",Go=$n?.action==="pull",qo=$n?.action==="push",ja=Xe||ff,Ko=ma?a("rightSidebar.changeAuditScopeAll"):ir.length===1?ir[0].label:`${ir.length} repos`,ah=ir.length>0,Ac=Vt.length>0,oh=b?e.jsx(Cd,{open:so,onOpenChange:ao,showScopePicker:!0,selectedAll:ma,repos:Bt,selectedRoots:ha,onToggleRepo:zf,onGenerate:()=>Kf(Oo?"regenerate":"generate"),disabled:!ah,generateDisabled:!Ac,inserted:q?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:a(Oo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.branchAuditGenerateTitle"),ariaLabel:a("rightSidebar.branchAuditShort"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ko,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a(Oo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Vf()},secondaryDisabled:!Ac||T,secondaryLabel:a("rightSidebar.branchAuditViewDiff"),secondaryTitle:a("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:T,loading:sl.size>0,statusTitle:sl.size>0?a("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsxs("label",{className:"flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:a("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:a("rightSidebar.includeUncommittedHint")})]}),e.jsx("input",{type:"checkbox",checked:Ir,onChange:r=>nl(r.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),oc.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:a("rightSidebar.missingBaseReposSkipped",{repositories:oc.map(r=>r.label).join(w==="zh"?"、":", ")})})]}),renderRepoExtra:r=>{const i=gt.get(r.root),u=[],x=new Set,v=(Y,Ce)=>{!Y||x.has(Y)||(x.add(Y),u.push({value:Y,label:Y,meta:Ce}))};v(xr[r.root]||i?.context?.branch,a("rightSidebar.pushCurrentBranchBadge"));for(const Y of i?.context?.branches??[])v(Y,Y===i?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):a("rightSidebar.localBranch"));for(const Y of i?.context?.remoteBranches??[])v(Y,a("rightSidebar.remoteBranch"));const R=[],A=new Set,H=(Y,Ce)=>{!Y||A.has(Y)||(A.add(Y),R.push({value:Y,label:Y,meta:Ce}))};H(Rt[r.root],Rt[r.root]?a("rightSidebar.pushUpstreamBadge"):void 0),H(i?.context?.upstream,i?.context?.upstream?a("rightSidebar.pushUpstreamBadge"):void 0);for(const Y of i?.context?.remoteBranches??[])H(Y,"remote");for(const Y of i?.context?.branches??[])H(Y,Y===i?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(qn,{label:a("rightSidebar.currentBranchLabel"),value:xr[r.root]||i?.context?.branch||"",options:u,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),onChange:Y=>{Os(Ce=>({...Ce,[r.root]:Y}))}}),e.jsx(qn,{label:a("rightSidebar.branchAuditBaseLabel"),value:Rt[r.root]||"",options:R,placeholder:a("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:a("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:a("rightSidebar.branchAuditBaseEmpty"),onChange:Y=>{Us(Ce=>({...Ce,[r.root]:Y}))}})]})}}):null,Pc=ys(jt.reduce((r,i)=>Math.max(r,i.injectedAt??0),0),w),ih=b?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>rl(r=>{const i=!r;return xt(ei,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":ns,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(Es,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Ko})]}),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 ${ns?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]}),ns&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[a("rightSidebar.changeAuditScopeLabel"),": ",Ko]}),oh]}),ie&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ie}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Qr.map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===r.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Yf(r),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diff.baseRef??r.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:a("rightSidebar.branchAuditViewDiff")})]}),ys(r.createdAt,w)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:ys(r.createdAt,w)})]}),e.jsx("button",{type:"button",onClick:()=>Xf(r.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:a("common.delete"),"aria-label":a("common.delete"),children:e.jsx(Ba,{size:12})})]},r.key)),zn.length>0?zn.slice(0,Math.max(0,8-Qr.length)).map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===r.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Jf(r.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.baseRef}),r.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diffFingerprint})]}),ys(r.latestInjectedAt,w)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:a("rightSidebar.branchAuditGeneratedAt",{time:ys(r.latestInjectedAt,w)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{Uf(r)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:a("rightSidebar.branchAuditClearTitle"),"aria-label":a("rightSidebar.branchAuditClearTitle"),children:e.jsx(Ba,{size:12})})]},r.key)):Qr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Tc=sr&&b&&Hn?e.jsxs("div",{className:ja?"overflow-visible":"overflow-hidden",children:[ih,e.jsxs("button",{type:"button",onClick:()=>{Xe||hf(r=>{const i=!r;return i&&ve&&!Hn&&!nn&&Ro(ve),i})},"aria-expanded":ja,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${Xe?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(Rr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${gn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[nn&&e.jsx(vt,{size:10,className:"animate-spin"}),gn.staged>0?a("rightSidebar.stagedCount",{count:gn.staged}):a("rightSidebar.noStagedChangesShort")]}),!Xe&&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 ${ja?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]})]}),ja&&e.jsxs("div",{className:"space-y-0",children:[Lt.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:a("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Mf})]})}),e.jsx(qn,{label:a("rightSidebar.gitRepositoryLabel"),value:ve??"",options:Lt,placeholder:a("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:a("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:a("rightSidebar.gitRepositoryEmpty"),disabled:!!Ae,onChange:r=>{$c(r||null)}}),We&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:a("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/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:a("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:Ln!==ec?ec:null})]}),e.jsxs("button",{type:"button",onClick:()=>{rh()},disabled:!_f,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 ${Wo?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Ae?.action==="switch-branch"||Wo?"opacity-0":"",children:a("rightSidebar.switchBranch")}),Ae?.action==="switch-branch"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),Wo&&Ae?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(qn,{label:a("rightSidebar.currentBranchLabel"),value:Ln,options:Lf,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),disabled:!!Ae,onChange:Gs})]}),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:a("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:We?a("rightSidebar.selectRepositoryForGitActions"):gn.staged>0?a("rightSidebar.commitReadyHint",{count:gn.staged}):a("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Lc()},disabled:!!Ae||We||gn.staged===0||!Ws.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 ${zo?"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:We?a("rightSidebar.selectRepositoryForGitActions"):gn.staged===0?a("rightSidebar.commitNeedsStaged"):a("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Ae?.action==="commit"||zo?"opacity-0":"",children:a("rightSidebar.commitChanges")}),Ae?.action==="commit"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),zo&&Ae?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ws,onChange:r=>dl(r.target.value),onKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),Lc())},placeholder:a("rightSidebar.commitMessagePlaceholder"),disabled:!!Ae,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:()=>gr(r=>!r),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":tr,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:a("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Q&&e.jsx(vt,{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 ${tr?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]})]}),tr&&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(Vn,{size:12,className:"shrink-0"}),e.jsx("input",{value:Cn,onChange:r=>Zr(r.target.value),placeholder:a("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),Cn&&e.jsx("button",{type:"button",onClick:()=>Zr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Ut,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:$f,children:[en.length>0?en.map(r=>{const[i,...u]=r.split(/\s+/),x=u.join(" ")||r;return e.jsxs("button",{type:"button",onClick:()=>{Qf(r)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:x,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),rr[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${rr[i]==="ahead"?"bg-accent/10 text-accent":rr[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:a(rr[i]==="ahead"?"rightSidebar.commitAhead":rr[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),ze===i&&e.jsx(vt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},r)}):Q?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:a("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.recentCommitsEmpty")}),Tt&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(vt,{size:12,className:"animate-spin"})}),no&&!Tt&&en.length>0&&e.jsx("button",{type:"button",onClick:()=>{ms({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:a("rightSidebar.recentCommitsLoadMore")})]})]}),nt&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:nt}),el&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:el})]}),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:a("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{sh()},disabled:!Df,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 ${Go?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Ae?.action==="pull"||Go?"opacity-0":"",children:a("rightSidebar.pullChanges")}),Ae?.action==="pull"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),Go&&Ae?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{nh()},disabled:!Ff,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 ${qo?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Ae?.action==="push"||qo?"opacity-0":"",children:a("rightSidebar.pushChanges")}),Ae?.action==="push"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),qo&&Ae?.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] ${lc.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:lc.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 ${ac?"grid-cols-2":"grid-cols-1"}`,children:[ac&&e.jsx(qn,{label:a("rightSidebar.pushRemoteLabel"),value:sn,options:sc,placeholder:a("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:a("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:a("rightSidebar.pushNoRemotes"),disabled:!!Ae,onChange:qs}),e.jsx(qn,{label:a("rightSidebar.pushBranchLabel"),value:an,options:Af,placeholder:a("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:a("rightSidebar.pushBranchSearchPlaceholder"),emptyText:a("rightSidebar.pushNoBranches"),disabled:!!Ae,onChange:Ks})]})]})]})]}):null,lh=o.useCallback(r=>{const i=it(r,b);if(!i)return[];const u=hi(r),x=[];return r.canStage&&x.push({key:"stage-file",label:a("rightSidebar.stageFile"),onClick:()=>{ot({action:"stage-file",cwd:i,paths:[r.path]},a("rightSidebar.stageFile"),u)}}),r.canUnstage&&x.push({key:"unstage-file",label:a("rightSidebar.unstageFile"),onClick:()=>{ot({action:"unstage-file",cwd:i,paths:[r.path]},a("rightSidebar.unstageFile"),u)}}),r.canStash&&x.push({key:"stash-file",label:a("rightSidebar.stashFile"),onClick:()=>{ot({action:"stash-file",cwd:i,paths:[r.path]},a("rightSidebar.stashFile"),u)}}),r.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:a("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Dr({kind:"restore",file:r,phrase:""})}),x},[b,ot,a]),ch=o.useCallback(()=>{if(m){f?.();return}yr(0),kr.current?.slideTo(0),vr(!1),kt(null)},[f,m]),Ic=o.useCallback(r=>{if(j(""),It(r),Ye(null),kt(null),ne(null),ee){m&&f?.(),yr(0),kr.current?.slideTo(0),vr(!1);return}},[ee,f,m,Ye,It]);o.useEffect(()=>{const r=i=>{const u=i.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;j(""),kt(null),Ie(null);const v=!!(b&&(x===b||x.startsWith(`${b}/`)));if(u.kind==="file"){const R=di(x);us(x),typeof u.line=="number"&&Number.isSafeInteger(u.line)&&u.line>0&&Ie(u.line),It(v?null:R),ne(A=>({path:x,nonce:(A?.nonce??0)+1}));return}Ye(null),v?(It(null),ne(R=>({path:x,nonce:(R?.nonce??0)+1}))):(ne(null),It(x)),ee&&(m&&f?.(),yr(0),kr.current?.slideTo(0),vr(!1))};return window.addEventListener(Kc,r),()=>window.removeEventListener(Kc,r)},[us,ee,f,m,b,Ye,It]),o.useEffect(()=>{t||(At(!1),zt(!1))},[t]),o.useEffect(()=>{if(!Jt&&!dr)return;const r=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(Ts.current?.contains(i.target)||wn.current?.contains(i.target))||(At(!1),zt(!1))};return window.addEventListener("mousedown",r),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",r)}},[dr,Jt]);const Dc=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:Rf,disabled:!ca,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.parentFolder"),title:a("rightSidebar.parentFolder"),children:e.jsx(Fd,{size:14})}),e.jsx("button",{type:"button",onClick:ql,disabled:!b||Pn===b,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.backToProjectRoot"),title:a("rightSidebar.backToProjectRoot"),children:e.jsx(Xc,{size:14})}),e.jsx("button",{type:"button",onClick:Cf,disabled:!pe,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.refreshFiles"),title:ul?a("rightSidebar.fileWatchUnavailable",{message:ul}):a("rightSidebar.refreshFiles"),children:e.jsx(vi,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:pe??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:Sf}),ea==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:a("fileTree.sortedByModified"),"aria-label":a("fileTree.sortedByModified"),children:e.jsx(Vc,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>pe&&zr(pe,Et??void 0),disabled:!pe,...pe&&Et?$o(la(pe),Et):{},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 ${Et&&(q===Et||Re===Et)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":a(Et&&Re===Et?"rightSidebar.copied":Et&&q===Et?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:a("rightSidebar.insertCurrentFolder"),children:Et&&(q===Et||Re===Et)?e.jsx(bi,{size:13}):e.jsx(za,{size:13})}),e.jsxs("div",{ref:wn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{At(!1),zt(r=>!r)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${dr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":dr,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(xi,{size:14})}),dr&&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:()=>{zt(!1),Nf()},disabled:!Ao,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${hs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[hs?e.jsx(Xo,{size:14}):e.jsx($a,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(hs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),gf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${bo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[bo?e.jsx(ym,{size:14}):e.jsx(ki,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(bo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!pe,onClick:()=>{pe&&(zt(!1),bf(pe,ea==="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:[ea==="modified"?e.jsx(nm,{size:14}):e.jsx(Vc,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ea==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),b&&(da.length>0||jf)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:ql,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 ${pe===b?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:b,children:[e.jsx(Xc,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:Ke})]}),da.map(r=>{const i=r.path,u=r.kind==="file",x=u?Ve===i:pe===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?us(i):It(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(Si,{size:10,className:"shrink-0"}):e.jsx($a,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ft(i)})]}),e.jsx("button",{type:"button",onClick:()=>ln(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":a("rightSidebar.unpinFolder",{name:ft(i)}),title:a("rightSidebar.unpinFolder",{name:ft(i)}),children:e.jsx(Ut,{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"})]}),Vo=o.useMemo(()=>{if(En===null)return null;const r=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((fo-En)/1e3)),u=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),[x,v]=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(x,v)},[fo,En]),Fc=b&&!ds?e.jsx("button",{type:"button",onClick:()=>{th(!xo)},"aria-pressed":xo,title:a("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${xo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:a("rightSidebar.multiRepoScan")}):null,_c=b?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Vo?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:a("rightSidebar.gitLastUpdated",{time:Vo}),children:Vo}):null,e.jsx("button",{type:"button",onClick:()=>{ls()},disabled:Fr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":a("rightSidebar.refreshGit"),title:a("rightSidebar.refreshGit"),children:e.jsx(vi,{size:13,className:Fr?"animate-spin":""})})]}):null,dh=Pl?a("rightSidebar.changeAuditScopeAll"):fn.length===1?fn[0].relativeRoot==="."?Ke:fn[0].relativeRoot||fn[0].name:`${fn.length} repos`,Bc=b?e.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[e.jsx(Cd,{open:Fs,onOpenChange:Ar,showScopePicker:bn,selectedAll:Pl,repos:xf,selectedRoots:qt,onToggleRepo:Hf,onGenerate:()=>Bf(),disabled:!b,inserted:q===Gl,buttonLabel:a("rightSidebar.changeAuditShort"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:a("rightSidebar.insertChangeAuditPrompt"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:dh,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a("rightSidebar.changeAuditShort"),loading:$r,error:!!Lr,statusTitle:Lr??($r?a("rightSidebar.changeAuditLoading"):jt.length>0?`${a("rightSidebar.changeAuditLoaded",{count:jt.length})}${Pc?` · ${a("rightSidebar.changeAuditLoadedAt",{time:Pc})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{Of()},disabled:$r||jt.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${jt.length>0?"":"invisible"}`,title:a("rightSidebar.clearChangeAuditTitle"),"aria-label":a("rightSidebar.clearChangeAudit"),children:e.jsx(Ba,{size:12})})]}):null,Ra=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:[ae?.available&&ae.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:ae.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ae.branch})]}),st.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[st.modified,"M"]}),st.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",st.added]}),st.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",st.deleted]}),st.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[st.renamed,"R"]}),st.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[st.copied,"C"]}),st.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[st.untracked,"U"]}),st.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[st.conflicted,"!"]}),st.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[st.other,"?"]}),st.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:a("rightSidebar.stagedCountShort",{count:st.staged})}),ae?.available&&b&&we.size>0&&V.length<=1&&e.jsx("button",{type:"button",onClick:()=>{ot({action:"stage-all",cwd:b},a("rightSidebar.stageAll"))},disabled:!!Ae,className:"rounded-md bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),ae?.available&&b&&we.size>0&&V.length<=1&&e.jsx("button",{type:"button",onClick:()=>Dr({kind:"stash-all",repoRoot:b,repoLabel:Ke}),disabled:!!Ae,className:"rounded-md bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]});return e.jsxs(sm,{side:"right",isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c,children:[$o.popoverNode,e.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:b??void 0,children:Ke}),(!ee||co)&&ae?.available&&ae.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:ae.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:ae.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const r=!se;fe(r),r?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):j("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${se?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleSearch"),title:a("common.search"),children:e.jsx(Vn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Qe,onClick:()=>{vn(r=>!r),lr(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Qe?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleContextDraft"),title:a("rightSidebar.contextDraftTitle"),children:[e.jsx(am,{size:14}),!Qe&&wt.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:pl,type:"file",multiple:!0,className:"hidden",onChange:r=>{const i=r.target.files;!i||i.length===0||(fs(Array.from(i)),r.target.value="")}}),e.jsx("input",{ref:gl,type:"file",accept:"image/*",className:"hidden",onChange:r=>{const i=r.target.files?.[0];r.target.value="",i&&kf(i)}}),h&&e.jsx("button",{type:"button",onClick:h,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${c?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:c?e.jsx(Xo,{size:14}):e.jsx($a,{size:14})}),e.jsxs("div",{ref:Ts,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),At(r=>!r)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Jt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Jt,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(xi,{size:15})}),Jt&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),pl.current?.click()},disabled:Vs,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:[Vs?e.jsx(vt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(_m,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),gl.current?.click()},disabled:Vs,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:[Vs?e.jsx(vt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Rm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.insertLocalImage")})]}),h&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),h()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${c?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[c?e.jsx(Xo,{size:14}):e.jsx($a,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),c&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":a("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:a("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",a("rightSidebar.layoutModeAuto")],["narrow",a("rightSidebar.layoutModeNarrow")],["wide",a("rightSidebar.layoutModeWide")]].map(([r,i])=>{const u=G===r;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(r),At(!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},r)})})]})]})]}),e.jsx("button",{type:"button",onClick:s,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":a("rightSidebar.close"),children:e.jsx(Ut,{size:14})})]}),se&&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(Vn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:O,onChange:r=>j(r.target.value),placeholder:a(M==="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 ${ee?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Nc("name"),"aria-pressed":M==="name",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${M==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Nc("content"),"aria-pressed":M==="content",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${M==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeContent")})]}),O&&e.jsx("button",{type:"button",onClick:()=>j(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Ut,{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(om,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:K,onChange:r=>re(r.target.value),onKeyDown:r=>{r.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchScopePlaceholder"),"aria-label":a("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),K!=="."&&e.jsx("button",{type:"button",onClick:()=>re("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.resetSearchScope"),children:e.jsx(Ut,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>je(r=>!r),"aria-expanded":me,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${me||os.length>0||C||ue||Ge?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:a("rightSidebar.searchOptions"),"aria-label":a("rightSidebar.searchOptions"),children:[e.jsx(im,{size:13}),os.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:os.length})]})]}),me&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:oe,onChange:r=>he(r.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchExcludePlaceholder"),"aria-label":a("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),oe&&e.jsx("button",{type:"button",onClick:()=>he(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":a("rightSidebar.clearSearchExclude"),children:e.jsx(Ut,{size:11})})]}),M==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":a("rightSidebar.contentSearchOptions"),children:[[C,()=>Z(r=>!r),xm,a("rightSidebar.matchCase")],[ue,()=>Ee(r=>!r),Om,a("rightSidebar.matchWholeWord")],[Ge,()=>Fe(r=>!r),Lm,a("rightSidebar.useRegex")]].map(([r,i,u,x])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":r,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${r?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),x]},x))})]})]}),ds?null:e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>on("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Rr,{size:12}),a("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:()=>on("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Yd,{size:12}),a("rightSidebar.tabChanges"),we.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:we.size}):null]}),e.jsxs("button",{type:"button",onClick:()=>on("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(fm,{size:12}),a("rightSidebar.tabFiles")]})]}),e.jsx("div",{className:"h-2"}),ll&&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:ll})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(li,{active:Xe,mounted:sr,fallback:e.jsx(ci,{slow:!1}),children:Ue?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(ed,{items:Wf,selectedKey:lf,onSelect:_s,emptyText:a("rightSidebar.noChanges"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a("rightSidebar.recentCommitsTitle"),headerMeta:`${Ue.headRef??""}${Ue.commits?.[0]?` · ${Ue.commits[0]}`:""}`,onClose:()=>{$e(null),_s(null)},closeLabel:a("common.back"),wrap:$t,onToggleWrap:ee?wa:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba})}):pr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(ed,{items:Bo,selectedKey:io,onSelect:rn,emptyText:a(Me?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a(Me?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:xa?`${xa.repoLabel} · ${xa.branchName??"HEAD"} → ${xa.baseRef}`:void 0,onClose:()=>{Zt(!1),er(null)},closeLabel:a("common.back"),wrap:$t,onToggleWrap:ee?wa:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,walkthroughs:Gf,onWalkthroughNavigate:qf,initialDetailScrollTop:Me&&Ze?jn[Ze]:void 0,onDetailScrollPositionChange:Zf,externalSwiperRef:ee?sa:void 0,onMobileSlideChange:ee?lo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:Tc?e.jsx("div",{className:"px-3",children:Tc}):Fr?e.jsx(ci,{slow:jl}):cn?e.jsx(Fa,{message:cn,onRetry:()=>{ls()}}):Ad(ae)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):ae?.available===!1?e.jsx(Fa,{message:ae.error??a("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ls()}}):b?e.jsx(ci,{slow:jl}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(li,{active:On,children:ee?e.jsxs(Bd,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:r=>{kr.current=r,r.slideTo(ol,0)},onSlideChange:r=>{if(yr(r.activeIndex),is.current===r.activeIndex){is.current=null;return}r.activeIndex===0&&(vr(!1),kt(null),f?.())},children:[e.jsx(yi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Dn,onScroll:Il,onDragOver:oa,onDragEnter:oa,onDragLeave:_l,onDrop:Bl,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[fl&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:a("rightSidebar.dropToUpload")})}),!O.trim()&&Dc,e.jsx(Yc,{rootPath:pe??"",onFileSelect:us,onPathReference:zr,getReferenceText:la,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onDirectoryRoot:Kl,onSearchFromDirectory:Vl,onDirectoryPinToggle:Yl,onFilePinToggle:Xl,pinnedPaths:mn,selectedFilePath:Ve,query:le,searchRootPath:Ml,searchOptions:$l,searchMode:M,onContentMatchSelect:Dl,onDirectoryDropFiles:(r,i)=>fs(i,r),revealDirectory:X,canOpenInFileBrowser:hl,onOpenInFileBrowser:Fl})]})}),e.jsx(yi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Oi,{filePath:On&&(cf||ol===1)?Ve:null,onInsertReference:zr,onInsertText:jr,onInsertFeature:jr,onReviewReference:zl,onReferenceCopied:Sr,onClose:ch,onDirectoryLinkOpen:Ic,isMobile:!0,lineRange:Kr,onLineRangeChange:kt,insertedReferenceKey:q,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Dn,onScroll:Il,onDragOver:oa,onDragEnter:oa,onDragLeave:_l,onDrop:Bl,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:mo},children:[fl&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:a("rightSidebar.dropToUpload")})}),!O.trim()&&Dc,e.jsx(Yc,{rootPath:pe??"",onFileSelect:us,onPathReference:zr,getReferenceText:la,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onDirectoryRoot:Kl,onSearchFromDirectory:Vl,onDirectoryPinToggle:Yl,onFilePinToggle:Xl,pinnedPaths:mn,selectedFilePath:Ve,query:le,searchRootPath:Ml,searchOptions:$l,searchMode:M,onContentMatchSelect:Dl,onDirectoryDropFiles:(r,i)=>fs(i,r),revealDirectory:X,canOpenInFileBrowser:hl,onOpenInFileBrowser:Fl})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("rightSidebar.resizeFileTree"),title:a("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:vf,onPointerMove:yf,onPointerUp:Tl,onPointerCancel:Tl,onDoubleClick:()=>{po(Mi),xt(ws,Mi)},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(Oi,{filePath:On?Ve:null,onInsertReference:zr,onInsertText:jr,onInsertFeature:jr,onReviewReference:zl,onReferenceCopied:Sr,onDirectoryLinkOpen:Ic,isMobile:!1,lineRange:Kr,onLineRangeChange:kt,insertedReferenceKey:q,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:D})})]})}),e.jsx(li,{active:pt,mounted:df||pt,children:()=>Co?e.jsx(lm,{}):ee?e.jsx(wi,{mobile:!0,backLabel:a("rightSidebar.backToChangeList"),externalSwiperRef:sa,onMobileSlideChange:lo,groups:Ot.length>0?pc():[],mode:St,onModeChange:ya,selectedKey:Ve,scrollToKey:vc,scrollToKeyNonce:Xs.nonce,compact:!1,collapsedDirectoryKeys:ur,onToggleDirectory:kc,onSelectFile:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);i&&va(ut(i))},renderLeading:bc,renderTrailing:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?hc(i):null},renderDirectoryTrailing:mc,renderSubtitle:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?uc(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:r=>b&&e.jsxs("div",{className:"px-0 py-0",children:[Ra&&e.jsx("div",{className:"mb-2",children:Ra}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Ot.length,"/",we.size]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[cc(),Fc,r,c&&Fo(),Bc,_c]}),Ct&&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:Ct.label}),Ct.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:Ct.branch})]}),!Ct&&bn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:fa?(r=>wc(r)):void 0,emptyContent:Co?null:cn&&we.size===0?e.jsx(Fa,{message:cn,onRetry:()=>{ls()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ot.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>cs(0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:a("rightSidebar.backToChangeList"),children:[e.jsx(Ns,{size:14}),a("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[c&&Fo(),e.jsxs("button",{type:"button",onClick:wa,"aria-pressed":$t,title:a("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${$t?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:a($t?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:gc(),activePane:pt,wrap:$t,diffViewType:pf,inlineMode:Jn,diffOptions:Cc,reloadKey:fr,renderStreamBadge:r=>e.jsx(js,{status:r}),onHunkGitAction:Mc,onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,onDetailScroll:pa}):e.jsx(wi,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:a("rightSidebar.backToChangeList"),groups:Ot.length>0?pc():[],mode:St,onModeChange:ya,selectedKey:Ve,scrollToKey:vc,scrollToKeyNonce:Xs.nonce,compact:!0,collapsedDirectoryKeys:ur,onToggleDirectory:kc,onSelectFile:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);i&&va(ut(i))},renderLeading:bc,renderTrailing:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?hc(i):null},renderDirectoryTrailing:mc,renderSubtitle:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?uc(i):null},aiContent:fa?(r=>wc(r)):void 0,emptyContent:Co?null:cn&&we.size===0?e.jsx(Fa,{message:cn,onRetry:()=>{ls()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ot.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderListHeader:r=>b&&e.jsxs("div",{className:"px-0 py-0",children:[Ra&&e.jsx("div",{className:"mb-2",children:Ra}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Ot.length,"/",we.size]})})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[cc(),Fc,r,Fo(),e.jsxs("button",{type:"button",onClick:wa,"aria-pressed":$t,title:a("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 ${$t?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:a($t?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Bc,_c]}),Ct&&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:Ct.label}),Ct.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:Ct.branch}),e.jsx("button",{type:"button",onClick:()=>Sa("stage-all",Ct.root,Ct.label),disabled:!!Ae,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>Sa("stash-all",Ct.root,Ct.label),disabled:!!Ae,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}),!Ct&&bn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),files:gc(),activePane:pt,wrap:$t,diffViewType:Qt,inlineMode:Jn,diffOptions:Cc,reloadKey:fr,renderStreamBadge:r=>e.jsx(js,{status:r}),onHunkGitAction:Mc,onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,onDetailScroll:pa})})]}),t&&Qe&&e.jsx(fp,{value:wt,collapsed:ht,autoCollapseAfterSend:Xt,focusRequest:qr,insertError:Xn?a("rightSidebar.contextDraftInsertFailed"):null,onChange:r=>{Wt(!1),Ht(r)},onCollapsedChange:lr,onAutoCollapseAfterSendChange:yn,onDisable:()=>vn(!1),onClear:()=>Ht(""),onInsert:()=>Wl(!1),onInsertAndSend:()=>Wl(!0),labels:{title:a("rightSidebar.contextDraftTitle"),hint:a("rightSidebar.contextDraftHint"),placeholder:a("rightSidebar.contextDraftPlaceholder"),collapse:a("rightSidebar.contextDraftCollapse"),expand:a("rightSidebar.contextDraftExpand"),disable:a("rightSidebar.contextDraftDisable"),clear:a("rightSidebar.contextDraftClear"),insert:a("rightSidebar.contextDraftInsert"),insertAndSend:a("rightSidebar.contextDraftInsertAndSend"),inserted:a("rightSidebar.contextDraftInserted"),sent:a("rightSidebar.contextDraftSent"),send:a("rightSidebar.contextDraftSend"),appended:a("rightSidebar.contextDraftAppended"),resize:a("rightSidebar.contextDraftResize"),autoCollapseAfterSend:a("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:r=>a("rightSidebar.contextDraftCharacterCount",{count:r})}}),If(),ct&&typeof document<"u"&&Gr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Dr(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:r=>r.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:ct.kind==="restore"?a("rightSidebar.confirmRestoreTitle"):a("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:ct.kind==="restore"?a("rightSidebar.confirmRestoreDescription",{path:Dd(ct.file.absolutePath,b)}):a("rightSidebar.confirmStashAllDescription")}),ct.kind==="restore"&&e.jsx("input",{value:ct.phrase,onChange:r=>Dr({...ct,phrase:r.target.value}),placeholder:a("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Dr(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:a("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Ae||ct.kind==="restore"&&ct.phrase.trim()!==a("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(ct.kind==="restore"){const r=it(ct.file,b);if(!r)return;ot({action:"restore-worktree-file",cwd:r,paths:[ct.file.path],confirm:{acknowledged:!0,phrase:ct.phrase}},a("rightSidebar.restoreFile"),hi(ct.file))}else{const r=ct.repoRoot??b;if(!r)return;ot({action:"stash-all",cwd:r},a("rightSidebar.stashAll"),`repo:${r}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${ct.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:a(Ae?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const Fb=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Oi,MarkdownImageLightbox:Vu,MarkdownPreview:Yu,RightSidebar:Rb,__testParseMarkdownListBlock:Hg,buildMarkdownPreviewBlocks:Zg,buildMarkdownPreviewRenderResult:Ji,collectKnownGitRepoRoots:vu,computeMarkdownImageDisplayBox:Lu,getMarkdownHeadingOutline:Ku,getMarkdownHeadingPathAtLine:qu,getNextMarkdownPreviewLineRange:ab,isSvgImageSrc:Za,mountRightSidebarRepoPickerOverlay:su,replaceGitRepositorySnapshot:tf,resolveMarkdownLocalLinkTarget:Gi,resolveRightSidebarDiffViewType:gu,shouldCloseMarkdownImageLightboxDrag:zu,showsGitRepoGroupHeader:$i},Symbol.toStringTag,{value:"Module"}));export{ki as E,Xc as H,Nm as M,Fb as R,ym as a,$m as b,zm as c,Db as m};