termdock 1.4.355 → 1.4.357

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 (495) hide show
  1. package/README.md +22 -4
  2. package/dist/client/assets/AndroidMirrorView-BGagwKtL.js +3 -0
  3. package/dist/client/assets/AndroidMirrorView-BGagwKtL.js.br +0 -0
  4. package/dist/client/assets/AndroidMirrorView-BGagwKtL.js.gz +0 -0
  5. package/dist/client/assets/App-DpMhxwYW.js +178 -0
  6. package/dist/client/assets/App-DpMhxwYW.js.br +0 -0
  7. package/dist/client/assets/App-DpMhxwYW.js.gz +0 -0
  8. package/dist/client/assets/ArchitecturePanel-Bd_l74EC.js +9 -0
  9. package/dist/client/assets/ArchitecturePanel-Bd_l74EC.js.br +0 -0
  10. package/dist/client/assets/ArchitecturePanel-Bd_l74EC.js.gz +0 -0
  11. package/dist/client/assets/{ChangeWalkthroughPanel-mAiaX5i8.js → ChangeWalkthroughPanel-6DN-2BdR.js} +2 -2
  12. package/dist/client/assets/ChangeWalkthroughPanel-6DN-2BdR.js.br +0 -0
  13. package/dist/client/assets/ChangeWalkthroughPanel-6DN-2BdR.js.gz +0 -0
  14. package/dist/client/assets/{ChatRichContent-D2NtgMuL.js → ChatRichContent-DjwpmW7d.js} +55 -55
  15. package/dist/client/assets/ChatRichContent-DjwpmW7d.js.br +0 -0
  16. package/dist/client/assets/ChatRichContent-DjwpmW7d.js.gz +0 -0
  17. package/dist/client/assets/CollaborationMainWorkspace-DPTJ9pCt.js +1 -0
  18. package/dist/client/assets/CollaborationMainWorkspace-DPTJ9pCt.js.br +0 -0
  19. package/dist/client/assets/CollaborationMainWorkspace-DPTJ9pCt.js.gz +0 -0
  20. package/dist/client/assets/CollaborationTaskContent-Cbu1Bjl0.js +1 -0
  21. package/dist/client/assets/ComputerControlView-CwB-wQqB.js +6 -0
  22. package/dist/client/assets/ComputerControlView-CwB-wQqB.js.br +0 -0
  23. package/dist/client/assets/ComputerControlView-CwB-wQqB.js.gz +0 -0
  24. package/dist/client/assets/{DagPlayground-CbEuQA68.js → DagPlayground-DMn9Gyrw.js} +1 -1
  25. package/dist/client/assets/DagPlayground-DMn9Gyrw.js.br +0 -0
  26. package/dist/client/assets/DagPlayground-DMn9Gyrw.js.gz +0 -0
  27. package/dist/client/assets/{DiffLab-PysBkJrJ.js → DiffLab-YBWlCU2T.js} +1 -1
  28. package/dist/client/assets/DiffLab-YBWlCU2T.js.br +0 -0
  29. package/dist/client/assets/DiffLab-YBWlCU2T.js.gz +0 -0
  30. package/dist/client/assets/DiffReview-YOPDWqhv.js +1 -0
  31. package/dist/client/assets/DiffReview-YOPDWqhv.js.br +0 -0
  32. package/dist/client/assets/DiffReview-YOPDWqhv.js.gz +0 -0
  33. package/dist/client/assets/{DiffReviewLab-D6PxvtBY.js → DiffReviewLab-SYomq14c.js} +1 -1
  34. package/dist/client/assets/DiffReviewLab-SYomq14c.js.br +0 -0
  35. package/dist/client/assets/DiffReviewLab-SYomq14c.js.gz +0 -0
  36. package/dist/client/assets/{DiffViewer-Bp-BLT2f.js → DiffViewer-mh9cBl5v.js} +1 -1
  37. package/dist/client/assets/DiffViewer-mh9cBl5v.js.br +0 -0
  38. package/dist/client/assets/DiffViewer-mh9cBl5v.js.gz +0 -0
  39. package/dist/client/assets/{GitLoadingSkeleton-Fa4AXG-N.js → GitLoadingSkeleton-DKRTc5sz.js} +1 -1
  40. package/dist/client/assets/GitLoadingSkeleton-DKRTc5sz.js.br +0 -0
  41. package/dist/client/assets/GitLoadingSkeleton-DKRTc5sz.js.gz +0 -0
  42. package/dist/client/assets/Markdown-C8OP1j-g.js +23 -0
  43. package/dist/client/assets/Markdown-C8OP1j-g.js.br +0 -0
  44. package/dist/client/assets/Markdown-C8OP1j-g.js.gz +0 -0
  45. package/dist/client/assets/Markdown-DKQhs57e.css +1 -0
  46. package/dist/client/assets/Markdown-DKQhs57e.css.br +0 -0
  47. package/dist/client/assets/Markdown-DKQhs57e.css.gz +0 -0
  48. package/dist/client/assets/{ModelPreview-Cl0X7I-U.js → ModelPreview-CsZry3Wd.js} +3 -3
  49. package/dist/client/assets/ModelPreview-CsZry3Wd.js.br +0 -0
  50. package/dist/client/assets/ModelPreview-CsZry3Wd.js.gz +0 -0
  51. package/dist/client/assets/RecordingSaveDialog-CoRGi97z.js +1 -0
  52. package/dist/client/assets/RecordingSaveDialog-CoRGi97z.js.br +0 -0
  53. package/dist/client/assets/RecordingSaveDialog-CoRGi97z.js.gz +0 -0
  54. package/dist/client/assets/RightSidebar-DNY2kC6B.js +1662 -0
  55. package/dist/client/assets/RightSidebar-DNY2kC6B.js.br +0 -0
  56. package/dist/client/assets/RightSidebar-DNY2kC6B.js.gz +0 -0
  57. package/dist/client/assets/SessionChatView-DXNpYUrk.js +13 -0
  58. package/dist/client/assets/SessionChatView-DXNpYUrk.js.br +0 -0
  59. package/dist/client/assets/SessionChatView-DXNpYUrk.js.gz +0 -0
  60. package/dist/client/assets/SessionResourceSidebar-B_379HBJ.js +2 -0
  61. package/dist/client/assets/SessionResourceSidebar-B_379HBJ.js.br +0 -0
  62. package/dist/client/assets/SessionResourceSidebar-B_379HBJ.js.gz +0 -0
  63. package/dist/client/assets/TodoWorkspace-DfwGOAHB.js +1 -0
  64. package/dist/client/assets/TodoWorkspace-DfwGOAHB.js.br +0 -0
  65. package/dist/client/assets/TodoWorkspace-DfwGOAHB.js.gz +0 -0
  66. package/dist/client/assets/{abnfDiagram-VCTEODGH-BajyXVpH.js → abnfDiagram-VCTEODGH-C9M0gnl-.js} +1 -1
  67. package/dist/client/assets/abnfDiagram-VCTEODGH-C9M0gnl-.js.br +0 -0
  68. package/dist/client/assets/abnfDiagram-VCTEODGH-C9M0gnl-.js.gz +0 -0
  69. package/dist/client/assets/app-CovJYQoW.js +37 -0
  70. package/dist/client/assets/app-CovJYQoW.js.br +0 -0
  71. package/dist/client/assets/app-CovJYQoW.js.gz +0 -0
  72. package/dist/client/assets/{arc-CbhM5I2d.js → arc-q4wfkQcT.js} +1 -1
  73. package/dist/client/assets/arc-q4wfkQcT.js.br +0 -0
  74. package/dist/client/assets/arc-q4wfkQcT.js.gz +0 -0
  75. package/dist/client/assets/{architectureDiagram-5GKGNRK7-CDKLcS6D.js → architectureDiagram-5GKGNRK7-CCuna3ab.js} +1 -1
  76. package/dist/client/assets/architectureDiagram-5GKGNRK7-CCuna3ab.js.br +0 -0
  77. package/dist/client/assets/architectureDiagram-5GKGNRK7-CCuna3ab.js.gz +0 -0
  78. package/dist/client/assets/{arrow-down-Dp27yS0N.js → arrow-down-WyzmLXwQ.js} +1 -1
  79. package/dist/client/assets/{blockDiagram-I7D4REHJ-CXiIO6_W.js → blockDiagram-I7D4REHJ-BXK68Qyt.js} +1 -1
  80. package/dist/client/assets/blockDiagram-I7D4REHJ-BXK68Qyt.js.br +0 -0
  81. package/dist/client/assets/blockDiagram-I7D4REHJ-BXK68Qyt.js.gz +0 -0
  82. package/dist/client/assets/{c4Diagram-7LVT6UL2-uZ-i2eKH.js → c4Diagram-7LVT6UL2-BqwmmVmS.js} +1 -1
  83. package/dist/client/assets/{c4Diagram-7LVT6UL2-uZ-i2eKH.js.br → c4Diagram-7LVT6UL2-BqwmmVmS.js.br} +0 -0
  84. package/dist/client/assets/c4Diagram-7LVT6UL2-BqwmmVmS.js.gz +0 -0
  85. package/dist/client/assets/channel-Dd6WQGB7.js +1 -0
  86. package/dist/client/assets/{chevron-left-D8ntyw2S.js → chevron-left-CxeWIsDK.js} +1 -1
  87. package/dist/client/assets/{chunk-2Q5K7J3B-DVe3dVJR.js → chunk-2Q5K7J3B-esKGR38U.js} +1 -1
  88. package/dist/client/assets/{chunk-5VM5RSS4-BDBNKGuU.js → chunk-5VM5RSS4-B3InxqDA.js} +1 -1
  89. package/dist/client/assets/{chunk-F27PBJKO-BP7hTwtm.js → chunk-F27PBJKO-CjUVyF-E.js} +1 -1
  90. package/dist/client/assets/chunk-F27PBJKO-CjUVyF-E.js.br +0 -0
  91. package/dist/client/assets/chunk-F27PBJKO-CjUVyF-E.js.gz +0 -0
  92. package/dist/client/assets/{chunk-IMKFNOWR-LIGuOtnb.js → chunk-IMKFNOWR-BR8mmBs7.js} +1 -1
  93. package/dist/client/assets/chunk-IMKFNOWR-BR8mmBs7.js.br +0 -0
  94. package/dist/client/assets/chunk-IMKFNOWR-BR8mmBs7.js.gz +0 -0
  95. package/dist/client/assets/{chunk-JWPE2WC7-C1_iFEvk.js → chunk-JWPE2WC7-CplXNOA7.js} +1 -1
  96. package/dist/client/assets/{chunk-POPQ4Y6H-CYZsO-QL.js → chunk-POPQ4Y6H-D0JWCGnb.js} +1 -1
  97. package/dist/client/assets/{chunk-SVP7TREG-FnWYLNCS.js → chunk-SVP7TREG-BdJtJSmy.js} +1 -1
  98. package/dist/client/assets/chunk-SVP7TREG-BdJtJSmy.js.br +0 -0
  99. package/dist/client/assets/chunk-SVP7TREG-BdJtJSmy.js.gz +0 -0
  100. package/dist/client/assets/{chunk-TICWLB2K-dcOCcmQq.js → chunk-TICWLB2K-CoevFj8I.js} +1 -1
  101. package/dist/client/assets/chunk-TICWLB2K-CoevFj8I.js.br +0 -0
  102. package/dist/client/assets/chunk-TICWLB2K-CoevFj8I.js.gz +0 -0
  103. package/dist/client/assets/{chunk-XXDRQBXY-B2H2Yt9G.js → chunk-XXDRQBXY-D7qYRhMH.js} +1 -1
  104. package/dist/client/assets/{circle-Pldg1yI9.js → circle-xgKDXpwG.js} +1 -1
  105. package/dist/client/assets/classDiagram-ZZMXUADV-BdIUq_D7.js +1 -0
  106. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BdIUq_D7.js +1 -0
  107. package/dist/client/assets/{clipboard-tTkMEO1S.js → clipboard-DeK6pJD3.js} +1 -1
  108. package/dist/client/assets/clipboardText-BWOwer6N.js +1 -0
  109. package/dist/client/assets/clipboardText-BWOwer6N.js.br +0 -0
  110. package/dist/client/assets/clipboardText-BWOwer6N.js.gz +0 -0
  111. package/dist/client/assets/clipboardText-vX90C7eX.css +1 -0
  112. package/dist/client/assets/clipboardText-vX90C7eX.css.br +0 -0
  113. package/dist/client/assets/clipboardText-vX90C7eX.css.gz +0 -0
  114. package/dist/client/assets/{cose-bilkent-JH36ORCC-Bz38mqD8.js → cose-bilkent-JH36ORCC-CvnsiaWP.js} +1 -1
  115. package/dist/client/assets/cose-bilkent-JH36ORCC-CvnsiaWP.js.br +0 -0
  116. package/dist/client/assets/cose-bilkent-JH36ORCC-CvnsiaWP.js.gz +0 -0
  117. package/dist/client/assets/{cynefin-OW5HDTMX-CZAa1A6y.js → cynefin-OW5HDTMX-BSGz8Olu.js} +1 -1
  118. package/dist/client/assets/cynefin-OW5HDTMX-BSGz8Olu.js.br +0 -0
  119. package/dist/client/assets/cynefin-OW5HDTMX-BSGz8Olu.js.gz +0 -0
  120. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-BaQnW4VG.js → cynefinDiagram-5FMLGOSQ-DYYT0AHs.js} +1 -1
  121. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DYYT0AHs.js.br +0 -0
  122. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DYYT0AHs.js.gz +0 -0
  123. package/dist/client/assets/{dagre-GXQ25YYZ-BdnT61bc.js → dagre-GXQ25YYZ-BM883MN7.js} +1 -1
  124. package/dist/client/assets/dagre-GXQ25YYZ-BM883MN7.js.br +0 -0
  125. package/dist/client/assets/dagre-GXQ25YYZ-BM883MN7.js.gz +0 -0
  126. package/dist/client/assets/{diagram-S7CK7UJ4-BWiF8QNc.js → diagram-S7CK7UJ4-CYnxXy7R.js} +1 -1
  127. package/dist/client/assets/diagram-S7CK7UJ4-CYnxXy7R.js.br +0 -0
  128. package/dist/client/assets/diagram-S7CK7UJ4-CYnxXy7R.js.gz +0 -0
  129. package/dist/client/assets/{diagram-UQ7AKVKN-DLURjCFp.js → diagram-UQ7AKVKN-UOIBVxRf.js} +1 -1
  130. package/dist/client/assets/diagram-UQ7AKVKN-UOIBVxRf.js.br +0 -0
  131. package/dist/client/assets/diagram-UQ7AKVKN-UOIBVxRf.js.gz +0 -0
  132. package/dist/client/assets/{diagram-VSXAHHWV-DYIcLklz.js → diagram-VSXAHHWV-CqTJzfmm.js} +1 -1
  133. package/dist/client/assets/diagram-VSXAHHWV-CqTJzfmm.js.br +0 -0
  134. package/dist/client/assets/diagram-VSXAHHWV-CqTJzfmm.js.gz +0 -0
  135. package/dist/client/assets/{diagram-VX7I27RA-C9vqviXX.js → diagram-VX7I27RA-T9Y88CFB.js} +1 -1
  136. package/dist/client/assets/diagram-VX7I27RA-T9Y88CFB.js.br +0 -0
  137. package/dist/client/assets/diagram-VX7I27RA-T9Y88CFB.js.gz +0 -0
  138. package/dist/client/assets/{diagram-Z3DM3KII-BJuQxTkw.js → diagram-Z3DM3KII-kIQDy7E0.js} +1 -1
  139. package/dist/client/assets/diagram-Z3DM3KII-kIQDy7E0.js.br +0 -0
  140. package/dist/client/assets/diagram-Z3DM3KII-kIQDy7E0.js.gz +0 -0
  141. package/dist/client/assets/{ebnfDiagram-PWID7BFC-BcbISm-z.js → ebnfDiagram-PWID7BFC-z_VqR_JE.js} +1 -1
  142. package/dist/client/assets/ebnfDiagram-PWID7BFC-z_VqR_JE.js.br +0 -0
  143. package/dist/client/assets/ebnfDiagram-PWID7BFC-z_VqR_JE.js.gz +0 -0
  144. package/dist/client/assets/{erDiagram-RLTQ6QDP-fhNpRzUG.js → erDiagram-RLTQ6QDP-0q52Z-pm.js} +1 -1
  145. package/dist/client/assets/erDiagram-RLTQ6QDP-0q52Z-pm.js.br +0 -0
  146. package/dist/client/assets/erDiagram-RLTQ6QDP-0q52Z-pm.js.gz +0 -0
  147. package/dist/client/assets/{external-link-DE8Gj-da.js → external-link-CsydVmO1.js} +1 -1
  148. package/dist/client/assets/{flowDiagram-HODETNUW-CVDJ_1Zu.js → flowDiagram-HODETNUW-BrGqcUWn.js} +1 -1
  149. package/dist/client/assets/flowDiagram-HODETNUW-BrGqcUWn.js.br +0 -0
  150. package/dist/client/assets/flowDiagram-HODETNUW-BrGqcUWn.js.gz +0 -0
  151. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-Dzn-mrfe.js → ganttDiagram-EL5Y4UJY-CHAN6vQv.js} +1 -1
  152. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHAN6vQv.js.br +0 -0
  153. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHAN6vQv.js.gz +0 -0
  154. package/dist/client/assets/{git-compare-Ct2eJNs4.js → git-compare-BmKAtQTt.js} +1 -1
  155. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-Ci-wfvCz.js → gitGraphDiagram-WWUBYQGX-C0ZV4FeB.js} +1 -1
  156. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C0ZV4FeB.js.br +0 -0
  157. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C0ZV4FeB.js.gz +0 -0
  158. package/dist/client/assets/index-DEAMSl55.css +1 -0
  159. package/dist/client/assets/index-DEAMSl55.css.br +0 -0
  160. package/dist/client/assets/index-DEAMSl55.css.gz +0 -0
  161. package/dist/client/assets/{infoDiagram-27XIBGKW-npBmeTt7.js → infoDiagram-27XIBGKW-CrLj9y1o.js} +1 -1
  162. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-CCn5Ha25.js → ishikawaDiagram-5VMMS53U-BxGvUfLX.js} +1 -1
  163. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxGvUfLX.js.br +0 -0
  164. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxGvUfLX.js.gz +0 -0
  165. package/dist/client/assets/{journeyDiagram-3NMN7TZE-CPl5oPfe.js → journeyDiagram-3NMN7TZE-rW9xlQ8G.js} +1 -1
  166. package/dist/client/assets/journeyDiagram-3NMN7TZE-rW9xlQ8G.js.br +0 -0
  167. package/dist/client/assets/journeyDiagram-3NMN7TZE-rW9xlQ8G.js.gz +0 -0
  168. package/dist/client/assets/{kanban-definition-UXKFOSKX-Dmia2kLZ.js → kanban-definition-UXKFOSKX-CFI5iv9R.js} +1 -1
  169. package/dist/client/assets/kanban-definition-UXKFOSKX-CFI5iv9R.js.br +0 -0
  170. package/dist/client/assets/kanban-definition-UXKFOSKX-CFI5iv9R.js.gz +0 -0
  171. package/dist/client/assets/{layout-B2Kz5M73.js → layout-Ct_an5XT.js} +1 -1
  172. package/dist/client/assets/layout-Ct_an5XT.js.br +0 -0
  173. package/dist/client/assets/layout-Ct_an5XT.js.gz +0 -0
  174. package/dist/client/assets/{linear-D2CT7wE3.js → linear-DpEFOA9l.js} +1 -1
  175. package/dist/client/assets/linear-DpEFOA9l.js.br +0 -0
  176. package/dist/client/assets/linear-DpEFOA9l.js.gz +0 -0
  177. package/dist/client/assets/{link-x33s12VI.js → link-34ChBc4F.js} +3 -3
  178. package/dist/client/assets/link-34ChBc4F.js.br +0 -0
  179. package/dist/client/assets/link-34ChBc4F.js.gz +0 -0
  180. package/dist/client/assets/{list-tree-XBmm9il2.js → list-tree-48dzbuUh.js} +1 -1
  181. package/dist/client/assets/{maximize-2-t-zzENew.js → maximize-2-CbvSsu7O.js} +1 -1
  182. package/dist/client/assets/{mermaid.core-G9XIcppl.js → mermaid.core-DnVKnMmy.js} +5 -5
  183. package/dist/client/assets/mermaid.core-DnVKnMmy.js.br +0 -0
  184. package/dist/client/assets/mermaid.core-DnVKnMmy.js.gz +0 -0
  185. package/dist/client/assets/{mindmap-definition-YA3MSWOX-D2OX9OkO.js → mindmap-definition-YA3MSWOX-C6shupTY.js} +1 -1
  186. package/dist/client/assets/mindmap-definition-YA3MSWOX-C6shupTY.js.br +0 -0
  187. package/dist/client/assets/mindmap-definition-YA3MSWOX-C6shupTY.js.gz +0 -0
  188. package/dist/client/assets/{passwordBootstrap-DkTynZfV.js → passwordBootstrap-Doe50DSa.js} +1 -1
  189. package/dist/client/assets/passwordBootstrap-Doe50DSa.js.br +0 -0
  190. package/dist/client/assets/passwordBootstrap-Doe50DSa.js.gz +0 -0
  191. package/dist/client/assets/{pegDiagram-XKGWAZYB-qNjd6dbd.js → pegDiagram-XKGWAZYB-CDcnrvKX.js} +1 -1
  192. package/dist/client/assets/pegDiagram-XKGWAZYB-CDcnrvKX.js.br +0 -0
  193. package/dist/client/assets/pegDiagram-XKGWAZYB-CDcnrvKX.js.gz +0 -0
  194. package/dist/client/assets/{pieDiagram-E7YTZNPT-DcCmKDFh.js → pieDiagram-E7YTZNPT-CrGc03Tg.js} +1 -1
  195. package/dist/client/assets/pieDiagram-E7YTZNPT-CrGc03Tg.js.br +0 -0
  196. package/dist/client/assets/pieDiagram-E7YTZNPT-CrGc03Tg.js.gz +0 -0
  197. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BpDzkl9h.js → quadrantDiagram-AXDQQJYC-3-aldwKj.js} +1 -1
  198. package/dist/client/assets/quadrantDiagram-AXDQQJYC-3-aldwKj.js.br +0 -0
  199. package/dist/client/assets/quadrantDiagram-AXDQQJYC-3-aldwKj.js.gz +0 -0
  200. package/dist/client/assets/{quote-DeByS04O.js → quote-B5GeKEq1.js} +1 -1
  201. package/dist/client/assets/{railroadDiagram-O6MQD6OU-DkwV8w7x.js → railroadDiagram-O6MQD6OU-51uKwR2_.js} +1 -1
  202. package/dist/client/assets/railroadDiagram-O6MQD6OU-51uKwR2_.js.br +0 -0
  203. package/dist/client/assets/railroadDiagram-O6MQD6OU-51uKwR2_.js.gz +0 -0
  204. package/dist/client/assets/rdpSession-ocpkj4XY.js +1 -0
  205. package/dist/client/assets/rdpSession-ocpkj4XY.js.br +0 -0
  206. package/dist/client/assets/rdpSession-ocpkj4XY.js.gz +0 -0
  207. package/dist/client/assets/referenceSelection-fvfRDbgp.js +4 -0
  208. package/dist/client/assets/referenceSelection-fvfRDbgp.js.br +0 -0
  209. package/dist/client/assets/referenceSelection-fvfRDbgp.js.gz +0 -0
  210. package/dist/client/assets/{requirementDiagram-BXWQKSXE-BRwt5MXl.js → requirementDiagram-BXWQKSXE-CY6kp0_Y.js} +1 -1
  211. package/dist/client/assets/requirementDiagram-BXWQKSXE-CY6kp0_Y.js.br +0 -0
  212. package/dist/client/assets/requirementDiagram-BXWQKSXE-CY6kp0_Y.js.gz +0 -0
  213. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-DZ8y_gv3.js → sankeyDiagram-P5KCCOFB-BsA0NkHG.js} +1 -1
  214. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BsA0NkHG.js.br +0 -0
  215. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BsA0NkHG.js.gz +0 -0
  216. package/dist/client/assets/{search-CDJ4fv-q.js → search-CbpNLSpd.js} +1 -1
  217. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CJ9lZEsN.js → sequenceDiagram-WJ2MYXX4-BDzn7N2D.js} +1 -1
  218. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BDzn7N2D.js.br +0 -0
  219. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BDzn7N2D.js.gz +0 -0
  220. package/dist/client/assets/{sizeCapture-INFHLROL-Dt9ZzegQ.js → sizeCapture-INFHLROL-gxtam7nc.js} +1 -1
  221. package/dist/client/assets/sizeCapture-INFHLROL-gxtam7nc.js.br +0 -0
  222. package/dist/client/assets/sizeCapture-INFHLROL-gxtam7nc.js.gz +0 -0
  223. package/dist/client/assets/{stateDiagram-D77RDMKH-DgeQtV3s.js → stateDiagram-D77RDMKH-C4XjYLZR.js} +1 -1
  224. package/dist/client/assets/stateDiagram-D77RDMKH-C4XjYLZR.js.br +0 -0
  225. package/dist/client/assets/stateDiagram-D77RDMKH-C4XjYLZR.js.gz +0 -0
  226. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BfHWFf-I.js +1 -0
  227. package/dist/client/assets/{sun-CvzpsfHU.js → sun-CMXn_ntS.js} +1 -1
  228. package/dist/client/assets/{swimlanes-42K2YHIH-DHB6MQ8v.js → swimlanes-42K2YHIH--a1wkQO8.js} +1 -1
  229. package/dist/client/assets/swimlanes-42K2YHIH--a1wkQO8.js.br +0 -0
  230. package/dist/client/assets/swimlanes-42K2YHIH--a1wkQO8.js.gz +0 -0
  231. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DsiDF1XD.js +8 -0
  232. package/dist/client/assets/swiper-CTPycjLq.js +1 -0
  233. package/dist/client/assets/swiper-CTPycjLq.js.br +0 -0
  234. package/dist/client/assets/swiper-CTPycjLq.js.gz +0 -0
  235. package/dist/client/assets/{terminal-Dea8wJF3.js → terminal-DaiFCKy_.js} +7 -7
  236. package/dist/client/assets/terminal-DaiFCKy_.js.br +0 -0
  237. package/dist/client/assets/terminal-DaiFCKy_.js.gz +0 -0
  238. package/dist/client/assets/{timeline-definition-24CTP7MA-EqVVyv-E.js → timeline-definition-24CTP7MA-DFmXXUuU.js} +1 -1
  239. package/dist/client/assets/timeline-definition-24CTP7MA-DFmXXUuU.js.br +0 -0
  240. package/dist/client/assets/timeline-definition-24CTP7MA-DFmXXUuU.js.gz +0 -0
  241. package/dist/client/assets/triangle-alert-DgGU_xB4.js +1 -0
  242. package/dist/client/assets/{unplug-BNUx6Lmk.js → unplug-CnZtWzVW.js} +1 -1
  243. package/dist/client/assets/use-gesture-react.esm-DHU0wi7Q.js +1 -0
  244. package/dist/client/assets/use-gesture-react.esm-DHU0wi7Q.js.br +0 -0
  245. package/dist/client/assets/use-gesture-react.esm-DHU0wi7Q.js.gz +0 -0
  246. package/dist/client/assets/{vennDiagram-4TSXK5OY-BBE17-sL.js → vennDiagram-4TSXK5OY-DgR4zroQ.js} +1 -1
  247. package/dist/client/assets/vennDiagram-4TSXK5OY-DgR4zroQ.js.br +0 -0
  248. package/dist/client/assets/vennDiagram-4TSXK5OY-DgR4zroQ.js.gz +0 -0
  249. package/dist/client/assets/{videoCompression-B09OiyP5.js → videoCompression-CcffRZdP.js} +1 -1
  250. package/dist/client/assets/videoCompression-CcffRZdP.js.br +0 -0
  251. package/dist/client/assets/videoCompression-CcffRZdP.js.gz +0 -0
  252. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-B4gZGXiA.js → wardleyDiagram-VM6X3IG4-CY4SVUkf.js} +1 -1
  253. package/dist/client/assets/wardleyDiagram-VM6X3IG4-CY4SVUkf.js.br +0 -0
  254. package/dist/client/assets/wardleyDiagram-VM6X3IG4-CY4SVUkf.js.gz +0 -0
  255. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BDO5xF5D.js → xychartDiagram-S5SC5T6Z-PblQhR-b.js} +1 -1
  256. package/dist/client/assets/xychartDiagram-S5SC5T6Z-PblQhR-b.js.br +0 -0
  257. package/dist/client/assets/xychartDiagram-S5SC5T6Z-PblQhR-b.js.gz +0 -0
  258. package/dist/client/index.html +3 -3
  259. package/dist/client/index.html.br +0 -0
  260. package/dist/client/index.html.gz +0 -0
  261. package/dist/client/sw-encrypted-background.js +1 -1
  262. package/dist/client/sw-encrypted-background.js.br +0 -0
  263. package/dist/client/sw-encrypted-background.js.gz +0 -0
  264. package/dist/client/sw.js +1 -1
  265. package/dist/client/sw.js.br +0 -0
  266. package/dist/client/sw.js.gz +0 -0
  267. package/dist/server/agent/chatUIPrompt.js +1 -0
  268. package/dist/server/agent/collaborationPeerTransport.js +14 -69
  269. package/dist/server/agent/collaborationStore.js +5 -0
  270. package/dist/server/agent/installers.js +89 -33
  271. package/dist/server/agent/integrationServer.js +31 -2
  272. package/dist/server/agent/pluginPackages.js +51 -22
  273. package/dist/server/agent/sessionChatRoutes.js +45 -7
  274. package/dist/server/agentHook.js +56 -12
  275. package/dist/server/android/adb.js +24 -31
  276. package/dist/server/cli.js +52 -110
  277. package/dist/server/entry.js +17 -23
  278. package/dist/server/federation/cli.js +13 -47
  279. package/dist/server/federation/connectionErrors.js +37 -0
  280. package/dist/server/federation/connectionModel.js +83 -0
  281. package/dist/server/federation/desktopTargets.js +35 -13
  282. package/dist/server/federation/directRoutes.js +28 -36
  283. package/dist/server/federation/directTargetRegistry.js +106 -0
  284. package/dist/server/federation/httpUploadLimit.js +8 -0
  285. package/dist/server/federation/invitations.js +5 -1
  286. package/dist/server/federation/relay.js +13 -6
  287. package/dist/server/federation/relayTransport.js +147 -0
  288. package/dist/server/federation/routeAccess.js +5 -3
  289. package/dist/server/federation/routeInvitations.js +5 -1
  290. package/dist/server/federation/runtime.js +4 -2
  291. package/dist/server/federation/selfRelay.js +10 -59
  292. package/dist/server/federation/serviceTransport.js +123 -0
  293. package/dist/server/federation/streamLimits.js +3 -0
  294. package/dist/server/federation/trustedCa.js +61 -0
  295. package/dist/server/routes/android.js +5 -7
  296. package/dist/server/routes/terminal.js +149 -111
  297. package/dist/server/shared/androidDevices.js +64 -0
  298. package/dist/server/shared/programStatus.js +174 -0
  299. package/dist/server/shared/shareResources.js +3 -2
  300. package/dist/server/todos/routes.js +36 -0
  301. package/dist/server/todos/store.js +31 -1
  302. package/dist/server/utils/bootCheck.js +41 -271
  303. package/dist/server/utils/localHttpsSetup.js +257 -0
  304. package/dist/server/utils/oscBuffer.js +9 -0
  305. package/dist/server/utils/sessionDisplayName.js +11 -9
  306. package/dist/server/utils/settings.js +6 -3
  307. package/dist/server/utils/tmuxDisplayGeometry.js +54 -0
  308. package/dist/server/utils/tmuxObserverSize.js +26 -0
  309. package/docs/integrations.md +2 -1
  310. package/package.json +5 -1
  311. package/runtime-manifest.json +3 -3
  312. package/scripts/ensure-node-pty.cjs +22 -7
  313. package/scripts/install-utils.cjs +81 -0
  314. package/scripts/postinstall.mjs +24 -110
  315. package/dist/client/assets/AndroidMirrorView-BC_6L3mG.js +0 -3
  316. package/dist/client/assets/AndroidMirrorView-BC_6L3mG.js.br +0 -0
  317. package/dist/client/assets/AndroidMirrorView-BC_6L3mG.js.gz +0 -0
  318. package/dist/client/assets/App-BGECv_n_.js +0 -178
  319. package/dist/client/assets/App-BGECv_n_.js.br +0 -0
  320. package/dist/client/assets/App-BGECv_n_.js.gz +0 -0
  321. package/dist/client/assets/ArchitecturePanel-CYdolNzT.js +0 -9
  322. package/dist/client/assets/ArchitecturePanel-CYdolNzT.js.br +0 -0
  323. package/dist/client/assets/ArchitecturePanel-CYdolNzT.js.gz +0 -0
  324. package/dist/client/assets/ChangeWalkthroughPanel-mAiaX5i8.js.br +0 -0
  325. package/dist/client/assets/ChangeWalkthroughPanel-mAiaX5i8.js.gz +0 -0
  326. package/dist/client/assets/ChatRichContent-D2NtgMuL.js.br +0 -0
  327. package/dist/client/assets/ChatRichContent-D2NtgMuL.js.gz +0 -0
  328. package/dist/client/assets/CollaborationMainWorkspace-CcHsVfXD.js +0 -1
  329. package/dist/client/assets/CollaborationMainWorkspace-CcHsVfXD.js.br +0 -0
  330. package/dist/client/assets/CollaborationMainWorkspace-CcHsVfXD.js.gz +0 -0
  331. package/dist/client/assets/CollaborationTaskContent-FcrGGSr_.js +0 -2
  332. package/dist/client/assets/ComputerControlView-DU9krDsg.js +0 -6
  333. package/dist/client/assets/ComputerControlView-DU9krDsg.js.br +0 -0
  334. package/dist/client/assets/ComputerControlView-DU9krDsg.js.gz +0 -0
  335. package/dist/client/assets/DagPlayground-CbEuQA68.js.br +0 -0
  336. package/dist/client/assets/DagPlayground-CbEuQA68.js.gz +0 -0
  337. package/dist/client/assets/DiffLab-PysBkJrJ.js.br +0 -0
  338. package/dist/client/assets/DiffLab-PysBkJrJ.js.gz +0 -0
  339. package/dist/client/assets/DiffReview-Ce3wKMBk.js +0 -1
  340. package/dist/client/assets/DiffReview-Ce3wKMBk.js.br +0 -0
  341. package/dist/client/assets/DiffReview-Ce3wKMBk.js.gz +0 -0
  342. package/dist/client/assets/DiffReviewLab-D6PxvtBY.js.br +0 -0
  343. package/dist/client/assets/DiffReviewLab-D6PxvtBY.js.gz +0 -0
  344. package/dist/client/assets/DiffViewer-Bp-BLT2f.js.br +0 -0
  345. package/dist/client/assets/DiffViewer-Bp-BLT2f.js.gz +0 -0
  346. package/dist/client/assets/GitLoadingSkeleton-Fa4AXG-N.js.br +0 -0
  347. package/dist/client/assets/GitLoadingSkeleton-Fa4AXG-N.js.gz +0 -0
  348. package/dist/client/assets/MarkdownPreview-_Z5UzhLt.js +0 -19
  349. package/dist/client/assets/MarkdownPreview-_Z5UzhLt.js.br +0 -0
  350. package/dist/client/assets/MarkdownPreview-_Z5UzhLt.js.gz +0 -0
  351. package/dist/client/assets/ModelPreview-Cl0X7I-U.js.br +0 -0
  352. package/dist/client/assets/ModelPreview-Cl0X7I-U.js.gz +0 -0
  353. package/dist/client/assets/RecordingSaveDialog-Ca2iJsOW.js +0 -1
  354. package/dist/client/assets/RecordingSaveDialog-Ca2iJsOW.js.br +0 -0
  355. package/dist/client/assets/RecordingSaveDialog-Ca2iJsOW.js.gz +0 -0
  356. package/dist/client/assets/RightSidebar-CwXIBpEw.js +0 -1662
  357. package/dist/client/assets/RightSidebar-CwXIBpEw.js.br +0 -0
  358. package/dist/client/assets/RightSidebar-CwXIBpEw.js.gz +0 -0
  359. package/dist/client/assets/SessionChatView-D3sLcYAc.js +0 -13
  360. package/dist/client/assets/SessionChatView-D3sLcYAc.js.br +0 -0
  361. package/dist/client/assets/SessionChatView-D3sLcYAc.js.gz +0 -0
  362. package/dist/client/assets/SessionChatView-D8GoESjb.css +0 -1
  363. package/dist/client/assets/SessionChatView-D8GoESjb.css.br +0 -0
  364. package/dist/client/assets/SessionChatView-D8GoESjb.css.gz +0 -0
  365. package/dist/client/assets/SessionResourceSidebar-BObKJeA9.js +0 -2
  366. package/dist/client/assets/SessionResourceSidebar-BObKJeA9.js.br +0 -0
  367. package/dist/client/assets/SessionResourceSidebar-BObKJeA9.js.gz +0 -0
  368. package/dist/client/assets/TodoWorkspace-BdesAuz4.js +0 -1
  369. package/dist/client/assets/TodoWorkspace-BdesAuz4.js.br +0 -0
  370. package/dist/client/assets/TodoWorkspace-BdesAuz4.js.gz +0 -0
  371. package/dist/client/assets/abnfDiagram-VCTEODGH-BajyXVpH.js.br +0 -0
  372. package/dist/client/assets/abnfDiagram-VCTEODGH-BajyXVpH.js.gz +0 -0
  373. package/dist/client/assets/app-C3WX_u_Z.js +0 -37
  374. package/dist/client/assets/app-C3WX_u_Z.js.br +0 -0
  375. package/dist/client/assets/app-C3WX_u_Z.js.gz +0 -0
  376. package/dist/client/assets/arc-CbhM5I2d.js.br +0 -0
  377. package/dist/client/assets/arc-CbhM5I2d.js.gz +0 -0
  378. package/dist/client/assets/architectureDiagram-5GKGNRK7-CDKLcS6D.js.br +0 -0
  379. package/dist/client/assets/architectureDiagram-5GKGNRK7-CDKLcS6D.js.gz +0 -0
  380. package/dist/client/assets/arrow-up-BEUQcf-s.js +0 -1
  381. package/dist/client/assets/blockDiagram-I7D4REHJ-CXiIO6_W.js.br +0 -0
  382. package/dist/client/assets/blockDiagram-I7D4REHJ-CXiIO6_W.js.gz +0 -0
  383. package/dist/client/assets/c4Diagram-7LVT6UL2-uZ-i2eKH.js.gz +0 -0
  384. package/dist/client/assets/channel-Dg7JKsqi.js +0 -1
  385. package/dist/client/assets/chunk-F27PBJKO-BP7hTwtm.js.br +0 -0
  386. package/dist/client/assets/chunk-F27PBJKO-BP7hTwtm.js.gz +0 -0
  387. package/dist/client/assets/chunk-IMKFNOWR-LIGuOtnb.js.br +0 -0
  388. package/dist/client/assets/chunk-IMKFNOWR-LIGuOtnb.js.gz +0 -0
  389. package/dist/client/assets/chunk-SVP7TREG-FnWYLNCS.js.br +0 -0
  390. package/dist/client/assets/chunk-SVP7TREG-FnWYLNCS.js.gz +0 -0
  391. package/dist/client/assets/chunk-TICWLB2K-dcOCcmQq.js.br +0 -0
  392. package/dist/client/assets/chunk-TICWLB2K-dcOCcmQq.js.gz +0 -0
  393. package/dist/client/assets/classDiagram-ZZMXUADV-D6QBd_IP.js +0 -1
  394. package/dist/client/assets/classDiagram-v2-VYDZK3BY-D6QBd_IP.js +0 -1
  395. package/dist/client/assets/clipboardText-BapOM7QN.js +0 -1
  396. package/dist/client/assets/clipboardText-BapOM7QN.js.br +0 -0
  397. package/dist/client/assets/clipboardText-BapOM7QN.js.gz +0 -0
  398. package/dist/client/assets/cose-bilkent-JH36ORCC-Bz38mqD8.js.br +0 -0
  399. package/dist/client/assets/cose-bilkent-JH36ORCC-Bz38mqD8.js.gz +0 -0
  400. package/dist/client/assets/cynefin-OW5HDTMX-CZAa1A6y.js.br +0 -0
  401. package/dist/client/assets/cynefin-OW5HDTMX-CZAa1A6y.js.gz +0 -0
  402. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BaQnW4VG.js.br +0 -0
  403. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BaQnW4VG.js.gz +0 -0
  404. package/dist/client/assets/dagre-GXQ25YYZ-BdnT61bc.js.br +0 -0
  405. package/dist/client/assets/dagre-GXQ25YYZ-BdnT61bc.js.gz +0 -0
  406. package/dist/client/assets/diagram-S7CK7UJ4-BWiF8QNc.js.br +0 -0
  407. package/dist/client/assets/diagram-S7CK7UJ4-BWiF8QNc.js.gz +0 -0
  408. package/dist/client/assets/diagram-UQ7AKVKN-DLURjCFp.js.br +0 -0
  409. package/dist/client/assets/diagram-UQ7AKVKN-DLURjCFp.js.gz +0 -0
  410. package/dist/client/assets/diagram-VSXAHHWV-DYIcLklz.js.br +0 -0
  411. package/dist/client/assets/diagram-VSXAHHWV-DYIcLklz.js.gz +0 -0
  412. package/dist/client/assets/diagram-VX7I27RA-C9vqviXX.js.br +0 -0
  413. package/dist/client/assets/diagram-VX7I27RA-C9vqviXX.js.gz +0 -0
  414. package/dist/client/assets/diagram-Z3DM3KII-BJuQxTkw.js.br +0 -0
  415. package/dist/client/assets/diagram-Z3DM3KII-BJuQxTkw.js.gz +0 -0
  416. package/dist/client/assets/ebnfDiagram-PWID7BFC-BcbISm-z.js.br +0 -0
  417. package/dist/client/assets/ebnfDiagram-PWID7BFC-BcbISm-z.js.gz +0 -0
  418. package/dist/client/assets/erDiagram-RLTQ6QDP-fhNpRzUG.js.br +0 -0
  419. package/dist/client/assets/erDiagram-RLTQ6QDP-fhNpRzUG.js.gz +0 -0
  420. package/dist/client/assets/flowDiagram-HODETNUW-CVDJ_1Zu.js.br +0 -0
  421. package/dist/client/assets/flowDiagram-HODETNUW-CVDJ_1Zu.js.gz +0 -0
  422. package/dist/client/assets/ganttDiagram-EL5Y4UJY-Dzn-mrfe.js.br +0 -0
  423. package/dist/client/assets/ganttDiagram-EL5Y4UJY-Dzn-mrfe.js.gz +0 -0
  424. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Ci-wfvCz.js.br +0 -0
  425. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Ci-wfvCz.js.gz +0 -0
  426. package/dist/client/assets/index-DOq3vkFG.css +0 -1
  427. package/dist/client/assets/index-DOq3vkFG.css.br +0 -0
  428. package/dist/client/assets/index-DOq3vkFG.css.gz +0 -0
  429. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CCn5Ha25.js.br +0 -0
  430. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CCn5Ha25.js.gz +0 -0
  431. package/dist/client/assets/journeyDiagram-3NMN7TZE-CPl5oPfe.js.br +0 -0
  432. package/dist/client/assets/journeyDiagram-3NMN7TZE-CPl5oPfe.js.gz +0 -0
  433. package/dist/client/assets/kanban-definition-UXKFOSKX-Dmia2kLZ.js.br +0 -0
  434. package/dist/client/assets/kanban-definition-UXKFOSKX-Dmia2kLZ.js.gz +0 -0
  435. package/dist/client/assets/layout-B2Kz5M73.js.br +0 -0
  436. package/dist/client/assets/layout-B2Kz5M73.js.gz +0 -0
  437. package/dist/client/assets/linear-D2CT7wE3.js.br +0 -0
  438. package/dist/client/assets/linear-D2CT7wE3.js.gz +0 -0
  439. package/dist/client/assets/link-x33s12VI.js.br +0 -0
  440. package/dist/client/assets/link-x33s12VI.js.gz +0 -0
  441. package/dist/client/assets/loader-circle-D_nJKmMD.js +0 -1
  442. package/dist/client/assets/mermaid.core-G9XIcppl.js.br +0 -0
  443. package/dist/client/assets/mermaid.core-G9XIcppl.js.gz +0 -0
  444. package/dist/client/assets/mindmap-definition-YA3MSWOX-D2OX9OkO.js.br +0 -0
  445. package/dist/client/assets/mindmap-definition-YA3MSWOX-D2OX9OkO.js.gz +0 -0
  446. package/dist/client/assets/passwordBootstrap-DkTynZfV.js.br +0 -0
  447. package/dist/client/assets/passwordBootstrap-DkTynZfV.js.gz +0 -0
  448. package/dist/client/assets/pegDiagram-XKGWAZYB-qNjd6dbd.js.br +0 -0
  449. package/dist/client/assets/pegDiagram-XKGWAZYB-qNjd6dbd.js.gz +0 -0
  450. package/dist/client/assets/pieDiagram-E7YTZNPT-DcCmKDFh.js.br +0 -0
  451. package/dist/client/assets/pieDiagram-E7YTZNPT-DcCmKDFh.js.gz +0 -0
  452. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BpDzkl9h.js.br +0 -0
  453. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BpDzkl9h.js.gz +0 -0
  454. package/dist/client/assets/railroadDiagram-O6MQD6OU-DkwV8w7x.js.br +0 -0
  455. package/dist/client/assets/railroadDiagram-O6MQD6OU-DkwV8w7x.js.gz +0 -0
  456. package/dist/client/assets/rdpSession-D5NrFTav.js +0 -1
  457. package/dist/client/assets/rdpSession-D5NrFTav.js.br +0 -0
  458. package/dist/client/assets/rdpSession-D5NrFTav.js.gz +0 -0
  459. package/dist/client/assets/requirementDiagram-BXWQKSXE-BRwt5MXl.js.br +0 -0
  460. package/dist/client/assets/requirementDiagram-BXWQKSXE-BRwt5MXl.js.gz +0 -0
  461. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DZ8y_gv3.js.br +0 -0
  462. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DZ8y_gv3.js.gz +0 -0
  463. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CJ9lZEsN.js.br +0 -0
  464. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CJ9lZEsN.js.gz +0 -0
  465. package/dist/client/assets/settings-2-DtFz7lgk.js +0 -1
  466. package/dist/client/assets/sizeCapture-INFHLROL-Dt9ZzegQ.js.br +0 -0
  467. package/dist/client/assets/sizeCapture-INFHLROL-Dt9ZzegQ.js.gz +0 -0
  468. package/dist/client/assets/stateDiagram-D77RDMKH-DgeQtV3s.js.br +0 -0
  469. package/dist/client/assets/stateDiagram-D77RDMKH-DgeQtV3s.js.gz +0 -0
  470. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CKS6y2rR.js +0 -1
  471. package/dist/client/assets/swimlanes-42K2YHIH-DHB6MQ8v.js.br +0 -0
  472. package/dist/client/assets/swimlanes-42K2YHIH-DHB6MQ8v.js.gz +0 -0
  473. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DvUzDKPI.js +0 -8
  474. package/dist/client/assets/swiper-DJjq1TYT.js +0 -1
  475. package/dist/client/assets/swiper-DJjq1TYT.js.br +0 -0
  476. package/dist/client/assets/swiper-DJjq1TYT.js.gz +0 -0
  477. package/dist/client/assets/syntaxHighlight-DF6Q5phI.js +0 -4
  478. package/dist/client/assets/syntaxHighlight-DF6Q5phI.js.br +0 -0
  479. package/dist/client/assets/syntaxHighlight-DF6Q5phI.js.gz +0 -0
  480. package/dist/client/assets/terminal-Dea8wJF3.js.br +0 -0
  481. package/dist/client/assets/terminal-Dea8wJF3.js.gz +0 -0
  482. package/dist/client/assets/timeline-definition-24CTP7MA-EqVVyv-E.js.br +0 -0
  483. package/dist/client/assets/timeline-definition-24CTP7MA-EqVVyv-E.js.gz +0 -0
  484. package/dist/client/assets/triangle-alert--5QOrsVl.js +0 -1
  485. package/dist/client/assets/use-gesture-react.esm-DYpdiE_k.js +0 -1
  486. package/dist/client/assets/use-gesture-react.esm-DYpdiE_k.js.br +0 -0
  487. package/dist/client/assets/use-gesture-react.esm-DYpdiE_k.js.gz +0 -0
  488. package/dist/client/assets/vennDiagram-4TSXK5OY-BBE17-sL.js.br +0 -0
  489. package/dist/client/assets/vennDiagram-4TSXK5OY-BBE17-sL.js.gz +0 -0
  490. package/dist/client/assets/videoCompression-B09OiyP5.js.br +0 -0
  491. package/dist/client/assets/videoCompression-B09OiyP5.js.gz +0 -0
  492. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B4gZGXiA.js.br +0 -0
  493. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B4gZGXiA.js.gz +0 -0
  494. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BDO5xF5D.js.br +0 -0
  495. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BDO5xF5D.js.gz +0 -0
@@ -1,1662 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-Cl0X7I-U.js","assets/app-C3WX_u_Z.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-Dea8wJF3.js","assets/index-DOq3vkFG.css","assets/search-CDJ4fv-q.js","assets/sun-CvzpsfHU.js","assets/list-tree-XBmm9il2.js","assets/AndroidMirrorView-BC_6L3mG.js","assets/v4-EwEgHOG0.js","assets/RecordingSaveDialog-Ca2iJsOW.js","assets/use-gesture-react.esm-DYpdiE_k.js","assets/gestureArbiter-DszagC-d.js","assets/arrow-up-BEUQcf-s.js","assets/unplug-BNUx6Lmk.js","assets/circle-Pldg1yI9.js","assets/quote-DeByS04O.js","assets/MarkdownPreview-_Z5UzhLt.js","assets/swiper-DJjq1TYT.js","assets/swiper-C2J0D0kV.css","assets/syntaxHighlight-DF6Q5phI.js","assets/GitLoadingSkeleton-Fa4AXG-N.js","assets/DiffReview-Ce3wKMBk.js","assets/DiffViewer-Bp-BLT2f.js","assets/git-compare-Ct2eJNs4.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert--5QOrsVl.js","assets/ChangeWalkthroughPanel-mAiaX5i8.js","assets/chevron-left-D8ntyw2S.js","assets/maximize-2-t-zzENew.js","assets/loader-circle-D_nJKmMD.js","assets/arrow-down-Dp27yS0N.js","assets/ArchitecturePanel-CYdolNzT.js","assets/link-x33s12VI.js","assets/purify.es-4eNOHKSq.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-DU9krDsg.js","assets/clipboard-tTkMEO1S.js","assets/settings-2-DtFz7lgk.js"])))=>i.map(i=>d[i]);
2
- import{aV as Jr,ea as _t,cg as t,n as po,cq as Qd,r as Gi,u as lt,F as eh,h as ds,a4 as Xt,ej as U,V as sa,eq as Pt,cG as ct,c as mo,bK as Zd,C as go,g as aa,_ as co,e5 as Zs,e6 as Wi,$ as Zc,d1 as eu,dT as th,dq as rh,b5 as nh,L as bo,R as uo,c0 as sh,as as Ws,be as ah,ed as tu,c8 as oh,ca as ih,cb as lh,cc as ch,c9 as qs,bu as dh,E as uh,w as fh,c4 as hh,cI as ph,cL as mh,cM as gh,bX as bh,cJ as ed,ar as yt,ak as ru,am as xh,p as qi,k as vh,m as yh,v as Ri,al as wh,e8 as ji,bW as td,bo as rd,bk as kh,by as Ci,bz as nd,er as ra,bb as Ks,bA as Sh,cw as Rh,dQ as sd,br as jh,e3 as Ch,at as Ni,de as Nh,ek as Yr,d5 as An,an as Ph,ao as ad,bD as Eh,aB as od,aA as Ah,bl as id,bq as Th,bw as ld,dh as Mh,ad as cd,j as dd,I as Pi,H as ro,b as Lh,y as ud,U as fd,t as Ih,q as hd,ap as $h,a5 as sl,d6 as Fh,eo as Dh,J as _h}from"./app-C3WX_u_Z.js";import{u as Bh,j as Ei,Z as Uh,a as nu,F as Oh,M as Hh,_ as zh,c as Gh,d as Wh,e as qh,g as Kh,f as Vh,h as Yh,r as Xh,s as Jh}from"./MarkdownPreview-_Z5UzhLt.js";import{b as n,r as Qr}from"./dnd-BCFAPC0L.js";import{b as Qh,a as Zh,P as ep,d as tp,c as rp,N as pd,S as np,C as sp,G as ap,A as op}from"./GitLoadingSkeleton-Fa4AXG-N.js";import{S as ip,a as md}from"./swiper-DJjq1TYT.js";import{S as lp,U as cp}from"./RecordingSaveDialog-Ca2iJsOW.js";import{A as al}from"./arrow-up-BEUQcf-s.js";import{D as Ki,C as na,f as dp,n as up}from"./DiffReview-Ce3wKMBk.js";import{T as fp,G as br}from"./triangle-alert--5QOrsVl.js";import{C as su,M as au}from"./ChangeWalkthroughPanel-mAiaX5i8.js";import{R as ou,S as gd,V as hp,d as pp,M as mp,A as Ai,u as gp,f as bp,i as bd,H as xd,b as xp}from"./AndroidMirrorView-BC_6L3mG.js";import{u as vp}from"./DiffViewer-Bp-BLT2f.js";import{r as yp,s as wp,l as kp,a as vd,g as Vi,b as Sp,h as Rp}from"./syntaxHighlight-DF6Q5phI.js";import{L as yd}from"./loader-circle-D_nJKmMD.js";import{a as wd,S as kd}from"./gestureArbiter-DszagC-d.js";import{M as iu}from"./maximize-2-t-zzENew.js";import{L as jp}from"./list-tree-XBmm9il2.js";import{S as us}from"./search-CDJ4fv-q.js";import{A as Cp}from"./arrow-down-Dp27yS0N.js";import{G as lu}from"./git-compare-Ct2eJNs4.js";const Np=[["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"}]],Pp=Jr("case-sensitive",Np);const Ep=[["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"}]],Ap=Jr("eye-off",Ep);const Tp=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Yi=Jr("eye",Tp);const Mp=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Lp=Jr("funnel",Mp);const Ip=[["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"}]],$p=Jr("image-plus",Ip);const Fp=[["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"}]],Dp=Jr("regex",Fp);const _p=[["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"}]],Bp=Jr("scan",_p);const Up=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],Op=Jr("whole-word",Up);function Sd({children:r,actions:a}){const{t:i}=_t(),[c,f]=n.useState(!1),p=n.useId(),g=n.useRef(null),k=n.useRef(null),m=()=>{f(!1),g.current?.focus({preventScroll:!0})};return n.useLayoutEffect(()=>{if(!c)return;const x=g.current,w=k.current;if(!x||!w)return;const R=window.visualViewport,b=()=>{const P=x.getBoundingClientRect(),$=(R?.offsetLeft??0)+8,D=(R?.offsetTop??0)+8,te=Math.max(0,(R?.width??window.innerWidth)-16),M=D+(R?.height??window.innerHeight)-16,I=Math.min(240,te),H=Math.max(0,P.top-D-6),Y=Math.max(0,M-P.bottom-6),be=w.scrollHeight>Y&&H>Y;Object.assign(w.style,{width:`${I}px`,left:`${Math.max($,Math.min(P.right-I,$+te-I))}px`,top:`${be?P.top-6:P.bottom+6}px`,maxHeight:`${be?H:Y}px`,transform:be?"translateY(-100%)":"none"})};b();const A=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return A?.observe(x),A?.observe(w),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),R?.addEventListener("resize",b),R?.addEventListener("scroll",b),()=>{A?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),R?.removeEventListener("resize",b),R?.removeEventListener("scroll",b)}},[c]),n.useEffect(()=>{if(!c)return;k.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const x=w=>{w.target instanceof Node&&!g.current?.contains(w.target)&&!k.current?.contains(w.target)&&f(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[c]),t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,t.jsxs("button",{ref:g,type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?p:void 0,onClick:()=>f(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),f(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${c?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[t.jsx(po,{size:14}),i("sidebar.moreActions")]})]}),typeof document<"u"&&Qr.createPortal(t.jsx("div",{ref:k,id:p,hidden:!c,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":i("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:x=>{if(!x.currentTarget.contains(x.target))return;const w=[...x.currentTarget.querySelectorAll("button:not(:disabled)")],R=w.indexOf(document.activeElement);let b;if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),m();return}if(x.key==="Tab"){m();return}if(x.key==="ArrowDown")b=(R+1)%w.length;else if(x.key==="ArrowUp")b=(R-1+w.length)%w.length;else if(x.key==="Home")b=0;else if(x.key==="End")b=w.length-1;else return;x.preventDefault(),w[b]?.focus({preventScroll:!0})},children:a(m)}),document.body)]})}const Ti="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",is=n.memo(function({active:a,mounted:i=!0,fallback:c=null,children:f}){const p=n.useRef(null);return n.useLayoutEffect(()=>{const g=p.current;if(!g||a)return;const k=new Map,m=R=>{k.has(R)||(k.set(R,R.inert),R.inert=!0)},x=R=>{R instanceof HTMLElement&&R.matches(Ti)&&m(R),R.querySelectorAll(Ti).forEach(m)};x(g);const w=new MutationObserver(R=>{for(const b of R)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Ti)&&m(b.target):b.addedNodes.forEach(A=>{A instanceof Element&&x(A)})});return w.observe(g,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{w.disconnect();for(const[R,b]of k)R.inert=b}},[a,i]),t.jsx("div",{ref:p,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:a?void 0:{clipPath:"inset(100%)"},"aria-hidden":!a,children:i?typeof f=="function"?f():f:c})},(r,a)=>!r.active&&!a.active&&r.mounted===a.mounted);async function Hp(r){let a;try{await Promise.race([r(),new Promise(i=>{a=setTimeout(i,3e3)})])}catch{}finally{clearTimeout(a)}}function zp({active:r,rootPath:a,loading:i,delay:c,lastStartedRoot:f,load:p}){n.useEffect(()=>{if(!r||!a||i||f.current===a)return;const g=window.setTimeout(()=>{f.current=a,p(a)},c);return()=>window.clearTimeout(g)},[r,a,i,c,f,p])}function Gp({rootPath:r,paths:a,disabled:i,onChange:c}){const{t:f}=_t(),[p,g]=n.useState(""),[k,m]=n.useState(0),[x,w]=n.useState(null),[R,b]=n.useState(!1),[A,P]=n.useState(!1),$=`${r.replace(/[\\/]+$/,"")}/${p}`;n.useEffect(()=>{const I=new AbortController;return w(null),b(!1),Qd($,I.signal,!0,"pick_git_ignore_exception").then(H=>{I.signal.aborted||w({directory:p,entries:H.entries,truncated:!!H.truncated})}).catch(()=>{I.signal.aborted||b(!0)}),()=>I.abort()},[$,p,k]);const D=I=>{w(null),b(!1),g(I)},te=x?.directory===p,M=I=>{if(I.length>200){P(!0);return}P(!1),c(I)};return t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[t.jsx("button",{type:"button",disabled:i||!p,onClick:()=>D(p.slice(0,Math.max(0,p.lastIndexOf("/")))),"aria-label":f("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:t.jsx(al,{size:14})}),t.jsx("button",{type:"button",disabled:i||!p,onClick:()=>D(""),"aria-label":f("rightSidebar.backToProjectRoot"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:t.jsx(Gi,{size:14})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:$,children:p||"./"})]}),t.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":f("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!te&&!R,children:[R?t.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[t.jsx("p",{role:"alert",className:"text-destructive",children:f("rightSidebar.gitIgnoreExceptionsLoadFailed")}),t.jsx("button",{type:"button",disabled:i,onClick:()=>{b(!1),m(I=>I+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:f("common.retry")})]}):te?x.entries.length===0?t.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:f("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):x.entries.map(I=>{const H=p?`${p}/${I.name}`:I.name,Y=H+(I.type==="directory"?"/":""),be=a.includes(Y)||a.includes(H),_=a.some(ae=>ae.endsWith("/")&&H.startsWith(ae)),o=I.type==="directory"?Gi:eh;return t.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[t.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[t.jsx("input",{type:"checkbox",checked:be||_,disabled:i||_,onChange:()=>M(be?a.filter(ae=>ae!==Y&&ae!==H):[...a,Y]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),t.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",title:I.name,children:I.name})]}),I.type==="directory"&&t.jsx("button",{type:"button",disabled:i,onClick:()=>D(H),"aria-label":f("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:I.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:t.jsx(ds,{size:15})})]},I.name)}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lt,{size:18})}),te&&x.truncated&&t.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:f("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[t.jsx("span",{className:"font-medium",children:f("rightSidebar.gitIgnoreExceptionsSelected",{count:a.length})}),t.jsx("button",{type:"button",disabled:i||a.length===0,onClick:()=>M([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:f("rightSidebar.gitIgnoreExceptionsClear")})]}),a.length>0&&t.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:a.map(I=>t.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:I,children:I}),t.jsx("button",{type:"button",disabled:i,onClick:()=>M(a.filter(H=>H!==I)),"aria-label":f("rightSidebar.gitIgnoreExceptionsRemove",{path:I}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:t.jsx(Xt,{size:13})})]},I))}),A&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:f("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function Wp({rootPath:r,disabled:a,pressed:i,saving:c,onToggle:f}){const{t:p}=_t(),g=n.useId(),k=n.useRef(null),m=n.useRef(null),x=n.useRef(null),w=n.useRef(null),R=n.useRef(!1),[b,A]=n.useState(!1),[P,$]=n.useState([]),[D,te]=n.useState(!1),[M,I]=n.useState(null),H=U(W=>W.setGitIgnoreExceptions),Y=()=>{x.current!==null&&clearTimeout(x.current),x.current=null,w.current=null},be=()=>{Y(),!(a||D||!r)&&($([...U.getState().gitIgnoreExceptions[r]??[]]),I(null),A(!0))},_=()=>{D||A(!1)},o=W=>{Y(),R.current=!1,!(W.button!==0||!W.isPrimary||a)&&(W.currentTarget.setPointerCapture(W.pointerId),w.current={x:W.clientX,y:W.clientY},x.current=setTimeout(()=>{R.current=!0,be()},450))};n.useEffect(()=>(A(!1),Y(),Y),[r]),n.useEffect(()=>{if(b)return m.current?.focus(),()=>k.current?.focus()},[b]);const ae=p(i?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:k,type:"button",disabled:a||D,"aria-pressed":i,"aria-label":ae,"aria-description":p("rightSidebar.gitIgnoreConfigureHint"),title:`${ae} · ${p("rightSidebar.gitIgnoreConfigureHint")}`,onClick:W=>{if(R.current&&W.detail!==0){R.current=!1,W.preventDefault();return}f()},onContextMenu:W=>{W.preventDefault(),R.current=!0,b||be()},onPointerDown:o,onPointerMove:W=>{const he=w.current;he&&Math.hypot(W.clientX-he.x,W.clientY-he.y)>10&&Y()},onPointerUp:Y,onPointerCancel:Y,onLostPointerCapture:Y,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${i?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:c?t.jsx(lt,{size:14}):t.jsx(Lp,{size:14})}),b&&Qr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:_,children:t.jsxs("form",{ref:m,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${g}-title`,"aria-describedby":`${g}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:W=>W.stopPropagation(),onKeyDown:W=>{if(W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),_()),W.key==="Tab"){const he=Array.from(m.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!he.length){W.preventDefault(),m.current?.focus();return}const G=he[0],le=he[he.length-1];W.shiftKey&&document.activeElement===G&&(W.preventDefault(),le?.focus()),document.activeElement===m.current?(W.preventDefault(),(W.shiftKey?le:G)?.focus()):!W.shiftKey&&document.activeElement===le&&(W.preventDefault(),G?.focus())}},onSubmit:W=>{if(W.preventDefault(),!(!r||D)){if(P.length>200){I(p("rightSidebar.gitIgnoreExceptionsInvalid"));return}te(!0),I(null),H(r,P).then(()=>A(!1)).catch(()=>I(p("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>te(!1))}},children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{id:`${g}-title`,className:"text-sm font-medium",children:p("rightSidebar.gitIgnoreExceptionsTitle")}),t.jsx("button",{type:"button",disabled:D,onClick:_,"aria-label":p("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:t.jsx(Xt,{size:16})})]}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),t.jsx("p",{id:`${g}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:p("rightSidebar.gitIgnoreExceptionsHint")}),t.jsx("p",{className:"text-xs font-medium",children:p("rightSidebar.gitIgnoreExceptionsPaths")}),r&&t.jsx(Gp,{rootPath:r,paths:P,onChange:$,disabled:D}),M&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:M}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",disabled:D,onClick:_,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:p("common.cancel")}),t.jsxs("button",{type:"submit",disabled:D,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[D&&t.jsx(lt,{size:13}),p("common.save")]})]})]})}),document.body)]})}function qp(r,a,i){try{const c=r instanceof HTMLImageElement?r.naturalWidth:r.width,f=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!c||!f)return Promise.resolve(null);const p=r instanceof HTMLImageElement?1400/Math.max(c,f):Math.min(1,1400/Math.max(c,f)),g=document.createElement("canvas");g.width=Math.max(1,Math.round(c*p)),g.height=Math.max(1,Math.round(f*p));const k=g.getContext("2d");if(!k)return Promise.resolve(null);const m=getComputedStyle(document.documentElement);if(k.fillStyle=m.getPropertyValue("--surface").trim()||"white",k.fillRect(0,0,g.width,g.height),k.drawImage(r,0,0,g.width,g.height),i){const x=Math.max(10,Math.min(16,g.width/35));k.font=`${x}px sans-serif`;const w=[];let R="";for(const b of i.split(" "))R&&k.measureText(`${R} ${b}`).width>g.width-20?(w.push(R),R=b):R=R?`${R} ${b}`:b;R&&w.push(R),k.fillStyle=m.getPropertyValue("--surface").trim()||"white",k.fillRect(0,0,g.width,w.length*(x+4)+12),k.fillStyle=m.getPropertyValue("--foreground").trim()||"black",w.forEach((b,A)=>k.fillText(b,10,8+x+A*(x+4)))}if(a){const x=a.xPercent*g.width/100,w=a.yPercent*g.height/100,R=Math.max(4,Math.min(12,Math.min(g.width,g.height)*.015)),b=R*1.6;k.strokeStyle=m.getPropertyValue("--primary").trim()||"black",k.lineWidth=Math.max(1,R/3),k.beginPath(),k.arc(x,w,R,0,Math.PI*2),k.stroke(),k.beginPath(),k.moveTo(x-b,w),k.lineTo(x+b,w),k.moveTo(x,w-b),k.lineTo(x,w+b),k.stroke()}return new Promise(x=>g.toBlob(x,"image/png"))}catch{return Promise.resolve(null)}}function Kp(r,a,i,c){return[r.trim(),a.trim(),c?`截图:${c}`:""].filter(Boolean).join(`
3
- `)}function Eb(r,a,i){const c=a*Math.PI/360,f=Math.min(c,Math.atan(Math.tan(c)*Math.max(i,.05)));return Math.max(r,1e-6)/Math.sin(f)*1.15}async function Vp(r,a,i,c){if(!i?.snapshot)return c.isCurrent()?await c.insert(r,a):!1;const f=new Date().toISOString(),p=new AbortController;let g,k;try{k=await Promise.race([(async()=>{const m=await i.snapshot;if(!(!m||p.signal.aborted||!c.isCurrent()))return c.upload(new File([m],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),p.signal)})(),new Promise(m=>{g=setTimeout(()=>{p.abort(),m(void 0)},3e3)})])}catch{}finally{clearTimeout(g),p.abort()}return c.isCurrent()?await c.insert(k?Kp(r,"",f,k):r,a):!1}function Yp(r,a){return r===a||a.endsWith(`/${r}`)||r.endsWith(`/${a}`)}function Rd(r,a){return`${r??""}\0${a}`}function Xp(r,a,i){if(!r||r.length===0||!i)return{explained:0,stale:0};const c=Rd(a,i);let f=0,p=0;for(const g of r){const k=[g.filePath,g.newPath,g.oldPath].filter(x=>typeof x=="string"&&x.length>0);(k.some(x=>Rd(g.repoRoot,x)===c)||k.some(x=>Yp(x,i)))&&(f+=1)}return{explained:f,stale:p}}function Jp({status:r}){if(!r)return null;const a=r.stale>0&&r.explained===0;if(!(r.explained>0||r.stale>0))return null;const c=a?"AI audit explanation is stale":"AI audit explanation available";return t.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${a?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:c,"aria-label":c,children:a?t.jsx(fp,{size:10}):t.jsx(sa,{size:10})})}function Xi({changeStatus:r,auditStatus:a,renderChangeBadge:i}){return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[i(r),t.jsx(Jp,{status:a})]})}const cu="termdock:right-sidebar:diff-change-list-mode:v1";function Qp(r){return r==="list"||r==="tree"}function Zp(){return ct(cu,Qp)??"tree"}function em(r){for(const a of r){const i=a.hunk;if(i.oldPath&&i.newPath&&i.oldPath!==i.newPath)return"renamed";if(i.oldPath===null&&i.newPath)return"added";if(i.oldPath&&i.newPath===null)return"deleted"}return"modified"}function tm(r){const a=new Map;for(const c of r){const f=a.get(c.hunk.filePath)??{key:c.hunk.filePath,filePath:c.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};f.items.push(c),f.additions+=c.hunk.additions,f.deletions+=c.hunk.deletions,c.current&&(f.explained+=1),c.stale&&(f.stale+=1),a.set(c.hunk.filePath,f)}const i=Array.from(a.values()).sort((c,f)=>c.filePath.localeCompare(f.filePath));for(const c of i)c.changeType=em(c.items);return i}function rm(r){const a=r.filePath.split("/").pop()??r.filePath;return{key:r.key,path:r.filePath,displayName:a,displayDir:r.filePath.includes("/")?r.filePath.slice(0,-a.length-1):"",status:r.changeType,title:r.filePath}}function nm(r,a){const i=r.filter(p=>p.trim().length>0);if(i.length<=1)return i[0]??"";const c=[],f=new Set;for(const[p,g]of i.entries()){const k=g.split(`
4
- `),m=k.findIndex(R=>R.startsWith("@@ "));if(m<0){c.push(...k);continue}p===0&&c.push(...k.slice(0,m));const x=a[p];let w=m;for(;w>=0&&w<k.length;){const R=k.findIndex((te,M)=>M>w&&te.startsWith("@@ ")),b=R>=0?R:k.length,A=k.slice(w,b),P=A[0]??"",$=x?P===x:!0,D=P||x||A.join(`
5
- `);$&&!f.has(D)&&(c.push(...A),f.add(D)),w=R}}return c.join(`
6
- `)}function sm({groups:r,onInsertDiffReference:a}){return r.map(i=>{const c=nm(i.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),i.items.map(m=>m.hunk.hunkHeader)),f=i.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})),p=i.filePath.split("/").pop()??i.filePath,g=i.filePath.includes("/")?i.filePath.slice(0,-p.length-1):"",k=i.items[0]?.repoRoot??f[0]?.repoRoot??null;return{key:i.key,path:i.filePath,oldPath:i.items[0]?.hunk.oldPath??void 0,absolutePath:k?`${k}/${i.items[0]?.repositoryPath??i.filePath}`:i.filePath,status:i.changeType,repoRoot:k,displayName:p,displayDir:g,diffOverride:c,oldSourceRef:i.items[0]?.current?.headRef?`${i.items[0].current.baseRef}...${i.items[0].current.headRef}`:i.items[0]?.stale?.headRef?`${i.items[0].stale.baseRef}...${i.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(i.items.flatMap(m=>m.hunk.previewRevert?[[m.hunk.hunkHeader,m.hunk.previewRevert]]:[])),auditRecords:f,onInsertDiffReference:a}})}function am(r,a,i){const c=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(c.length===0)return null;const p=r.getBoundingClientRect().top+48;let g=null,k=Number.POSITIVE_INFINITY;for(const x of c){const w=x.getBoundingClientRect();if(w.bottom<p)continue;const R=Math.abs(w.top-p);R<k&&(g=x,k=R)}const m=g?.dataset.diffSelectionPath??g?.dataset.diffStreamItem??null;return!m||m===a||i(m),m}function jd({items:r,selectedKey:a,onSelect:i,emptyText:c,mobile:f=!1,backLabel:p="Back",headerTitle:g,headerMeta:k,onClose:m,closeLabel:x="Back",wrap:w=!0,diffViewType:R,inlineMode:b,viewControls:A,onToggleWrap:P,wrapTitle:$,wrapOnLabel:D="Wrap on",wrapOffLabel:te="Wrap off",desktopLayout:M="split",onInsertDiffReference:I,onReferenceCopied:H,renderPathReference:Y,insertedReferenceKey:be,copiedReferenceKey:_,onClearAuditRecord:o,onRefresh:ae,localOptions:W,onHunkGitAction:he,error:G,refreshing:le,actionsBusy:j,refreshLabel:F,refreshTitle:ee,walkthroughs:C=[],onWalkthroughNavigate:L,initialDetailScrollTop:q,onDetailScrollPositionChange:ne,scrollToKey:pe,scrollToKeyNonce:Ne,externalSwiperRef:we,onMobileSlideChange:Pe}){const{t:O}=_t(),ue=n.useMemo(()=>tm(r),[r]),oe=n.useMemo(()=>new Map(ue.map(V=>[V.key,V])),[ue]),[Fe,Ie]=n.useState(()=>Zp()),[E,xe]=n.useState(()=>new Set),[ge,De]=n.useState({key:null,nonce:0}),Ve=ue.find(V=>V.explained>0||V.stale>0)?.key??ue[0]?.key??null,Ae=a&&ue.some(V=>V.key===a)?a:Ve,Jt=n.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ue.map(rm)}],[ue]),Be=n.useMemo(()=>sm({groups:ue,onInsertDiffReference:I}),[ue,I]),ft=n.useRef(Ve),Ue=n.useRef(i);ft.current=Ve,Ue.current=i,n.useEffect(()=>{!a&&ft.current&&Ue.current(ft.current)},[a]);const Qt=P?t.jsxs("button",{type:"button",onClick:P,"aria-pressed":w,title:$,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${w?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:w?D:te})]}):null,me=W?.map(V=>t.jsxs("label",{title:V.disabled?O("rightSidebar.includeUncommittedCurrentBranchOnly"):V.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[t.jsx("input",{type:"checkbox",checked:V.checked,disabled:le||j||V.disabled&&!V.checked,onChange:ye=>V.onChange(ye.target.checked),className:"accent-primary"}),t.jsxs("span",{children:[V.label," · ",O("rightSidebar.includeUncommitted"),V.disabled&&t.jsx("span",{className:"block text-[10px]",children:O("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},V.key)),dt=G?t.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:G}):null,at=ae?t.jsxs("button",{type:"button",onClick:ae,disabled:le||j,title:ee??F,"aria-label":ee??F,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[t.jsx(ou,{size:12,className:le?"animate-spin":""}),F&&t.jsx("span",{children:F})]}):null,bt=V=>t.jsxs("div",{className:"px-0 py-0",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[g&&t.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:g}),k&&t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:k})]}),m&&t.jsxs("button",{type:"button",onClick:m,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[t.jsx(mo,{size:14}),x]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[V,me,at,A,Qt,dt]})]});if(r.length===0){const V=t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:c});return!g&&!m?V:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[bt(null),V]})}const Oe=P||ae?({slideToList:V})=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.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:V,children:[t.jsx(mo,{size:14}),p]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[me,at,A,P&&t.jsxs("button",{type:"button",onClick:P,"aria-pressed":w,title:$,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${w?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:w?D:te})]})]}),dt]}):void 0;return t.jsx(Ki,{mobile:f,preserveScrollOnUpdate:!!W?.length,desktopLayout:M,backLabel:p,groups:Jt,selectedKey:Ae,mode:Fe,onModeChange:V=>{Ie(V),V!=="ai"&&Pt(cu,V)},compact:f,collapsedDirectoryKeys:E,onToggleDirectory:V=>{xe(ye=>{const Ze=new Set(ye);return Ze.has(V)?Ze.delete(V):Ze.add(V),Ze})},onSelectFile:V=>{i(V.key),De(ye=>({key:V.key,nonce:ye.nonce+1}))},renderLeading:V=>{const ye=oe.get(V.key);return t.jsx(Xi,{changeStatus:V.status,auditStatus:ye,renderChangeBadge:Ze=>t.jsx(na,{status:Ze})})},renderTrailing:V=>{const ye=oe.get(V.key);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[ye&&t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",ye.additions," -",ye.deletions]}),Y?.(V.path,"file")]})},renderDirectoryTrailing:V=>Y?.(V,"directory"),renderListHeader:bt,aiContent:({slideToDetail:V,fullscreen:ye,toggleFullscreen:Ze})=>C.length>0&&L?t.jsx(su,{walkthroughs:C,repoRoot:C[0]?.repoRoot,fullscreen:ye,onToggleFullscreen:Ze,onNavigate:wt=>{f&&window.requestAnimationFrame(V),L(wt)}}):t.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:O("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Oe,externalSwiperRef:we,onMobileSlideChange:Pe,detailContainerClassName:f?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:q,scrollToKey:pe??ge.key,scrollToKeyNonce:pe==null?ge.nonce:Ne,onDetailScroll:V=>{am(V,Ae,i),ne?.(V.scrollTop)},files:Be,activePane:!0,wrap:w,diffViewType:R,inlineMode:b,renderStreamBadge:(V,ye)=>{const Ze=oe.get(ye.key);return t.jsx(Xi,{changeStatus:V,auditStatus:Ze,renderChangeBadge:wt=>t.jsx(na,{status:wt})})},onInsertDiffReference:I,onReferenceCopied:H,insertedReferenceKey:be,copiedReferenceKey:_,onClearAuditRecord:o,onHunkGitAction:le?void 0:he,emptyContent:t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:c})})}function om(r){return r.replace(/\/+$/,"")||"/"}function im(r){return[...new Set(Array.from(r,om))].sort((a,i)=>a.localeCompare(i))}function lm(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function cm(r){let a=null;return{applicableEvents:r.filter(c=>{const f=c.type==="rescan-required"&&!lm(c.reason);return f&&c.reason&&!a&&(a=c.reason),!f}),unavailableReason:a}}const dm=1400,um=1200,du=44,fm=.7;function Mi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ji(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function hm(r){try{const a=window.localStorage.getItem(Ji(r)),i=a===null?NaN:Number(a);return Number.isFinite(i)&&i>=du?i:null}catch{return null}}function Cd(r,a){try{a===null?window.localStorage.removeItem(Ji(r)):window.localStorage.setItem(Ji(r),String(a))}catch{}}function no(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function pm({value:r,collapsed:a,labels:i,focusRequest:c,insertError:f,autoCollapseAfterSend:p,onChange:g,onCollapsedChange:k,onAutoCollapseAfterSendChange:m,onDisable:x,onClear:w,onInsert:R,onInsertAndSend:b}){const[A,P]=n.useState(null),[$,D]=n.useState(!1),te=n.useRef(!1),M=n.useRef(!0),[I,H]=n.useState(!1),[Y,be]=n.useState(()=>hm(Mi())),_=n.useRef(Y),o=n.useRef(null),ae=n.useRef(null),W=n.useRef(r),he=n.useRef(null),G=n.useRef(null),le=!!r.trim(),j=r.trim().split(`
7
- `)[0]??"",F=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";n.useEffect(()=>(M.current=!0,()=>{M.current=!1,o.current!==null&&window.clearTimeout(o.current),ae.current!==null&&window.clearTimeout(ae.current)}),[]),n.useEffect(()=>{let E=!1;const xe=Mi();return Zd().then(ge=>{if(E)return;const De=ge.contextDraftHeight?.[xe]??null;Cd(xe,De),_.current=De,be(De)}).catch(()=>{}),()=>{E=!0}},[]),n.useEffect(()=>{if(c!==void 0&&c>0){const E=he.current;if(!E)return;no()||E.focus(),E.setSelectionRange(E.value.length,E.value.length),E.scrollTop=E.scrollHeight}},[c]),n.useEffect(()=>{const E=W.current;W.current=r,!(!a||r.length<=E.length)&&(H(!0),ae.current!==null&&window.clearTimeout(ae.current),ae.current=window.setTimeout(()=>{ae.current=null,H(!1)},um))},[r,a]),n.useEffect(()=>{if(a)return;const E=he.current;E&&(E.style.height=Y!==null?`${Y}px`:"")},[r,a,Y]),n.useEffect(()=>{if(a)return;const E=he.current;!E||document.activeElement===E||(E.scrollTop=E.scrollHeight)},[r,a]),n.useEffect(()=>{if(a||no())return;const E=he.current;!E||document.activeElement===E||(E.focus(),E.setSelectionRange(E.value.length,E.value.length))},[a]);const ee=n.useRef(null);n.useLayoutEffect(()=>{if(!no())return;const E=window.visualViewport;if(!E)return;const xe=()=>{const ge=ee.current;if(!ge)return;if(E.height>=window.innerHeight*.75){ge.style.transform="";return}const De=ge.getBoundingClientRect(),Ve=Math.round(E.height-De.bottom);ge.style.transform=Ve!==0?`translateY(${Ve}px)`:""};return xe(),E.addEventListener("resize",xe),E.addEventListener("scroll",xe),()=>{E.removeEventListener("resize",xe),E.removeEventListener("scroll",xe),ee.current&&(ee.current.style.transform="")}},[a]);const C=E=>{P(E),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,P(null)},dm)},L=E=>{k(!1),no()&&window.requestAnimationFrame(()=>{const xe=he.current;if(!xe)return;xe.focus();const ge=xe.value.length;xe.setSelectionRange(ge,ge),window.requestAnimationFrame(()=>{xe.setSelectionRange(ge,ge)})})},q=async(E,xe)=>{if(!(!le||te.current)){te.current=!0,D(!0),P(null);try{await(E==="sent"?b(xe):R(xe))&&M.current&&C(E)}catch{}finally{te.current=!1,M.current&&D(!1)}}},ne=E=>{q("inserted",E.currentTarget)},pe=E=>{q("sent",E.currentTarget)},Ne=E=>{if(E.key==="Escape"){E.preventDefault(),k(!0);return}E.nativeEvent.isComposing||E.keyCode===229||E.key!=="Enter"||!E.metaKey&&!E.ctrlKey||(E.preventDefault(),pe(E))},we=E=>{E.preventDefault()},Pe=E=>{E.preventDefault();const xe=he.current;xe&&(G.current={startY:E.clientY,startHeight:xe.getBoundingClientRect().height},E.currentTarget.setPointerCapture?.(E.pointerId))},O=E=>{const xe=G.current;if(!xe)return;const ge=window.visualViewport?.height??window.innerHeight,De=Math.round(Math.min(Math.max(xe.startHeight+(xe.startY-E.clientY),du),ge*fm));_.current=De,be(De)},ue=E=>{const xe=Mi();Cd(xe,E),Zs({contextDraftHeight:{[xe]:E}}).catch(()=>{})},oe=()=>{G.current&&(G.current=null,_.current!==null&&ue(_.current))},Fe=()=>{_.current=null,be(null),ue(null)},Ie=r.length>0&&t.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:i.characterCount(r.length)});return a?t.jsx("section",{ref:ee,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:t.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[t.jsxs("button",{type:"button",onClick:()=>L(),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":i.expand,title:i.expand,children:[t.jsx(Qh,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),t.jsx("span",{className:`truncate text-[11px] ${f?"text-destructive":I?"text-primary":le?"text-foreground/80":"text-muted-foreground/50"}`,children:f??(I?i.appended:le?j:i.title)})]}),Ie,t.jsx("button",{type:"button",onClick:pe,disabled:!le||$,"aria-busy":$,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${le?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":i.send,title:i.send,children:$?t.jsx(yd,{size:12,className:"animate-spin"}):A==="sent"?t.jsx(go,{size:12}):t.jsx(gd,{size:12})})]})}):t.jsxs("section",{ref:ee,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[t.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:Pe,onPointerMove:O,onPointerUp:oe,onPointerCancel:oe,onDoubleClick:Fe,title:i.resize,"aria-hidden":"true",children:t.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),t.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[t.jsxs("button",{type:"button",onPointerDown:we,onClick:()=>k(!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":i.collapse,title:i.collapse,children:[t.jsx(aa,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:i.title}),Ie]}),t.jsx("button",{type:"button",role:"switch","aria-checked":p,onPointerDown:we,onClick:()=>m(!p),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":i.autoCollapseAfterSend,title:i.autoCollapseAfterSend,children:t.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${p?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${p?"translate-x-2.5":"translate-x-0.5"}`})})}),t.jsx("button",{type:"button",onPointerDown:we,onClick:x,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":i.disable,title:i.disable,children:t.jsx(Xt,{size:11})})]}),t.jsx("div",{className:"px-2 pb-2",children:t.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[t.jsx("textarea",{ref:he,value:r,onChange:E=>g(E.target.value),onKeyDown:Ne,placeholder:i.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}),t.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[t.jsx("button",{type:"button",onPointerDown:we,onClick:w,disabled:!le,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":i.clear,title:i.clear,children:t.jsx(co,{size:11})}),f?t.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:f}):t.jsx("span",{className:"flex-1"}),t.jsxs("button",{type:"button",onPointerDown:we,onClick:ne,disabled:!le||$,"aria-busy":$,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:[t.jsx(Zh,{size:11}),t.jsx("span",{children:$?i.pending??i.insert:A==="inserted"?i.inserted:i.insert})]}),t.jsxs("button",{type:"button",onPointerDown:we,onClick:pe,disabled:!le||$,"aria-busy":$,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:`${i.insertAndSend} · ${F}`,children:[$?t.jsx(yd,{size:11,className:"animate-spin"}):A==="sent"?t.jsx(go,{size:11}):t.jsx(gd,{size:11}),t.jsx("span",{children:A==="sent"?i.sent:i.send})]})]})]})})]})}function mm(r,a){const i=a.trim();if(!i)return r;if(!r.trim())return i;const c=r.endsWith(`
8
-
9
- `)?"":r.endsWith(`
10
- `)?`
11
- `:`
12
-
13
- `;return`${r}${c}${i}`}function gm(r,a){const i=r.trim();return i?a?`${i}\r`:/\s$/.test(r)?r:`${i} `:""}function bm(r,a){return{text:gm(r,a),options:{paste:/[\r\n]/.test(r),submitAfterPaste:a}}}function xm(r){const[a,i]=n.useState(null),c=n.useRef(null),f=n.useRef(null),p=n.useRef(!0),g=n.useRef(r);g.current=r,n.useEffect(()=>(p.current=!0,()=>{p.current=!1,c.current?.controller.abort()}),[]);const k=n.useCallback(async b=>{if(c.current)return!1;c.current=b,f.current=b;const A=P=>{b.task={...b.task,...P},p.current&&c.current===b&&i(b.task)};A({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const P=await Wi(b.task.directory,b.task.retryFiles,b.controller.signal);if(A({uploaded:[...b.task.uploaded,...P.files]}),g.current(b.task.directory),P.files.length!==b.task.retryFiles.length){const $=new Set(P.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw A({retryFiles:P.results?b.task.retryFiles.filter((D,te)=>!$.has(te)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}A({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){A({status:"inserting"});const P=b.task.uploaded[0]?.path;if(!P||!b.isCurrent?.()||!await b.insert(P)||!b.isCurrent?.()||b.controller.signal.aborted)return A({status:"error",error:"reference"}),!1}return A({status:"done"}),!0}catch(P){if(P instanceof Zc&&P.result?.files.length){const $=new Set(P.result.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);A({uploaded:[...b.task.uploaded,...P.result.files],retryFiles:P.result.results?b.task.retryFiles.filter((D,te)=>!$.has(te)):[]}),g.current(b.task.directory)}return A({status:b.controller.signal.aborted?"canceled":"error",error:P instanceof Zc&&P.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":P instanceof Error?P.message:String(P)}),!1}finally{c.current===b&&(c.current=null)}},[]),m=n.useCallback((b,A,P,$)=>A.length?k({task:{kind:P?"image":"files",directory:b,files:A,retryFiles:A,uploaded:[],status:"uploading"},controller:new AbortController,insert:P,isCurrent:$}):Promise.resolve(!1),[k]),x=n.useCallback(()=>{const b=f.current;if(!b||c.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const A={...b,controller:new AbortController,task:{...b.task}};return k(A)},[k]),w=n.useCallback(()=>{const b=c.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),R=n.useCallback(()=>{c.current||(f.current=null,i(null))},[]);return{task:a,start:m,retry:x,cancel:w,dismiss:R,busy:a?.status==="uploading"||a?.status==="inserting"}}function vm({task:r,labels:a,onCancel:i,onRetry:c,onDismiss:f}){const p=r.status==="uploading"||r.status==="inserting",g=r.error==="reference"?a.referenceRejected:r.error==="UPLOAD_LIMIT"?a.limit:r.status==="error"?`${a.failed}: ${r.error??""}`:a[r.status],k=r.status==="error"&&(r.kind==="image"&&r.uploaded.length>0||r.retryFiles.length>0&&r.retryFiles.length<=50);return t.jsxs("section",{className:"shrink-0 border-t border-border/20 bg-surface/80 px-3 py-2 text-xs","data-sidebar-upload-status":!0,"aria-busy":p,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`min-w-0 flex-1 break-words ${r.status==="error"?"text-destructive":"text-foreground"}`,role:r.status==="error"?"alert":"status",children:g}),r.status==="uploading"&&t.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:i,children:a.cancel}),k&&t.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:c,children:a.retry}),!p&&t.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-muted-foreground hover:bg-surface-2",onClick:f,"aria-label":a.dismiss,children:"×"})]}),t.jsx("div",{className:"mt-1 truncate text-muted-foreground",title:r.directory,children:r.directory}),t.jsxs("details",{className:"mt-1 min-w-0 text-muted-foreground",children:[t.jsxs("summary",{className:"cursor-pointer truncate",children:[a.files," · ",r.files[0]?.name]}),t.jsxs("ul",{className:"mt-1 max-h-24 overflow-y-auto font-mono text-[10px]",children:[r.files.map((m,x)=>t.jsx("li",{className:"break-all",children:m.name},`${x}:${m.name}`)),r.uploaded.map(m=>t.jsx("li",{className:"break-all text-foreground",children:m.path},m.path))]})]})]})}function ym(r){const a=n.useRef(r),i=n.useRef(0);(a.current.text!==r.text||a.current.sessionId!==r.sessionId||a.current.active!==r.active)&&(i.current+=1),a.current=r;const c=n.useRef(!0),f=n.useRef(!1);return n.useEffect(()=>(c.current=!0,()=>{c.current=!1,i.current+=1}),[]),n.useCallback(async(p,g)=>{if(f.current||!a.current.active)return!1;const k=a.current,m=i.current,{text:x,options:w}=bm(k.text,p);if(!x)return!1;f.current=!0;try{const R=await eu(x,k.sessionId,()=>c.current&&a.current.active&&a.current.sessionId===k.sessionId,g,w),b=c.current&&m===i.current;return b&&(R?a.current.onAccepted():a.current.onRejected()),R&&b}finally{f.current=!1}},[])}const Nd={status:"idle",error:null,result:null};function wm(r,a=!0){const[i,c]=n.useState(Nd),f=n.useRef(null);n.useEffect(()=>th(k=>{const m=f.current;!m||m.targetPeerId===k?.targetPeerId||(f.current=null,m.controller.abort(new DOMException("Download target changed","AbortError")),c({status:"canceled",error:null,result:"canceled"}))}),[]),n.useLayoutEffect(()=>(c(Nd),()=>{const k=f.current;f.current=null,k?.controller.abort()}),[r,a]);const p=n.useCallback(()=>{const k=f.current;k&&(f.current=null,k.controller.abort(),c({status:"canceled",error:null,result:"canceled"}))},[]),g=n.useCallback(async()=>{if(!a||!r||f.current)return;const k=new AbortController,m=rh()?.targetPeerId;f.current={controller:k,targetPeerId:m},c({status:"pending",error:null,result:null});try{const x=await nh(r,k.signal);if(f.current?.controller!==k)return;f.current=null;const w=k.signal.aborted?"canceled":x;c({status:w,error:null,result:w})}catch(x){if(f.current?.controller!==k)return;f.current=null,k.signal.aborted?c({status:"canceled",error:null,result:"canceled"}):c({status:"error",error:x instanceof Error?x.message:String(x),result:null})}},[r,a]);return{...i,start:g,cancel:p}}const Qi="termdock:right-sidebar:html-view-mode-by-file:v1";function km(r){return r==="preview"||r==="source"}function uu(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(km)}function fu(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Pd(r,a){const i=fu(r,a);return i?ct(Qi,uu)?.[i]??"source":"source"}function Sm(r,a,i){const c=fu(r,a);if(!c)return;const f=ct(Qi,uu)??{};Pt(Qi,{...f,[c]:i})}function Li(r){const a=Number.isFinite(r)&&r>0?Math.floor(r):0,i=Math.floor(a/3600),c=Math.floor(a%3600/60),f=a%60,p=String(c).padStart(2,"0"),g=String(f).padStart(2,"0");return i>0?`${i}:${p}:${g}`:`${p}:${g}`}function Rm(r,a,i){return!Number.isFinite(i)||i<=0||!a.width?0:Math.min(1,Math.max(0,(r-a.left)/a.width))*i}const Xr=2,jm=8,Cm=60,so=5,Ed=.05,Nm=900;function Pm(r){return!Number.isFinite(r)||r<=0?Xr:Math.min(jm,Xr+Math.floor(r/Cm))}const Em=350,Am=6,Tm=90;function Mm({url:r,onLoadError:a}){const i=Bh(r,a),{t:c}=_t(),f=n.useRef(null),p=n.useRef(null),g=n.useRef(null),k=n.useRef(null),m=n.useRef(!1),x=n.useRef(null),w=n.useRef(null),R=n.useRef(0),b=n.useRef(!1),A=n.useRef(!1),P=n.useRef(!1),$=n.useRef(null),D=n.useRef(null),te=n.useRef(!1),M=n.useRef(1),I=n.useRef(!1),[H,Y]=n.useState(0),[be,_]=n.useState(0),[o,ae]=n.useState(!1),[W,he]=n.useState(!1),[G,le]=n.useState(null),[j,F]=n.useState(!1),[ee,C]=n.useState(0),[L,q]=n.useState(!1),[ne,pe]=n.useState({width:0,height:0}),[Ne,we]=n.useState(Xr),[Pe,O]=n.useState(1),[ue,oe]=n.useState(null),Fe=n.useRef(Xr),Ie=n.useRef(null),E=n.useCallback(()=>{$.current!==null&&(clearTimeout($.current),$.current=null)},[]),xe=n.useCallback(()=>{E();const N=D.current;if(D.current=null,!te.current)return!1;const Q=g.current;if(Q&&(Q.playbackRate=M.current,N))try{Q.releasePointerCapture?.(N.id)}catch{}return te.current=!1,Fe.current=Xr,F(!1),!0},[E]);n.useEffect(()=>()=>{x.current!==null&&cancelAnimationFrame(x.current),w.current!==null&&clearTimeout(w.current),Ie.current!==null&&clearTimeout(Ie.current),E();const N=g.current;N&&te.current&&(N.playbackRate=M.current)},[E]),n.useEffect(()=>{const N=p.current;if(!N||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(([ke])=>{ke&&pe({width:ke.contentRect.width,height:ke.contentRect.height})});return Q.observe(N),()=>Q.disconnect()},[]),n.useEffect(()=>{const N=()=>q(document.fullscreenElement===f.current);return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]);const ge=n.useCallback((N,Q=!1)=>{const ke=g.current;if(!ke)return!1;const Ye=Number.isFinite(ke.duration)?ke.duration:N,ht=Math.min(Math.max(N,0),Ye);if(_(ht),Math.abs(ke.currentTime-ht)<1/120)return!1;const yr=ke.fastSeek;return Q&&typeof yr=="function"?yr.call(ke,ht):ke.currentTime=ht,!0},[]),De=n.useCallback(()=>{x.current===null&&(x.current=requestAnimationFrame(()=>{x.current=null;const N=g.current;if(!N||!b.current||A.current||N.seeking)return;const Q=P.current;P.current=!1,A.current=ge(R.current,!Q)}))},[ge]),Ve=n.useCallback(N=>{const Q=k.current,ke=g.current;if(!Q||!ke)return;const Ye=Q.getBoundingClientRect(),ht=Rm(N,Ye,ke.duration);R.current=ht,le(ht),P.current=!1,De(),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,P.current=!0,De()},Tm)},[De]),Ae=n.useCallback(()=>{x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),w.current!==null&&(clearTimeout(w.current),w.current=null),P.current=!1,A.current=!1,ge(R.current)},[ge]),Jt=n.useCallback(N=>{const Q=g.current;if(!(!Q||!Number.isFinite(Q.duration)||Q.duration<=0)){m.current=!Q.paused,Q.pause(),b.current=!0,he(!0);try{N.currentTarget.setPointerCapture(N.pointerId)}catch{}Ve(N.clientX)}},[Ve]),Be=n.useCallback(()=>{b.current=!1,Ae(),he(!1),le(null);const N=g.current;N&&m.current&&!N.ended&&N.play().catch(()=>{}),m.current=!1},[Ae]),ft=n.useCallback(()=>{const N=g.current;if(N){if(I.current){I.current=!1;return}N.paused?N.play().catch(()=>{}):N.pause()}},[]),Ue=n.useCallback(N=>{const Q=g.current;if(!Q)return;const ke=Math.min(1,Math.max(0,Math.round((Q.volume+N)*100)/100));Q.volume=ke,ke>0&&(Q.muted=!1),O(ke),oe(ke),Ie.current!==null&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>{Ie.current=null,oe(null)},Nm)},[]),Qt=n.useCallback(N=>{const Q=g.current;if(Q){if(N.key==="ArrowLeft"){N.preventDefault(),ge(Q.currentTime-(N.shiftKey?so*2:so));return}if(N.key==="ArrowRight"){N.preventDefault(),ge(Q.currentTime+(N.shiftKey?so*2:so));return}if(N.key==="ArrowUp"){N.preventDefault(),Ue(Ed);return}if(N.key==="ArrowDown"){N.preventDefault(),Ue(-Ed);return}(N.key===" "||N.key==="Spacebar"||N.key==="k"||N.key==="K")&&(N.preventDefault(),Q.paused?Q.play().catch(()=>{}):Q.pause())}},[ge,Ue]),me=n.useCallback(N=>{const Q=g.current;!Q||Q.paused||N.button!==0||(E(),D.current={id:N.pointerId,x:N.clientX,y:N.clientY},$.current=setTimeout(()=>{$.current=null;const ke=D.current;if(M.current=Q.playbackRate,Q.playbackRate=Xr,Fe.current=Xr,we(Xr),te.current=!0,F(!0),ke)try{Q.setPointerCapture?.(ke.id)}catch{}},Em))},[E]),dt=n.useCallback(N=>{const Q=D.current;if(!Q||Q.id!==N.pointerId)return;if(!te.current){Math.hypot(N.clientX-Q.x,N.clientY-Q.y)>Am&&(E(),D.current=null);return}const ke=Pm(N.clientX-Q.x);if(ke===Fe.current)return;Fe.current=ke,we(ke);const Ye=g.current;Ye&&(Ye.playbackRate=ke)},[E]),at=n.useCallback(()=>{xe()&&(I.current=!0)},[xe]);n.useEffect(()=>(window.addEventListener("pointerup",at),window.addEventListener("pointercancel",at),window.addEventListener("blur",at),()=>{window.removeEventListener("pointerup",at),window.removeEventListener("pointercancel",at),window.removeEventListener("blur",at)}),[at]);const bt=n.useCallback(async()=>{const N=f.current,Q=g.current;if(!(!N||!Q))try{document.fullscreenElement===N?await document.exitFullscreen():N.requestFullscreen?await N.requestFullscreen():Q.webkitEnterFullscreen?.()}catch{Q.webkitEnterFullscreen?.()}},[]),Oe=n.useCallback(()=>C(N=>(N+90)%360),[]),V=n.useCallback(N=>{const Q=g.current;if(!Q||!Number.isFinite(Q.duration))return;const ke=N.shiftKey?10:5;let Ye=null;N.key==="ArrowLeft"?Ye=Q.currentTime-ke:N.key==="ArrowRight"?Ye=Q.currentTime+ke:N.key==="Home"?Ye=0:N.key==="End"&&(Ye=Q.duration),Ye!==null&&(N.preventDefault(),ge(Ye))},[ge]),ye=W&&G!==null?G:be,Ze=H>0?Math.min(1,Math.max(0,ye/H)):0,ir=(ee===90||ee===270)&&ne.width>0&&ne.height>0?{width:`${ne.height}px`,height:`${ne.width}px`}:{width:"100%",height:"100%"};return t.jsxs("div",{ref:f,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":ee,children:[t.jsxs("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[t.jsx("video",{ref:g,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${j?` ${wd}`:""}`,style:{...ir,transform:`translate(-50%, -50%) rotate(${ee}deg)`},src:i,preload:"auto",playsInline:!0,tabIndex:0,...j?{[kd]:""}:{},onClick:ft,onKeyDown:Qt,onVolumeChange:N=>O(N.currentTarget.volume),onPointerDown:me,onPointerMove:dt,onPointerUp:at,onPointerCancel:at,onContextMenu:N=>{te.current&&N.preventDefault()},onPlay:()=>ae(!0),onPause:()=>ae(!1),onTimeUpdate:N=>_(N.currentTarget.currentTime),onSeeked:N=>{const Q=N.currentTarget;if(_(Q.currentTime),A.current=!1,!b.current)return;const ke=Q.requestVideoFrameCallback;typeof ke=="function"?ke.call(Q,()=>{b.current&&De()}):requestAnimationFrame(()=>{b.current&&De()})},onLoadedMetadata:N=>Y(Number.isFinite(N.currentTarget.duration)?N.currentTarget.duration:0),onDurationChange:N=>Y(Number.isFinite(N.currentTarget.duration)?N.currentTarget.duration:0),onError:a,children:c("rightSidebar.videoUnsupported")}),j&&t.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:c("rightSidebar.videoLongPressSpeed",{rate:String(Ne)})}),ue!==null&&t.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[t.jsx(hp,{size:13}),c("rightSidebar.videoVolume",{percent:Math.round(Pe*100)})]}),W&&G!==null&&t.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${Ze*100}%`},"data-testid":"file-preview-video-scrub-time",children:Li(G)})]}),t.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${wd}`,[kd]:"",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:ft,"aria-label":c(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:c(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:o?t.jsx(ep,{size:14}):t.jsx(tp,{size:14})}),t.jsxs("div",{ref:k,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(H),"aria-valuenow":Math.floor(ye),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:Jt,onPointerMove:N=>{W&&Ve(N.clientX)},onPointerUp:Be,onPointerCancel:Be,onKeyDown:V,children:[t.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),t.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${Ze*100}%`}}),t.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${Ze*100}%`}})]}),t.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Li(ye)," / ",Li(H)]}),t.jsx("button",{type:"button",onClick:Oe,"aria-label":c("rightSidebar.videoRotate"),title:c("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:t.jsx(ou,{size:14})}),t.jsx("button",{type:"button",onClick:()=>{bt()},"aria-label":c(L?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:c(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:L?t.jsx(pp,{size:14}):t.jsx(mp,{size:14})})]})})]})}function Lm(r){const a=Math.max(0,Math.min(100,r.xPercent)),i=Math.max(0,Math.min(100,r.yPercent));return{...a<=50?{left:`calc(${a}% + 8px)`}:{right:`calc(${100-a}% + 8px)`},...i<=50?{top:`calc(${i}% + 8px)`}:{bottom:`calc(${100-i}% + 8px)`}}}function wo({anchor:r,children:a,disabled:i=!1,onClick:c,title:f}){return t.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:i,onClick:p=>{p.stopPropagation(),c(p.currentTarget)},title:f,style:Lm(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[t.jsx(bo,{size:11}),a]})}function Im(r,a,i,c){if(i.width<=0||i.height<=0||c.width<=0||c.height<=0)return null;const f=Math.min(i.width/c.width,i.height/c.height);if(!Number.isFinite(f)||f<=0)return null;const p=c.width*f,g=c.height*f,k=i.left+(i.width-p)/2,m=i.top+(i.height-g)/2,x=r-k,w=a-m;if(x<0||w<0||x>p||w>g)return null;const R=x/p*100,b=w/g*100;return{x:c.x+c.width*R/100,y:c.y+c.height*b/100,xPercent:R,yPercent:b}}function $m(r,a,i){const c=[`SVG标注: ${r}`,`视图: ${a}`,`SVG坐标: (${i.x.toFixed(2)},${i.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${i.xPercent.toFixed(1)}%,${i.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return i.nearestText&&c.push(`最近文字: ${i.nearestText}`),`"${c.join(" / ")}"`}function Fm(r){const a=new DOMParser().parseFromString(r,"image/svg+xml"),i=a.documentElement;if(i.nodeName.toLowerCase()!=="svg"||a.querySelector("parsererror"))throw new Error("Invalid SVG document");return a.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(c=>c.remove()),a.querySelectorAll("*").forEach(c=>{for(const f of Array.from(c.attributes)){const p=f.name.toLowerCase(),g=f.value.trim();(p.startsWith("on")||(p==="href"||p.endsWith(":href"))&&g&&!g.startsWith("#"))&&c.removeAttribute(f.name)}}),i.removeAttribute("width"),i.removeAttribute("height"),i.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(i)}function Dm(r,a,i){let c=null;for(const f of Array.from(r.querySelectorAll("text"))){const p=(f.textContent??"").replace(/\s+/g," ").trim();if(!p)continue;const g=Number(f.getAttribute("x")),k=Number(f.getAttribute("y"));if(!Number.isFinite(g)||!Number.isFinite(k))continue;const m=Math.hypot(g-a,k-i);(!c||m<c.distance)&&(c={text:p,distance:m})}return c?.text.slice(0,120)}function hu({blobUrl:r,filePath:a,viewLabel:i,onInsertAnnotation:c}){const f=n.useRef(null),p=n.useRef(null),[g,k]=n.useState(null),[m,x]=n.useState(null),[w,R]=n.useState(1),[b,A]=n.useState(!1),[P,$]=n.useState(null),D=n.useRef(new Map),te=n.useRef(null),M=n.useRef(!1),I=n.useRef(null),H=n.useRef(w);H.current=w,n.useEffect(()=>{const C=new AbortController;return k(null),x(null),$(null),R(1),fetch(r,{signal:C.signal}).then(L=>L.text()).then(L=>k(Fm(L))).catch(L=>{C.signal.aborted||x(L instanceof Error?L.message:"SVG preview failed")}),()=>C.abort()},[r]),n.useEffect(()=>{if(!b)return;const C=L=>{L.key==="Escape"&&A(!1)};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[b]),n.useLayoutEffect(()=>{const C=p.current,L=C?.querySelector("[data-svg-document] > svg");if(!C||!L)return;let q;try{q=L.getBBox()}catch{return}if(!q.width||!q.height)return;const ne=Math.max(2,Math.min(q.width,q.height)*.025);L.setAttribute("viewBox",`${q.x-ne} ${q.y-ne} ${q.width+2*ne} ${q.height+2*ne}`),L.style.width=`${w*100}%`,L.style.height=`${w*100}%`,L.style.minWidth=`${w*100}%`,L.style.minHeight=`${w*100}%`,L.style.display="block"},[g,w]);const Y=n.useMemo(()=>P?$m(a,i,P):null,[a,P,i]),be=C=>{if(M.current){M.current=!1;return}const L=p.current,q=L?.querySelector("[data-svg-document] > svg"),ne=f.current;if(!L||!q||!ne)return;const pe=q.viewBox.baseVal,Ne=Im(C.clientX,C.clientY,q.getBoundingClientRect(),pe);if(!Ne)return;const we=ne.getBoundingClientRect();$({...Ne,nearestText:Dm(q,Ne.x,Ne.y),stageX:C.clientX-we.left,stageY:C.clientY-we.top,stageXPercent:(C.clientX-we.left)/we.width*100,stageYPercent:(C.clientY-we.top)/we.height*100})},_=C=>Math.max(1,Math.min(12,C)),o=(C,L)=>{const q=_(L),ne=C.querySelector("[data-svg-document] > svg");if(!ne)return q;const pe=`${q*100}%`;return ne.style.width=pe,ne.style.height=pe,ne.style.minWidth=pe,ne.style.minHeight=pe,H.current=q,q},ae=(C,L,q,ne)=>{const pe=H.current,Ne=C.getBoundingClientRect(),we=q-Ne.left,Pe=ne-Ne.top,O=(C.scrollLeft+we)/pe,ue=(C.scrollTop+Pe)/pe,oe=o(C,L);return C.scrollLeft=O*oe-we,C.scrollTop=ue*oe-Pe,oe},W=()=>{const C=Array.from(D.current.values());return C.length>=2?Math.hypot(C[0].x-C[1].x,C[0].y-C[1].y):0},he=C=>{if(C.pointerType==="mouse"&&C.button!==0)return;const L=p.current;L&&(D.current.set(C.pointerId,{x:C.clientX,y:C.clientY}),L.setPointerCapture?.(C.pointerId),D.current.size>=2?(te.current={kind:"pinch",startX:C.clientX,startY:C.clientY,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startDistance:W(),startZoom:H.current,moved:!1},M.current=!0):H.current>1&&(te.current={kind:"pan",startX:C.clientX,startY:C.clientY,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startZoom:H.current,moved:!1}))},G=C=>{if(!D.current.has(C.pointerId))return;D.current.set(C.pointerId,{x:C.clientX,y:C.clientY});const L=p.current,q=te.current;if(!(!L||!q)){if(D.current.size>=2&&q.kind==="pinch"){const ne=W();if(!q.startDistance||!ne)return;const pe=_(q.startZoom*ne/q.startDistance);if(Math.abs(pe-H.current)<.01)return;const Ne=Array.from(D.current.values()),we=(Ne[0].x+Ne[1].x)/2,Pe=(Ne[0].y+Ne[1].y)/2;q.moved=!0,M.current=!0,ae(L,pe,we,Pe),C.preventDefault();return}if(q.kind==="pan"&&D.current.size===1){const ne=C.clientX-q.startX,pe=C.clientY-q.startY;if(!q.moved&&Math.hypot(ne,pe)<6)return;q.moved=!0,M.current=!0,L.scrollLeft=q.startScrollLeft-ne,L.scrollTop=q.startScrollTop-pe,C.preventDefault()}}},le=C=>{const L=p.current,q=te.current,ne=D.current.size===1&&!q?.moved;D.current.delete(C.pointerId);try{L?.releasePointerCapture?.(C.pointerId)}catch{}if(D.current.size===1&&q?.kind==="pinch"){const we=Array.from(D.current.values())[0];te.current=L?{kind:"pan",startX:we.x,startY:we.y,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startZoom:H.current,moved:!1}:null;return}if(D.current.size>0||(te.current=null,q?.kind==="pinch"&&R(H.current),!ne||M.current))return;const pe=Date.now(),Ne=I.current;Ne&&pe-Ne.time<350&&Math.hypot(C.clientX-Ne.x,C.clientY-Ne.y)<24?(I.current=null,M.current=!0,R(we=>we>1?1:2.5)):I.current={time:pe,x:C.clientX,y:C.clientY}},j=C=>{if(!C.ctrlKey&&!C.metaKey)return;const L=p.current;if(!L)return;C.preventDefault();const q=ae(L,H.current*Math.exp(-C.deltaY*.01),C.clientX,C.clientY);R(q)},F=()=>{R(1),H.current=1,p.current&&(p.current.scrollLeft=0,p.current.scrollTop=0)},ee=t.jsxs("div",{className:b?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[t.jsxs("div",{ref:f,className:"relative min-h-0 flex-1",children:[t.jsx("div",{ref:p,role:"button",tabIndex:0,onClick:be,onDoubleClick:C=>{C.preventDefault(),R(L=>L>1?1:2.5)},onPointerDown:he,onPointerMove:G,onPointerUp:le,onPointerCancel:le,onWheel:j,onScroll:()=>$(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:m?t.jsx("div",{className:"p-4 text-sm text-destructive",children:m}):g?t.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:g}}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),P&&t.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:P.stageX,top:P.stageY}}),P&&Y&&t.jsx(wo,{anchor:{xPercent:P.stageXPercent,yPercent:P.stageYPercent},title:"引用 SVG 标注",onClick:async C=>{await c?.(Y,`svg:${P.x.toFixed(2)}:${P.y.toFixed(2)}`,void 0,C)!==!1&&$(null)},children:"引用 SVG 标注"}),t.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[w>1.001&&t.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:C=>{C.stopPropagation(),F()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:t.jsx(Bp,{size:14})}),t.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:C=>{C.stopPropagation(),A(L=>!L)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:b?t.jsx(au,{size:14}):t.jsx(iu,{size:14})})]})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:P?`SVG (${P.x.toFixed(2)}, ${P.y.toFixed(2)}) · ${P.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return b?Qr.createPortal(ee,document.body):ee}function fo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function _m(r,a,i,c){const f=[`电子标注: ${r}`,`视图: ${fo(a)}`,`图片位置: (${i.xPercent.toFixed(1)}%,${i.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(c?.available&&c.xMm!==void 0&&c.yMm!==void 0&&(f.push(`PCB坐标: (${c.xMm.toFixed(2)},${c.yMm.toFixed(2)})mm [KiCad板坐标]`),c.layer&&f.push(`显示层: ${c.layer}`),c.nearest)){const p=[c.nearest.net?`网络 ${c.nearest.net}`:null,`对象层 ${c.nearest.layer}`,`距离 ${c.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");f.push(`最近对象: ${c.nearest.label}${p?`(${p})`:""}`)}return`"${f.join(" / ")}"`}function Bm({blobUrl:r,filePath:a,view:i,board:c,onViewChange:f,onInsertAnnotation:p,onRefresh:g,interactive3d:k}){const{t:m}=_t(),x=n.useRef(null),w=n.useRef(null),R=n.useRef(null),[b,A]=n.useState(null),[P,$]=n.useState(!1);n.useEffect(()=>(R.current?.abort(),A(null),$(!1),()=>R.current?.abort()),[r,i]);const D=n.useMemo(()=>b?_m(a,i,b,b.inspection):null,[a,b,i]),te=I=>{const H=x.current,Y=w.current;if(!H||!Y||!Y.naturalWidth||!Y.naturalHeight)return;const be=H.getBoundingClientRect(),_=Y.getBoundingClientRect(),o=Math.min(_.width/Y.naturalWidth,_.height/Y.naturalHeight),ae=Y.naturalWidth*o,W=Y.naturalHeight*o,he=_.left+(_.width-ae)/2,G=_.top+(_.height-W)/2,le=I.clientX-he,j=I.clientY-G;if(le<0||j<0||le>ae||j>W)return;const F={xPercent:Math.max(0,Math.min(100,le/ae*100)),yPercent:Math.max(0,Math.min(100,j/W*100)),stageXPercent:(I.clientX-be.left)/be.width*100,stageYPercent:(I.clientY-be.top)/be.height*100,inspecting:c&&i!=="pcb-3d"};if(A(F),R.current?.abort(),!F.inspecting)return;const ee=new AbortController;R.current=ee,sh(a,i,F.xPercent,F.yPercent,ee.signal).then(C=>A(L=>L===F?{...L,inspection:C,inspecting:!1}:L)).catch(()=>{ee.signal.aborted||A(C=>C===F?{...C,inspection:{available:!1},inspecting:!1}:C)})},M=c?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:M.map(I=>t.jsx("button",{type:"button",onClick:()=>f(I),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${I===i?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:fo(I)},I))}),t.jsx("button",{type:"button",onClick:g,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:m("rightSidebar.edaRefresh"),"aria-label":m("rightSidebar.edaRefresh"),children:t.jsx(uo,{size:13})})]}),c&&k?t.jsx("div",{className:i==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:k}):null,c?i==="pcb-3d"?k?null:t.jsx("div",{className:"min-h-0 flex-1"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:x,role:"button",tabIndex:0,onClick:te,onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),A({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:m("rightSidebar.edaPickHint"),children:[t.jsx("img",{ref:w,src:r,alt:`${a} ${fo(i)}`,onLoad:()=>$(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${P?"opacity-100":"opacity-0"}`}),b&&t.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${b.stageXPercent}%`,top:`${b.stageYPercent}%`}}),b&&D&&t.jsx(wo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:m("rightSidebar.edaInsertAnnotation"),onClick:async I=>{await p?.(D,`eda:${i}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:w.current?qp(w.current,b):Promise.resolve(null)},I)!==!1&&A(null)},children:m("rightSidebar.edaInsertAnnotation")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:b?b.inspecting?m("rightSidebar.edaInspecting"):b.inspection?.available?m("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??m("rightSidebar.edaNoNearbyObject")}):m("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):m("rightSidebar.edaPickHint")})})]}):t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(hu,{blobUrl:r,filePath:a,viewLabel:fo(i),onInsertAnnotation:p})})]})}function Um(r){const a=[];let i=[],c="",f=!1;for(let p=0;p<r.length;p+=1){const g=r[p];f?g==='"'&&r[p+1]==='"'?(c+='"',p+=1):g==='"'?f=!1:c+=g:g==='"'?f=!0:g===","?(i.push(c),c=""):g===`
14
- `?(i.push(c.replace(/\r$/,"")),a.push(i),i=[],c=""):c+=g}return(c||i.length>0)&&(i.push(c.replace(/\r$/,"")),a.push(i)),a}function Om(r,a,i,c,f){const p=a[f]||`第${f+1}列`,g=i[f]??"",k=a.map((m,x)=>`${m||`第${x+1}列`}=${i[x]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${c+1} / 列: ${p} / 值: ${g} / 记录: ${k}"`}function Hm({content:r,filePath:a,onInsertAnnotation:i}){const{t:c}=_t(),f=n.useMemo(()=>Um(r),[r]),p=f[0]??[],g=f.slice(1),k=n.useRef(null),[m,x]=n.useState(null),w=m?g[m.row]:null,R=m&&w?Om(a,p,w,m.row+1,m.column):null;return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[t.jsxs("div",{ref:k,className:"relative min-h-0 flex-1",children:[t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.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:"#"}),p.map((b,A)=>t.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:b||c("rightSidebar.csvUnnamedColumn",{index:A+1})},`${b}:${A}`))]})}),t.jsx("tbody",{children:g.map((b,A)=>t.jsxs("tr",{className:"hover:bg-surface-2",children:[t.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:A+1}),p.map((P,$)=>{const D=m?.row===A&&m.column===$;return t.jsx("td",{className:`border-b border-r border-border/15 p-0 ${D?"bg-primary/15":""}`,children:t.jsx("button",{type:"button",onClick:te=>{const M=k.current?.getBoundingClientRect(),I=te.currentTarget.getBoundingClientRect();if(!M?.width||!M.height)return;const H=te.clientX||I.left+I.width/2,Y=te.clientY||I.top+I.height/2;x({row:A,column:$,xPercent:(H-M.left)/M.width*100,yPercent:(Y-M.top)/M.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:b[$]||" "})},`cell:${A}:${$}`)})]},`row:${A}`))})]})}),m&&R&&t.jsx(wo,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:c("rightSidebar.csvInsertAnnotation"),onClick:async b=>{await i?.(R,`csv:${a}:${m.row+1}:${m.column+1}`,void 0,b)!==!1&&x(null)},children:c("rightSidebar.csvInsertAnnotation")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:m&&w?c("rightSidebar.csvSelectedCell",{row:m.row+1,column:p[m.column]||m.column+1}):c("rightSidebar.csvPickHint",{rows:g.length,columns:p.length})})})]})}function ls(r,a){let i=r;for(const c of a){if(!i||typeof i!="object")return;i=i[c]}return i}function zm(r,a){const i=JSON.parse(r),c=ls(i,["meta","version"]);if(a)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(c??"未知")},{label:"活动层编号",value:String(ls(i,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(ls(i,["board","visible_layers"])??"未知")},{label:"Git 集成",value:ls(i,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const f=ls(i,["net_settings","classes"]),p=Array.isArray(f)?f.find(k=>k&&typeof k=="object"&&k.name==="Default"):void 0,g=ls(i,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(c??"未知")},{label:"网络类数量",value:String(Array.isArray(f)?f.length:0)},{label:"默认间距",value:p?.clearance!==void 0?`${p.clearance} mm`:"未设置"},{label:"默认线宽",value:p?.track_width!==void 0?`${p.track_width} mm`:"未设置"},{label:"默认过孔",value:p?.via_diameter!==void 0?`${p.via_diameter} / ${p.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(g)?g.length:0)}]}function Gm(r,a){return`"KiCad项目标注: ${r} / 项: ${a.label} / 值: ${a.value}"`}function Wm({content:r,filePath:a,localState:i,onInsertAnnotation:c}){const{t:f}=_t(),p=n.useRef(null),[g,k]=n.useState(null),m=n.useMemo(()=>{try{return{items:zm(r,i),error:null}}catch(w){return{items:[],error:w instanceof Error?w.message:String(w)}}},[r,i]),x=g===null?null:m.items[g.index];return m.error?t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[i&&t.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:f("rightSidebar.kicadLocalStateNotice")}),t.jsxs("div",{ref:p,className:"relative min-h-0 flex-1",children:[t.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[t.jsx("div",{className:"divide-y divide-border/15",children:m.items.map((w,R)=>t.jsxs("button",{type:"button",onClick:b=>{const A=p.current?.getBoundingClientRect(),P=b.currentTarget.getBoundingClientRect();if(!A?.width||!A.height)return;const $=b.clientX||P.left+P.width/2,D=b.clientY||P.top+P.height/2;k({index:R,xPercent:($-A.left)/A.width*100,yPercent:(D-A.top)/A.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 ${g?.index===R?"bg-primary/10":""}`,children:[t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:w.label}),t.jsx("span",{className:"break-words text-xs text-foreground",children:w.value})]},w.label))}),t.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[t.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:f("rightSidebar.kicadShowRawJson")}),t.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),x&&g&&t.jsx(wo,{anchor:{xPercent:g.xPercent,yPercent:g.yPercent},title:f("rightSidebar.kicadInsertSetting"),onClick:async w=>{await c?.(Gm(a,x),`kicad-project:${a}:${x.label}`,void 0,w)!==!1&&k(null)},children:f("rightSidebar.kicadInsertSetting")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:x?`${x.label}: ${x.value}`:f("rightSidebar.kicadProjectPickHint")})})]})}const qm=`/** ES Module Shims Wasm @version 2.8.4 */
15
- (function () {
16
-
17
- const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
18
-
19
- let invalidate;
20
- const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
21
- const initHotReload = (topLevelLoad, importShim) => {
22
- let _importHook = importHook,
23
- _resolveHook = resolveHook,
24
- _metaHook = metaHook;
25
-
26
- let defaultResolve;
27
- let hotResolveHook = (id, parent, _defaultResolve) => {
28
- if (!defaultResolve) defaultResolve = _defaultResolve;
29
- const originalParent = stripVersion(parent);
30
- const url = stripVersion(defaultResolve(id, originalParent));
31
- const hotState = getHotState(url);
32
- const parents = hotState.p;
33
- if (!parents.includes(originalParent)) parents.push(originalParent);
34
- return toVersioned(url, hotState);
35
- };
36
- const hotImportHook = (url, _, __, source, sourceType) => {
37
- const hotState = getHotState(url);
38
- hotState.e = typeof source === 'string' ? source : true;
39
- hotState.t = sourceType;
40
- };
41
- const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
42
-
43
- const Hot = class Hot {
44
- constructor(url) {
45
- this.data = getHotState((this.url = stripVersion(url))).d;
46
- }
47
- accept(deps, cb) {
48
- if (typeof deps === 'function') {
49
- cb = deps;
50
- deps = null;
51
- }
52
- const hotState = getHotState(this.url);
53
- if (!hotState.A) return;
54
- (hotState.a = hotState.a || []).push([
55
- typeof deps === 'string' ? defaultResolve(deps, this.url)
56
- : deps ? deps.map(d => defaultResolve(d, this.url))
57
- : null,
58
- cb
59
- ]);
60
- }
61
- dispose(cb) {
62
- getHotState(this.url).u = cb;
63
- }
64
- invalidate() {
65
- const hotState = getHotState(this.url);
66
- hotState.a = hotState.A = null;
67
- const seen = [this.url];
68
- hotState.p.forEach(p => invalidate(p, this.url, seen));
69
- }
70
- };
71
-
72
- const versionedRegEx = /\\?v=\\d+$/;
73
- const stripVersion = url => {
74
- const versionMatch = url.match(versionedRegEx);
75
- return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
76
- };
77
-
78
- const toVersioned = (url, hotState) => {
79
- const { v } = hotState;
80
- return url + (v ? '?v=' + v : '');
81
- };
82
-
83
- let hotRegistry = {},
84
- curInvalidationRoots = new Set(),
85
- curInvalidationInterval;
86
- const getHotState = url =>
87
- hotRegistry[url] ||
88
- (hotRegistry[url] = {
89
- // version
90
- v: 0,
91
- // accept list ([deps, cb] pairs)
92
- a: null,
93
- // accepting acceptors
94
- A: true,
95
- // unload callback
96
- u: null,
97
- // entry point or inline script source
98
- e: false,
99
- // hot data
100
- d: {},
101
- // parents
102
- p: [],
103
- // source type
104
- t: undefined
105
- });
106
-
107
- invalidate = (url, fromUrl, seen = []) => {
108
- const hotState = hotRegistry[url];
109
- if (!hotState || seen.includes(url)) return false;
110
- seen.push(url);
111
- hotState.A = false;
112
- if (
113
- fromUrl &&
114
- hotState.a &&
115
- hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
116
- ) {
117
- curInvalidationRoots.add(fromUrl);
118
- } else {
119
- if (hotState.e || hotState.a) curInvalidationRoots.add(url);
120
- hotState.v++;
121
- if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
122
- }
123
- if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
124
- return true;
125
- };
126
-
127
- const handleInvalidations = () => {
128
- curInvalidationInterval = null;
129
- const earlyRoots = new Set();
130
- for (const root of curInvalidationRoots) {
131
- const hotState = hotRegistry[root];
132
- topLevelLoad(
133
- toVersioned(root, hotState),
134
- baseUrl,
135
- defaultFetchOpts,
136
- typeof hotState.e === 'string' ? hotState.e : undefined,
137
- false,
138
- undefined,
139
- hotState.t
140
- ).then(m => {
141
- if (hotState.a) {
142
- hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
143
- // unload should be the latest unload handler from the just loaded module
144
- if (hotState.u) {
145
- hotState.u(hotState.d);
146
- hotState.u = null;
147
- }
148
- }
149
- hotState.p.forEach(p => {
150
- const hotState = hotRegistry[p];
151
- if (hotState && hotState.a)
152
- hotState.a.forEach(
153
- async ([d, c]) =>
154
- d &&
155
- !earlyRoots.has(c) &&
156
- (typeof d === 'string' ?
157
- d === root && c(m)
158
- : c(await Promise.all(d.map(d => (earlyRoots.add(c), importShim(toVersioned(d, getHotState(d))))))))
159
- );
160
- });
161
- }, throwError);
162
- }
163
- curInvalidationRoots = new Set();
164
- };
165
-
166
- setHooks(
167
- _importHook ? chain(_importHook, hotImportHook) : hotImportHook,
168
- _resolveHook ?
169
- (id, parent, defaultResolve) =>
170
- hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
171
- : hotResolveHook,
172
- _metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
173
- );
174
- };
175
-
176
- const hasDocument = typeof document !== 'undefined';
177
-
178
- const noop = () => {};
179
-
180
- const chain = (a, b) =>
181
- function () {
182
- a.apply(this, arguments);
183
- b.apply(this, arguments);
184
- };
185
-
186
- const dynamicImport = (u, _errUrl) => import(u);
187
-
188
- const defineValue = (obj, prop, value) =>
189
- Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
190
-
191
- const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
192
-
193
- const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
194
- Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
195
-
196
- const version = "2.8.4";
197
-
198
- const r$1 = esmsInitOptions.version;
199
- if (self_.importShim || (r$1 && r$1 !== version)) {
200
- return;
201
- }
202
-
203
- // shim mode is determined on initialization, no late shim mode
204
- const shimMode =
205
- esmsInitOptions.shimMode ||
206
- (hasDocument ?
207
- document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
208
- .length > 0
209
- // Without a document, shim mode is always true as we cannot polyfill
210
- : true);
211
-
212
- let importHook,
213
- resolveHook,
214
- fetchHook = fetch,
215
- sourceHook,
216
- metaHook,
217
- tsTransform =
218
- esmsInitOptions.tsTransform ||
219
- (hasDocument && document.currentScript && document.currentScript.src.replace(/(\\.\\w+)?\\.js$/, '-typescript.js')) ||
220
- './es-module-shims-typescript.js';
221
-
222
- const defaultFetchOpts = { credentials: 'same-origin' };
223
-
224
- const globalHook = name => (typeof name === 'string' ? self_[name] : name);
225
-
226
- if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
227
- if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
228
- if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
229
- if (esmsInitOptions.source) sourceHook = globalHook(esmsInitOptions.source);
230
- if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
231
-
232
- const hasCustomizationHooks = importHook || resolveHook || fetchHook !== fetch || sourceHook || metaHook;
233
-
234
- const {
235
- noLoadEventRetriggers,
236
- enforceIntegrity,
237
- hotReload,
238
- hotReloadInterval = 100,
239
- nativePassthrough = !hasCustomizationHooks && !hotReload
240
- } = esmsInitOptions;
241
-
242
- const setHooks = (importHook_, resolveHook_, metaHook_) => (
243
- (importHook = importHook_),
244
- (resolveHook = resolveHook_),
245
- (metaHook = metaHook_)
246
- );
247
-
248
- const mapOverrides = esmsInitOptions.mapOverrides;
249
-
250
- let nonce = esmsInitOptions.nonce;
251
- if (!nonce && hasDocument) {
252
- const nonceElement = document.querySelector('script[nonce]');
253
- if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
254
- }
255
-
256
- const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
257
-
258
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
259
- const disable = Array.isArray(esmsInitOptions.polyfillDisable) ? esmsInitOptions.polyfillDisable : [];
260
-
261
- const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
262
- const wasmInstancePhaseEnabled =
263
- enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
264
- const wasmSourcePhaseEnabled =
265
- enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
266
- const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
267
- const cssModulesEnabled = !disable.includes('css-modules');
268
- const jsonModulesEnabled = !disable.includes('json-modules');
269
-
270
- const onpolyfill =
271
- esmsInitOptions.onpolyfill ?
272
- globalHook(esmsInitOptions.onpolyfill)
273
- : () => {
274
- console.log(\`%c^^ Module error above is polyfilled and can be ignored ^^\`, 'font-weight:900;color:#391');
275
- };
276
-
277
- const baseUrl =
278
- hasDocument ? document.baseURI
279
- : typeof location !== 'undefined' ?
280
- \`\${location.protocol}//\${location.host}\${
281
- location.pathname.includes('/') ?
282
- location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
283
- : location.pathname
284
- }\`
285
- : 'about:blank';
286
-
287
- const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
288
- let { skip } = esmsInitOptions;
289
- if (Array.isArray(skip)) {
290
- const l = skip.map(s => new URL(s, baseUrl).href);
291
- skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
292
- } else if (typeof skip === 'string') {
293
- const r = new RegExp(skip);
294
- skip = s => r.test(s);
295
- } else if (skip instanceof RegExp) {
296
- skip = s => skip.test(s);
297
- }
298
-
299
- const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
300
-
301
- const throwError = err => {
302
- (self_.reportError || dispatchError)(err);
303
- onerror(err);
304
- };
305
-
306
- const fromParent = parent => (parent ? \` imported from \${parent}\` : '');
307
-
308
- const backslashRegEx = /\\\\/g;
309
-
310
- const asURL = url => {
311
- try {
312
- if (url.indexOf(':') !== -1) return new URL(url).href;
313
- } catch (_) {}
314
- };
315
-
316
- const resolveUrl = (relUrl, parentUrl) =>
317
- resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
318
-
319
- const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
320
- const hIdx = parentUrl.indexOf('#'),
321
- qIdx = parentUrl.indexOf('?');
322
- if (hIdx + qIdx > -2)
323
- parentUrl = parentUrl.slice(
324
- 0,
325
- hIdx === -1 ? qIdx
326
- : qIdx === -1 || qIdx > hIdx ? hIdx
327
- : qIdx
328
- );
329
- if (relUrl.indexOf('\\\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
330
- // protocol-relative
331
- if (relUrl[0] === '/' && relUrl[1] === '/') {
332
- return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
333
- }
334
- // relative-url
335
- else if (
336
- (relUrl[0] === '.' &&
337
- (relUrl[1] === '/' ||
338
- (relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
339
- (relUrl.length === 1 && (relUrl += '/')))) ||
340
- relUrl[0] === '/'
341
- ) {
342
- const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
343
- if (parentProtocol === 'blob:') {
344
- throw new TypeError(
345
- \`Failed to resolve module specifier "\${relUrl}". Invalid relative url or base scheme isn't hierarchical.\`
346
- );
347
- }
348
- // Disabled, but these cases will give inconsistent results for deep backtracking
349
- //if (parentUrl[parentProtocol.length] !== '/')
350
- // throw new Error('Cannot resolve');
351
- // read pathname from parent URL
352
- // pathname taken to be part after leading "/"
353
- let pathname;
354
- if (parentUrl[parentProtocol.length + 1] === '/') {
355
- // resolving to a :// so we need to read out the auth and host
356
- if (parentProtocol !== 'file:') {
357
- pathname = parentUrl.slice(parentProtocol.length + 2);
358
- pathname = pathname.slice(pathname.indexOf('/') + 1);
359
- } else {
360
- pathname = parentUrl.slice(8);
361
- }
362
- } else {
363
- // resolving to :/ so pathname is the /... part
364
- pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
365
- }
366
-
367
- if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
368
-
369
- // join together and split for removal of .. and . segments
370
- // looping the string instead of anything fancy for perf reasons
371
- // '../../../../../z' resolved to 'x/y' is just 'z'
372
- const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
373
-
374
- const output = [];
375
- let segmentIndex = -1;
376
- for (let i = 0; i < segmented.length; i++) {
377
- // busy reading a segment - only terminate on '/'
378
- if (segmentIndex !== -1) {
379
- if (segmented[i] === '/') {
380
- output.push(segmented.slice(segmentIndex, i + 1));
381
- segmentIndex = -1;
382
- }
383
- continue;
384
- }
385
- // new segment - check if it is relative
386
- else if (segmented[i] === '.') {
387
- // ../ segment
388
- if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
389
- output.pop();
390
- i += 2;
391
- continue;
392
- }
393
- // ./ segment
394
- else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
395
- i += 1;
396
- continue;
397
- }
398
- }
399
- // it is the start of a new segment
400
- while (segmented[i] === '/') i++;
401
- segmentIndex = i;
402
- }
403
- // finish reading out the last segment
404
- if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
405
- return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
406
- }
407
- };
408
-
409
- const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
410
- const outMap = {
411
- imports: { ...parentMap.imports },
412
- scopes: { ...parentMap.scopes },
413
- integrity: { ...parentMap.integrity }
414
- };
415
-
416
- if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
417
-
418
- if (json.scopes)
419
- for (let s in json.scopes) {
420
- const resolvedScope = resolveUrl(s, baseUrl);
421
- resolveAndComposePackages(
422
- json.scopes[s],
423
- outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
424
- baseUrl,
425
- parentMap
426
- );
427
- }
428
-
429
- if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
430
-
431
- return outMap;
432
- };
433
-
434
- const getMatch = (path, matchObj) => {
435
- if (matchObj[path]) return path;
436
- let sepIndex = path.length;
437
- do {
438
- const segment = path.slice(0, sepIndex + 1);
439
- if (segment in matchObj) return segment;
440
- } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
441
- };
442
-
443
- const applyPackages = (id, packages) => {
444
- const pkgName = getMatch(id, packages);
445
- if (pkgName) {
446
- const pkg = packages[pkgName];
447
- if (pkg === null) return;
448
- return pkg + id.slice(pkgName.length);
449
- }
450
- };
451
-
452
- const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
453
- let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
454
- while (scopeUrl) {
455
- const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
456
- if (packageResolution) return packageResolution;
457
- scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
458
- }
459
- return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
460
- };
461
-
462
- const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
463
- for (let p in packages) {
464
- const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
465
- if (
466
- (!shimMode || !mapOverrides) &&
467
- outPackages[resolvedLhs] &&
468
- outPackages[resolvedLhs] !== packages[resolvedLhs]
469
- ) {
470
- console.warn(
471
- \`es-module-shims: Rejected map override "\${resolvedLhs}" from \${outPackages[resolvedLhs]} to \${packages[resolvedLhs]}.\`
472
- );
473
- continue;
474
- }
475
- let target = packages[p];
476
- if (typeof target !== 'string') continue;
477
- const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
478
- if (mapped) {
479
- outPackages[resolvedLhs] = mapped;
480
- continue;
481
- }
482
- console.warn(\`es-module-shims: Mapping "\${p}" -> "\${packages[p]}" does not resolve\`);
483
- }
484
- };
485
-
486
- const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
487
- for (let p in integrity) {
488
- const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
489
- if (
490
- (!shimMode || !mapOverrides) &&
491
- outIntegrity[resolvedLhs] &&
492
- outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
493
- ) {
494
- console.warn(
495
- \`es-module-shims: Rejected map integrity override "\${resolvedLhs}" from \${outIntegrity[resolvedLhs]} to \${integrity[resolvedLhs]}.\`
496
- );
497
- }
498
- outIntegrity[resolvedLhs] = integrity[p];
499
- }
500
- };
501
-
502
- let policy;
503
- if (
504
- typeof self !== 'undefined' &&
505
- (typeof self.trustedTypes !== 'undefined' || typeof self.TrustedTypes !== 'undefined')
506
- ) {
507
- try {
508
- policy = (self.trustedTypes || self.TrustedTypes).createPolicy('es-module-shims', {
509
- createHTML: html => html,
510
- createScript: script => script
511
- });
512
- } catch {}
513
- }
514
-
515
- function maybeTrustedInnerHTML(html) {
516
- return policy ? policy.createHTML(html) : html;
517
- }
518
-
519
- function maybeTrustedScript(script) {
520
- return policy ? policy.createScript(script) : script;
521
- }
522
-
523
- // support browsers without dynamic import support (eg Firefox 6x)
524
- let supportsJsonType = false;
525
- let supportsCssType = false;
526
-
527
- const supports = hasDocument && HTMLScriptElement.supports;
528
-
529
- let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
530
- let supportsWasmInstancePhase = false;
531
- let supportsWasmSourcePhase = false;
532
- let supportsMultipleImportMaps = false;
533
-
534
- const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
535
-
536
- let featureDetectionPromise = (async function () {
537
- // In shim mode, feature detection results are unused — skip the iframe overhead
538
- if (shimMode) return;
539
- if (!hasDocument)
540
- return Promise.all([
541
- import(createBlob(\`import"\${createBlob('{}', 'text/json')}"with{type:"json"}\`)).then(
542
- () => (
543
- (supportsJsonType = true),
544
- import(createBlob(\`import"\${createBlob('', 'text/css')}"with{type:"css"}\`)).then(
545
- () => (supportsCssType = true),
546
- noop
547
- )
548
- ),
549
- noop
550
- ),
551
- wasmInstancePhaseEnabled &&
552
- import(createBlob(\`import"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
553
- () => (supportsWasmInstancePhase = true),
554
- noop
555
- ),
556
- wasmSourcePhaseEnabled &&
557
- import(createBlob(\`import source x from"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
558
- () => (supportsWasmSourcePhase = true),
559
- noop
560
- )
561
- ]);
562
-
563
- const msgTag = \`s\${version}\`;
564
- return new Promise(resolve => {
565
- const iframe = document.createElement('iframe');
566
- iframe.style.display = 'none';
567
- iframe.setAttribute('nonce', nonce);
568
- function cb({ data }) {
569
- const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
570
- if (!isFeatureDetectionMessage) return;
571
- [
572
- ,
573
- supportsImportMaps,
574
- supportsMultipleImportMaps,
575
- supportsJsonType,
576
- supportsCssType,
577
- supportsWasmSourcePhase,
578
- supportsWasmInstancePhase
579
- ] = data;
580
- resolve();
581
- document.head.removeChild(iframe);
582
- window.removeEventListener('message', cb, false);
583
- }
584
- window.addEventListener('message', cb, false);
585
- // Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
586
- const importMapTest = \`<script nonce=\${nonce || ''}>\${
587
- policy ? 't=(window.trustedTypes||window.TrustedTypes).createPolicy("es-module-shims",{createScript:s=>s});' : ''
588
- }b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"\${nonce}",text:\${
589
- policy ? 't.createScript(innerText)' : 'innerText'
590
- }}));i(\\\`{"imports":{"x":"\\\${b('')}"}}\\\`);i(\\\`{"imports":{"y":"\\\${b('')}"}}\\\`);cm=\${
591
- supportsImportMaps && jsonModulesEnabled ? \`c(b(\\\`import"\\\${b('{}','text/json')}"with{type:"json"}\\\`))\` : 'false'
592
- };sp=\${
593
- supportsImportMaps && wasmSourcePhaseEnabled ?
594
- \`c(b(\\\`import source x from "\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\`
595
- : 'false'
596
- };Promise.all([\${supportsImportMaps ? 'true' : "c('x')"},\${supportsImportMaps ? "c('y')" : false},cm,\${
597
- supportsImportMaps && cssModulesEnabled ?
598
- \`cm.then(s=>s?c(b(\\\`import"\\\${b('','text/css')\\}"with{type:"css"}\\\`)):false)\`
599
- : 'false'
600
- },sp,\${
601
- supportsImportMaps && wasmInstancePhaseEnabled ?
602
- \`\${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\\\`import"\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\${wasmSourcePhaseEnabled ? ':false)' : ''}\`
603
- : 'false'
604
- }]).then(a=>parent.postMessage(['\${msgTag}'].concat(a),'*'))<\${''}/script>\`;
605
-
606
- // Safari will call onload eagerly on head injection, but we don't want the Wechat
607
- // path to trigger before setting srcdoc, therefore we track the timing
608
- let readyForOnload = false,
609
- onloadCalledWhileNotReady = false;
610
- function doOnload() {
611
- if (!readyForOnload) {
612
- onloadCalledWhileNotReady = true;
613
- return;
614
- }
615
- // WeChat browser doesn't support setting srcdoc scripts
616
- // But iframe sandboxes don't support contentDocument so we do this as a fallback
617
- const doc = iframe.contentDocument;
618
- if (doc && doc.head.childNodes.length === 0) {
619
- const s = doc.createElement('script');
620
- if (nonce) s.setAttribute('nonce', nonce);
621
- s.innerText = maybeTrustedScript(importMapTest.slice(15 + (nonce ? nonce.length : 0), -9));
622
- doc.head.appendChild(s);
623
- }
624
- }
625
-
626
- iframe.onload = doOnload;
627
- // WeChat browser requires append before setting srcdoc
628
- document.head.appendChild(iframe);
629
-
630
- // setting srcdoc is not supported in React native webviews on iOS
631
- // setting src to a blob URL results in a navigation event in webviews
632
- // document.write gives usability warnings
633
- readyForOnload = true;
634
- if ('srcdoc' in iframe) iframe.srcdoc = maybeTrustedInnerHTML(importMapTest);
635
- else iframe.contentDocument.write(importMapTest);
636
- // retrigger onload for Safari only if necessary
637
- if (onloadCalledWhileNotReady) doOnload();
638
- });
639
- })();
640
-
641
- /* es-module-lexer (minimal) 2.3.1 */
642
- let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="etaourceeferromsyncunctionlassvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallelsxportport";let c$1,t,n;function parse(k,l="@"){c$1=k,t=l;const u=2*c$1.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,108)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),c=new e.Uint8Array(r),t=new e.Uint16Array(r),n=1040;function b(e){e=e|0;var a=0,r=0,c=0,t=0,n=0,b=0,k=0,o=0,w=0,g=0,p=0,y=0,m=0,O=0,T=0;y=s[398]|0;a=f[71]|0;f[68]=a;k=a;p=a;o=y;g=0;e:while(1){r=f[72]|0;t=o<<16>>16==y<<16>>16;c=g&e;b=a;while(1){n=b+2|0;if(b>>>0>=r>>>0){a=0;w=100;break e}a=s[n>>1]|0;if(!(M(a)|0)){if(t){switch(a<<16>>16){case 125:case 93:case 41:case 59:case 44:{w=100;break e}default:{}}if(c?se(a)|0:0){w=100;break e}}if(!(se(a)|0))break}b=n;}f[71]=n;a:do{switch(a<<16>>16){case 101:{if((o<<16>>16==0?Q(n)|0:0)?(S(b+4|0,214,10)|0)==0:0){u();w=89;}else w=89;break}case 105:{if(((s[b+4>>1]|0)==109?Q(n)|0:0)?(S(b+6|0,224,8)|0)==0:0){l();w=89;}else w=89;break}case 99:{if((((s[b+4>>1]|0)==108?Q(n)|0:0)?(S(b+6|0,70,6)|0)==0:0)?L(s[b+12>>1]|0)|0:0){i[800]=1;w=89;}else w=89;break}case 40:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=1;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 91:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=8;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 93:if(!(o<<16>>16)){ee();break a}else {s[398]=o+-1<<16>>16;w=89;break a}case 44:{r=s[397]|0;if((!(o<<16>>16==0|r<<16>>16==0)?(f[(f[69]|0)+((o&65535)+-1<<3)>>2]|0)==5:0)?(m=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0,(f[m+4>>2]|0)==0):0){f[m+4>>2]=p+2;f[71]=b+4;v(1)|0;w=f[71]|0;f[m+16>>2]=w;f[71]=w+-2;w=89;}else w=89;break}case 41:{if(!(o<<16>>16)){ee();break a}w=o+-1<<16>>16;s[398]=w;r=s[397]|0;if(r<<16>>16!=0?(f[(f[69]|0)+((w&65535)<<3)>>2]|0)==5:0){c=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0;if(!(f[c+4>>2]|0))f[c+4>>2]=p+2;f[c+12>>2]=b+4;s[397]=r+-1<<16>>16;w=89;}else w=89;break}case 123:{w=f[62]|0;do{if((s[p>>1]|0)==41&(w|0)!=0?(f[w+12>>2]|0)==(p+2|0):0){r=f[63]|0;f[62]=r;if(!r){f[58]=0;break}else {f[r+32>>2]=0;break}}}while(0);b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=(i[800]|0)==0?2:6;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;i[800]=0;w=89;break}case 125:{if(!(o<<16>>16)){ee();break a}k=f[69]|0;w=o+-1<<16>>16;s[398]=w;if((f[k+((w&65535)<<3)>>2]|0)==4){d();w=89;}else w=89;break}case 34:case 39:{A(a);w=89;break}case 47:switch(s[b+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{c=s[p>>1]|0;r:do{if(!($(c)|0)){if(!(c<<16>>16==41?K(f[(f[69]|0)+((o&65535)<<3)+4>>2]|0)|0:0))w=62;}else switch(c<<16>>16){case 46:if(((s[p+-2>>1]|0)+-48&65535)<10){w=62;break r}else break r;case 43:if((s[p+-2>>1]|0)==43){w=62;break r}else break r;case 45:if((s[p+-2>>1]|0)==45){w=62;break r}else break r;default:break r}}while(0);r:do{if((w|0)==62){w=0;if(o<<16>>16!=0?(O=f[69]|0,T=(o&65535)+-1|0,c<<16>>16==102?(f[O+(T<<3)>>2]|0)==1:0):0){if(((s[p+-2>>1]|0)==111?C(p+-4|0)|0:0)?B(f[O+(T<<3)+4>>2]|0,178,3)|0:0)break}else w=67;if((w|0)==67?(0,c<<16>>16==125):0){t=f[69]|0;r=o&65535;if(U(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(h(p)|0)){switch(c<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}w=f[64]|0;if((w|0?p>>>0>=(f[w>>2]|0)>>>0:0)?p>>>0<=(f[w+4>>2]|0)>>>0:0){I();i[799]=0;w=89;break a}t=f[3]|0;r=p;do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;c=s[r>>1]|0;}while(!(D(c)|0));if(M(c)|0){do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;}while(M(s[r>>1]|0)|0);if(q(r)|0){I();i[799]=0;w=89;break a}}i[799]=1;w=89;break a}}}while(0);I();i[799]=0;w=89;break a}}case 96:{b=f[69]|0;w=o&65535;f[b+(w<<3)+4>>2]=k;s[398]=o+1<<16>>16;f[b+(w<<3)>>2]=3;d();w=89;break}default:w=89;}}while(0);if((w|0)==89){w=0;f[68]=f[71];}if(i[798]|0){a=0;break}r=f[68]|0;a:do{if((r|0)==(p|0))if(g&((s[398]|0)==y<<16>>16&e)){a=s[f[71]>>1]|0;if(se(a)|0)break e;else a=1;}else a=g;else {if(a<<16>>16==47){a=(i[799]|0)==0;break}if(G(a)|0)a=1;else {switch(a<<16>>16){case 96:case 34:case 39:case 41:case 93:case 125:{a=1;break a}default:{}}a=0;}}}while(0);k=r;p=r;o=s[398]|0;g=a;a=f[71]|0;}if((w|0)==100)f[71]=n;return a|0}function k(){var e=0,a=0,r=0,c=0,t=0,b=0,k=0,o=0,w=0;w=n;n=n+10240|0;s[397]=0;s[398]=0;f[68]=f[2];i[799]=0;f[67]=0;i[798]=0;f[69]=w+2048;f[70]=w;i[800]=0;r=(f[3]|0)+-2|0;f[71]=r;e=r+(f[65]<<1)|0;f[72]=e;e:while(1){a=r+2|0;f[71]=a;if(r>>>0>=e>>>0){c=85;break}e=s[a>>1]|0;a:do{switch(e<<16>>16){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[398]|0)==0?Q(a)|0:0)?(S(r+4|0,214,10)|0)==0:0){u();c=84;}else c=84;break}case 105:{if(((s[r+4>>1]|0)==109?Q(a)|0:0)?(S(r+6|0,224,8)|0)==0:0){l();c=84;}else c=84;break}case 99:{if((((s[r+4>>1]|0)==108?Q(a)|0:0)?(S(r+6|0,70,6)|0)==0:0)?L(s[r+12>>1]|0)|0:0){i[800]=1;c=84;}else c=84;break}case 40:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=1;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 91:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=8;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 93:{e=s[398]|0;if(!(e<<16>>16)){c=21;break e}s[398]=e+-1<<16>>16;c=84;break}case 44:{e=s[397]|0;if(((e<<16>>16!=0?(t=s[398]|0,t<<16>>16!=0):0)?(f[(f[69]|0)+((t&65535)+-1<<3)>>2]|0)==5:0)?(b=f[(f[70]|0)+((e&65535)+-1<<2)>>2]|0,(f[b+4>>2]|0)==0):0){f[b+4>>2]=(f[68]|0)+2;f[71]=r+4;v(1)|0;c=f[71]|0;f[b+16>>2]=c;f[71]=c+-2;c=84;}else c=84;break}case 41:{e=s[398]|0;if(!(e<<16>>16)){c=29;break e}s[398]=e+-1<<16>>16;a=s[397]|0;if(a<<16>>16!=0?(f[(f[69]|0)+((e+-1&65535)<<3)>>2]|0)==5:0){e=f[(f[70]|0)+((a&65535)+-1<<2)>>2]|0;if(!(f[e+4>>2]|0))f[e+4>>2]=(f[68]|0)+2;f[e+12>>2]=r+4;s[397]=a+-1<<16>>16;c=84;}else c=84;break}case 123:{e=f[68]|0;c=f[62]|0;do{if((s[e>>1]|0)==41&(c|0)!=0?(f[c+12>>2]|0)==(e+2|0):0){a=f[63]|0;f[62]=a;if(!a){f[58]=0;break}else {f[a+32>>2]=0;break}}}while(0);r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=(i[800]|0)==0?2:6;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=e;i[800]=0;c=84;break}case 125:{e=s[398]|0;if(!(e<<16>>16)){c=42;break e}c=f[69]|0;s[398]=e+-1<<16>>16;if((f[c+((e+-1&65535)<<3)>>2]|0)==4){d();c=84;}else c=84;break}case 34:case 39:{A(e);c=84;break}case 47:switch(s[r+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{e=f[68]|0;a=s[e>>1]|0;r:do{if(!($(a)|0))if(a<<16>>16==41){r=s[398]|0;if(!(K(f[(f[69]|0)+((r&65535)<<3)+4>>2]|0)|0))c=57;}else c=56;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){c=56;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){c=56;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){c=56;break r}else break r;default:break r}}while(0);if((c|0)==56){r=s[398]|0;c=57;}r:do{if((c|0)==57){c=0;if(r<<16>>16!=0?(k=f[69]|0,o=(r&65535)+-1|0,a<<16>>16==102?(f[k+(o<<3)>>2]|0)==1:0):0){if(((s[e+-2>>1]|0)==111?C(e+-4|0)|0:0)?B(f[k+(o<<3)+4>>2]|0,178,3)|0:0)break}else c=62;if((c|0)==62?(0,a<<16>>16==125):0){c=f[69]|0;r=r&65535;if(U(f[c+(r<<3)+4>>2]|0)|0)break;if((f[c+(r<<3)>>2]|0)==6)break}if(!(h(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}c=f[64]|0;if((c|0?e>>>0>=(f[c>>2]|0)>>>0:0)?e>>>0<=(f[c+4>>2]|0)>>>0:0){I();i[799]=0;c=84;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;a=s[e>>1]|0;}while(!(D(a)|0));if(M(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;}while(M(s[e>>1]|0)|0);if(q(e)|0){I();i[799]=0;c=84;break a}}i[799]=1;c=84;break a}}}while(0);I();i[799]=0;c=84;break a}}case 96:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)+4>>2]=f[68];s[398]=c+1<<16>>16;f[r+((c&65535)<<3)>>2]=3;d();c=84;break}default:c=84;}}while(0);if((c|0)==84){c=0;f[68]=f[71];}r=f[71]|0;e=f[72]|0;}if((c|0)==21){ee();e=0;}else if((c|0)==29){ee();e=0;}else if((c|0)==42){ee();e=0;}else if((c|0)==85)e=(i[798]|0)==0?(s[397]|s[398])<<16>>16==0:0;n=w;return e|0}function l(){var e=0,a=0,r=0,c=0,t=0,n=0;n=f[71]|0;f[71]=n+12;e=v(1)|0;r=f[71]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&r>>>0>(n+12|0)>>>0)){if(!(e<<16>>16==100&r>>>0>(n+10|0)>>>0)){r=0;t=28;break}if(S(r+2|0,32,8)|0){a=r;e=100;r=0;t=60;break}if(!(L(s[r+10>>1]|0)|0)){a=r;e=100;r=0;t=60;break}f[71]=r+10;e=v(1)|0;if(e<<16>>16==42){e=42;c=2;t=62;break}f[71]=r;r=0;t=28;break}if((S(r+2|0,22,10)|0)==0?L(s[r+12>>1]|0)|0:0){f[71]=r+12;e=v(1)|0;a=f[71]|0;if((a|0)!=(r+12|0)){if(e<<16>>16!=102){r=1;t=28;break}if(S(a+2|0,40,6)|0){e=102;r=1;t=60;break}if(!(D(s[a+8>>1]|0)|0)){e=102;r=1;t=60;break}}f[71]=r;r=0;t=28;}else {a=r;e=115;r=0;t=60;}}else {f[71]=r+2;switch((v(1)|0)<<16>>16){case 109:{e=f[71]|0;if(S(e+2|0,16,6)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;g(n,n,e+8|0,2);break e}case 115:{e=f[71]|0;if(S(e+2|0,22,10)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+12;e=v(1)|0;r=1;t=28;break e}case 100:{e=f[71]|0;if(S(e+2|0,32,8)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+10;e=v(1)|0;r=2;t=28;break e}default:break e}}}while(0);e:do{if((t|0)==28){if(e<<16>>16==40){a=f[69]|0;c=s[398]|0;f[a+((c&65535)<<3)>>2]=5;e=f[71]|0;s[398]=c+1<<16>>16;f[a+((c&65535)<<3)+4>>2]=e;if((s[f[68]>>1]|0)==46)break;f[71]=e+2;a=v(1)|0;g(n,f[71]|0,0,e);if(!r)e=f[62]|0;else {e=f[62]|0;f[e+28>>2]=(r|0)==1?5:7;}c=f[70]|0;n=s[397]|0;s[397]=n+1<<16>>16;f[c+((n&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{A(39);break}case 34:{A(34);break}case 96:{if(!(y()|0))t=37;break}default:t=37;}if((t|0)==37){f[71]=(f[71]|0)+-2;break}e=(f[71]|0)+2|0;f[71]=e;switch((v(1)|0)<<16>>16){case 44:{f[71]=(f[71]|0)+2;v(1)|0;c=f[62]|0;f[c+4>>2]=e;n=f[71]|0;f[c+16>>2]=n;i[c+24>>0]=1;f[71]=n+-2;break e}case 41:{s[398]=(s[398]|0)+-1<<16>>16;n=f[62]|0;f[n+4>>2]=e;f[n+12>>2]=(f[71]|0)+2;i[n+24>>0]=1;s[397]=(s[397]|0)+-1<<16>>16;break e}default:{f[71]=(f[71]|0)+-2;break e}}}if(!((r|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{c=r;t=62;break e}default:{}}a=f[71]|0;t=60;break}e=f[71]|0;if(s[398]|0){f[71]=e+-2;break}while(1){if(e>>>0>=(f[72]|0)>>>0)break;e=v(1)|0;if(!(ae(e)|0)){if(e<<16>>16==125){t=50;break}}else A(e);e=(f[71]|0)+2|0;f[71]=e;}if((t|0)==50)f[71]=(f[71]|0)+2;c=(v(1)|0)<<16>>16==102;e=f[71]|0;if(c?S(e+2|0,40,6)|0:0){ee();break}f[71]=e+8;e=v(1)|0;if(ae(e)|0){w(n,e,0);break}else {ee();break}}}while(0);if((t|0)==60)if((a|0)==(n+12|0))f[71]=n+10;else {c=r;t=62;}do{if((t|0)==62){if(!((e<<16>>16==42|(c|0)!=2)&(s[398]|0)==0)){f[71]=(f[71]|0)+-2;break}e=f[72]|0;a=f[71]|0;while(1){if(a>>>0>=e>>>0){t=69;break}r=s[a>>1]|0;if(ae(r)|0){t=67;break}t=a+2|0;f[71]=t;a=t;}if((t|0)==67){w(n,r,c);break}else if((t|0)==69){ee();break}}}while(0);return}function u(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0,k=0,l=0,u=0;k=f[71]|0;l=f[64]|0;f[71]=k+12;a=v(1)|0;e=f[71]|0;if(!((e|0)==(k+12|0)?!(O(a)|0):0))u=3;e:do{if((u|0)==3){a:do{switch(a<<16>>16){case 123:{f[71]=e+2;e=v(1)|0;r=f[71]|0;while(1){if(ae(e)|0){A(e);e=(f[71]|0)+2|0;f[71]=e;}else {H(e)|0;e=f[71]|0;}v(1)|0;e=p(r,e)|0;if(e<<16>>16==44){f[71]=(f[71]|0)+2;e=v(1)|0;}a=r;r=f[71]|0;if(e<<16>>16==125){u=15;break}if((r|0)==(a|0)){u=12;break}if(r>>>0>(f[72]|0)>>>0){u=14;break}}if((u|0)==12){ee();break e}else if((u|0)==14){ee();break e}else if((u|0)==15){f[71]=r+2;u=49;break a}break}case 42:{f[71]=e+2;v(1)|0;u=f[71]|0;p(u,u)|0;u=49;break}case 100:{f[71]=e+14;switch((v(1)|0)<<16>>16){case 97:{a=f[71]|0;if((S(a+2|0,46,8)|0)==0?M(s[a+10>>1]|0)|0:0){f[71]=a+10;v(0)|0;u=21;}break}case 102:{u=21;break}case 99:{a=f[71]|0;if(((S(a+2|0,68,8)|0)==0?(l=s[a+10>>1]|0,L(l)|0|l<<16>>16==123):0)?(f[71]=a+10,r=v(1)|0,r<<16>>16!=123):0){n=r;u=30;}break}default:{}}r:do{if((u|0)==21?(i=f[71]|0,(S(i+2|0,54,14)|0)==0):0){a=s[i+16>>1]|0;if(!(L(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[71]=i+16;a=v(1)|0;if(a<<16>>16==42){f[71]=(f[71]|0)+2;a=v(1)|0;}if(a<<16>>16!=40){n=a;u=30;}}}while(0);if((u|0)==30?(c=f[71]|0,H(n)|0,t=f[71]|0,t>>>0>c>>>0):0){E(e,e+14|0,c,t);f[71]=(f[71]|0)+-2;break e}E(e,e+14|0,0,0);f[71]=e+12;break e}case 97:{f[71]=e+10;v(0)|0;e=f[71]|0;u=34;break}case 102:{u=34;break}case 99:{if((S(e+2|0,68,8)|0)==0?D(s[e+10>>1]|0)|0:0){f[71]=e+10;u=v(1)|0;l=f[71]|0;H(u)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break e}f[71]=e+4;e=e+4|0;u=41;break}case 108:case 118:{u=41;break}default:break e}}while(0);if((u|0)==34){f[71]=e+16;e=v(1)|0;if(e<<16>>16==42){f[71]=(f[71]|0)+2;e=v(1)|0;}l=f[71]|0;H(e)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break}else if((u|0)==41){f[71]=e+6;while(1){a=v(1)|0;e=f[71]|0;if(e>>>0>(f[72]|0)>>>0)break;a=P(a)|0;if((f[71]|0)==(e|0))break;if(a<<16>>16==61)a=b(1)|0;e=f[71]|0;if(a<<16>>16!=44)break;f[71]=e+2;}f[71]=e+-2;break}else if((u|0)==49){u=(v(1)|0)<<16>>16==102;e=f[71]|0;if(u?(S(e+2|0,40,6)|0)==0:0){f[71]=e+8;w(k,v(1)|0,0);e=(l|0)==0?236:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[71]=e+-2;break}}}while(0);return}function o(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0;e=f[71]|0;c=(s[e>>1]|0)==123;f[71]=e+2;e=v(1)|0;t=c?125:93;e:while(1){if((t|0)==(e&65535|0))break;i=f[71]|0;if(i>>>0>(f[72]|0)>>>0)break;if((e<<16>>16==46?(s[i+2>>1]|0)==46:0)?(s[i+4>>1]|0)==46:0){f[71]=i+6;e=P(v(1)|0)|0;}else n=9;a:do{if((n|0)==9){n=0;do{if(c){do{if(e<<16>>16==91){b(0)|0;f[71]=(f[71]|0)+2;a=i;}else {if(ae(e)|0){A(e);f[71]=(f[71]|0)+2;a=i;break}if((e+-48&65535)>=10){H(e)|0;a=f[71]|0;break}e=i;r:while(1){r=e+2|0;a=s[r>>1]|0;i:do{if((a+-48&65535)>=10){switch(a<<16>>16){case 67:case 68:case 70:case 97:case 65:case 99:case 100:case 102:case 46:case 66:case 69:case 79:case 88:case 95:case 98:case 101:case 110:case 111:case 120:break i;case 43:case 45:break;default:break r}switch(s[e>>1]|0){case 69:case 101:break;default:break r}}}while(0);e=r;}f[71]=r;a=i;}}while(0);e=v(1)|0;if(e<<16>>16==58){f[71]=(f[71]|0)+2;e=P(v(1)|0)|0;break}if(a>>>0>i>>>0)E(i,a,i,a);}else if(e<<16>>16==44){f[71]=i+2;e=v(1)|0;break a}else {e=P(e)|0;break}}while(0);if(e<<16>>16==61)e=b(0)|0;if(e<<16>>16!=44)break e;f[71]=(f[71]|0)+2;e=v(1)|0;}}while(0)}return}function h(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=B(e+-4|0,76,2)|0;break e}case 108:{e=B(e+-4|0,80,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=z(e+-6|0,101)|0;break e}case 97:{e=z(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=B(e+-4|0,86,4)|0;break e}case 117:{e=B(e+-4|0,94,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=B(e+-8|0,106,6)|0;break e}case 112:{e=B(e+-8|0,118,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=B(e+-2|0,122,4)|0;break}case 110:{if(z(e+-2|0,105)|0)e=1;else e=B(e+-2|0,130,5)|0;break}case 111:{e=z(e+-2|0,100)|0;break}case 114:{e=B(e+-2|0,140,7)|0;break}case 116:{e=B(e+-2|0,154,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=z(e+-4|0,110)|0;break e}case 111:{e=B(e+-4|0,162,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function w(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,c=0;i=(f[71]|0)+2|0;switch(a<<16>>16){case 39:{A(39);c=5;break}case 34:{A(34);c=5;break}default:ee();}do{if((c|0)==5){g(e,i,f[71]|0,1);if((r|0)>0)f[(f[62]|0)+28>>2]=(r|0)==1?4:6;f[71]=(f[71]|0)+2;c=(v(0)|0)<<16>>16==119;a=f[71]|0;if(((c?(s[a+2>>1]|0)==105:0)?(s[a+4>>1]|0)==116:0)?(s[a+6>>1]|0)==104:0){f[71]=a+8;if((v(1)|0)<<16>>16!=123){f[71]=a;break}r=f[71]|0;i=r;e:while(1){f[71]=i+2;i=v(1)|0;switch(i<<16>>16){case 39:{A(39);f[71]=(f[71]|0)+2;i=v(1)|0;break}case 34:{A(34);f[71]=(f[71]|0)+2;i=v(1)|0;break}default:i=H(i)|0;}if(i<<16>>16!=58){c=20;break}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 39:{A(39);break}case 34:{A(34);break}default:{c=24;break e}}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 125:{c=28;break e}case 44:break;default:{c=26;break e}}i=(f[71]|0)+2|0;f[71]=i;}if((c|0)==20){f[71]=a;break}else if((c|0)==24){f[71]=a;break}else if((c|0)==26){f[71]=a;break}else if((c|0)==28){c=f[62]|0;f[c+16>>2]=r;f[c+12>>2]=(f[71]|0)+2;break}}f[71]=a+-2;}}while(0);return}function d(){var e=0,a=0,r=0;a=f[72]|0;r=f[71]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[71]=e;a=f[69]|0;r=s[398]|0;f[a+((r&65535)<<3)>>2]=4;s[398]=r+1<<16>>16;f[a+((r&65535)<<3)+4>>2]=e;}else if((a|0)==7){f[71]=e;a=f[69]|0;r=(s[398]|0)+-1<<16>>16;s[398]=r;if((f[a+((r&65535)<<3)>>2]|0)!=3)ee();}else if((a|0)==10){f[71]=e;ee();}return}function v(e){e=e|0;var a=0,r=0,i=0;r=f[71]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(L(a)|0)break;else break e;else if(M(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{F();break a}case 42:{x(e);break a}default:{a=47;break e}}}while(0);i=f[71]|0;r=i+2|0;f[71]=r;}while(i>>>0<(f[72]|0)>>>0);return a|0}function A(e){e=e|0;var a=0,r=0,i=0,c=0;c=f[72]|0;a=f[71]|0;while(1){i=a+2|0;if(a>>>0>=c>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(se(r)|0){a=9;break}else a=i;}if((a|0)==9){f[71]=i;ee();}else if((a|0)==10)f[71]=i;return}function C(e){e=e|0;var a=0,r=0;a=s[e>>1]|0;if(L(a)|0)r=3;else switch(a<<16>>16){case 41:case 125:case 93:{r=3;break}default:e=0;}e:do{if((r|0)==3){r=f[3]|0;while(1){if(e>>>0<=r>>>0)break;e=e+-2|0;if(!(L(a)|0))break;a=s[e>>1]|0;}switch(a<<16>>16){case 41:case 125:case 93:{e=1;break e}default:{}}e=(O(a)|0)^1;}}while(0);return e|0}function g(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var c=0,t=0;t=f[66]|0;f[66]=t+36;c=f[62]|0;f[((c|0)==0?232:c+32|0)>>2]=t;f[63]=c;f[62]=t;f[t+8>>2]=e;if(2==(s|0)){e=3;c=r;}else {e=1==(s|0)?1:2;c=1==(s|0)?r+2|0:0;}f[t+12>>2]=c;f[t+28>>2]=e;f[t>>2]=a;f[t+4>>2]=r;f[t+16>>2]=0;f[t+20>>2]=s;i[t+24>>0]=1==(s|0)&1;f[t+32>>2]=0;return}function p(e,a){e=e|0;a=a|0;var r=0,i=0,c=0,t=0;r=f[71]|0;i=s[r>>1]|0;c=(e|0)==(a|0)?0:e;t=(e|0)==(a|0)?0:a;if(i<<16>>16==97){f[71]=r+4;r=v(1)|0;e=f[71]|0;if(ae(r)|0){A(r);a=(f[71]|0)+2|0;f[71]=a;}else {H(r)|0;a=f[71]|0;}i=v(1)|0;r=f[71]|0;}if((r|0)!=(e|0))E(e,a,c,t);return i|0}function y(){var e=0,a=0,r=0,i=0;i=f[71]|0;r=f[72]|0;a=i;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=7;break}switch(s[e>>1]|0){case 96:{a=8;break e}case 92:{e=a+4|0;break}case 36:{if((s[a+4>>1]|0)==123){a=7;break e}break}default:{}}a=e;}if((a|0)==7){f[71]=i;e=0;}else if((a|0)==8){f[71]=e;e=1;}return e|0}function m(){var e=0,a=0,r=0;r=f[72]|0;a=f[71]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[71]=e;ee();e=0;}else if((a|0)==7){f[71]=e;e=93;}return e|0}function I(){var e=0,a=0;e:while(1){e=f[71]|0;f[71]=e+2;if(e>>>0>=(f[72]|0)>>>0){a=7;break}switch(s[e+2>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{m()|0;break}case 92:{f[71]=e+4;break}default:{}}}if((a|0)==7)ee();return}function U(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=B(e+-2|0,188,4)|0;break}case 121:{e=B(e+-2|0,196,6)|0;break}case 101:{e=B(e+-2|0,208,3)|0;break}default:e=0;}return e|0}function x(e){e=e|0;var a=0,r=0,i=0,c=0,t=0;c=(f[71]|0)+2|0;f[71]=c;r=f[72]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?se(i)|0:0)break;if(i<<16>>16==42?(s[c+4>>1]|0)==47:0){t=8;break}c=a;}if((t|0)==8){f[71]=a;a=c+4|0;}f[71]=a;return}function S(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function O(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function $(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function T(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(O(a)|0)return a<<16>>16!=46|(N(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function j(e){e=e|0;var a=0,r=0;r=n;n=n+16|0;f[r>>2]=0;f[65]=e;a=f[3]|0;s[a+(e<<1)>>1]=0;f[r>>2]=a+(e<<1)+2;f[66]=a+(e<<1)+2;f[58]=0;f[62]=0;f[60]=0;f[59]=0;f[64]=0;f[61]=0;n=r;return a|0}function B(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;s=e+(0-r<<1)+2|0;i=f[3]|0;if(s>>>0>=i>>>0?(S(s,a,r<<1)|0)==0:0)if((s|0)==(i|0))i=1;else i=T(e+(0-r<<1)|0)|0;else i=0;return i|0}function E(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var s=0,c=0;s=f[66]|0;f[66]=s+20;c=f[64]|0;f[((c|0)==0?236:c+16|0)>>2]=s;f[64]=s;f[s>>2]=e;f[s+4>>2]=a;f[s+8>>2]=r;f[s+12>>2]=i;f[s+16>>2]=0;return}function P(e){e=e|0;var a=0;switch(e<<16>>16){case 91:case 123:{o();f[71]=(f[71]|0)+2;break}default:{a=f[71]|0;H(e)|0;e=f[71]|0;if(e>>>0>a>>>0)E(a,e,a,e);}}return v(1)|0}function q(e){e=e|0;switch(s[e>>1]|0){case 107:{e=B(e+-2|0,122,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=B(e+-4|0,94,6)|0;else e=0;break}default:e=0;}return e|0}function z(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=D(s[e+-2>>1]|0)|0;else r=0;return r|0}function D(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(O(e)|0);}}while(0);return e|0}function F(){var e=0,a=0,r=0;e=f[72]|0;r=f[71]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[71]=a;return}function G(e){e=e|0;e:do{if(((e&-33)+-65&65535)<26|(e+-48&65535)<10)e=1;else {switch(e<<16>>16){case 36:case 95:{e=1;break e}default:{}}e=(e&65535)>127;}}while(0);return e|0}function H(e){e=e|0;while(1){if(L(e)|0)break;if(O(e)|0)break;e=(f[71]|0)+2|0;f[71]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(){var e=0;e=f[(f[60]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function K(e){e=e|0;if(!(B(e,168,5)|0)?!(B(e,178,3)|0):0)e=B(e,184,2)|0;else e=1;return e|0}function L(e){e=e|0;switch(e<<16>>16){case 160:case 9:case 10:case 11:case 12:case 13:case 32:{e=1;break}default:e=0;}return e|0}function M(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function N(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function Q(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=T(e+-2|0)|0;return e|0}function R(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function V(){var e=0;e=f[(f[60]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function W(){var e=0;e=f[(f[61]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function X(){var e=0;e=f[(f[60]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Y(){var e=0;e=f[(f[60]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Z(){var e=0;e=f[60]|0;e=f[((e|0)==0?232:e+32|0)>>2]|0;f[60]=e;return (e|0)!=0|0}function _(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+16|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function ee(){i[798]=1;f[67]=(f[71]|0)-(f[3]|0)>>1;f[71]=(f[72]|0)+2;return}function ae(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function re(){return (f[(f[60]|0)+8>>2]|0)-(f[3]|0)>>1|0}function ie(){return (f[(f[61]|0)+4>>2]|0)-(f[3]|0)>>1|0}function se(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function fe(){return (f[f[60]>>2]|0)-(f[3]|0)>>1|0}function ce(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function te(){return c[(f[60]|0)+24>>0]|0|0}function ne(e){e=e|0;f[3]=e;return}function be(){return f[(f[60]|0)+28>>2]|0}function ke(){return f[67]|0}function le(e,a){e=e|0;a=a|0;n=e+a+15&-16;return a}return {su:le,ai:X,e:ke,ee:ie,ele:R,els:W,es:ce,id:J,ie:Y,ip:te,is:fe,it:be,p:k,re:_,ri:Z,sa:j,se:V,ses:ne,ss:re}}("undefined"!=typeof globalThis?globalThis:self,{},a),r=e.su(i-(2<<17),1040);}const h=c$1.length+1;e.ses(r),e.sa(h-1),s(c$1,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),t=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,c$1.charCodeAt(-1===s?a-1:a)));let l=null;w.push({t:n,n:k,s:a,e:r,ss:f,se:t,d:s,a:i,at:l});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=i<0?void 0:v(i,s),c=v(a,r);d.push({s:a,e:r,ls:i,le:s,n:c,ln:f});}return [w,d];function v(e,a){const r=c$1.charCodeAt(e);return 34===r||39===r?b(e+1,r):c$1.slice(e,a)}}function b(e,a){n=e;let r="",i=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&96!==a&&o(),++n);}return r+=c$1.slice(i,n++),r}function k(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\\n";case 114:return "\\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=c$1.charCodeAt(n);let a;123===e?(++n,a=l(c$1.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\\t";case 98:return "\\b";case 118:return "\\v";case 102:return "\\f";case 13:10===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=c$1.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(\`Parse error \${t}:\${c$1.slice(0,n).split("\\n").length}:\${n-c$1.lastIndexOf("\\n",n-1)}\`),{idx:n})}
643
-
644
- const _resolve = (id, parentUrl = baseUrl) => {
645
- const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
646
- const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
647
- const composedResolved =
648
- composedImportMap === firstImportMap ? firstResolved : (
649
- resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
650
- );
651
- const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
652
- // needsShim, shouldShim per load record to set on parent
653
- let n = false,
654
- N = false;
655
- if (!supportsImportMaps) {
656
- // bare specifier -> needs shim
657
- if (!urlResolved) n = true;
658
- // url mapping -> should shim
659
- else if (urlResolved !== resolved) N = true;
660
- } else if (!supportsMultipleImportMaps) {
661
- // bare specifier and not resolved by first import map -> needs shim
662
- if (!urlResolved && !firstResolved) n = true;
663
- // resolution doesn't match first import map -> should shim
664
- if (firstResolved && resolved !== firstResolved) N = true;
665
- }
666
- return { r: resolved, n, N };
667
- };
668
-
669
- const resolve = (id, parentUrl) => {
670
- if (!resolveHook) return _resolve(id, parentUrl);
671
- const result = resolveHook(id, parentUrl, defaultResolve);
672
-
673
- return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
674
- };
675
-
676
- // import()
677
- async function importShim(id, opts, parentUrl) {
678
- if (typeof opts === 'string') {
679
- parentUrl = opts;
680
- opts = undefined;
681
- }
682
- await initPromise; // needed for shim check
683
- if (shimMode || !baselineSupport) {
684
- if (hasDocument) processScriptsAndPreloads();
685
- legacyAcceptingImportMaps = false;
686
- }
687
- let sourceType = undefined;
688
- if (typeof opts === 'object') {
689
- if (opts.lang === 'ts') sourceType = 'ts';
690
- if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
691
- sourceType = opts.with.type;
692
- }
693
- }
694
- return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
695
- }
696
-
697
- // import.source()
698
- // (opts not currently supported as no use cases yet)
699
- if (shimMode || wasmSourcePhaseEnabled)
700
- importShim.source = async (id, opts, parentUrl) => {
701
- if (typeof opts === 'string') {
702
- parentUrl = opts;
703
- opts = undefined;
704
- }
705
- await initPromise; // needed for shim check
706
- if (shimMode || !baselineSupport) {
707
- if (hasDocument) processScriptsAndPreloads();
708
- legacyAcceptingImportMaps = false;
709
- }
710
- await importMapPromise;
711
- const url = resolve(id, parentUrl || baseUrl).r;
712
- const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
713
- await load.f;
714
- return importShim._s[load.r];
715
- };
716
-
717
- // import.defer() is just a proxy for import(), since we can't actually defer
718
- if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
719
-
720
- if (hotReload) {
721
- initHotReload(topLevelLoad, importShim);
722
- importShim.hotReload = hotReload$1;
723
- }
724
-
725
- const defaultResolve = (id, parentUrl) => {
726
- return (
727
- resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
728
- throwUnresolved(id, parentUrl)
729
- );
730
- };
731
-
732
- const throwUnresolved = (id, parentUrl) => {
733
- throw Error(\`Unable to resolve specifier '\${id}'\${fromParent(parentUrl)}\`);
734
- };
735
-
736
- const metaResolve = function (id, parentUrl = this.url) {
737
- return resolve(id, \`\${parentUrl}\`).r;
738
- };
739
-
740
- importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
741
- importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
742
- importShim.addImportMap = importMapIn => {
743
- if (!shimMode) throw new Error('Unsupported in polyfill mode.');
744
- composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
745
- };
746
- importShim.version = version;
747
-
748
- const registry = (importShim._r = {});
749
- // Wasm caches
750
- const sourceCache = (importShim._s = {});
751
- /* const instanceCache = */ importShim._i = new WeakMap();
752
-
753
- // Ensure this version is the only version
754
- defineValue(self_, 'importShim', Object.freeze(importShim));
755
- const shimModeOptions = { ...esmsInitOptions, shimMode: true };
756
- if (optionsScript) optionsScript.innerText = maybeTrustedScript(JSON.stringify(shimModeOptions));
757
- self_.esmsInitOptions = shimModeOptions;
758
-
759
- const loadAll = async (load, seen) => {
760
- seen[load.u] = 1;
761
- await load.L;
762
- await Promise.all(
763
- load.d.map(({ l: dep, s: sourcePhase }) => {
764
- if (dep.b || seen[dep.u]) return;
765
- if (sourcePhase) return dep.f;
766
- return loadAll(dep, seen);
767
- })
768
- );
769
- };
770
-
771
- let importMapSrc = false;
772
- let multipleImportMaps = false;
773
- let firstImportMap = null;
774
- // To support polyfilling multiple import maps, we separately track the composed import map from the first import map
775
- let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
776
- let baselineSupport;
777
-
778
- const initPromise = featureDetectionPromise.then(() => {
779
- baselineSupport =
780
- supportsImportMaps &&
781
- (!jsonModulesEnabled || supportsJsonType) &&
782
- (!cssModulesEnabled || supportsCssType) &&
783
- (!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
784
- (!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
785
- !deferPhaseEnabled &&
786
- (!multipleImportMaps || supportsMultipleImportMaps) &&
787
- !importMapSrc &&
788
- !hasCustomizationHooks;
789
- if (!shimMode && typeof WebAssembly !== 'undefined') {
790
- if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
791
- const s = Symbol();
792
- const brand = m => defineValue(m, s, 'WebAssembly.Module');
793
- class AbstractModuleSource {
794
- get [Symbol.toStringTag]() {
795
- if (this[s]) return this[s];
796
- throw new TypeError('Not an AbstractModuleSource');
797
- }
798
- }
799
- const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
800
- WebAssembly.Module = Object.setPrototypeOf(
801
- Object.assign(function Module(...args) {
802
- return brand(new wasmModule(...args));
803
- }, wasmModule),
804
- AbstractModuleSource
805
- );
806
- WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
807
- WebAssembly.compile = function compile(...args) {
808
- return wasmCompile(...args).then(brand);
809
- };
810
- WebAssembly.compileStreaming = function compileStreaming(...args) {
811
- return wasmCompileStreaming(...args).then(brand);
812
- };
813
- }
814
- }
815
- if (hasDocument) {
816
- if (!supportsImportMaps) {
817
- const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
818
- HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
819
- }
820
- if (shimMode || !baselineSupport) {
821
- attachMutationObserver();
822
- if (document.readyState === 'complete') {
823
- readyStateCompleteCheck();
824
- } else {
825
- document.addEventListener('readystatechange', readyListener);
826
- }
827
- }
828
- processScriptsAndPreloads();
829
- }
830
- return undefined;
831
- });
832
-
833
- const attachMutationObserver = () => {
834
- const observer = new MutationObserver(mutations => {
835
- for (const mutation of mutations) {
836
- if (mutation.type !== 'childList') continue;
837
- for (const node of mutation.addedNodes) {
838
- if (node.tagName === 'SCRIPT') {
839
- if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
840
- if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
841
- } else if (
842
- node.tagName === 'LINK' &&
843
- node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
844
- !node.ep
845
- ) {
846
- processPreload(node);
847
- }
848
- }
849
- }
850
- });
851
- observer.observe(document, { childList: true });
852
- observer.observe(document.head, { childList: true });
853
- processScriptsAndPreloads();
854
- };
855
-
856
- let importMapPromise = initPromise;
857
- let firstPolyfillLoad = true;
858
- let legacyAcceptingImportMaps = true;
859
-
860
- async function topLevelLoad(
861
- url,
862
- parentUrl,
863
- fetchOpts,
864
- source,
865
- nativelyLoaded,
866
- lastStaticLoadPromise,
867
- sourceType
868
- ) {
869
- await initPromise;
870
- await importMapPromise;
871
- url = (await resolve(url, parentUrl)).r;
872
-
873
- // we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
874
- // because we can't syntactically pass through to dynamic import with a second argument
875
- if (sourceType === 'css' || sourceType === 'json') {
876
- // Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
877
- source = \`import m from'\${url}'with{type:"\${sourceType}"};export default m;\`;
878
- url += '?entry';
879
- }
880
-
881
- if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
882
- // early analysis opt-out - no need to even fetch if we have feature support
883
- if (!shimMode && baselineSupport && nativePassthrough && sourceType !== 'ts') {
884
- // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
885
- if (nativelyLoaded) return null;
886
- await lastStaticLoadPromise;
887
- return dynamicImport(source ? createBlob(source) : url);
888
- }
889
- const load = getOrCreateLoad(url, fetchOpts, undefined, source);
890
- linkLoad(load, fetchOpts);
891
- const seen = {};
892
- await loadAll(load, seen);
893
- resolveDeps(load, seen);
894
- await lastStaticLoadPromise;
895
- if (!shimMode && !load.n) {
896
- if (nativelyLoaded) {
897
- return;
898
- }
899
- if (source) {
900
- return await dynamicImport(createBlob(source));
901
- }
902
- }
903
- if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
904
- onpolyfill();
905
- firstPolyfillLoad = false;
906
- }
907
- const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
908
- dynamicImport(load.b, load.u)
909
- : import(load.u));
910
- // if the top-level load is a shell, run its update function
911
- if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
912
- revokeObjectURLs(Object.keys(seen));
913
- return module;
914
- }
915
-
916
- const revokeObjectURLs = registryKeys => {
917
- let curIdx = 0;
918
- const handler = self_.requestIdleCallback || self_.requestAnimationFrame || (fn => setTimeout(fn, 0));
919
- handler(cleanup);
920
- function cleanup() {
921
- for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
922
- const load = registry[key];
923
- if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
924
- }
925
- if (curIdx < registryKeys.length) handler(cleanup);
926
- }
927
- };
928
-
929
- const urlJsString = url => \`'\${url.replace(/'/g, "\\\\'")}'\`;
930
-
931
- let resolvedSource, lastIndex;
932
- const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
933
- while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
934
- const dynamicImportEnd = dynamicImportEndStack.pop();
935
- resolvedSource += \`\${load.S.slice(lastIndex, dynamicImportEnd)}, \${urlJsString(load.r)}\`;
936
- lastIndex = dynamicImportEnd;
937
- }
938
- resolvedSource += load.S.slice(lastIndex, originalIndex);
939
- lastIndex = originalIndex;
940
- };
941
-
942
- const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
943
- const urlStart = commentStart + commentPrefix.length;
944
- const commentEnd = load.S.indexOf('\\n', urlStart);
945
- const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
946
- let sourceUrl = load.S.slice(urlStart, urlEnd);
947
- try {
948
- sourceUrl = new URL(sourceUrl, load.r).href;
949
- } catch (e) {}
950
- pushStringTo(load, urlStart, dynamicImportEndStack);
951
- resolvedSource += sourceUrl;
952
- lastIndex = urlEnd;
953
- };
954
-
955
- const resolveDeps = (load, seen) => {
956
- if (load.b || !seen[load.u]) return;
957
- seen[load.u] = 0;
958
-
959
- for (const { l: dep, s: sourcePhase } of load.d) {
960
- if (!sourcePhase) resolveDeps(dep, seen);
961
- }
962
-
963
- if (!load.n) load.n = load.d.some(dep => dep.l.n);
964
- if (!load.N) load.N = load.d.some(dep => dep.l.N);
965
-
966
- // use native loader whenever possible (n = needs shim) via executable subgraph passthrough
967
- // so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
968
- if (nativePassthrough && !shimMode && !load.n && !load.N) {
969
- load.b = load.u;
970
- load.S = undefined;
971
- return;
972
- }
973
-
974
- const [imports, exports] = load.a;
975
-
976
- // "execution"
977
- let source = load.S,
978
- depIndex = 0,
979
- dynamicImportEndStack = [];
980
-
981
- // once all deps have loaded we can inline the dependency resolution blobs
982
- // and define this blob
983
- resolvedSource = '';
984
- lastIndex = 0;
985
-
986
- for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a, at } of imports) {
987
- // source phase
988
- if (t === 4) {
989
- let { l: depLoad } = load.d[depIndex++];
990
- pushStringTo(load, statementStart, dynamicImportEndStack);
991
- resolvedSource += \`\${source.slice(statementStart, start - 1).replace('source', '')}/*\${source.slice(start - 1, end + 1)}*/'\${createBlob(\`export default importShim._s[\${urlJsString(depLoad.r)}]\`)}'\`;
992
- lastIndex = end + 1;
993
- }
994
- // dependency source replacements
995
- else if (dynamicImportIndex === -1) {
996
- let keepAssertion = false;
997
- if (a > 0 && !shimMode) {
998
- // strip assertions only when unsupported in polyfill mode
999
- // minimal lexer builds do not provide parsed attributes, so sniff the assertion source directly
1000
- const assertion = source.slice(a, statementEnd - 1);
1001
- keepAssertion =
1002
- nativePassthrough &&
1003
- ((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
1004
- }
1005
-
1006
- // defer phase stripping
1007
- if (t === 6) {
1008
- pushStringTo(load, statementStart, dynamicImportEndStack);
1009
- resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
1010
- lastIndex = start;
1011
- }
1012
- let { l: depLoad } = load.d[depIndex++],
1013
- blobUrl = depLoad.b,
1014
- cycleShell = !blobUrl;
1015
- if (cycleShell) {
1016
- // circular shell creation
1017
- if (!(blobUrl = depLoad.s)) {
1018
- blobUrl = depLoad.s = createBlob(
1019
- \`export function u$_(m){\${depLoad.a[1]
1020
- .map(({ s, e }, i) => {
1021
- const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
1022
- return \`e$_\${i}=m\${q ? \`[\` : '.'}\${depLoad.S.slice(s, e)}\${q ? \`]\` : ''}\`;
1023
- })
1024
- .join(',')}}\${
1025
- depLoad.a[1].length ? \`let \${depLoad.a[1].map((_, i) => \`e$_\${i}\`).join(',')};\` : ''
1026
- }export {\${depLoad.a[1]
1027
- .map(({ s, e }, i) => \`e$_\${i} as \${depLoad.S.slice(s, e)}\`)
1028
- .join(',')}}\\n//# sourceURL=\${depLoad.r}?cycle\`
1029
- );
1030
- }
1031
- }
1032
-
1033
- pushStringTo(load, start - 1, dynamicImportEndStack);
1034
- resolvedSource += \`/*\${source.slice(start - 1, end + 1)}*/'\${blobUrl}'\`;
1035
-
1036
- // circular shell execution
1037
- if (!cycleShell && depLoad.s) {
1038
- resolvedSource += \`;import*as m$_\${depIndex} from'\${depLoad.b}';import{u$_ as u$_\${depIndex}}from'\${depLoad.s}';u$_\${depIndex}(m$_\${depIndex})\`;
1039
- depLoad.s = undefined;
1040
- }
1041
- lastIndex = keepAssertion ? end + 1 : statementEnd;
1042
- }
1043
- // import.meta
1044
- else if (dynamicImportIndex === -2) {
1045
- load.m = { url: load.r, resolve: metaResolve };
1046
- if (metaHook) metaHook(load.m, load.u);
1047
- pushStringTo(load, start, dynamicImportEndStack);
1048
- resolvedSource += \`importShim._r[\${urlJsString(load.u)}].m\`;
1049
- lastIndex = statementEnd;
1050
- }
1051
- // dynamic import
1052
- else {
1053
- pushStringTo(load, statementStart + 6, dynamicImportEndStack);
1054
- resolvedSource += \`Shim\${t === 5 ? '.source' : ''}(\`;
1055
- dynamicImportEndStack.push(statementEnd - 1);
1056
- lastIndex = start;
1057
- }
1058
- }
1059
-
1060
- // support progressive cycle binding updates (try statement avoids tdz errors)
1061
- if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
1062
- resolvedSource += \`\\n;import{u$_}from'\${load.s}';try{u$_({\${exports
1063
- .filter(e => e.ln)
1064
- .map(({ s, e, ln }) => \`\${source.slice(s, e)}:\${ln}\`)
1065
- .join(',')}})}catch(_){};\\n\`;
1066
-
1067
- let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
1068
- let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
1069
-
1070
- // ignore sourceMap comments before already spliced code
1071
- if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
1072
- if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
1073
-
1074
- // sourceURL first / only
1075
- if (
1076
- sourceURLCommentStart !== -1 &&
1077
- (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
1078
- ) {
1079
- pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
1080
- }
1081
- // sourceMappingURL
1082
- if (sourceMapURLCommentStart !== -1) {
1083
- pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
1084
- // sourceURL last
1085
- if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
1086
- pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
1087
- }
1088
-
1089
- pushStringTo(load, source.length, dynamicImportEndStack);
1090
-
1091
- if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
1092
-
1093
- load.b = createBlob(resolvedSource);
1094
- load.S = resolvedSource = undefined;
1095
- };
1096
-
1097
- const sourceURLCommentPrefix = '\\n//# sourceURL=';
1098
- const sourceMapURLCommentPrefix = '\\n//# sourceMappingURL=';
1099
- const cssUrlRegEx = /url\\(\\s*(?:(["'])((?:\\\\.|[^\\n\\\\"'])+)\\1|((?:\\\\.|[^\\s,"'()\\\\])+))\\s*\\)/g;
1100
-
1101
- // restrict in-flight fetches to a pool of 100
1102
- let p = [];
1103
- let c = 0;
1104
- const pushFetchPool = () => {
1105
- if (++c > 100) return new Promise(r => p.push(r));
1106
- };
1107
- const popFetchPool = () => {
1108
- c--;
1109
- if (p.length) p.shift()();
1110
- };
1111
-
1112
- const doFetch = async (url, fetchOpts, parent) => {
1113
- if (enforceIntegrity && !fetchOpts.integrity) throw Error(\`No integrity for \${url}\${fromParent(parent)}.\`);
1114
- let res,
1115
- poolQueue = pushFetchPool();
1116
- if (poolQueue) await poolQueue;
1117
- try {
1118
- res = await fetchHook(url, fetchOpts);
1119
- } catch (e) {
1120
- e.message = \`Unable to fetch \${url}\${fromParent(parent)} - see network log for details.\\n\` + e.message;
1121
- throw e;
1122
- } finally {
1123
- popFetchPool();
1124
- }
1125
-
1126
- if (!res.ok) {
1127
- const error = new TypeError(\`\${res.status} \${res.statusText} \${res.url}\${fromParent(parent)}\`);
1128
- error.response = res;
1129
- throw error;
1130
- }
1131
- return res;
1132
- };
1133
-
1134
- let esmsTsTransform;
1135
- const initTs = async () => {
1136
- const m = await import(tsTransform);
1137
- if (!esmsTsTransform) esmsTsTransform = m.transform;
1138
- };
1139
-
1140
- async function defaultSourceHook(url, fetchOpts, parent) {
1141
- let res = await doFetch(url, fetchOpts, parent),
1142
- contentType,
1143
- [, json, type, jsts] =
1144
- (contentType = res.headers.get('content-type') || '').match(
1145
- /^(?:[^/;]+\\/(?:[^/+;]+\\+)?(json)|(?:text|application)\\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/
1146
- ) || [];
1147
- if (!(type = json || (jsts ? jsts[0] + 's' : type || (/\\.m?ts(\\?|#|$)/.test(url) && 'ts')))) {
1148
- throw Error(
1149
- \`Unsupported Content-Type "\${contentType}" loading \${url}\${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.\`
1150
- );
1151
- }
1152
- return {
1153
- url: res.url,
1154
- source: await (type > 'v' ? WebAssembly.compileStreaming(res) : res.text()),
1155
- type
1156
- };
1157
- }
1158
-
1159
- const hotPrefix = 'var h=import.meta.hot,';
1160
- const fetchModule = async (reqUrl, fetchOpts, parent) => {
1161
- const mapIntegrity = composedImportMap.integrity[reqUrl];
1162
- fetchOpts = mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts;
1163
- let {
1164
- url = reqUrl,
1165
- source,
1166
- type
1167
- } = (await (sourceHook || defaultSourceHook)(reqUrl, fetchOpts, parent, defaultSourceHook)) || {};
1168
- if (type === 'wasm') {
1169
- const exports = WebAssembly.Module.exports((sourceCache[url] = source));
1170
- const imports = WebAssembly.Module.imports(source);
1171
- const rStr = urlJsString(url);
1172
- source = \`import*as $_ns from\${rStr};\`;
1173
- let i = 0,
1174
- obj = '';
1175
- for (const { module, kind } of imports) {
1176
- const specifier = urlJsString(module);
1177
- source += \`import*as impt\${i} from\${specifier};\\n\`;
1178
- obj += \`\${specifier}:\${kind === 'global' ? \`importShim._i.get(impt\${i})||impt\${i++}\` : \`impt\${i++}\`},\`;
1179
- }
1180
- source += \`\${hotPrefix}i=await WebAssembly.instantiate(importShim._s[\${rStr}],{\${obj}});importShim._i.set($_ns,i);\`;
1181
- obj = '';
1182
- for (const { name, kind } of exports) {
1183
- source += \`export let \${name}=i.exports['\${name}'];\`;
1184
- if (kind === 'global') source += \`try{\${name}=\${name}.value}catch(_){\${name}=undefined}\`;
1185
- obj += \`\${name},\`;
1186
- }
1187
- source += \`if(h)h.accept(m=>({\${obj}}=m))\`;
1188
- } else if (type === 'json') {
1189
- source = \`\${hotPrefix}j=JSON.parse(\${JSON.stringify(source)});export{j as default};if(h)h.accept(m=>j=m.default)\`;
1190
- } else if (type === 'css') {
1191
- source = \`\${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(\${JSON.stringify(
1192
- source.replace(
1193
- cssUrlRegEx,
1194
- (_match, quotes = '', relUrl1, relUrl2) => \`url(\${quotes}\${resolveUrl(relUrl1 || relUrl2, url)}\${quotes})\`
1195
- )
1196
- )});if(h){h.data.s=s;h.accept(()=>{})}export default s\`;
1197
- } else if (type === 'ts') {
1198
- if (!esmsTsTransform) await initTs();
1199
- const transformed = esmsTsTransform(source, url);
1200
- // even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
1201
- // a valid JS MIME here, so we must still polyfill it
1202
- source = transformed === undefined ? source : transformed;
1203
- }
1204
- return { url, source, type };
1205
- };
1206
-
1207
- const getOrCreateLoad = (url, fetchOpts, parent, source) => {
1208
- if (source && registry[url]) {
1209
- let i = 0;
1210
- while (registry[url + '#' + ++i]);
1211
- url += '#' + i;
1212
- }
1213
- let load = registry[url];
1214
- if (load) return load;
1215
- registry[url] = load = {
1216
- // url
1217
- u: url,
1218
- // response url
1219
- r: source ? url : undefined,
1220
- // fetchPromise
1221
- f: undefined,
1222
- // source
1223
- S: source,
1224
- // linkPromise
1225
- L: undefined,
1226
- // analysis
1227
- a: undefined,
1228
- // deps
1229
- d: undefined,
1230
- // blobUrl
1231
- b: undefined,
1232
- // shellUrl
1233
- s: undefined,
1234
- // needsShim: does it fail execution in the current native loader?
1235
- n: false,
1236
- // shouldShim: does it need to be loaded by the polyfill loader?
1237
- N: false,
1238
- // type
1239
- t: null,
1240
- // meta
1241
- m: null
1242
- };
1243
- load.f = (async () => {
1244
- if (load.S === undefined) {
1245
- // preload fetch options override fetch options (race)
1246
- ({ url: load.r, source: load.S, type: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
1247
- if (
1248
- !load.n &&
1249
- load.t !== 'js' &&
1250
- !shimMode &&
1251
- ((load.t === 'css' && !supportsCssType) ||
1252
- (load.t === 'json' && !supportsJsonType) ||
1253
- (load.t === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
1254
- load.t === 'ts')
1255
- ) {
1256
- load.n = true;
1257
- }
1258
- }
1259
- try {
1260
- load.a = parse(load.S, load.u);
1261
- } catch (e) {
1262
- throwError(e);
1263
- load.a = [[], [], false];
1264
- }
1265
- return load;
1266
- })();
1267
- return load;
1268
- };
1269
-
1270
- const featErr = feat =>
1271
- Error(
1272
- \`\${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["\${feat}"] }<\${''}/script>\`
1273
- );
1274
-
1275
- const linkLoad = (load, fetchOpts) => {
1276
- if (load.L) return;
1277
- load.L = load.f.then(() => {
1278
- let childFetchOpts = fetchOpts;
1279
- load.d = load.a[0]
1280
- .map(({ n, d, t, a, se }) => {
1281
- const phaseImport = t >= 4;
1282
- const sourcePhase = phaseImport && t < 6;
1283
- if (phaseImport) {
1284
- if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
1285
- throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
1286
- if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
1287
- }
1288
- let source = undefined;
1289
- if (a > 0 && !shimMode && nativePassthrough) {
1290
- const assertion = load.S.slice(a, se - 1);
1291
- // no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
1292
- if (assertion.includes('json')) {
1293
- if (supportsJsonType) source = '';
1294
- else load.n = true;
1295
- } else if (assertion.includes('css')) {
1296
- if (supportsCssType) source = '';
1297
- else load.n = true;
1298
- }
1299
- }
1300
- if (d !== -1 || !n) return;
1301
- const resolved = resolve(n, load.r || load.u);
1302
- if (resolved.n || hasCustomizationHooks) load.n = true;
1303
- if (d >= 0 || resolved.N) load.N = true;
1304
- if (d !== -1) return;
1305
- if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
1306
- if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
1307
- const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
1308
- // assertion case -> inline the CSS / JSON URL directly
1309
- if (source === '') child.l.b = child.l.u;
1310
- if (!child.s) linkLoad(child.l, fetchOpts);
1311
- // load, sourcePhase
1312
- return child;
1313
- })
1314
- .filter(l => l);
1315
- });
1316
- };
1317
-
1318
- const processScriptsAndPreloads = () => {
1319
- for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
1320
- if (!link.ep) processPreload(link);
1321
- }
1322
- for (const script of document.querySelectorAll('script[type]')) {
1323
- if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
1324
- if (!script.ep) processImportMap(script);
1325
- } else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
1326
- legacyAcceptingImportMaps = false;
1327
- if (!script.ep) processScript(script);
1328
- }
1329
- }
1330
- };
1331
-
1332
- const getFetchOpts = script => {
1333
- const fetchOpts = {};
1334
- if (script.integrity) fetchOpts.integrity = script.integrity;
1335
- if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
1336
- if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
1337
- if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
1338
- else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
1339
- else fetchOpts.credentials = 'same-origin';
1340
- return fetchOpts;
1341
- };
1342
-
1343
- let lastStaticLoadPromise = Promise.resolve();
1344
-
1345
- let domContentLoaded = false;
1346
- let domContentLoadedCnt = 1;
1347
- const domContentLoadedCheck = m => {
1348
- if (m === undefined) {
1349
- if (domContentLoaded) return;
1350
- domContentLoaded = true;
1351
- domContentLoadedCnt--;
1352
- }
1353
- if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1354
- document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
1355
- document.dispatchEvent(new Event('DOMContentLoaded'));
1356
- }
1357
- };
1358
- let loadCnt = 1;
1359
- const loadCheck = () => {
1360
- if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1361
- window.removeEventListener('load', loadEvent);
1362
- window.dispatchEvent(new Event('load'));
1363
- }
1364
- };
1365
-
1366
- const domContentLoadedEvent = async () => {
1367
- await initPromise;
1368
- domContentLoadedCheck();
1369
- };
1370
- const loadEvent = async () => {
1371
- await initPromise;
1372
- domContentLoadedCheck();
1373
- loadCheck();
1374
- };
1375
-
1376
- // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
1377
- if (hasDocument) {
1378
- document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
1379
- window.addEventListener('load', loadEvent);
1380
- }
1381
-
1382
- const readyListener = async () => {
1383
- await initPromise;
1384
- processScriptsAndPreloads();
1385
- if (document.readyState === 'complete') {
1386
- readyStateCompleteCheck();
1387
- }
1388
- };
1389
-
1390
- let readyStateCompleteCnt = 1;
1391
- const readyStateCompleteCheck = () => {
1392
- if (--readyStateCompleteCnt === 0) {
1393
- domContentLoadedCheck();
1394
- if (!noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1395
- document.removeEventListener('readystatechange', readyListener);
1396
- document.dispatchEvent(new Event('readystatechange'));
1397
- }
1398
- }
1399
- };
1400
-
1401
- const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
1402
- const epCheck = (script, ready) =>
1403
- script.ep ||
1404
- (!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
1405
- script.getAttribute('noshim') !== null ||
1406
- !(script.ep = true);
1407
-
1408
- const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
1409
- if (epCheck(script, ready)) return;
1410
- // we dont currently support external import maps in polyfill mode to match native
1411
- if (script.src) {
1412
- if (!shimMode) return;
1413
- importMapSrc = true;
1414
- }
1415
- importMapPromise = importMapPromise
1416
- .then(async () => {
1417
- composedImportMap = resolveAndComposeImportMap(
1418
- script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
1419
- script.src || baseUrl,
1420
- composedImportMap
1421
- );
1422
- })
1423
- .catch(e => {
1424
- if (e instanceof SyntaxError)
1425
- e = new Error(\`Unable to parse import map \${e.message} in: \${script.src || script.innerHTML}\`);
1426
- throwError(e);
1427
- });
1428
- if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
1429
- if (!legacyAcceptingImportMaps && !multipleImportMaps) {
1430
- multipleImportMaps = true;
1431
- if (!shimMode && baselineSupport && !supportsMultipleImportMaps) {
1432
- baselineSupport = false;
1433
- if (hasDocument) attachMutationObserver();
1434
- }
1435
- }
1436
- legacyAcceptingImportMaps = false;
1437
- };
1438
-
1439
- const processScript = (script, ready = readyStateCompleteCnt > 0) => {
1440
- if (epCheck(script, ready)) return;
1441
- // does this load block readystate complete
1442
- const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
1443
- // does this load block DOMContentLoaded
1444
- const isDomContentLoadedScript = domContentLoadedCnt > 0;
1445
- const isLoadScript = loadCnt > 0;
1446
- if (isLoadScript) loadCnt++;
1447
- if (isBlockingReadyScript) readyStateCompleteCnt++;
1448
- if (isDomContentLoadedScript) domContentLoadedCnt++;
1449
- let loadPromise;
1450
- const ts = script.lang === 'ts';
1451
- if (ts && !script.src) {
1452
- loadPromise = Promise.resolve(esmsTsTransform || initTs())
1453
- .then(() => {
1454
- const transformed = esmsTsTransform(script.innerHTML, baseUrl);
1455
- if (transformed !== undefined) {
1456
- onpolyfill();
1457
- firstPolyfillLoad = false;
1458
- }
1459
- return topLevelLoad(
1460
- script.src || baseUrl,
1461
- baseUrl,
1462
- getFetchOpts(script),
1463
- transformed === undefined ? script.innerHTML : transformed,
1464
- !shimMode && transformed === undefined,
1465
- isBlockingReadyScript && lastStaticLoadPromise,
1466
- 'ts'
1467
- );
1468
- })
1469
- .catch(throwError);
1470
- } else {
1471
- loadPromise = topLevelLoad(
1472
- script.src || baseUrl,
1473
- baseUrl,
1474
- getFetchOpts(script),
1475
- !script.src ? script.innerHTML : undefined,
1476
- !shimMode,
1477
- isBlockingReadyScript && lastStaticLoadPromise,
1478
- ts ? 'ts' : undefined
1479
- ).catch(throwError);
1480
- }
1481
- if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
1482
- if (isBlockingReadyScript && !ts) {
1483
- lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
1484
- }
1485
- if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
1486
- if (isLoadScript) loadPromise.then(loadCheck);
1487
- };
1488
-
1489
- const fetchCache = {};
1490
- const processPreload = link => {
1491
- link.ep = true;
1492
- initPromise.then(() => {
1493
- if (baselineSupport && !shimMode) return;
1494
- if (fetchCache[link.href]) return;
1495
- fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
1496
- });
1497
- };
1498
-
1499
- })();
1500
- `,Km=`/* Runs only in the opaque preview frame. All local reads use its directory capability. */
1501
- function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
1502
- const external = new Set(externalOrigins);
1503
- const report = () => parent.postMessage({ type: 'preview-error', capability }, '*');
1504
- const nativeFetch = window.fetch.bind(window);
1505
- const nativeWorker = window.Worker;
1506
- const externalUrl = value => {
1507
- const url = new URL(value, base);
1508
- const origin = url.protocol === 'wss:' ? 'https://' + url.host : url.origin;
1509
- if (!external.has(origin)) throw new Error('Outside preview network scope');
1510
- return url;
1511
- };
1512
- const bridgeFetch = async (input, init = {}) => {
1513
- const url = new URL(typeof input === 'string' ? input : input.url || String(input), base);
1514
- const method = String(init.method || (input && input.method) || 'GET').toUpperCase();
1515
- if (url.protocol === 'blob:' || url.protocol === 'data:') return nativeFetch(input, init);
1516
- if (url.origin !== new URL(base).origin) {
1517
- externalUrl(url.href);
1518
- return nativeFetch(url.href, { ...init, method, credentials: 'omit', referrerPolicy: 'no-referrer' });
1519
- }
1520
- if (!['GET', 'HEAD'].includes(method) || !url.pathname.startsWith(new URL(base).pathname)) throw new Error('Outside preview directory');
1521
- return new Promise((resolve, reject) => {
1522
- if (init.signal?.aborted) { reject(init.signal.reason); return; }
1523
- const channel = new MessageChannel();
1524
- const finish = () => { clearTimeout(timer); channel.port1.close(); init.signal?.removeEventListener('abort', abort); };
1525
- const abort = () => { finish(); reject(init.signal.reason); };
1526
- const timer = setTimeout(() => { finish(); report(); reject(new Error('Preview resource timeout')); }, 15000);
1527
- init.signal?.addEventListener('abort', abort, { once: true });
1528
- channel.port1.onmessage = event => {
1529
- finish();
1530
- if (event.data.error) { reject(new Error(event.data.error)); return; }
1531
- const response = new Response(method === 'HEAD' ? null : event.data.data, { status: event.data.status, headers: event.data.headers });
1532
- Object.defineProperty(response, 'url', { value: url.href }); resolve(response);
1533
- };
1534
- parent.postMessage({ type: 'preview-fetch', capability, url: url.href, method }, '*', [channel.port2]);
1535
- });
1536
- };
1537
- Object.defineProperty(window, 'fetch', { configurable: false, writable: false, value: bridgeFetch });
1538
- window.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: bridgeFetch, onerror: report };
1539
- class PreviewXHR extends EventTarget {
1540
- readyState = 0; status = 0; statusText = ''; response = null; responseText = ''; responseURL = ''; responseType = ''; timeout = 0;
1541
- upload = new EventTarget(); withCredentials = false;
1542
- open(method, url, async = true) {
1543
- if (!async) throw new Error('Synchronous preview requests are unavailable');
1544
- this.abort(); this.method = method; this.url = new URL(url, base).href; this.headers = {}; this.readyState = 1; this.emit('readystatechange');
1545
- }
1546
- setRequestHeader(name, value) { this.headers[name] = value; }
1547
- getAllResponseHeaders() { return this.responseHeaders ? [...this.responseHeaders].map(([key, value]) => key + ': ' + value + '\\r\\n').join('') : ''; }
1548
- getResponseHeader(name) { return this.responseHeaders?.get(name) ?? null; }
1549
- overrideMimeType(value) { this.mime = value; }
1550
- emit(type, event = new Event(type)) { this.dispatchEvent(event); this['on' + type]?.call(this, event); }
1551
- abort() { if (this.controller) { this.controller.abort(); this.controller = null; this.readyState = 0; this.emit('abort'); this.emit('loadend'); } }
1552
- send(body = null) {
1553
- const controller = new AbortController(); this.controller = controller;
1554
- const timer = this.timeout > 0 ? setTimeout(() => { if (this.controller !== controller) return; controller.abort(); this.controller = null; this.emit('timeout'); this.emit('loadend'); }, this.timeout) : null;
1555
- this.emit('loadstart');
1556
- bridgeFetch(this.url, { method: this.method, headers: this.headers, body, signal: controller.signal }).then(async response => {
1557
- this.status = response.status; this.statusText = response.statusText; this.responseURL = response.url; this.responseHeaders = response.headers;
1558
- this.readyState = 2; this.emit('readystatechange'); this.readyState = 3; this.emit('readystatechange');
1559
- const bytes = await response.arrayBuffer();
1560
- if (this.controller !== controller) return;
1561
- this.responseText = new TextDecoder().decode(bytes);
1562
- this.response = this.responseType === 'arraybuffer' ? bytes : this.responseType === 'blob' ? new Blob([bytes], { type: this.mime || response.headers.get('content-type') || '' }) : this.responseType === 'json' ? (() => { try { return JSON.parse(this.responseText); } catch { return null; } })() : this.responseType === 'document' ? new DOMParser().parseFromString(this.responseText, 'text/html') : this.responseText;
1563
- this.readyState = 4; this.emit('readystatechange'); this.emit('progress', new ProgressEvent('progress', { lengthComputable: true, loaded: bytes.byteLength, total: bytes.byteLength })); this.emit('load'); this.emit('loadend'); this.controller = null;
1564
- }).catch(() => { if (this.controller !== controller) return; this.controller = null; this.status = 0; this.readyState = 4; this.emit('readystatechange'); this.emit('error'); this.emit('loadend'); }).finally(() => clearTimeout(timer));
1565
- }
1566
- }
1567
- for (const [key, value] of Object.entries({ UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4 })) { PreviewXHR[key] = value; PreviewXHR.prototype[key] = value; }
1568
- Object.defineProperty(window, 'XMLHttpRequest', { configurable: false, writable: false, value: PreviewXHR });
1569
- for (const name of ['WebSocket', 'EventSource']) {
1570
- const Native = window[name];
1571
- if (Native) Object.defineProperty(window, name, { configurable: false, writable: false, value: class extends Native {
1572
- constructor(url, options) { super(externalUrl(url).href, name === 'EventSource' ? { withCredentials: false } : options); }
1573
- } });
1574
- }
1575
- // A worker receives the same read-only bridge over a private MessagePort. Its
1576
- // module graph is loaded by the same shim, including computed dynamic imports.
1577
- class PreviewWorker extends EventTarget {
1578
- constructor(url, options = {}) {
1579
- super();
1580
- const entry = new URL(url, base).href;
1581
- const workerSource = \`(\${workerBootstrap.toString()})(\${JSON.stringify(entry)},\${JSON.stringify(options.type || 'classic')},\${JSON.stringify(shimUrl)});\`;
1582
- this.objectUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));
1583
- this.worker = new nativeWorker(this.objectUrl, { name: options.name });
1584
- const channel = new MessageChannel(); this.port = channel.port1;
1585
- this.port.onmessage = async event => {
1586
- const { id, url, init } = event.data;
1587
- try { const response = await bridgeFetch(url, init); const data = await response.arrayBuffer(); this.port.postMessage({ id, status: response.status, headers: [...response.headers], data }, [data]); }
1588
- catch (error) { this.port.postMessage({ id, error: String(error) }); }
1589
- };
1590
- this.worker.postMessage({ previewInit: true, base: entry, importMap: window.importShim?.getImportMap?.() }, [channel.port2]);
1591
- for (const type of ['message', 'messageerror', 'error']) this.worker.addEventListener(type, event => {
1592
- const forwarded = type === 'error' ? new ErrorEvent(type, { message: event.message }) : new MessageEvent(type, { data: event.data, ports: event.ports });
1593
- this.dispatchEvent(forwarded); this['on' + type]?.call(this, forwarded);
1594
- });
1595
- }
1596
- postMessage(value, transfer) { this.worker.postMessage(value, transfer); }
1597
- terminate() { this.worker.terminate(); this.port.close(); URL.revokeObjectURL(this.objectUrl); }
1598
- }
1599
- function workerBootstrap(entry, type, shim) {
1600
- const queued = []; let initialized = false, ready = false;
1601
- const receive = event => {
1602
- if (!event.data?.previewInit || initialized) { if (!ready) { event.stopImmediatePropagation(); queued.push(event); } return; }
1603
- initialized = true; event.stopImmediatePropagation();
1604
- const port = event.ports[0]; const pending = new Map(); let next = 0;
1605
- port.onmessage = message => { const done = pending.get(message.data.id); if (!done) return; pending.delete(message.data.id); message.data.error ? done.reject(new Error(message.data.error)) : done.resolve(new Response(message.data.data, { status: message.data.status, headers: message.data.headers })); };
1606
- self.fetch = (url, init = {}) => new Promise((resolve, reject) => { const id = ++next; pending.set(id, { resolve, reject }); port.postMessage({ id, url: new URL(typeof url === 'string' ? url : url.url || String(url), entry).href, init: { method: init.method || 'GET', headers: init.headers } }); });
1607
- self.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: self.fetch };
1608
- const nativeImport = self.importScripts.bind(self);
1609
- nativeImport(shim);
1610
- if (event.data.importMap) self.importShim.addImportMap(event.data.importMap);
1611
- const load = type === 'module' ? self.importShim(entry) : self.fetch(entry).then(r => r.text()).then(source => { const blob = URL.createObjectURL(new Blob([source], { type: 'text/javascript' })); nativeImport(blob); URL.revokeObjectURL(blob); });
1612
- load.then(() => { ready = true; removeEventListener('message', receive); for (const message of queued) dispatchEvent(new MessageEvent('message', { data: message.data, ports: message.ports })); }).catch(error => setTimeout(() => { throw error; }));
1613
- };
1614
- addEventListener('message', receive);
1615
- }
1616
- Object.defineProperty(window, 'Worker', { configurable: false, writable: false, value: PreviewWorker });
1617
- const navigate = value => {
1618
- const url = new URL(value, base);
1619
- if (url.origin === new URL(base).origin && url.pathname.startsWith(new URL(base).pathname)) parent.postMessage({ type: 'preview-navigate', capability, url: url.href }, '*');
1620
- else { externalUrl(url.href); parent.postMessage({ type: 'preview-external', capability, url: url.href }, '*'); }
1621
- };
1622
- Object.defineProperty(window, 'open', { configurable: false, writable: false, value: value => { navigate(value); return null; } });
1623
- document.addEventListener('click', event => { const anchor = event.target.closest?.('a,area'); const href = anchor?.getAttribute('href'); if (href && !href.startsWith('#')) { event.preventDefault(); navigate(href); } }, true);
1624
- document.addEventListener('submit', event => {
1625
- event.preventDefault(); const form = event.target;
1626
- const url = new URL(form.getAttribute('action') || base, base);
1627
- if ((form.getAttribute('method') || 'get').toLowerCase() !== 'get') { report(); return; }
1628
- for (const [key, value] of new FormData(form)) if (typeof value === 'string') url.searchParams.append(key, value);
1629
- navigate(url.href);
1630
- }, true);
1631
- window.addEventListener('securitypolicyviolation', report);
1632
- window.addEventListener('error', report, true);
1633
- window.addEventListener('unhandledrejection', report);
1634
- }
1635
- `,ao="/api/terminal/fs/preview/",Vm=8*1024*1024,Ym=32*1024*1024,Xm=128,Jm="data:,";function Nt(r){throw new Error(r)}function Qm(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Ad(r,a,i){let c="",f=0;for(const p of r.matchAll(a))c+=r.slice(f,p.index)+await i(p),f=p.index+p[0].length;return c+r.slice(f)}async function pu(r,a){const i=a.origin??location.origin,c=new URL(r,i);(c.origin!==i||!Ws(c.pathname)?.startsWith(ao))&&Nt("预览地址不是有效的本地文件入口");const f=crypto.randomUUID(),p=`https://termdock-preview.invalid/${f}/`,g=[],k=F=>{!g.includes(F)&&g.length<20&&g.push(F)},m=new Set,x=[],w=new Set,R=new Map,b=new Map;let A=0,P=!1;const $=new Set,D=()=>{P=!0;for(const F of[...$])F();m.clear(),x.length=0};async function te(F){F.ok||Nt(`预览资源读取失败(${F.status})`);const ee=F.body?.getReader(),C=[];let L=0;try{if(ee)for(;;){const pe=await ee.read();if(pe.done)break;L+=pe.value.byteLength,A+=pe.value.byteLength,(L>Vm||A>Ym)&&Nt("预览资源超出大小限制"),C.push(pe.value)}}catch(pe){throw await ee?.cancel().catch(()=>{}),pe}finally{ee?.releaseLock()}const q=new Uint8Array(L);let ne=0;for(const pe of C)q.set(pe,ne),ne+=pe.length;return{bytes:q,type:F.headers.get("content-type")??"application/octet-stream",status:F.status}}let M=c,I;for(let F=0;F<4;F++){const ee=await a.fetch(M.pathname+M.search,{signal:a.signal,redirect:"manual"});if(![301,302,303,307,308].includes(ee.status)){I=ee;break}const C=ee.headers.get("location");await ee.body?.cancel(),C||Nt("预览重定向缺少目标");const L=new URL(C,M);(L.origin!==i||!Ws(L.pathname)?.startsWith(ao))&&Nt("预览重定向越出文件范围"),M=L}I||Nt("预览重定向次数过多");const H=Ws(M.pathname),Y=H.slice(ao.length).split("/");/^[a-f0-9]{32}$/.test(Y[0])||Nt("服务未提供有效的预览资源授权");const be=Ws(c.pathname).slice(ao.length).split("/");/^[a-f0-9]{32}$/.test(be[0])&&be.shift(),be.join("/").replace(/\/$/,"")!==Y.slice(1).join("/").replace(/\/$/,"")&&Nt("预览重定向改变了文件范围");const _=H.endsWith("/")?H:H.slice(0,H.lastIndexOf("/")+1),o=new URL(M.pathname.endsWith("/")?M.pathname:M.pathname.slice(0,M.pathname.lastIndexOf("/")+1),i);function ae(F,ee){const C=new URL(F,ee);return C.origin!==i?null:(Ws(C.pathname)?.startsWith(_)||Nt("已阻止预览访问目录之外的资源"),C)}function W(F){const ee=new URL(F,p);(ee.origin!==new URL(p).origin||!ee.pathname.startsWith(new URL(p).pathname))&&Nt("已阻止预览访问服务接口或目录之外的资源");const C=ee.pathname.slice(new URL(p).pathname.length)+ee.search;return ae(C,o)??Nt("预览资源无效")}function he(F){const ee=F.pathname+F.search,C=R.get(ee);if(C)return C;if(P||a.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(R.size>=Xm)return Promise.reject(new Error("预览资源数量超出限制"));const L=a.fetch(ee,{signal:a.signal,redirect:"manual"}).then(te);return R.set(ee,L),L}function G(F,ee){P&&Nt("预览已关闭");const C=`termdock-resource-${f}-${x.length}`;return x.push({token:C,data:F,type:ee}),m.add(C),C}async function le(F,ee,C,L=new Set){if(!F||F.startsWith("#")||/^data:(?:image|font)\//i.test(F)&&C==="resource")return F;try{const q=ae(F,ee);if(!q){const Pe=new URL(F,ee);return(Pe.protocol!=="https:"||Pe.username||Pe.password||Pe.origin===new URL(p).origin)&&Nt("已阻止不安全的外部资源"),w.add(Pe.origin),Pe.href}const ne=`${C}:${q.href}`;(L.has(ne)||L.size>=8)&&Nt("预览资源存在循环或过深引用");const pe=b.get(ne);if(pe)return pe;const Ne=new Set(L);Ne.add(ne);const we=(async()=>{const Pe=await he(q);return C==="css"?G(await j(new TextDecoder().decode(Pe.bytes),q,Ne),"text/css"):C==="script"?G(Pe.bytes,"text/javascript"):G(Pe.bytes,Pe.type)})();return b.set(ne,we),await we}catch(q){return k(q instanceof Error?q.message:"部分预览资源未能加载"),Jm}}async function j(F,ee,C){return F=await Ad(F,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async L=>`@import url("${await le(L[1],ee,"css",C)}")${L[2]};`),Ad(F,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async L=>{const q=(L[1]??L[2]??L[3]).trim();return m.has(q)?L[0]:`url("${await le(q,ee,"resource",C)}")`})}try{const F=await te(I),ee=G(qm,"text/javascript"),C=new DOMParser().parseFromString(new TextDecoder().decode(F.bytes),"text/html");C.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(O=>O.remove());for(const O of C.querySelectorAll("*")){if(O.removeAttribute("ping"),O.removeAttribute("srcdoc"),O.hasAttribute("style")&&O.setAttribute("style",await j(O.getAttribute("style"),M,new Set)),O.tagName==="STYLE"&&(O.textContent=await j(O.textContent??"",M,new Set)),O.tagName==="A"||O.tagName==="AREA"){const ue=O.getAttribute("href");try{if(ue&&!ue.startsWith("#")){const oe=ae(ue,M);if(oe)O.setAttribute("href",new URL(oe.pathname.slice(o.pathname.length)+oe.search+oe.hash,p).href);else{const Fe=new URL(ue,M);if(Fe.protocol!=="https:"){O.removeAttribute("href");continue}w.add(Fe.origin),O.setAttribute("href",Fe.href)}}}catch(oe){O.removeAttribute("href"),k(oe instanceof Error?oe.message:"预览链接无法加载")}}for(const ue of["data","manifest"])O.removeAttribute(ue);if(O.tagName==="SCRIPT"&&O.getAttribute("type")==="module"){O.setAttribute("type","module-shim");const ue=O.getAttribute("src");if(ue){const oe=ae(ue,M);if(oe)O.setAttribute("src",new URL(oe.pathname.slice(o.pathname.length)+oe.search,p).href);else{const Fe=new URL(ue,M);if(Fe.protocol!=="https:"){O.remove();continue}w.add(Fe.origin),O.setAttribute("src",Fe.href)}}continue}if(O.tagName==="SCRIPT"&&O.getAttribute("type")==="importmap"){O.setAttribute("type","importmap-shim");continue}if(O.tagName==="LINK"){const ue=(O.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ue)){O.remove();continue}const oe=O.getAttribute("href");oe&&O.setAttribute("href",await le(oe,M,ue==="stylesheet"?"css":"resource"))}if(O.hasAttribute("src")&&O.setAttribute("src",await le(O.getAttribute("src"),M,O.tagName==="SCRIPT"?"script":"resource")),O.hasAttribute("poster")&&O.setAttribute("poster",await le(O.getAttribute("poster"),M,"resource")),O.hasAttribute("srcset")){const ue=O.getAttribute("srcset");/data:/i.test(ue)?(O.removeAttribute("srcset"),k("混合内嵌图片候选暂不支持安全预览")):O.setAttribute("srcset",(await Promise.all(ue.split(",").map(async oe=>{const[Fe,...Ie]=oe.trim().split(/\s+/);return`${await le(Fe,M,"resource")} ${Ie.join(" ")}`}))).join(", "))}O.setAttribute("referrerpolicy","no-referrer"),O.removeAttribute("integrity"),O.removeAttribute("crossorigin")}const L=[...w].join(" "),q=C.createElement("meta");q.httpEquiv="Content-Security-Policy",q.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${L}; style-src 'unsafe-inline' blob: ${L}; img-src blob: data: ${L}; font-src blob: data: ${L}; media-src blob: data: ${L}; connect-src blob: ${L} ${[...w].map(O=>O.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ne=C.createElement("base");ne.href=p;const pe=C.createElement("meta");pe.name="referrer",pe.content="no-referrer";const Ne=C.createElement("script");Ne.textContent=Km+`
1636
- installPreviewRuntime(`+[f,p,[...w],ee].map(Qm).join(",")+");";const we=C.createElement("script");we.src=ee,C.head.prepend(q,pe,ne,Ne,we);const Pe=`<!doctype html>
1637
- `+C.documentElement.outerHTML;return{html:Pe,shellUrl:`/preview-shell.html#${f}`,errors:g,attach(O,ue){const oe=new Set,Fe=E=>{if(E.source!==O.contentWindow||E.data?.capability!==f)return;if(E.data.type==="preview-ready"){O.contentWindow?.postMessage({type:"preview-init",capability:f,html:Pe,resources:x},"*");return}if(E.data.type==="preview-error"){ue("部分动态内容被安全预览限制");return}if(E.data.type==="preview-navigate"){(async()=>{const ge=W(String(E.data.url)),De=await pu(ge.pathname+ge.search,a);if(P){De.dispose();return}const Ve=De.attach(O,ue);$.add(()=>{Ve(),De.dispose()}),O.src=De.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ge=>ue(ge instanceof Error?ge.message:"无法打开预览页面"));return}if(E.data.type==="preview-external"){try{const ge=new URL(String(E.data.url));ge.protocol==="https:"&&w.has(ge.origin)&&window.open(ge.href,"_blank","noopener,noreferrer")}catch{}return}if(E.data.type!=="preview-fetch"||E.ports.length!==1)return;const xe=E.ports[0];if(oe.size>=8||!["GET","HEAD"].includes(E.data.method)){xe.postMessage({error:"预览仅允许读取已授权目录资源"}),xe.close();return}oe.add(xe),(async()=>{const ge=W(String(E.data.url)),De=await he(ge);if(!oe.has(xe)||P)return;const Ve=E.data.method==="HEAD"?new Uint8Array:De.bytes.slice();xe.postMessage({status:De.status,headers:{"content-type":De.type},data:Ve.buffer},[Ve.buffer])})().catch(()=>{xe.postMessage({error:"预览资源不在授权范围或无法加载"}),ue("部分动态资源不可用或超出预览目录")}).finally(()=>{oe.delete(xe),xe.close()})};window.addEventListener("message",Fe);const Ie=()=>{window.removeEventListener("message",Fe);for(const E of oe)E.close();oe.clear(),$.delete(Ie)};return $.add(Ie),Ie},dispose:D}}catch(F){throw D(),F}}const Zm=n.forwardRef(function({src:a,title:i,exitFullscreenLabel:c,onFullscreenChange:f},p){const g=n.useRef(null),[k,m]=n.useState(null),[x,w]=n.useState(),[R,b]=n.useState("");n.useEffect(()=>{const H=new AbortController;let Y;return w(void 0),b(""),(async()=>{const be=await ah();if(Y=await pu(a,{fetch:(_,o)=>be.fetch(_,o),signal:H.signal}),H.signal.aborted){Y.dispose();return}w(Y),Y.errors.length&&b(Y.errors.join(";"))})().catch(be=>{H.signal.aborted||b(be instanceof Error?be.message:"安全预览加载失败")}),()=>{H.abort(),Y?.dispose()}},[a]),n.useEffect(()=>{if(!(!x||!k))return x.attach(k,b)},[x,k]);const[A,P]=n.useState(!1),[$,D]=n.useState(!1),te=A||$;n.useEffect(()=>{f?.(te)},[te,f]),n.useEffect(()=>{const H=()=>{P(document.fullscreenElement===g.current)};return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]),n.useEffect(()=>{if(!$)return;const H=Y=>{Y.key==="Escape"&&D(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[$]);const M=n.useCallback(async()=>{const H=g.current;if(H){if($){D(!1);return}if(document.fullscreenElement===H){await document.exitFullscreen();return}if(H.requestFullscreen&&document.fullscreenEnabled!==!1)try{await H.requestFullscreen();return}catch{}D(!0)}},[$]);n.useImperativeHandle(p,()=>({toggleFullscreen:M}),[M]);const I=t.jsxs("div",{ref:g,"data-html-preview-frame":!0,className:te?"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:[te&&t.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:[t.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:i}),t.jsx("button",{type:"button",onClick:()=>{M()},"aria-label":c,title:`${c} (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:t.jsx(au,{size:15})})]}),R&&t.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:R}),!x&&!R&&t.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),t.jsx("iframe",{ref:m,src:x?.shellUrl,referrerPolicy:"no-referrer",title:i,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return $?Qr.createPortal(I,document.body):I}),mu="termdock-file-search-match",Zi="termdock-file-search-current";function eg(r,a,i){return!!(a&&r?.isConnected&&!i.defaultPrevented&&!r.closest('[inert], [aria-hidden="true"], [hidden]')&&i.target instanceof Node&&r.contains(i.target))}function tg(r){const a=r.metaKey||r.ctrlKey,i=r.key.toLocaleLowerCase();return a&&i==="f"?"open":a&&i==="g"||r.key==="F3"?r.shiftKey?"previous":"next":r.key==="Escape"?"close":null}function rg(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function ng(r,a){const i=a.trim().toLocaleLowerCase();if(!i)return[];const c=[];let f="",p=null;const g=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let w=g.nextNode();w;w=g.nextNode()){if(!(w instanceof Text)||!w.data)continue;const R=rg(w);if(!R)continue;p&&p!==R&&(f+=`
1638
- `);const b=f.length;f+=w.data,c.push({node:w,start:b,end:f.length,group:R}),p=R}const k=f.toLocaleLowerCase(),m=[];let x=0;for(;x<=k.length-i.length;){const w=k.indexOf(i,x);if(w<0)break;const R=w+i.length,b=c.find(P=>P.start<=w&&P.end>w),A=c.find(P=>P.start<R&&P.end>=R);if(b&&A&&b.group===A.group){const P=document.createRange();P.setStart(b.node,w-b.start),P.setEnd(A.node,R-A.start),m.push(P)}x=w+Math.max(i.length,1)}return m}function gu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let xo;function Td(r){return xo===r}function oo(r){if(r&&xo!==r)return;const a=gu();a?.delete(mu),a?.delete(Zi),xo=void 0}function Ii(r,a,i){const c=gu();if(!c||typeof Highlight>"u")return;xo=i,c.set(mu,new Highlight(...r));const f=r[a];f?c.set(Zi,new Highlight(f)):c.delete(Zi)}function Md(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function sg(r){return Array.from(new Set(r.split(/[\n,]/).map(a=>a.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function ag(r,a){const i=a.trim();return!i||i==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(i)?i.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${i.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function og(r,a){if(a===r)return".";const i=`${r.replace(/[\\/]+$/,"")}/`;return a.startsWith(i)?a.slice(i.length):a}function bu(r,a,i){return a?r:Qr.createPortal(r,i)}const ol="termdock:right-sidebar:file-tree-scroll:v1",il="termdock:right-sidebar:file-preview-reading-state:v1",ea="termdock:right-sidebar:file-tree-width:v1",xu="termdock:right-sidebar:markdown-view-mode:v1",vu="termdock:right-sidebar:diff-change-list-mode:v1",yu="termdock:right-sidebar:diff-wrap:v1",wu="termdock:diff-viewer:view-type:v1",ku="termdock:right-sidebar:file-search-mode:v1",$i="termdock:right-sidebar:collapsed-git-repo-groups:v1",Ld="termdock:right-sidebar:collapsed-diff-directories:v1",Fi="termdock:right-sidebar:branch-audit-module-open:v1",Su="termdock:right-sidebar:branch-audit-module:v1",ig=150,Id="termdock:right-sidebar:context-draft-enabled:v1",$d="termdock:right-sidebar:context-draft-collapsed:v1",Fd="termdock:right-sidebar:context-draft-auto-collapse:v1",Di="termdock:right-sidebar:context-draft-text:v1",lg=300,cg=20,dg=120,ug=250,fg=250,hg=120,pg=700,_i=600,mg=6e4;function Vs(r){return!!(r&&U.getState().nestedGitScanRoots[r])}const Dd=[2e3,5e3,15e3,3e4],gg=320,bg=500,xg=20,vg=12e3,el=300,_d=240,yg=560,Bd=n.lazy(()=>sl(()=>import("./ModelPreview-Cl0X7I-U.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]))),wg=n.lazy(()=>sl(()=>import("./ArchitecturePanel-CYdolNzT.js"),__vite__mapDeps([33,1,2,3,4,5,34,11,12,13,14,24,21,25,26,35,18,19,20,8,9,10,15,16,22,23,27,28,29,30,31,6,32,36])).then(r=>({default:r.ArchitecturePanel}))),kg=n.lazy(()=>sl(()=>import("./ComputerControlView-DU9krDsg.js").then(r=>r.a),__vite__mapDeps([37,1,2,3,4,5,29,31,15,38,30,39])));function Ru(r,a,i){return r&&!a?"unified":i}const Sg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Rg(r){return r==="preview"||r==="source"}function jg(r){return r==="list"||r==="tree"||r==="ai"}function Ud(){return ct(xu,Rg)??"preview"}function Cg(){return ct(vu,jg)??"tree"}function ta(r){return typeof r=="boolean"}function Ng(r){return typeof r=="string"}function Pg(){return ct(yu,ta)??!0}function Eg(r){return r==="unified"||r==="split"}function Ag(){return ct(wu,Eg)??"unified"}function Tg(r){return r==="name"||r==="content"||r==="regex"}function Mg(){return ct(ku,Tg)??"name"}function ju(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:gt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Lg(r,a){if(!a)return null;const i=new Set((r.repoFilters??[]).map(c=>c.root));return i.has(a)?a:i.size>0?null:(r.repositories??[]).some(c=>c.root===a)?a:null}function tl(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Cu(...r){const a=new Set;for(const i of r)for(const c of i)a.add(c.root);return a}function rl(r){return Array.isArray(r)&&r.every(a=>typeof a=="string")}function Od(r){const a=ct(r,rl);return a?new Set(a):new Set}function Bi(r,a){Pt(r,[...a])}function Ig(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.filePath=="string"&&typeof a.hunkHeader=="string"&&typeof a.hunkIndex=="number"&&typeof a.fingerprint=="string"&&typeof a.additions=="number"&&typeof a.deletions=="number"&&typeof a.diff=="string"&&(a.oldPath===void 0||a.oldPath===null||typeof a.oldPath=="string")&&(a.newPath===void 0||a.newPath===null||typeof a.newPath=="string")&&(a.source===void 0||a.source==="committed"||a.source==="uncommitted"||a.source==="unknown")&&(a.commit===void 0||a.commit===null||typeof a.commit=="string")}function $g(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.available=="boolean"&&(a.repoRoot===void 0||typeof a.repoRoot=="string")&&(a.workspaceRoot===void 0||typeof a.workspaceRoot=="string")&&(a.baseRef===void 0||typeof a.baseRef=="string")&&(a.baseBranch===void 0||typeof a.baseBranch=="string")&&(a.currentBranch===void 0||a.currentBranch===null||typeof a.currentBranch=="string")&&(a.headRef===void 0||a.headRef===null||typeof a.headRef=="string")&&(a.diffFingerprint===void 0||typeof a.diffFingerprint=="string")&&(a.stat===void 0||typeof a.stat=="string")&&(a.files===void 0||rl(a.files))&&(a.hunks===void 0||Array.isArray(a.hunks)&&a.hunks.every(Ig))&&(a.commits===void 0||rl(a.commits))&&(a.commitCount===void 0||typeof a.commitCount=="number")&&(a.diff===void 0||typeof a.diff=="string")&&(a.truncated===void 0||typeof a.truncated=="boolean")&&(a.error===void 0||typeof a.error=="string")}function Fg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.key=="string"&&$g(a.diff)&&typeof a.repoLabel=="string"&&typeof a.createdAt=="number"}function Dg(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(a=>{if(!a||typeof a!="object"||Array.isArray(a))return!1;const i=a;return Array.isArray(i.selectedRepoRoots)&&i.selectedRepoRoots.every(c=>typeof c=="string")&&!!i.repoTargetBranches&&typeof i.repoTargetBranches=="object"&&!Array.isArray(i.repoTargetBranches)&&Object.values(i.repoTargetBranches).every(c=>typeof c=="string")&&(i.repoBaseBranches===void 0||!!i.repoBaseBranches&&typeof i.repoBaseBranches=="object"&&!Array.isArray(i.repoBaseBranches)&&Object.values(i.repoBaseBranches).every(c=>typeof c=="string"))&&(i.previewEntries===void 0||Array.isArray(i.previewEntries)&&i.previewEntries.every(Fg))&&(i.selectedPreviewKey===void 0||i.selectedPreviewKey===null||typeof i.selectedPreviewKey=="string")&&(i.selectedPreviewFileKey===void 0||i.selectedPreviewFileKey===null||typeof i.selectedPreviewFileKey=="string")&&(i.previewDetailOpen===void 0||typeof i.previewDetailOpen=="boolean")&&(i.previewScrollTops===void 0||!!i.previewScrollTops&&typeof i.previewScrollTops=="object"&&!Array.isArray(i.previewScrollTops)&&Object.values(i.previewScrollTops).every(c=>typeof c=="number"))&&(i.previewMobileSlideIndex===void 0||typeof i.previewMobileSlideIndex=="number")&&(i.repoIncludeUncommitted===void 0||!!i.repoIncludeUncommitted&&typeof i.repoIncludeUncommitted=="object"&&!Array.isArray(i.repoIncludeUncommitted)&&Object.values(i.repoIncludeUncommitted).every(c=>typeof c=="boolean"))&&(i.includeUncommitted===void 0||typeof i.includeUncommitted=="boolean")&&typeof i.updatedAt=="number"})}function Hd(){return ct(Su,Dg)??{}}function zd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Gd(r){const a=r?.trim()??"",i=a.indexOf("/");return i>=0?a.slice(i+1):a}function Nu(r,a){const i=r?.trim(),c=a?.trim();return!i||!c?!1:i===c||Gd(i)===Gd(c)}function Wd(r){const a=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(c=>c&&!Nu(c,a))??""}function nl(r,a){const i=Math.max(_d,a-320),c=Math.min(yg,i);return Math.min(c,Math.max(_d,r))}function _g(r){return typeof r=="number"&&Number.isFinite(r)}function Bg(r){return nl(ct(ea,_g)??el,r)}function Pu(r){const a=r.split(/[\\/]/).pop()??r,i=a.lastIndexOf(".");return i>=0?a.slice(i).toLowerCase():""}function Ys(r){return Sg.has(Pu(r))}function cs({label:r,value:a,options:i,placeholder:c,searchPlaceholder:f,emptyText:p,disabled:g,onChange:k}){const{t:m}=_t(),[x,w]=n.useState(!1),[R,b]=n.useState(""),[A,P]=n.useState(null),$=n.useRef(null),D=n.useRef(null),te=R.trim().toLowerCase(),M=n.useMemo(()=>te?i.filter(_=>`${_.label} ${_.meta??""}`.toLowerCase().includes(te)):i,[te,i]),I=i.find(_=>_.value===a),H=()=>{const _=R.trim();_&&(k(_),w(!1),b(""))},Y=n.useCallback(()=>{const _=$.current?.getBoundingClientRect();if(!_)return!1;const o=12,ae=Math.max(220,Math.min(_.width,window.innerWidth-o*2)),W=Math.min(Math.max(o,_.left),window.innerWidth-ae-o),he=window.innerHeight-_.bottom-o,G=_.top-o,le=he>=180||he>=G,j=Math.max(96,(le?he:G)-4),F=Math.min(320,j);return P({left:W,top:le?_.bottom+4:Math.max(o,_.top-F-4),width:ae,maxHeight:F}),!0},[]),be=()=>{Y(),w(!0)};return n.useEffect(()=>{if(!x)return;let _=0;const o=()=>{_||(_=window.requestAnimationFrame(()=>{_=0,Y()}))},ae=W=>{const he=W.target;he instanceof Node&&($.current?.contains(he)||D.current?.contains(he)||(w(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",ae,!0),()=>{_&&window.cancelAnimationFrame(_),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",ae,!0)}},[x,Y]),t.jsxs("div",{className:"relative min-w-0",children:[t.jsxs("button",{ref:$,type:"button",disabled:g,onClick:()=>{if(!g){if(b(""),x){w(!1);return}be()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),t.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${a?"text-foreground":"text-muted-foreground/70"}`,children:I?.label??(a||c)})]}),t.jsx(aa,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${x?"rotate-180":""}`})]}),x&&!g&&typeof document<"u"&&Qr.createPortal(t.jsxs("div",{ref:D,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:_=>_.stopPropagation(),style:{left:A?.left??12,top:A?.top??12,width:A?.width??260,maxHeight:A?.maxHeight??320},children:[t.jsx("div",{className:"border-b border-border/10 p-1.5",children:t.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[t.jsx(us,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsx("input",{autoFocus:!0,value:R,onChange:_=>b(_.target.value),onKeyDown:_=>{if(_.key==="Escape"){_.preventDefault(),w(!1),b("");return}_.key==="Enter"&&(_.preventDefault(),H())},onBlur:()=>{R.trim()&&M.length===0&&H()},placeholder:f,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),t.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(A?.maxHeight??320)-46)},children:[R.trim()&&!i.some(_=>_.value===R.trim())&&t.jsxs("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:H,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[t.jsx("span",{className:"min-w-0 truncate",children:R.trim()}),t.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:m("common.use")})]}),M.length>0?M.map(_=>t.jsxs("button",{type:"button",onClick:()=>{k(_.value),w(!1),b("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${_.value===a?"bg-accent/10 text-accent":"text-foreground"}`,children:[t.jsx("span",{className:"min-w-0 truncate font-medium",children:_.label}),_.meta&&t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:_.meta})]},_.value)):t.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:p})]})]}),document.body)]})}function qd({open:r,onOpenChange:a,showScopePicker:i,selectedAll:c,repos:f,selectedRoots:p,onToggleRepo:g,onGenerate:k,onSecondaryAction:m,disabled:x,generateDisabled:w,secondaryDisabled:R,inserted:b,buttonLabel:A,insertedLabel:P,title:$,ariaLabel:D,scopeTitle:te,scopeLabel:M,allLabel:I,generateLabel:H,secondaryLabel:Y,secondaryTitle:be,secondaryLoading:_,loading:o,error:ae,statusTitle:W,extraContent:he,renderRepoExtra:G,menuItem:le=!1}){return t.jsxs("div",{className:le?"relative w-full":"relative inline-flex shrink-0",children:[t.jsxs("button",{type:"button",role:le?"menuitem":void 0,tabIndex:le?-1:void 0,onClick:j=>{i?a(!r):w||k(j.currentTarget)},disabled:x,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${le?"min-h-10 w-full gap-2.5 px-2.5 text-left text-[12px] focus:bg-surface-2 focus:outline-none [@media(pointer:coarse)]:min-h-11":"h-7 shrink-0 justify-center gap-1 px-2 text-[11px] font-medium active:scale-95"} ${ae?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":le?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:W??(i?`${te}: ${M}`:$),children:[o?t.jsx(lt,{size:le?15:13,className:"shrink-0 animate-spin"}):t.jsx(sa,{size:le?15:13,className:le?"shrink-0 text-muted-foreground":void 0}),t.jsx("span",{className:le?"min-w-0 flex-1":void 0,children:b?P:A}),i&&(le?t.jsx(ds,{size:13,className:"shrink-0 text-muted-foreground"}):t.jsx(aa,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),ae&&t.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),i&&r&&typeof document<"u"&&Qr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>a(!1),children:t.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:j=>j.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:te}),t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:M})]}),t.jsx("button",{type:"button",onClick:()=>a(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:t.jsx(Xt,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[he,t.jsxs("button",{type:"button",onClick:()=>g(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${c?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[t.jsx("span",{className:"truncate",children:I}),c&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),f.map(j=>{const F=p.includes(j.root);return t.jsxs("div",{className:`mt-1 rounded-md transition ${F?"bg-primary/15 text-primary":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>g(j.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${F?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:j.root,children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate",children:j.label}),j.branch&&t.jsx("span",{className:"block truncate text-[9px] opacity-70",children:j.branch})]}),F&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),G&&(c||F)&&t.jsx("div",{className:"px-2 pb-2",children:G(j)})]},j.root)})]}),t.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${m&&Y?"sm:grid-cols-2":""}`,children:[m&&Y&&t.jsxs("button",{type:"button",onClick:()=>{R||(a(!1),m())},disabled:R,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:be,children:[_?t.jsx(lt,{size:12,className:"animate-spin"}):t.jsx(lu,{size:12}),Y]}),t.jsxs("button",{type:"button",onClick:async j=>{if(w)return;await k(j.currentTarget)!==!1&&a(!1)},disabled:w,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:$,children:[t.jsx(sa,{size:12}),H]})]})]})}),document.body)]})}function Ug(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const a of Object.values(r)){if(!a||typeof a!="object"||Array.isArray(a))return!1;const i=a;if(typeof i.top!="number"||!Number.isFinite(i.top)||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))return!1}return!0}function Eu(){return ct(ol,Ug)??{}}function Og(r,a){const i=Eu(),c=Object.entries({...i,[r]:{top:a,updatedAt:Date.now()}}).sort(([,f],[,p])=>p.updatedAt-f.updatedAt).slice(0,cg);ra(ol,Object.fromEntries(c),ug)}function Hg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.start=="number"&&Number.isFinite(a.start)&&typeof a.end=="number"&&Number.isFinite(a.end)&&a.start>=1&&a.end>=a.start}function zg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const a of Object.values(r)){if(!a||typeof a!="object"||Array.isArray(a))return!1;const i=a;if(typeof i.top!="number"||!Number.isFinite(i.top)||i.left!==void 0&&(typeof i.left!="number"||!Number.isFinite(i.left))||i.markdownTop!==void 0&&(typeof i.markdownTop!="number"||!Number.isFinite(i.markdownTop))||i.lineRange!==void 0&&i.lineRange!==null&&!Hg(i.lineRange)||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))return!1}return!0}function ll(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Au(){return ct(il,zg)??{}}function Kd(r,a){const i=ll(r,a);return i?Au()[i]??null:null}function Ui(r,a,i){const c=ll(r,a);if(!c)return;const f=Au(),p=f[c]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},g=Object.entries({...f,[c]:{...p,...i,updatedAt:Date.now()}}).sort(([,k],[,m])=>m.updatedAt-k.updatedAt).slice(0,dg);ra(il,Object.fromEntries(g),fg)}function Oi({slow:r}){return t.jsx(ap,{slow:r})}function io({message:r,onRetry:a}){const{t:i}=_t();return t.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[t.jsx("div",{className:"font-medium",children:i("rightSidebar.gitChangesLoadFailed")}),t.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),t.jsx("button",{type:"button",onClick:a,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:i("rightSidebar.retryGitChanges")})]})}function ho(r,a){const i=a&&r.startsWith(`${a}/`)?r.slice(a.length+1):r,c=i.split("/").filter(Boolean);return{name:c.pop()||i,dir:c.join("/")}}function gt(r){if(!r)return"";const a=r.replace(/\/+$/,"");return a.split("/").pop()||a||"/"}function lo(r){if(!r)return null;const a=r.replace(/\/+$/,"")||"/";if(a==="/")return null;const i=a.slice(0,a.lastIndexOf("/"))||"/";return i===a?null:i}function Gg(r,a,i){return Vi(r,a,i)}function Tu(r){const a=new Map;for(const i of r)a.set(cl(i),i);return a}function Mu(r,a){const i=new Map(r);for(const c of a)i.set(cl(c),c);return i}function Vd(r,a){let i=0;for(const c of r){const f=ut(c,a);f&&a&&f!==a&&(i+=1)}return i}function Wg(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function qg(r,a){return Array.from(Mu(Tu(r),a).values()).sort((i,c)=>i.path.localeCompare(c.path))}function Kg(r,a){const i=r.relativeRoot==="."?gt(a??r.root)||r.name||r.root:r.relativeRoot||r.name||gt(r.root)||r.root;return{root:r.root,label:i,branch:r.context?.branch??null,count:r.files.length,staged:Wg(r.files)}}function Lu(r,a){const i=gt(a??"")||a||"";return r.map(c=>Kg(c,a)).sort((c,f)=>i&&c.label===i?-1:i&&f.label===i?1:c.label.localeCompare(f.label))}function Iu(r,a,i,c,f){const p=ju(i),g=p.find($=>$.root===c)??p[0]??null,k=a.find($=>$.root===c)??null,m=k?.relativeRoot??g?.relativeRoot??".",x=k?.name??g?.name??(gt(c)||c),w=(g?.files??i.files).map($=>({...$,repoRoot:c,repoRelativeRoot:m,repoName:x})),R=g?.context??i.context,b={...k??g??{id:c,root:c,relativeRoot:m,name:x,depth:0,nested:!!(f&&c!==f),available:i.available,files:[],context:null},...g??{},id:k?.id??g?.id??c,root:c,displayRoot:k?.displayRoot??g?.displayRoot,relativeRoot:m,name:x,depth:k?.depth??g?.depth??0,nested:k?.nested??g?.nested??!!(f&&c!==f),available:g?.available??i.available,deferred:g?.deferred??!1,files:w,context:R?{...R,root:c,changedFiles:w.map($=>({path:$.path,absolutePath:$.absolutePath,status:$.status}))}:null,untrackedDeferred:g?.untrackedDeferred??i.untrackedDeferred,error:g?.error??i.error},A=k?a.map($=>$.root===c?b:$):[...a,b];return{files:Array.from(r).filter($=>ut($,f)!==c).concat(w),repositories:A,repoFilters:Lu(A,f)}}function ut(r,a){return r.repoRoot??a}function cl(r){return`${r.repoRoot??""}\0${r.path}`}function xr(r){return r.absolutePath||r.path}function Hi(r){return cl(r)}function Vg(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function Yd(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function Xd(r){const a={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const i of r)i.status==="added"?a.added+=1:i.status==="modified"?a.modified+=1:i.status==="deleted"?a.deleted+=1:i.status==="renamed"?a.renamed+=1:i.status==="copied"?a.copied+=1:i.status==="untracked"?a.untracked+=1:i.status==="conflicted"?a.conflicted+=1:a.other+=1,i.staged&&(a.staged+=1);return a}function Xs(r){let a=0;const i=r??"root";for(let c=0;c<i.length;c+=1)a=Math.imul(a^i.charCodeAt(c),16777619);return`right-sidebar-git-bundle:${(a>>>0).toString(36)}`}function Js(r,a){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(a==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function vr(r){return r instanceof DOMException&&r.name==="AbortError"}function Yg(r){const a=r.error??r.context?.error??"";return a.includes("request was cancelled")||a.includes("IO_REQUEST_CANCELLED")}function Jd(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function Xg({actions:r,running:a,completed:i}){const{t:c}=_t(),[f,p]=n.useState(!1),g=n.useRef(null),k=r.find(x=>a?.action===x.key),m=r.find(x=>i?.action===x.key);return r.length===0?null:(n.useEffect(()=>{if(!f)return;const x=R=>{const b=R.target;b instanceof Node&&g.current?.contains(b)||p(!1)},w=R=>{R.key==="Escape"&&p(!1)};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",w)}},[f]),t.jsxs("div",{ref:g,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),p(w=>!w)},disabled:r.every(x=>x.disabled)&&!a&&!i,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${f?"bg-surface-elevated text-foreground":m?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:k?.label??m?.label??c("rightSidebar.gitQuickActions"),children:k?t.jsx(lt,{size:13,className:"animate-spin"}):m?t.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):t.jsx(po,{size:14})}),f&&t.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(x=>{const w=a?.action===x.key,R=i?.action===x.key;return t.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),x.onClick(),p(!1)},disabled:x.disabled||!!a,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${R?"bg-accent/10 text-accent":x.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:w?t.jsx(lt,{size:13,className:"animate-spin"}):R?"✓":null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:x.label})]},x.key)})})]}))}function Jg(r){const a=window.getComputedStyle(r).overflowY;return(a==="auto"||a==="scroll")&&r.scrollHeight>r.clientHeight+1}function $u(r){let a=r;for(;a;){if(a.classList.contains("termdock-diff-stream-scroller")&&Jg(a))return a;a=a.parentElement}return r.closest(".termdock-diff-stream-scroller")}function fs(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const zi=new WeakMap;function vo(r){const a=zi.get(r);a!==void 0&&window.clearTimeout(a),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const i=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),zi.delete(r)},1700);zi.set(r,i)}function Qg(r){const a=CSS.escape(r),i=[`[data-diff-stream-item="${a}"]`,`[data-diff-selection-path="${a}"]`,`[data-diff-absolute-path="${a}"]`].join(","),c=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let f=null;for(const k of c){if(!fs(k))continue;const m=k.querySelector(i);if(m&&fs(m)){f=m;break}}if(f??=Array.from(document.querySelectorAll(i)).find(fs)??null,!f)return;const p=$u(f);if(!p){f.scrollIntoView({block:"start",behavior:"smooth"}),vo(f);return}const g=f.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;p.scrollTo({top:Math.max(0,g),behavior:"instant"}),vo(f)}function Tn(r){const a=CSS.escape(r.filePath),i=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,c=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,f=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,p=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,g=[i!==null&&f?`[data-diff-section-audit="${a}"][data-diff-section-index="${i}"][data-diff-section-fingerprint="${f}"]`:null,i!==null&&f?`[data-diff-section-anchor="${a}"][data-diff-section-index="${i}"][data-diff-section-fingerprint="${f}"]`:null,i!==null?`[data-diff-section-audit="${a}"][data-diff-section-index="${i}"]`:null,i!==null?`[data-diff-section-anchor="${a}"][data-diff-section-index="${i}"]`:null,c!==null&&p?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"][data-diff-hunk-fingerprint="${p}"]`:null,c!==null?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"]`:null,`[data-diff-file-path="${a}"]`].filter(P=>!!P),k=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let m=null;for(const P of k)if(fs(P)){for(const $ of g){const D=P.querySelector($);if(D&&fs(D)){m=D;break}}if(m)break}if(m??=g.flatMap(P=>Array.from(document.querySelectorAll(P))).find(fs)??null,!m){Qg(r.filePath);return}const x=$u(m);if(!x){m.scrollIntoView({block:"center",behavior:"smooth"}),vo(m);return}const w=m.getBoundingClientRect(),R=x.getBoundingClientRect(),A=w.top-R.top+x.scrollTop-Math.max(24,(x.clientHeight-w.height)/2);x.scrollTo({top:Math.max(0,A),behavior:"instant"}),vo(m)}let Zg=0,eb=0,tb=0,rb=0,nb=0;function st(r,a={}){if(typeof window>"u")return;const i=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++eb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function Qs(r,a={}){if(typeof window>"u")return;const i=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++rb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function sb(){return`diff-ui-${Date.now().toString(36)}-${(++nb).toString(36)}`}function ab(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function ob(r){const a=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:a?.tagName,targetClass:a?.className,targetText:a?.textContent?.slice(0,80)}}function yo({onReviewReference:r,filePath:a,active:i=!0,onInsertReference:c,onInsertText:f,onInsertFeature:p,onReferenceCopied:g,onClose:k,onDirectoryLinkOpen:m,isMobile:x,markdownOutlineOpen:w,markdownOutlineCloseSignal:R,onOpenMarkdownOutline:b,onCloseMarkdownOutline:A,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:$,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:te,lineRange:M,onLineRangeChange:I,insertedReferenceKey:H,copiedReferenceKey:Y,scrollToLine:be,onScrollToLineHandled:_}){const{t:o}=_t(),ae=n.useRef(null),W=n.useRef({}),he=n.useRef(i);he.current=i,n.useEffect(()=>{i||ae.current?.querySelectorAll("video").forEach(S=>S.pause())},[i]);const G=U(S=>S.rootPath),le=U(S=>S.selectFile),[j,F]=n.useState({kind:"idle"}),[ee,C]=n.useState("schematic"),[L,q]=n.useState(null),ne=n.useRef(null),[pe,Ne]=n.useState(null),we=n.useRef(new Map),Pe=n.useRef(null),[O,ue]=n.useState(null),[oe,Fe]=n.useState(()=>Ud()),[Ie,E]=n.useState(()=>Pd(G,a)),xe=n.useRef(null),[ge,De]=n.useState(!1),[Ve,Ae]=n.useState(null),[Jt,Be]=n.useState(0),[ft,Ue]=n.useState([]),[Qt,me]=n.useState(null),dt=n.useRef(null),at=n.useRef(a),[bt,Oe]=n.useState(null),V=wm(G&&a&&!a.startsWith("/")?`${G}/${a}`:a,i),[ye,Ze]=n.useState(!1),[wt,ir]=n.useState(""),[N,Q]=n.useState([]),[ke,Ye]=n.useState(0),ht=n.useRef(null),yr=tu(g),kt=ll(G,a);n.useEffect(()=>{if(at.current===a)return;at.current=a;const S=a&&G&&!a.startsWith("/")?`${G}/${a}`:a;if(dt.current===S){dt.current=null;return}dt.current=null,Ue([]),me(null),Ze(!1),ir("")},[a,G]);const St=a?G&&!a.startsWith("/")?`${G}/${a}`:a:null,Mn=U(S=>St?(S.fileChangeVersions.get(St)??0)+S.fileWatchEpoch:S.fileWatchEpoch),hs=n.useRef(null),wr=n.useRef(null),[Bt,Zr]=n.useState(0),Zt=n.useCallback(()=>Zr(S=>S+1),[]);n.useEffect(()=>{const S=ne.current;return ne.current=null,q(null),S&&URL.revokeObjectURL(S.objectUrl),()=>{const T=ne.current;ne.current=null,T&&URL.revokeObjectURL(T.objectUrl)}},[St,Mn,Bt]),n.useEffect(()=>{if(!a){hs.current=null,F({kind:"idle"});return}const S=G&&!a.startsWith("/")?`${G}/${a}`:a,T=new AbortController,ce=++Zg,Se=`right-sidebar-file-preview:${ce}`,Je=performance.now();let Te=!1;const ze=(K,We={})=>{Te||(Te=!0,Ei("end",{loadingId:ce,reason:K,durationMs:Math.round(performance.now()-Je),filePath:a,fullPath:S,rootPath:G,...We}))};let Me=null;const Ge=oh(S),ot=Ge?S.toLowerCase().endsWith(".kicad_pcb")?ee==="schematic"?"pcb-front":ee:"schematic":ee,Fn=!Ge&&ih(S),cr=!Ge&&!Fn&&lh(S),ys=!Ge&&!Fn&&!cr&&ch(S),an=Ys(S),on=qs(S),zr=Ge?"eda":Fn?"image":cr?"model3d":ys?"video":"text",ln=hs.current!==S;if(hs.current=S,ln){Ei("start",{loadingId:ce,filePath:a,fullPath:S,rootPath:G,mode:zr,externalVersion:Mn}),F({kind:"loading",mode:zr}),wr.current=null;const K=Kd(G,a);I(K?.lineRange??null),Fe(an?Ud():"source"),E(on?Pd(G,a):"source"),Ge&&C(dh(S))}ln||F(K=>K.kind==="error"?{kind:"loading",mode:zr}:K);const cn=window.setTimeout(()=>{Te||T.signal.aborted||Ei("still_active",{loadingId:ce,filePath:a,fullPath:S,rootPath:G,mode:zr,durationMs:Math.round(performance.now()-Je),isPathChange:ln})},3e3),ws=window.setTimeout(()=>{if(Te||T.signal.aborted)return;const K=Ge?o("rightSidebar.edaTimeout"):cr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";T.abort(new DOMException(K,"TimeoutError")),F({kind:"error",message:K}),ze("stuck_timeout",{error:K})},Ge?uh+5e3:cr?fh+5e3:hh(S)?35e3:vg);if(Ge){const K=ot==="pcb-3d"?ne.current:null;K?(F(K),ze("eda_3d_client_cache_hit",{bytes:K.meta.size,view:K.view,mimeType:K.meta.mimeType})):ph(S,ot,T.signal,"view_file",Se).then(We=>{if(T.signal.aborted)return;Me=URL.createObjectURL(We.blob);const Tt={kind:"eda",sourcePath:We.path||S,objectUrl:Me,view:We.view,meta:{size:We.size,mimeType:We.mimeType,modified:We.modified}};if(We.view==="pcb-3d"){const dr=ne.current;dr&&dr.objectUrl!==Me&&URL.revokeObjectURL(dr.objectUrl),ne.current=Tt,q(Tt),Me=null}F(Tt),ze("eda_loaded",{bytes:We.size,view:We.view,mimeType:We.mimeType})}).catch(We=>{T.signal.aborted||(F({kind:"error",message:We instanceof Error&&/timed out/i.test(We.message)?o("rightSidebar.edaTimeout"):We instanceof Error?We.message:o("rightSidebar.edaLoadFailed")}),ze("error",{error:We instanceof Error?We.message:String(We)}))})}else if(Fn)mh(S,T.signal,"view_file",Se).then(K=>{Me=URL.createObjectURL(K.blob),F({kind:"image",objectUrl:Me,meta:{size:K.size,mimeType:K.mimeType,modified:K.modified}}),ze("image_loaded",{bytes:K.size,mimeType:K.mimeType})}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error?K.message:o("rightSidebar.imageLoadFailed")}),ze("error",{error:K instanceof Error?K.message:String(K)}))});else if(cr)gh(S,T.signal,"view_file",Se).then(K=>{T.signal.aborted||(Me=URL.createObjectURL(K.blob),F({kind:"model3d",sourcePath:K.path||S,objectUrl:Me,ext:K.ext,meta:{size:K.size,mimeType:K.mimeType,modified:K.modified}}),ze("model3d_loaded",{bytes:K.size,ext:K.ext}))}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error&&(K.name==="TimeoutError"||/timed out/i.test(K.message))?o("rightSidebar.model3dTimeout"):K instanceof Error?K.message:o("rightSidebar.model3dLoadFailed")}),ze("error",{error:K instanceof Error?K.message:String(K)}))});else if(ys){const K=bh(S)??"",We=$h(S);F(Tt=>Tt.kind==="video"&&Tt.url===We?Tt:{kind:"video",url:We,meta:{size:null,mimeType:K,modified:null}}),ze("video_ready",{mimeType:K})}else ed(S,T.signal,"view_file",Se).then(K=>{if(!T.signal.aborted){if(K.binary){F({kind:"binary"});return}F({kind:"text",content:K.content,sourcePath:K.path||S,meta:{size:K.size,truncated:K.truncated}}),ze("text_loaded",{bytes:K.size,truncated:!!K.truncated})}}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error?K.message:"Failed to read file"}),ze("error",{error:K instanceof Error?K.message:String(K)}))});return()=>{T.abort(),yt(Se),window.clearTimeout(cn),window.clearTimeout(ws),Me&&URL.revokeObjectURL(Me),ze("cleanup")}},[a,G,Mn,Bt,I,o,ee]),n.useEffect(()=>{if(j.kind!=="model3d"||!a){Ne(null);return}let S=!1;const T=a.lastIndexOf("/"),ce=T>=0?a.slice(T+1):a,Se=T>=0?a.slice(0,T):"",Je=Se.lastIndexOf("/"),Te=Je>=0?Se.slice(0,Je):"",ze=ce.replace(/\.(stl|glb|gltf)$/i,""),Me=`${Te?`${Te}/`:""}features/${ze}.json`;return ed(Me).then(Ge=>{if(!S)try{const ot=JSON.parse(Ge.content);Ne(ot.version===1&&Array.isArray(ot.features)&&ot.features.length>0?ot.features:null)}catch{Ne(null)}}).catch(()=>{S||Ne(null)}),()=>{S=!0}},[j,a]),n.useEffect(()=>{if(j.kind!=="text"){Oe(null);return}const S=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,T=yp(S),ce=j.content,Se=Ys(S??"")&&oe==="preview",Je=qs(S??"")&&Ie==="preview";if(!T||Se||Je||!wp(ce)){Oe(null);return}let Te=!1;const ze=Me=>{if(Te||!Me.registered(T)){Te||Oe(null);return}try{Oe(Sp(Me,ce,T))}catch{Oe(null)}};return Ve?ze(Ve):(Oe(null),kp().then(Me=>{Te||(Ae(Me),ze(Me))}).catch(()=>{})),()=>{Te=!0}},[j,Ve,a,G,oe,Ie]),n.useLayoutEffect(()=>{if(!kt||j.kind!=="text")return;const S=`${kt}:${oe}:${Ie}`;if(wr.current===S)return;const T=Kd(G,a);if(wr.current=S,!T)return;const ce=requestAnimationFrame(()=>{const Se=Pe.current;if(!Se)return;const Je=oe==="preview"?T.markdownTop??T.top:T.top;Se.scrollTo({top:Math.max(0,Je??0),left:Math.max(0,T.left??0)}),Be(oe==="preview"?Math.max(0,Je??0):0)});return()=>cancelAnimationFrame(ce)},[a,oe,Ie,j.kind,kt,G]),n.useEffect(()=>{kt&&Ui(G,a,{lineRange:M})},[a,M,kt,G]),n.useEffect(()=>{if(be==null||j.kind!=="text")return;ue(null),I({start:be,end:be});const S=be,T=requestAnimationFrame(()=>{const ce=we.current.get(S);ce&&ce.scrollIntoView({block:"center"}),_?.()});return()=>cancelAnimationFrame(T)},[be,j,I,_]);const Ln=n.useCallback(S=>{const T=Pe.current;if(!T)return!1;const ce=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(S):S.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=T.querySelector(`#${ce}`);return Se?(Se.scrollIntoView({block:"start"}),!0):!1},[]);n.useEffect(()=>{const S=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,T=j.kind==="text"&&Ys(S??"")&&oe==="preview";if(!Qt||!T)return;const ce=requestAnimationFrame(()=>{Ln(Qt)&&me(null)});return()=>cancelAnimationFrame(ce)},[a,Ln,oe,Qt,j,G]),n.useLayoutEffect(()=>{const S=Pe.current;if(!S||!M){ue(null);return}if(O)return;const T=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ce=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,Se=j.kind==="text"&&Ys(ce??"")&&oe==="preview",Je=j.kind==="text"&&qs(ce??"")&&Ie==="preview";if(j.kind!=="text"||T||Se||Je){ue(null);return}const Te=()=>{const Me=we.current.get(M.end);if(!Me||!S){ue(null);return}const Ge=Me.offsetTop+Me.offsetHeight/2,ot=S.scrollLeft+Math.max(8,S.clientWidth-120);ue({top:Ge,left:ot})};Te();const ze=new ResizeObserver(()=>Te());return ze.observe(S),()=>ze.disconnect()},[M,O,j,oe,Ie,a,G,bt]);const kr=j.kind==="text"&&!(qs(St??"")&&Ie==="preview")&&!St?.toLowerCase().endsWith(".csv")&&!St?.toLowerCase().endsWith(".kicad_pro")&&!St?.toLowerCase().endsWith(".kicad_prl"),In=n.useCallback(()=>{Ze(!1),ir(""),Q([]),Ye(0),oo(W.current)},[]),en=n.useCallback(()=>{!i||!kr||(Ze(!0),requestAnimationFrame(()=>{const S=ae.current;!he.current||!S?.isConnected||S.closest('[inert], [aria-hidden="true"], [hidden]')||S.getClientRects().length===0||getComputedStyle(S).visibility==="hidden"||!S.contains(document.activeElement)||(ht.current?.focus(),ht.current?.select())}))},[i,kr]),Dr=n.useCallback(S=>{Ye(T=>N.length===0?0:(T+S+N.length)%N.length)},[N.length]),Ut=n.useCallback(S=>{if(S.nativeEvent.isComposing||!eg(ae.current,i,S))return;const T=tg(S);if(T==="open"&&kr){S.preventDefault(),en();return}ye&&(T==="close"?(S.preventDefault(),In()):(T==="next"||T==="previous")&&(S.preventDefault(),Dr(T==="previous"?-1:1)))},[i,In,ye,Dr,en,kr]);if(n.useLayoutEffect(()=>{if(oo(W.current),!i||!ye||!wt.trim()||!Pe.current){Q([]),Ye(0);return}const S=ng(Pe.current,wt);return Q(S),Ye(0),(ae.current?.contains(document.activeElement)||Td(W.current))&&(Ii(S,0,W.current),Md(S[0])),()=>oo(W.current)},[i,ye,wt,bt,oe,j]),n.useEffect(()=>{!i||!ye||!wt.trim()||!ae.current?.contains(document.activeElement)&&!Td(W.current)||(Ii(N,ke,W.current),Md(N[ke]))},[i,ke,N,ye,wt]),n.useEffect(()=>()=>oo(W.current),[]),!a)return t.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.selectFilePrompt")});const He=G&&!a.startsWith("/")?`${G}/${a}`:a,Et=ho(He,G),Sr=ru(He,G),Rr=j.kind==="text"&&j.content?j.content.split(`
1639
- `):[],oa=Math.max(2,String(Rr.length).length)+1,jr=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,Cr=Ys(He),ia=He.toLowerCase().endsWith(".csv"),At=He.toLowerCase().endsWith(".kicad_pro"),ps=He.toLowerCase().endsWith(".kicad_prl"),Ot=j.kind==="text"&&Cr&&oe==="preview",la=qs(He),Ht=j.kind==="text"&&la&&Ie==="preview",ca=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ko=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",xt=j.kind==="video"||j.kind==="loading"&&j.mode==="video",tn=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",ms=j.kind==="text"?j.sourcePath:He,_r=xh(ms,G,M),Br=(()=>{if(!M||j.kind!=="text"||Rr.length===0)return _r;const S=[];for(let Se=M.start;Se<=M.end;Se+=1)S.push(`${Se} ${Rr[Se-1]??""}`);const T=Pu(He).replace(/^\./,""),ce="```";return`${_r}
1640
- ${ce}${T}
1641
- ${S.join(`
1642
- `)}
1643
- ${ce}
1644
- `})(),Nr=`path:${He}`,Pr=M?`path:${He}:${M.start}-${M.end}`:Nr,Ur=H===Nr,Or=H===Pr,$n=Y===Nr,gs=Y===Pr,rn=Or||gs,er=M?M.start===M.end?`L${M.start}`:`L${M.start}-${M.end}`:null,Hr=S=>{const T=Pe.current;if(!T)return;const ce=T.getBoundingClientRect(),Se=S.currentTarget.getBoundingClientRect(),Je=S.clientX||Se.left+Se.width/2,ze=(S.clientY||Se.top+Se.height/2)-ce.top+T.scrollTop,Me=x?116:132,Ge=T.scrollLeft+Math.max(8,T.clientWidth-Me),ot=Math.min(Math.max(8,Je-ce.left+T.scrollLeft+10),Ge);ue({top:ze,left:ot})},bs=(S,T)=>{Rp()||(Hr(S),I(ce=>{const Se=Vi(ce,T,T);return Se||ue(null),Se}))},xs=(S,T,ce)=>{Hr(S),I(Se=>{const Je=Vi(Se,T,ce);return Je||ue(null),Je})},Er=(S,T,ce,Se)=>{Se==="end"&&Hr(S),I({start:T,end:ce})},lr=S=>{const{scrollTop:T,scrollLeft:ce}=S.currentTarget;Be(T),Ui(G,a,{top:T,left:ce,markdownTop:T})},fe=S=>{if(S.directory){m?.(S.path);return}if(S.path===He||j.kind==="text"&&S.path===j.sourcePath){S.fragment&&Ln(S.fragment);return}Ue(T=>[...T,He]),dt.current=S.path,me(S.fragment),I(null),le(S.path)},tr=()=>{const S=ft[ft.length-1];S&&(Ue(T=>T.slice(0,-1)),dt.current=S,me(null),I(null),le(S))},nn=S=>{const{scrollTop:T,scrollLeft:ce}=S.currentTarget;Ui(G,a,{top:T,left:ce})},sn=S=>{if(r){r(Br,Pr,void 0,S.currentTarget);return}M&&f(Br,Pr,S.currentTarget)},vs=()=>{if(!(j.kind==="loading"||j.kind==="error"))return V.start()};return t.jsxs("div",{ref:ae,tabIndex:-1,onKeyDown:Ut,onFocusCapture:()=>{i&&ye&&wt.trim()&&Ii(N,ke,W.current)},onPointerDownCapture:S=>{S.target instanceof Element&&!S.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&S.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[yr.popoverNode,t.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${x&&(Ot||Ht)?"py-1.5":"py-2"}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[x&&k&&t.jsx("button",{type:"button",onClick:k,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:t.jsx(jp,{size:16})}),ft.length>0&&t.jsxs("button",{type:"button",onClick:tr,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 ${x?"w-9":"px-2.5"}`,"aria-label":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[t.jsx(mo,{size:15}),!x&&t.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),t.jsxs("div",{className:"min-w-0",title:He,children:[t.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Et.name}),Et.dir&&t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Et.dir})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[kr&&t.jsx("button",{type:"button",onClick:ye?In:en,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 ${ye?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:t.jsx(us,{size:14})}),Cr&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{w&&A?.(),Fe(S=>{const T=S==="preview"?"source":"preview";return Pt(xu,T),T}),I(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 ${x?"w-9 px-0":"px-3"}`,"aria-label":o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:x?oe==="preview"?t.jsx(qi,{size:14}):t.jsx(Yi,{size:14}):o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),la&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{E(S=>{const T=S==="preview"?"source":"preview";return Sm(G,a,T),T}),I(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 ${x?"w-9 px-0":"px-3"}`,"aria-label":o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:x?Ie==="preview"?t.jsx(qi,{size:14}):t.jsx(Yi,{size:14}):o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Ht&&t.jsx("button",{type:"button",onClick:()=>{xe.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o(ge?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ge?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:t.jsx(iu,{size:15})}),!x&&t.jsx("button",{type:"button",onClick:S=>c(He,Nr,S.currentTarget),...yr(Sr,Nr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Ur||$n?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Sr}),children:o($n?"rightSidebar.copied":Ur?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),t.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Sr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.copyReference",{reference:Sr}),"aria-label":o("rightSidebar.copyFileRef"),children:t.jsx(vh,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{vs()},disabled:V.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:V.status==="error"?V.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:V.status==="pending"?t.jsx(lt,{size:13,className:"animate-spin"}):t.jsx(yh,{size:14})}),V.status==="pending"&&t.jsx("button",{type:"button",onClick:V.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),V.status==="error"&&t.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",V.error]}),V.status==="canceled"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),V.status==="saved"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),V.status==="started"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),ye&&kr&&t.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[t.jsx(us,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),t.jsx("input",{ref:ht,type:"search",value:wt,onChange:S=>ir(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),Dr(S.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),t.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:N.length>0?`${ke+1}/${N.length}`:"0/0"})]}),t.jsx("button",{type:"button",onClick:()=>Dr(-1),disabled:N.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:t.jsx(al,{size:13})}),t.jsx("button",{type:"button",onClick:()=>Dr(1),disabled:N.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:t.jsx(Cp,{size:13})}),t.jsx("button",{type:"button",onClick:In,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:t.jsx(Xt,{size:13})})]}),jr&&!(x&&(Ot||Ht))&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[jr.size!==null&&t.jsx("span",{children:o("rightSidebar.byteCount",{count:jr.size.toLocaleString()})}),"truncated"in jr&&jr.truncated&&t.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in jr&&t.jsx("span",{children:jr.mimeType}),"dimensions"in j&&j.dimensions&&t.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(x&&(Ot||Ht))&&!ko&&j.kind!=="binary"&&t.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:t.jsx("span",{className:"truncate",children:tn?o("rightSidebar.edaPickHint"):ia?o("rightSidebar.csvTablePreview"):At||ps?o("rightSidebar.kicadProjectPickHint"):xt?o("rightSidebar.videoPreviewHint"):ca?o("rightSidebar.imagePreviewHint"):Ot?M?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.markdownPreviewHint"):Ht?o("rightSidebar.htmlPreviewHint"):M?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.multiLineHint")})})]}),!i&&(j.kind==="video"||j.kind==="model3d"||j.kind==="eda"||Ht)?null:j.kind==="loading"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:t.jsx(Ri,{label:j.mode==="eda"?o("rightSidebar.edaLoading"):j.mode==="image"?o("rightSidebar.loadingImage"):j.mode==="model3d"?o("rightSidebar.model3dLoading"):j.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):j.kind==="error"?t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[t.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}),t.jsx("button",{type:"button",onClick:Zt,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):j.kind==="binary"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:o("rightSidebar.binaryPreviewHint")})}):j.kind==="image"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:j.meta.mimeType==="image/svg+xml"?t.jsx(hu,{blobUrl:j.objectUrl,filePath:He,viewLabel:"SVG 文件",onInsertAnnotation:r??p}):t.jsx(Uh,{src:j.objectUrl,alt:Et.name,vector:!1,onLoad:S=>{const T=S.currentTarget;F(ce=>ce.kind==="image"?{...ce,dimensions:{width:T.naturalWidth,height:T.naturalHeight}}:ce)},onError:()=>F({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):j.kind==="video"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:t.jsx(Mm,{url:j.url,onLoadError:()=>F({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):j.kind==="eda"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(Bm,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:He.toLowerCase().endsWith(".kicad_pcb"),onViewChange:C,onInsertAnnotation:r??p,onRefresh:Zt,interactive3d:L?t.jsx(n.Suspense,{fallback:t.jsx(Ri,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:t.jsx(Bd,{blobUrl:L.objectUrl,ext:".glb",fileName:Et.name,filePath:L.sourcePath,features:null,onInsertFeature:r??p,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:S=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(S)?S:"PCB板体/铜箔/丝印",active:j.view==="pcb-3d"})}):void 0})}):j.kind==="model3d"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:t.jsx(n.Suspense,{fallback:t.jsx(Ri,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:t.jsx(Bd,{blobUrl:j.objectUrl,ext:j.ext,fileName:Et.name,filePath:j.sourcePath,features:pe,onInsertFeature:r??p,onRefresh:Zt})})}):j.kind==="text"&&ia?t.jsx(Hm,{content:j.content,filePath:He,onInsertAnnotation:r??p},He):j.kind==="text"&&(At||ps)?t.jsx(Wm,{content:j.content,filePath:He,localState:ps,onInsertAnnotation:r??p},He):Ot?t.jsxs("div",{ref:Pe,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:lr,style:{touchAction:"pan-x pan-y"},children:[t.jsx(nu,{content:j.content,filePath:j.sourcePath,rootPath:G,lineRange:M,onLineRangeClick:xs,onLineRangeDrag:Er,scrollTop:Jt,outlineOpen:w,outlineCloseSignal:R,onOutlineOpen:b,onOutlineClose:A,lightboxOpen:P,lightboxCloseSignal:$,onLightboxOpen:D,onLightboxClose:te,onLocalLinkOpen:fe}),M&&O&&t.jsxs("button",{type:"button",onClick:sn,...yr(Br,Pr),style:{top:O.top,left:O.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert markdown reference: ${_r}`,children:[t.jsx(bo,{size:x?13:11}),gs?o("rightSidebar.copied"):Or?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):Ht?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(Zm,{ref:xe,src:wh(He),title:`${Et.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:De},`${He}:${Mn}:${Bt}`)}):j.kind==="text"?t.jsxs("div",{ref:Pe,onScroll:nn,className:`${Oh} 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:[Rr.length>0?t.jsx("div",{className:"min-w-full",children:Rr.map((S,T)=>{const ce=T+1,Se=!!(M&&ce>=M.start&&ce<=M.end),Je=bt&&bt.length===Rr.length?bt[T]:null;return t.jsxs("div",{ref:Te=>{Te?we.current.set(ce,Te):we.current.delete(ce)},role:"button","data-file-preview-line":ce,tabIndex:0,onClick:Te=>bs(Te,ce),onKeyDown:Te=>{Te.key!=="Enter"&&Te.key!==" "||(Te.preventDefault(),bs(Te,ce))},style:{gridTemplateColumns:`${oa}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Se?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Sr}:${ce}`,children:[t.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Se?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ce}),t.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Je??(S||" ")})]},T)})}):"Empty file.",M&&O&&t.jsxs("button",{type:"button",onClick:sn,...yr(Br,Pr),style:{top:O.top,left:O.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert code reference: ${_r}`,children:[t.jsx(bo,{size:x?13:11}),gs?o("rightSidebar.copied"):Or?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):null]})}function ib({rootPath:r,file:a,active:i,...c}){const[f,p]=n.useState(null),[g,k]=n.useState(a.line??1),m=n.useCallback(()=>k(null),[]);return t.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:t.jsx(yo,{...c,filePath:`${r.replace(/\/+$/,"")}/${a.path}`,active:i,lineRange:f,onLineRangeChange:p,scrollToLine:g,onScrollToLineHandled:m,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function lb({isOpen:r,sessionId:a,drawerWidthPx:i,onClose:c,onOpen:f,push:p,pinned:g=!1,onTogglePinned:k,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:x,onOpenRightSidebarFilePreview:w,onCloseRightSidebarFilePreview:R,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:A,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:$,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H=!1,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_}){const{t:o,locale:ae}=_t(),[W,he]=n.useState(""),G=U(e=>e.pendingTerminalPath),[le,j]=n.useState(null),F=n.useRef(0),ee=U(e=>e.rightSearchOpen),C=U(e=>e.setRightSearchOpen),L=U(e=>e.rightSidebarLayoutPreference),q=U(e=>e.setRightSidebarLayoutPreference),[ne,pe]=n.useState(()=>Mg()),[Ne,we]=n.useState("."),[Pe,O]=n.useState(""),[ue,oe]=n.useState(!1),[Fe,Ie]=n.useState(!1),[E,xe]=n.useState(!1),[ge,De]=n.useState(!1),Ve=n.useDeferredValue(W),[Ae,Jt]=n.useState(null),[Be,ft]=n.useState([]),[Ue,Qt]=n.useState([]),me=U(e=>e.contextKey?e.activeGitRepos[e.contextKey]??null:null),dt=U(e=>e.setActiveGitRepo),[at,bt]=n.useState(null),[Oe,V]=n.useState(null),[ye,Ze]=n.useState(null),[wt,ir]=n.useState(!1),[N,Q]=n.useState(()=>ct(Id,ta)??!1),[ke,Ye]=n.useState(()=>ct($d,ta)??!1),[ht,yr]=n.useState(()=>ct(Fd,ta)??!1),[kt,St]=n.useState(()=>ct(Di,Ng)??""),[Mn,hs]=n.useState(0),[wr,Bt]=n.useState(!1),[Zr,Zt]=n.useState(!1),Ln=n.useRef(null),kr=n.useRef(null),[In,en]=n.useState(!1),[Dr,Ut]=n.useState(null),[He,Et]=n.useState(null),[Sr,Rr]=n.useState(()=>Od($i)),[oa,jr]=n.useState(()=>Od(Ld)),[Cr,ia]=n.useState(()=>Cg()),[At,ps]=n.useState(()=>Pg()),[Ot,la]=n.useState(()=>Ag()),Ht="words",[ca,ko]=n.useState(0),[xt,tn]=n.useState([]),[ms,_r]=n.useState([]),[Br,Nr]=n.useState(!1),[Pr,Ur]=n.useState(null),[Or,$n]=n.useState([]),[gs,rn]=n.useState(!1),[er,Hr]=n.useState([]),[bs,xs]=n.useState([]),[Er,lr]=n.useState(!1),[fe,tr]=n.useState(null),[nn,sn]=n.useState([]),[vs,S]=n.useState({}),T=n.useRef(0),[ce,Se]=n.useState(0),[Je,Te]=n.useState(!1),[ze,Me]=n.useState(null),[Ge,ot]=n.useState(null),[Fn,cr]=n.useState(null),[ys,an]=n.useState(null),[on,zr]=n.useState(!1),[ln,cn]=n.useState(""),ws=n.useDeferredValue(ln),[K,We]=n.useState({}),[Tt,dr]=n.useState([]),[da,ks]=n.useState(!1),[ua,Ss]=n.useState(!1),[So,Dn]=n.useState(null),[Ro,_n]=n.useState(!1),ur=n.useRef(null),Gr=n.useRef(0),dl=n.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Fu,fa]=n.useState(null),[Rs,ul]=n.useState(()=>ct(Fi,ta)??!1),[jo,Co]=n.useState(!1),[ha,No]=n.useState([]),[rr,pa]=n.useState({}),[Rt,ma]=n.useState({}),[dn,Po]=n.useState({}),[fl,hl]=n.useState(()=>new Set),[qe,un]=n.useState(null),[Eo,fn]=n.useState(null),[Du,Ar]=n.useState(!1),[Ao,Tr]=n.useState(0),[,To]=n.useState(0),[Mo,ga]=n.useState(!1),[_u,Bu]=n.useState(()=>U.getState().rightTab==="files"),[nr,Lo]=n.useState(!1),[Uu,pl]=n.useState(()=>U.getState().rightTab==="diff"),[Io,ml]=n.useState(()=>U.getState().rightTab==="android"),[Wr,gl]=n.useState(!1),[sr,bl]=n.useState({architecture:!1,computer:!1}),js=n.useRef(new Set),ba=ji(e=>e.docks[Ai]),Ou=!!ba,[$e,Cs]=n.useState(null),[Bn,Ns]=n.useState(null),[pt,hn]=n.useState(null),[xl,zt]=n.useState(null),[Un,vl]=n.useState(null),[$o,Hu]=n.useState(()=>Date.now()),[zu,Gu]=n.useState(!1),[pn,xa]=n.useState(!1),[va,yl]=n.useState(""),[On,ya]=n.useState(""),[mn,wa]=n.useState(""),[gn,ka]=n.useState(""),[wl,Hn]=n.useState(null),[kl,Fo]=n.useState(!1),[Sl,Rl]=n.useState(!1),[Sa,Wu]=n.useState({key:null,nonce:0}),jl=n.useRef(null),Cl=n.useRef(null),J=Fh(i,g,L),Do=Ru(J,g,Ot),[_o,Bo]=n.useState(()=>Bg(i)),Uo=U(e=>e.rightTab),Mt=U(e=>e.setRightTab),d=U(e=>e.rootPath),zn=U(e=>e.explorerRoot),Nl=U(e=>e.pinnedExplorerRootsCache),Pl=U(e=>e.hydratePinnedExplorerRoots),El=U(e=>e.syncPinnedExplorerRoots),Lt=U(e=>e.setExplorerRoot),Al=U(e=>e.resetExplorerToProject),Gn=U(e=>e.pinExplorerRoot),bn=U(e=>e.unpinExplorerRoot),et=U(e=>e.selectedFilePath),tt=U(e=>e.selectFile),Oo=U(e=>e.showHiddenFiles),qu=U(e=>e.toggleShowHiddenFiles),Ho=U(e=>!!(d&&e.nestedGitScanRoots[d])),Ee=U(e=>e.changedFiles),Ra=U(e=>e.setChangedFiles),Ps=U(e=>e.invalidateDirectoryCache),Ku=U(e=>e.setDirectorySortMode),Tl=U(e=>e.applyFileWatchEvents),Ml=U(e=>e.reconcileDirectoryCache),Ll=U(e=>e.bumpFileWatchEpoch),fr=U(e=>e.gitBundleLoading),Il=U(e=>e.gitBundleSlow),xn=U(e=>e.gitBundleError),Wn=U(e=>e.gitBundleLastLoadedAt),$l=U(e=>e.beginGitBundleLoading),Fl=U(e=>e.setGitBundleSlowFor),zo=U(e=>e.finishGitBundleLoading),ja=U(e=>e.resetGitBundleLoading),Go=U(e=>e.setGitBundleError),Dl=U(e=>e.markGitBundleLoaded),re=zn??d,Ca=U(e=>!!(re&&e.hideGitIgnoredRoots[re])),Vu=U(e=>e.hideGitIgnoredRootsHydrated),Yu=U(e=>e.setHideGitIgnoredRoot),[Wo,_l]=n.useState(!1),[Bl,qo]=n.useState(null);n.useEffect(()=>{qo(null)},[re]);const Ul=n.useMemo(()=>re?ag(re,Ne):"",[re,Ne]),Es=n.useMemo(()=>sg(Pe),[Pe]),Ol=n.useMemo(()=>({excludePatterns:Es,caseSensitive:Fe,wholeWord:E,regex:ge}),[Fe,Es,ge,E]),Na=U(e=>re?e.fileSortModes[re]??"name":"name"),Hl=U(e=>!!(re&&e.directoryCache.has(re))),qn=n.useRef(null),vt=n.useRef(0),[zl]=n.useState(()=>++tb),Mr=n.useRef(null),qr=n.useRef(null),Pa=n.useRef(0),Gt=n.useRef(new Map),Wt=n.useRef(new Map),hr=n.useRef(new Set),vn=n.useRef(new Set),yn=n.useRef(0),Kr=n.useRef(null),Kn=n.useRef(0),Vn=n.useRef(null),Yn=n.useRef(0),Vr=n.useRef(null),Ko=n.useRef(new Set),Vo=n.useRef(null),Yo=n.useRef(null),Ea=n.useRef(null),Xo=n.useRef(null),Jo=n.useRef(null),As=n.useRef(new Set);n.useEffect(()=>{if(Un===null)return;const e=Math.max(0,Date.now()-Un),s=e<6e4?1e3:e<36e5?6e4:e<864e5?36e5:864e5,l=Math.max(50,s-e%s),h=window.setTimeout(()=>Hu(Date.now()),l);return()=>window.clearTimeout(h)},[$o,Un]);const Aa=n.useRef(null),Lr=n.useRef(null),Qo=n.useRef(null),Gl=n.useRef(null),Ts=n.useRef(null),Re=n.useCallback(e=>U.getState().rootPath===e,[]);n.useEffect(()=>{if(!r||typeof window>"u")return;const e=s=>{const l=ab(s.target);l&&Qs("global_change_row_event",{...ob(s),selectionPath:l.dataset.diffSelectionPath,filePath:l.dataset.diffFilePath,absolutePath:l.dataset.diffAbsolutePath,repoRoot:l.dataset.diffRepoRoot,status:l.dataset.diffStatus,selectedFilePath:U.getState().selectedFilePath,rightTab:U.getState().rightTab,activeGitRepoRoot:me,changedFiles:U.getState().changedFiles.size})};return window.addEventListener("pointerdown",e,{capture:!0}),window.addEventListener("click",e,{capture:!0}),()=>{window.removeEventListener("pointerdown",e,{capture:!0}),window.removeEventListener("click",e,{capture:!0})}},[me,r]);const Wl=n.useCallback(async(e=d??void 0)=>{if(!e)return null;if(hr.current.has(e)||vn.current.has(e))return st("untracked_skip_cached",{cwd:e,rootPath:d,completed:hr.current.has(e),running:vn.current.has(e)}),null;const s=d,l=Pa.current+1;Pa.current=l,Gt.current.set(e,l);const h=`right-sidebar-git-untracked:${e}`,u=new AbortController;Wt.current.set(e,u),vn.current.add(e),st("untracked_start",{requestId:l,cwd:e,rootPath:d});try{let v=await td(e,u.signal,h),y=0;for(;v.status==="running"&&y<120;){if(Gt.current.get(e)!==l||u.signal.aborted)return st("untracked_stale_result",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,status:v.status}),null;if(!Re(s))return st("untracked_root_changed",{requestId:l,cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath}),null;await new Promise(Z=>window.setTimeout(Z,y<10?1e3:3e3)),y+=1,v=await td(e,u.signal,h)}if(Gt.current.get(e)!==l||!Re(s))return st("untracked_stale_result",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath,files:v.files.length,status:v.status}),null;if(v.status==="done")return Ra(Mu(U.getState().changedFiles,v.files)),v.files.length>0&&ft(Z=>{const je=new Map(Z.map(ie=>[ie.root,ie])).get(e);if(!je)return Z;const Ke=qg(je.files,v.files),z=Z.map(ie=>ie.root===e?{...ie,files:Ke,context:ie.context?{...ie.context,changedFiles:Ke.map(Ce=>({path:Ce.path,absolutePath:Ce.absolutePath,status:Ce.status})),truncated:!1}:ie.context,untrackedDeferred:!1}:ie);Qt(Lu(z,d));const B=z.find(ie=>ie.root===d);return B?.context&&Jt(ie=>ie?.root===B.root?{...ie,...B.context}:ie),z}),hr.current.add(e),st("untracked_apply",{requestId:l,cwd:e,files:v.files.length}),v;const X=v.error||(v.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return hr.current.add(e),st("untracked_error",{requestId:l,cwd:e,message:X,code:v.code,status:v.status}),null}catch(v){if(Gt.current.get(e)!==l||!Re(s)||vr(v))return st("untracked_aborted",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath,message:v instanceof Error?v.message:String(v)}),null;const y=v instanceof Error?v.message:"Failed to scan untracked files";return hr.current.add(e),st("untracked_error",{requestId:l,cwd:e,message:y}),null}finally{Wt.current.get(e)===u&&Wt.current.delete(e),Gt.current.get(e)===l&&Gt.current.delete(e),vn.current.delete(e)}},[Ae,Re,d,Ra]),ar=n.useMemo(()=>{const e=new Set(Ue.map(l=>l.root)),s=Or.filter(l=>e.has(l));return s.length>0?s:me?[me]:[]},[me,Or,Ue]),ql=ar.length===0,wn=n.useMemo(()=>ar.map(e=>Be.find(s=>s.root===e)).filter(e=>!!e),[ar,Be]),Xu=n.useMemo(()=>Ue.map(e=>({root:e.root,label:e.label,branch:e.branch??null})),[Ue]),pr=n.useCallback(async()=>{if(!d){tn([]),_r([]);return}const e=d,s=Kn.current+1;Kn.current=s,Vn.current?.abort();const l=new AbortController;Vn.current=l,Nr(xt.length===0),Ur(null);try{const h=ar.length>0?await Promise.all(ar.map(u=>rd({workspaceRoot:d,repoRoot:u},l.signal))).then(u=>({records:u.flatMap(v=>v.records),walkthroughs:u.flatMap(v=>v.walkthroughs??[])})):await rd({workspaceRoot:d},l.signal);if(Kn.current!==s||!Re(e))return;tn(h.records),_r(h.walkthroughs??[])}catch(h){if(Kn.current!==s||!Re(e)||vr(h))return;Ur(h instanceof Error?h.message:"Failed to load change audit explanations")}finally{Vn.current===l&&(Vn.current=null),Kn.current===s&&Re(e)&&Nr(!1)}},[xt.length,ar,Re,d]),Ta=n.useCallback(async(e,s,l)=>{if(!e&&!d){Hr([]),xs([]);return}const h=d,u=Yn.current+1;Yn.current=u,Vr.current?.abort();const v=new AbortController;Vr.current=v;try{const y=e?[e]:Array.from(new Set([d,...Be.map(Z=>Z.root)].filter(Z=>!!Z))),X=await Promise.all(y.map(Z=>kh({repoRoot:Z,baseRef:s,branchName:l},v.signal))).then(Z=>{const de=new Map,je=new Map;for(const Ke of Z){for(const z of Ke.records)de.set(z.id,z);for(const z of Ke.walkthroughs??[])je.set(z.id,z)}return{records:Array.from(de.values()),walkthroughs:Array.from(je.values())}});if(Yn.current!==u||!Re(h))return;Hr(X.records),xs(X.walkthroughs??[])}catch(y){if(Yn.current!==u||!Re(h)||vr(y))return;console.warn("[RightSidebar] Failed to load branch explanations",y)}finally{Vr.current===v&&(Vr.current=null)}},[Be,Re,d]),Xn=n.useCallback((e,s={})=>{if(!Re(d)){st("apply_skipped_root_changed",{expectedRootPath:d,currentRootPath:U.getState().rootPath,bundleRoot:e.context?.root,files:e.files.length});return}st(e.files.length===0?"empty_bundle":"apply",{rootPath:d,available:e.available,files:e.files.length,repositories:e.repositories?.map(B=>({root:B.root,relativeRoot:B.relativeRoot,files:B.files.length,available:B.available,error:B.error})),repoFilters:e.repoFilters?.map(B=>({root:B.root,label:B.label,count:B.count})),cached:e.cached,stale:e.stale,cacheAgeMs:e.cacheAgeMs,untrackedDeferred:e.untrackedDeferred,error:e.error});let l=ju(e),h=e.repoFilters??[],u=e.files;const v=U.getState().changedFiles;if(!!(s.cacheOnly&&!e.cached&&e.files.length===0&&l.length===0)&&(v.size>0||Be.length>0||Ae)){st("cache_only_apply_skipped_empty_backend_cache",{rootPath:d,currentFiles:v.size,currentRepositories:Be.length});return}const X=l.some(B=>B.deferred);if(X&&!s.replaceWorkspace){const B=new Set(l.filter(Ce=>!Ce.deferred||Ce.root===d).map(Ce=>Ce.root));u=[...Array.from(v.values()).filter(Ce=>!B.has(ut(Ce,d)??"")),...e.files]}const Z=Vd(v.values(),d),de=Vd(e.files,d),je=l.some(B=>B.root!==d);if(!!(s.background&&!X&&!s.replaceWorkspace&&v.size>0&&(e.files.length===0&&!e.error||Z>0&&de===0&&!je))){st("background_apply_skipped_degraded_bundle",{rootPath:d,currentFiles:v.size,nextFiles:e.files.length,currentNestedCount:Z,nextNestedCount:de,nextRepositories:l.map(B=>({root:B.root,relativeRoot:B.relativeRoot,files:B.files.length})),cached:e.cached,stale:e.stale,error:e.error});return}if(s.replaceRepoRoot){const B=Iu(v.values(),Be,e,s.replaceRepoRoot,d);u=B.files,l=B.repositories,h=B.repoFilters}if(Ra(Tu(u)),ft(B=>{if(!X||s.replaceWorkspace)return l;const ie=new Map(B.map(Ce=>[Ce.root,Ce]));return l.map(Ce=>{const _e=ie.get(Ce.root);return!Ce.deferred||!_e?Ce:{...Ce,available:_e.available,files:_e.files,context:_e.context,deferred:_e.deferred,untrackedDeferred:_e.untrackedDeferred,error:_e.error}})}),Qt(h),Jo.current=d,s.syncActiveRepo!==!1){const{contextKey:B,activeGitRepos:ie}=U.getState(),Ce=B?ie[B]??null:null,_e=s.activeRepoRoot!==void 0?s.activeRepoRoot:Ce,Le=Lg({...e,repositories:l,repoFilters:h},_e);dt(Le)}typeof e.cacheUpdatedAt=="number"&&vl(e.cacheUpdatedAt),Jt(B=>{if(s.replaceRepoRoot&&s.replaceRepoRoot!==d)return B;if(!e.context)return null;const ie=B?.root??d;return!B?.available||ie!==(e.context.root??d)?e.context:{...B,...e.context}}),s.reloadDiff&&ko(B=>B+1);const z=U.getState().selectedFilePath;if(z&&!z.startsWith("/")&&!u.some(B=>B.path===z||B.absolutePath===z)&&tt(null),Rr(B=>{const ie=new Set(u.map(_e=>ut(_e,d)).filter(Boolean)),Ce=new Set;for(const _e of B)ie.has(_e)&&Ce.add(_e);return Bi($i,Ce),Ce}),s.loadDeferred!==!1){const B=l.filter(ie=>ie.untrackedDeferred&&ie.root).map(ie=>ie.root);for(const ie of B)Wl(ie)}s.loadAudit!==!1&&pr()},[Re,pr,Wl,d,tt,dt,Ra]);n.useEffect(()=>{ja(),Vo.current=null,Yo.current=d;const e=[],s=[];vt.current+=1,yn.current+=1,Pa.current+=1,Mr.current?.abort(),yt(Xs(qr.current?.cwd??d??void 0)),qr.current=null,Mr.current=null,Kr.current?.abort(),yt("right-sidebar-git-details"),Kr.current=null;for(const y of Wt.current.values())y.abort();for(const y of Wt.current.keys())yt(`right-sidebar-git-untracked:${y}`);Wt.current.clear(),Gt.current.clear(),Kn.current+=1,Vn.current?.abort(),Vn.current=null,Yn.current+=1,Vr.current?.abort(),Vr.current=null,Gr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,tn([]),_r([]),Nr(!1),Ur(null),$n([]),rn(!1),Hr([]),xs([]),lr(!1),tr(null),Te(!1),Me(null),ot(null),cr(null),an(null),zr(!1),cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1),fa(null),un(null),fn(null),ul(!1),Pt(Fi,!1),Co(!1);const l=d?Hd()[d]:null,h=l?.previewEntries??[],u=l?.selectedPreviewKey??null,v=u?h.find(y=>y.key===u)??null:null;++T.current,Te(!1),No(l?.selectedRepoRoots??[]),pa(l?.repoTargetBranches??{}),ma(l?.repoBaseBranches??{}),sn(h),S(l?.previewScrollTops??{}),v&&l?.previewDetailOpen&&(v.diff.hunks?.length??0)>0&&(tr(v.diff),un(v.key),fn(l.selectedPreviewFileKey??(v.diff.hunks?.[0]?`${v.diff.hunks[0].filePath}\0${v.diff.hunks[0].hunkHeader}\0${v.diff.hunks[0].hunkIndex}`:null)),lr(!0)),Po(l?.repoIncludeUncommitted??Object.fromEntries(Object.keys(l?.repoTargetBranches??{}).map(y=>[y,l?.includeUncommitted??!0]))),Vo.current=d,xa(!1),hr.current.clear(),vn.current.clear(),Cs(null),Ns(null),hn(null),zt(null),vl(null),ft(e),Qt(s),Jt(null),Xo.current=null,Jo.current=null,As.current.clear()},[ja,d]);const It=n.useCallback(async(e=d??void 0,s={})=>{if(!e)return null;const l=d,h=vt.current;if(await Hp(()=>Promise.all([U.getState().hydrateNestedGitScanRoots(),U.getState().hydrateActiveGitRepos()]).then(()=>{})),vt.current!==h||!Re(l))return null;const u=e===d&&Vs(d),v=s.includeNested??u,y=s.refresh??s.reloadDiff??!1,X=s.cacheOnly??!1,Z=s.background??!1,de=v&&(s.discoverOnly??!1);y&&hr.current.clear();const je=qr.current;if(je&&je.cwd===e&&je.includeNested===v&&je.refresh===y&&je.cacheOnly===X&&je.discoverOnly===de)return st("reuse_pending",{cwd:e,includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de}),je.promise;const Ke=vt.current+1;vt.current=Ke;const z=`right-sidebar:${zl}:${Ke}`;Mr.current?.abort();const B=Xs(e);yt(B);const ie=new AbortController;Mr.current=ie;let Ce=null;Z||$l(z),Go(null),st("start",{requestId:Ke,cwd:e,rootPath:d,requestSlotId:B,includeNested:v,refresh:y,cacheOnly:X,background:Z,existingChanges:Ee.size,lastLoadedAt:Wn}),!Z&&typeof window<"u"&&(Ce=window.setTimeout(()=>{vt.current===Ke&&Fl(z,!0)},pg));const _e=(async()=>{const Le=await Ci(e,ie.signal,{includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de,action:y?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:B,requestTimeoutMs:y?null:void 0});if(Yg(Le)){if(st("cancelled_result_ignored",{requestId:Ke,activeRequestId:vt.current,cwd:e,error:Le.error??Le.context?.error}),ie.signal.aborted)return null;throw new Error(Le.error??Le.context?.error??"Failed to load Git changes")}return vt.current!==Ke||!Re(l)?(st("stale_result",{requestId:Ke,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:U.getState().rootPath,files:Le.files.length,repositories:Le.repositories?.length??0}),null):(Xn(Le,{reloadDiff:s.reloadDiff,syncActiveRepo:s.replaceWorkspace?!0:v,background:Z,cacheOnly:X,replaceRepoRoot:s.replaceRepoRoot,replaceWorkspace:s.replaceWorkspace}),Le)})();qr.current={cwd:e,includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de,promise:_e};try{const Le=await _e;return vt.current===Ke&&Le&&Re(l)?Dl({cached:Le.cached,stale:Le.stale,cacheAgeMs:Le.cacheAgeMs,nestedDeferred:!v||Le.nestedDeferred,untrackedDeferred:Le.untrackedDeferred}):vt.current===Ke&&Re(l)&&zo(z),Le}catch(Le){return vt.current!==Ke||!Re(l)||ie.signal.aborted?(st("aborted",{requestId:Ke,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:U.getState().rootPath,message:Le instanceof Error?Le.message:String(Le)}),null):(st("error",{requestId:Ke,cwd:e,includeNested:v,refresh:y,background:Z,message:Le instanceof Error?Le.message:String(Le)}),Z||(Jt(null),Go(Le instanceof Error?Le.message:"Failed to load Git changes")),null)}finally{Ce!==null&&window.clearTimeout(Ce),Mr.current===ie&&(Mr.current=null),qr.current?.promise===_e&&(qr.current=null),!Z&&vt.current===Ke&&Re(l)&&zo(z)}},[Xn,$l,Ee.size,zo,zl,Wn,Re,Dl,d,Go,Fl]),Jn=n.useCallback(async()=>{d&&await It(d,{reloadDiff:!0,refresh:!0})},[It,d]),Zo=n.useCallback(async(e=d??void 0)=>{if(!e)return null;const s=d,l=yn.current+1;yn.current=l,Kr.current?.abort(),yt("right-sidebar-git-details");const h=new AbortController;Kr.current=h,xa(!0);try{const u=await nd(e,h.signal,"load_git_details","right-sidebar-git-details");return yn.current!==l||!Re(s)?null:(ft(v=>v.map(y=>y.root===u.root?{...y,available:u.available,context:u,error:u.error}:y)),Jt(v=>v?.root&&u.root&&v.root!==u.root?v:!v?.available||!u.available?u:{...v,...u}),u)}catch(u){return vr(u)||!Re(s)||yn.current===l&&zt(u instanceof Error?u.message:"Failed to load Git details"),null}finally{Kr.current===h&&(Kr.current=null),yn.current===l&&Re(s)&&xa(!1)}},[Re,d]);n.useEffect(()=>{if(!r){vt.current+=1,ja(),Xo.current=null,yn.current+=1,Pa.current+=1,Mr.current?.abort(),yt(Xs(qr.current?.cwd??d??void 0)),qr.current=null,Mr.current=null,Kr.current?.abort(),yt("right-sidebar-git-details"),Kr.current=null;for(const e of Wt.current.values())e.abort();for(const e of Wt.current.keys())yt(`right-sidebar-git-untracked:${e}`);Wt.current.clear(),Gt.current.clear(),Yn.current+=1,Vr.current?.abort(),Vr.current=null,Gr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,xa(!1),Te(!1),Me(null),ot(null),cr(null),an(null),zr(!1),cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1),he(""),C(!1),Ut(null),Lo(!1),J&&pl(!1)}},[J,r,ja,C]),n.useEffect(()=>{if(!ee)return;const e=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(e)},[ee]),n.useEffect(()=>{J||Ar(!1)},[J]);const Kl=n.useCallback(e=>{To(e);const s=Qo.current;s&&(s.update(),s.slideTo(e,0),window.requestAnimationFrame(()=>{s.update(),s.slideTo(e,0)}))},[]);n.useEffect(()=>{if(J)if(Ar(m),m&&et){Tr(1);const e=Lr.current;e&&(e.update(),e.activeIndex!==1&&(Ts.current=1,e.slideTo(1,0)))}else{Tr(0);const e=Lr.current;e&&e.activeIndex!==0&&(Ts.current=0,e.slideTo(0,0)),Ut(null)}},[J,m,d,et]),n.useEffect(()=>{if(x!==void 0&&!m){Tr(0);const e=Lr.current;e&&e.activeIndex!==0&&(Ts.current=0,e.slideTo(0,0)),Ar(!1),Ut(null)}},[x,m]),n.useEffect(()=>{A!==void 0&&bt(null)},[A]),n.useEffect(()=>{!J&&m&&R?.()},[J,R,m]),n.useEffect(()=>{Bo(e=>nl(e,i))},[i]);const Ju=n.useCallback(e=>{J||(e.preventDefault(),Aa.current={startX:e.clientX,startWidth:_o,pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId))},[_o,J]),Qu=n.useCallback(e=>{const s=Aa.current;if(!s||s.pointerId!==e.pointerId)return;const l=nl(s.startWidth+e.clientX-s.startX,i);Bo(l),ra(ea,l,hg)},[i]),Vl=n.useCallback(e=>{const s=Aa.current;if(!(!s||s.pointerId!==e.pointerId)){Aa.current=null,Ks(ea);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),Qn=!!(d&&Wn!==null&&Jd(Ae)),ei=!!(d&&!xn&&Ee.size===0&&Wn===null),jt=(()=>{let e=Uo;return e==="android"&&!Wr&&(e="files"),(e==="architecture"||e==="computer")&&!sr[e]&&(e="files"),Qn&&(e==="git"||e==="diff")&&(e="files"),e})(),nt=jt==="git",Ir=jt==="files",Ct=jt==="diff",Zn=jt==="android",es=jt==="computer",kn=jt==="architecture",[Zu,ef]=n.useState(!1);n.useEffect(()=>{r&&es&&ef(!0)},[r,es]);const[tf,rf]=n.useState(!1);n.useEffect(()=>{r&&kn&&rf(!0)},[r,kn]);const ti=n.useRef(null),ts=n.useCallback((e,s)=>{const l=U.getState().rightTab;if(l===e)return;const h=performance.now(),u=h-s.timeStamp;ti.current={from:l,to:e,startedAt:h,inputDelayMs:u>=0&&u<6e4?Math.round(u):null},Mt(e)},[Mt]);n.useEffect(()=>{const e=ti.current;if(!e||e.to!==jt)return;ti.current=null;const s=Math.round(performance.now()-e.startedAt);let l=window.requestAnimationFrame(()=>{l=window.requestAnimationFrame(()=>{Qs("tab_switch_presented",{from:e.from,to:e.to,inputDelayMs:e.inputDelayMs,commitMs:s,frameMs:Math.round(performance.now()-e.startedAt)})})});return()=>window.cancelAnimationFrame(l)},[jt]);const nf=gp(e=>e.overlay==="sidebar")&&Zn;n.useEffect(()=>{if(!J){ga(!0);return}if(!r){const s=window.setTimeout(()=>{ga(!1)},bg);return()=>window.clearTimeout(s)}ga(!1);const e=window.setTimeout(()=>{ga(!0)},gg);return()=>window.clearTimeout(e)},[J,r]),n.useEffect(()=>{if(!J||!Ct)return;const e=Qo.current;if(!e)return;const s=window.requestAnimationFrame(()=>{e.update()});return()=>window.cancelAnimationFrame(s)},[Ct,J]),n.useEffect(()=>{if(!Qn||!d||fr)return;const e=window.setTimeout(()=>{It(d,{background:!0})},3e3);return()=>window.clearTimeout(e)},[Qn,d,fr,It]);const sf=n.useCallback(e=>{It(e,{discoverOnly:!0})},[It]);zp({active:r&&(nt||Ct),rootPath:d,loading:fr,delay:nt&&!J?0:_i,lastStartedRoot:Xo,load:sf}),n.useEffect(()=>{!r||!nt||(!J||Mo)&&Lo(!0)},[nt,J,r,Mo]),n.useEffect(()=>{if(!r||nt)return;const e=window.setTimeout(()=>{Lo(!0)},_i);return()=>window.clearTimeout(e)},[nt,r]),n.useEffect(()=>{Ir&&Bu(!0)},[Ir]),n.useEffect(()=>{Ct&&pl(!0)},[Ct]),n.useEffect(()=>{!r||!Zn||(a&&ba&&ba.sessionId!==a&&(ji.getState().setDock(Ai,null),Zs({androidPanel:{docked:null}}).catch(()=>{})),ml(!0))},[Zn,r,a,ba]),n.useEffect(()=>{if(r&&Zn||!Io)return;const e=window.setTimeout(()=>ml(!1),mg);return()=>window.clearTimeout(e)},[r,Zn,Io]),n.useEffect(()=>{let e=!1;return Zd().then(s=>{e||(js.current.has("android")||gl(s.androidPanel?.enabled===!0),bl(l=>({architecture:js.current.has("architecture")?l.architecture:s.rightSidebarTabs?.architecture===!0,computer:js.current.has("computer")?l.computer:s.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{e=!0}},[]);const Yl=n.useCallback(e=>{js.current.add("android"),gl(e),e?Mt("android"):U.getState().rightTab==="android"&&Mt("files"),Zs({androidPanel:{enabled:e}}).catch(()=>{})},[Mt]),af=n.useCallback((e,s)=>{js.current.add(e),bl(l=>({...l,[e]:s})),s?Mt(e):U.getState().rightTab===e&&Mt("files"),Zs({rightSidebarTabs:{[e]:s}}).catch(()=>{})},[Mt]),Xl=n.useCallback(e=>{re&&Og(re,e.currentTarget.scrollTop)},[re]);n.useEffect(()=>()=>{Mr.current?.abort(),Ks(ol),Ks(il),Ks(ea),Ks(Di)},[]),n.useEffect(()=>{if(!re||!Hl)return;const e=Eu()[re]?.top;if(typeof e!="number")return;let s=window.requestAnimationFrame(()=>{qn.current&&(qn.current.scrollTop=e),s=window.requestAnimationFrame(()=>{qn.current&&(qn.current.scrollTop=e)})});return()=>window.cancelAnimationFrame(s)},[re,Hl]),n.useEffect(()=>{if(!r)return;const e=new AbortController;return Sh(e.signal).then(s=>Rl(!!s.available)).catch(()=>Rl(!1)),()=>e.abort()},[r]);const Ms=n.useCallback(e=>{if(j(null),tt(e),Ut(null),J){Ar(!0),Tr(1),Lr.current?.slideTo(1),w?.();return}},[J,w,tt]),ri=n.useCallback((e,s)=>{if(j(null),tt(e),Et(s),J){Ar(!0),Tr(1),Lr.current?.slideTo(1),w?.();return}},[J,w,tt]),$t=xm(e=>Ps(e,!1)),Ma=$t.busy,Ls=n.useCallback(async(e,s)=>{const l=s||zn||d;!l||!e.length||await $t.start(l,e)},[zn,d,$t.start]),Jl=n.useCallback(async e=>{try{await Rh(e)}catch(s){zt(s instanceof Error?s.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>zt(null),4e3)}},[o]),La=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes("Files")&&Fo(!0)},[]),Ql=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1)},[]),Zl=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1);const s=e.dataTransfer.files;s.length>0&&Ls(Array.from(s))},[Ls]),ni=n.useCallback(e=>{V(e),window.setTimeout(()=>V(s=>s===e?null:s),1400)},[]),mr=n.useCallback(e=>{Ze(e),window.setTimeout(()=>Ze(s=>s===e?null:s),1400)},[]);n.useEffect(()=>{Pt(Id,N)},[N]),n.useEffect(()=>{Pt($d,ke)},[ke]),n.useEffect(()=>{Pt(Fd,ht)},[ht]),n.useEffect(()=>{ra(Di,kt,lg)},[kt]),n.useEffect(()=>(Pl().catch(()=>{}),sd(e=>{e.type==="pinned-explorer-roots"&&El(e.pinnedExplorerRoots)})),[Pl,El]);const ec=n.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Ia=n.useRef(null),Sn=n.useRef(null),[tc,si]=n.useState(!1);n.useEffect(()=>{if(!r)return;si(!1);let e=!1;jh().then(l=>{e||(Ia.current=l.text,St(h=>l.text&&l.text!==h?l.text:h),si(!0))}).catch(()=>{e||si(!0)});const s=sd(l=>{l.type==="context-draft"&&l.origin!==ec.current&&(Ia.current=l.text,St(l.text))});return()=>{e=!0,s(),Sn.current!==null&&(window.clearTimeout(Sn.current),Sn.current=null)}},[r]),n.useEffect(()=>{if(!tc||Ia.current===kt)return;Sn.current!==null&&window.clearTimeout(Sn.current);const e=kt;Sn.current=window.setTimeout(()=>{Sn.current=null,Ch(e,ec.current).then(()=>{Ia.current=e}).catch(()=>{})},500)},[kt,tc]);const rs=n.useCallback(async(e,s,l,h)=>{if(!e)return!1;if(ir(!1),h&&!Ni(h)())return ir(!0),!1;if(Nh(l?e+l:e))return ni(s),!0;if(N)St(u=>mm(u,e)+(l??"")),window.matchMedia("(pointer: coarse)").matches||(Ye(!1),hs(u=>u+1));else{const u=a??Yr.getState().activeSessionId;if(!await eu(l?e+l:e,u,()=>$s.current&&u===Yr.getState().activeSessionId,h))return ir(!0),!1}return ni(s),!0},[N,ni,a]),$a=n.useCallback(e=>{const s=An(e,d);return Ph(s,d)},[d]),ai=tu(mr),qt=n.useCallback((e,s,l)=>{const h=An(e,d);return rs(ad(h,d),s??`path:${h}`,void 0,l)},[d,rs]),ns=n.useRef({sessionId:a,contextDraftEnabled:N,isOpen:r});ns.current={sessionId:a,contextDraftEnabled:N,isOpen:r};const of=n.useCallback(async(e,s)=>{const l=a??Yr.getState().activeSessionId,h=()=>$s.current&&ns.current.isOpen&&(ns.current.sessionId??Yr.getState().activeSessionId)===l&&Yr.getState().activeSessionId===l&&ns.current.contextDraftEnabled===N;await $t.start("/tmp",[e],v=>qt(v,`path:${v}`,s),h)&&h()&&J&&!N&&c()},[N,qt,J,c,a,$t.start]),Is=n.useRef(!0),Fa=n.useRef(a);Fa.current=a,n.useEffect(()=>(Is.current=!0,()=>{Is.current=!1}),[]);const lf=n.useCallback(e=>{bp.getState().enqueue(e,a??null,d||"/",async(s,l)=>{if(ns.current.contextDraftEnabled&&Is.current&&Fa.current===a){if(!await oi.current(ad(s,null),`path:${s}`,l))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return bd(s,a,l)})},[a,d,N,qt,o]),cf=n.useCallback(async(e,s)=>{const l=Ni(s),u=(await Wi("/tmp",[e])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");if(!l()||!Is.current||Fa.current!==a||ns.current.contextDraftEnabled!==N)throw new Error(o("rightSidebar.uploadReferenceRejected"));if(N&&Is.current&&Fa.current===a){if(!await qt(u,void 0,s))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await bd(u,a,s)},[N,qt,a,o]),$r=n.useCallback((e,s,l)=>{if(!e)return Promise.resolve(!1);const h=e.includes(`
1645
- `)?`
1646
- `:void 0;return rs(e.endsWith(`
1647
- `)||e.endsWith(" ")?e:`${e} `,s,h,l)},[rs]),oi=n.useRef($r);oi.current=$r;const $s=n.useRef(!0);n.useEffect(()=>($s.current=!0,()=>{$s.current=!1}),[]);const ii=n.useRef(new Set),Da=n.useCallback((e,s,l,h)=>{if(ii.current.has(s))return!1;const u=Ni(h);if(!u())return!1;const v=a??Yr.getState().activeSessionId;return ii.current.add(s),Vp(e,s,l,{insert:(y,X)=>$r(y,X,h),upload:async(y,X)=>(await Wi("/tmp",[y],X)).files[0]?.path,isCurrent:()=>u()&&$s.current&&oi.current===$r&&v===Yr.getState().activeSessionId}).catch(()=>(ir(!0),!1)).finally(()=>ii.current.delete(s))},[$r,a]),Fr=n.useCallback((e,s,l,h)=>s?rs(s.endsWith(" ")?s:`${s} `,l??`context:${e}`,`
1648
- `,h):Promise.resolve(!1),[rs]),rc=ym({text:kt,sessionId:a??Yr.getState().activeSessionId,active:r&&N,onAccepted:()=>{en(!1),St(""),ht&&Ye(!0)},onRejected:()=>{en(!0),Ye(!1)}}),Qe=n.useMemo(()=>d?gt(d):o("rightSidebar.workspace"),[d,o]),df=n.useMemo(()=>gt(re)||Qe,[re,Qe]),_a=n.useMemo(()=>lo(re),[re]),Ba=n.useMemo(()=>d?Nl[d]??[]:[],[Nl,d]),Rn=n.useMemo(()=>new Set(Ba.map(e=>e.path)),[Ba]),Fs=!!(re&&Rn.has(re)),li=!!(d&&re&&re!==d),uf=!!(d&&zn&&zn!==d),Ft=re?`path:${re}`:null,nc="context:change-audit",ff=n.useCallback(()=>{_a&&Lt(_a)},[_a,Lt]),sc=n.useCallback(()=>{Al()},[Al]),hf=n.useCallback(()=>{re&&(Ps(re,!0),Ll())},[Ll,re,Ps]),pf=n.useCallback(()=>{!re||!li||(Fs?bn(re):Gn(re,"directory"))},[li,re,Fs,Gn,bn]),ac=n.useCallback(e=>{Lt(e),he("")},[Lt]),oc=n.useCallback(e=>{re&&(we(og(re,e)),C(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[re,C]),ic=n.useCallback(e=>{!d||e===d||(Rn.has(e)?bn(e):Gn(e,"directory"))},[Gn,Rn,d,bn]),lc=n.useCallback(e=>{!d||!e||(Rn.has(e)?bn(e):Gn(e,"file"))},[Gn,Rn,d,bn]),cc=U(e=>e.expandedPaths),ci=n.useMemo(()=>{const e=new Set;if(Ir&&re){e.add(re);const s=`${re.replace(/\/+$/,"")}/`;for(const l of cc)l.startsWith(s)&&e.add(l)}if(Ir&&d&&et){const s=et.startsWith("/")?et:`${d}/${et}`,l=lo(s);l&&e.add(l)}return im(e).join(`
1649
- `)},[cc,Ir,re,d,et]),jn=n.useRef(new Map);n.useEffect(()=>{const e=ci?ci.split(`
1650
- `):[];if(!r||e.length===0){Hn(null);return}const s=new AbortController;let l=!1,h=0,u=0;Hn(null);const v=async()=>{let y=0;for(;!l&&!s.signal.aborted;){let X=null;try{Hn(null),await Dh(e,de=>{const{applicableEvents:je,unavailableReason:Ke}=cm(de);je.length>0&&Tl(je);const z=new Set(je.filter(B=>B.type==="rescan-required").map(B=>B.path));if(Ca)for(const B of je){if(B.type==="created"||B.type==="updated"){const ie=lo(B.path);ie&&z.add(ie)}B.path.endsWith("/.gitignore")&&re&&Ps(re,!0)}for(const B of z){const ie={path:B},Ce=U.getState();if(!Ce.directoryCache.has(ie.path))continue;jn.current.get(ie.path)?.abort();const Le=new AbortController;jn.current.set(ie.path,Le);const Qc=`file-watch-rescan:${ie.path}`;yt(Qc),Qd(ie.path,Le.signal,Ce.showHiddenFiles,"watch_rescan",Qc,Ce.fileSortModes[ie.path]??"name",re??void 0).then(Gs=>{jn.current.get(ie.path)===Le&&Ml(ie.path,Gs.entries)}).catch(Gs=>{vr(Gs)||Hn(Gs instanceof Error?Gs.message:"File refresh unavailable")}).finally(()=>{jn.current.get(ie.path)===Le&&jn.current.delete(ie.path)})}Ke&&Hn(Ke)},s.signal),X=new Error("File watch stream ended")}catch(de){X=de}if(l||s.signal.aborted||vr(X))return;Hn(X instanceof Error?X.message:"File watching unavailable");const Z=Dd[Math.min(y,Dd.length-1)];y+=1,await new Promise(de=>{u=window.setTimeout(de,Z)})}};return h=window.setTimeout(()=>{l||v()},_i),()=>{l=!0,window.clearTimeout(h),window.clearTimeout(u),s.abort();for(const y of jn.current.values())y.abort();jn.current.clear()}},[Tl,r,Ml,ci,re,Ca,Ps]),n.useEffect(()=>{if(!d||Vo.current!==d)return;if(Yo.current===d){Yo.current=null;return}const e=Hd();ra(Su,{...e,[d]:{selectedRepoRoots:ha,repoTargetBranches:rr,repoBaseBranches:Rt,previewEntries:nn,selectedPreviewKey:fe&&Er?qe:null,selectedPreviewFileKey:fe&&Er?Eo:null,previewDetailOpen:!!(fe&&Er),previewScrollTops:vs,previewMobileSlideIndex:1,repoIncludeUncommitted:dn,updatedAt:Date.now()}},ig)},[Er,dn,fe,nn,vs,Rt,rr,ha,d,Eo,qe]);const it=n.useMemo(()=>Xd(Ee.values()),[Ee]),rt=n.useMemo(()=>{const e=new Map;for(const s of Be)e.set(s.root,s);return e},[Be]),Ds=n.useMemo(()=>{const e=new Map;for(const s of Be)s.deferred||e.set(s.root,s.files.length);return e},[Be]),Ua=n.useCallback(e=>{if(e){if(!e.deferred){As.current.delete(e.root);return}Ds.has(e.root)||As.current.has(e.root)||(As.current.add(e.root),It(e.root,{includeNested:!1,background:!0,replaceRepoRoot:e.root}).then(s=>{s||As.current.delete(e.root)}))}},[It,Ds]),or=n.useMemo(()=>me?Ue.find(e=>e.root===me)??null:null,[me,Ue]),Kt=n.useMemo(()=>et?Array.from(Ee.values()).find(e=>e.path===et||e.absolutePath===et)??null:null,[Ee,et]),Dt=n.useMemo(()=>{const e=new Map;for(const s of Be)s.available&&s.context?.available&&e.set(s.root,s);return e.size===0&&Ae?.available&&Ae.root&&e.set(Ae.root,{id:Ae.root,root:Ae.root,relativeRoot:".",name:Qe,depth:0,nested:!1,available:!0,files:Array.from(Ee.values()).filter(s=>ut(s,d)===Ae.root),context:Ae}),Array.from(e.values()).sort((s,l)=>s.root===d?-1:l.root===d?1:(s.relativeRoot||s.name).localeCompare(l.relativeRoot||l.name)).map(s=>{const l=s.relativeRoot==="."?Qe:s.relativeRoot||s.name||gt(s.root),h=Yd(s.files),u=s.files.length;return{value:s.root,label:l,meta:[s.context?.branch,u>0?o("rightSidebar.repoChangedCount",{count:u}):null,h>0?o("rightSidebar.repoStagedCount",{count:h}):null].filter(Boolean).join(" · ")}})},[Ee,Ae,Be,Qe,d,o]),ve=n.useMemo(()=>me&&Dt.some(e=>e.value===me)?me:Kt?.repoRoot&&Dt.some(e=>e.value===Kt.repoRoot)?Kt.repoRoot:Dt.length===1||Dt.length>1?Dt[0].value:null,[me,Dt,Kt?.repoRoot]),dc=ve?rt.get(ve)??null:null,se=dc?.context?.available?dc.context:ve===Ae?.root?Ae:null,Xe=Dt.length>0&&!ve,uc=n.useMemo(()=>Xe?[]:ve?Array.from(Ee.values()).filter(e=>ut(e,d)===ve):Array.from(Ee.values()),[ve,Ee,Xe,d]),Cn=n.useMemo(()=>Xd(uc),[uc]),di=!!(se?.available&&se.root&&ve&&se.root===ve),mf=ve?Dt.find(e=>e.value===ve)?.label??gt(ve):o("rightSidebar.gitRepositoryPlaceholder"),fc=di?se?.branch??"HEAD":Xe?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",Nn=!!(se?.available&&se.root===ve&&se.status);n.useEffect(()=>{dl.current={count:Tt.length,loading:da,loadingMore:ua,hasMore:Ro}},[Tt.length,Ro,da,ua]),n.useEffect(()=>{Gr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1)},[ve]);const _s=n.useCallback(async(e={})=>{if(!d||!ve||Xe)return;const s=e.reset??!1,l=dl.current,h=s?0:l.count;if(!s&&(l.loading||l.loadingMore||!l.hasMore))return;const u=Gr.current+1;Gr.current=u,ur.current?.abort(),yt("right-sidebar-recent-commits");const v=new AbortController;ur.current=v,s?ks(!0):Ss(!0),Dn(null);try{const y=await Eh({cwd:d,repoRoot:ve,limit:xg,skip:h,query:ws.trim(),requestSlotId:"right-sidebar-recent-commits"},v.signal);if(Gr.current!==u)return;if(!y.available){Dn(y.error??"Recent commits are unavailable"),s&&dr([]),_n(!1);return}We(X=>s?y.commitSyncStatus??{}:{...X,...y.commitSyncStatus}),dr(X=>s?y.commits:[...X,...y.commits]),_n(y.hasMore)}catch(y){if(Gr.current!==u||vr(y))return;Dn(y instanceof Error?y.message:"Failed to load recent commits"),s&&dr([]),_n(!1)}finally{ur.current===v&&(ur.current=null),Gr.current===u&&(ks(!1),Ss(!1))}},[ve,ws,Xe,d]);n.useEffect(()=>{on&&_s({reset:!0})},[ws,_s,on,se?.ahead,se?.behind,se?.upstream]);const gf=n.useCallback(e=>{const s=e.currentTarget;s.scrollTop+s.clientHeight<s.scrollHeight-48||_s({reset:!1})},[_s]);n.useEffect(()=>{!ve||!Ae?.available||!nt||!nr||Nn||pn||Xe||Zo(ve)},[ve,Ae?.available,Nn,pn,nt,nr,Zo,Xe]);const hc=r&&(Ct||nt);n.useEffect(()=>{!hc||!d||pr()},[hc,pr,d]),n.useEffect(()=>{!r||!nt||!nr||!Rs||!d||Ta(null)},[Rs,nt,nr,r,Ta,d]);const bf=n.useMemo(()=>{if(!me)return 0;const e=Ue.findIndex(s=>s.root===me);return e>=0?e+1:0},[me,Ue]),pc=n.useCallback(e=>{if(!e)return null;const s=Array.from(Ee.values()).filter(l=>ut(l,d)===e).sort((l,h)=>l.path.localeCompare(h.path))[0];return s?xr(s):null},[Ee,d]),Pn=Ue.length>1,Oa=n.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ee.size,branch:null,deferred:!1},...Ue.map(e=>({root:e.root,label:e.label,count:e.deferred?Ds.get(e.root)??0:e.count,branch:e.branch??null,deferred:!!e.deferred&&!Ds.has(e.root)}))],[Ee.size,Ue,Ds,o]),mc=Oa[bf]??Oa[0],Ha=!!me,gc=n.useMemo(()=>Cu(Ue,Be),[Ue,Be]);n.useEffect(()=>{Jo.current===d&&me&&!gc.has(me)&&dt(null),$n(e=>e.filter(s=>Ue.some(l=>l.root===s)))},[me,Ue,gc,d,dt]),n.useEffect(()=>{me&&Ua(rt.get(me))},[me,Ua,rt]);const xf=n.useMemo(()=>{const e=new Set;se?.branch&&e.add(se.branch);for(const s of se?.branches??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===se?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[se?.branch,se?.branches,o]),bc=n.useMemo(()=>{const e=new Set;se?.upstreamRemote&&e.add(se.upstreamRemote);for(const s of se?.remotes??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===se?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[se?.remotes,se?.upstreamRemote,o]),xc=bc.length>1,vf=n.useMemo(()=>{const e=[],s=new Set,l=(u,v)=>{!u||s.has(u)||(s.add(u),e.push({value:u,label:u,meta:v}))};l(se?.upstreamBranch,se?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),l(se?.branch,se?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const u of se?.branches??[])l(u,u===se?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const h=se?.upstreamRemote;for(const u of se?.remoteBranches??[]){const v=u.indexOf("/"),y=v>=0?u.slice(0,v):null,X=v>=0?u.slice(v+1):u;(!h||y===h)&&l(X,"remote")}return e},[se?.branch,se?.branches,se?.remoteBranches,se?.upstreamBranch,se?.upstreamRemote,o]),Vt=n.useMemo(()=>Dt.map(e=>{const s=rt.get(e.value);return{root:e.value,label:e.label,branch:s?.context?.branch??null}}),[Dt,rt]);n.useEffect(()=>{Vt.length!==0&&(pa(e=>{let s=!1;const l={...e},h=new Set(Vt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Vt)!l[u.root]&&u.branch&&(l[u.root]=u.branch,s=!0);return s?l:e}),ma(e=>{let s=!1;const l={...e},h=new Set(Vt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Vt){const v=rt.get(u.root)?.context;if(l[u.root]&&Nu(l[u.root],v?.branch)&&(delete l[u.root],s=!0),l[u.root])continue;const y=Wd(v);y&&(l[u.root]=y,s=!0)}return s?l:e}))},[Vt,rt]);const za=n.useMemo(()=>{const e=new Set(Vt.map(s=>s.root));return ha.filter(s=>e.has(s))},[ha,Vt]),Ga=za.length===0,gr=n.useMemo(()=>Ga?Vt:Vt.filter(e=>za.includes(e.root)),[Vt,za,Ga]),Bs=n.useMemo(()=>gr.filter(e=>!!Rt[e.root]?.trim()),[Rt,gr]),ss=n.useCallback((e,s)=>{const l=rt.get(e)?.context?.branch;return!!(l&&s&&s.replace(/^refs\/heads\//,"")===l)},[rt]),vc=n.useMemo(()=>gr.filter(e=>!Rt[e.root]?.trim()),[Rt,gr]),yc=n.useCallback(async e=>{if(!e||Ko.current.has(e))return;const s=rt.get(e)?.context;if((s?.branches?.length??0)>0||(s?.remoteBranches?.length??0)>0||s?.upstream)return;const l=d;Ko.current.add(e),hl(h=>new Set(h).add(e));try{const h=await nd(e,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${e}`);if(!h.available||!Re(l))return;ft(u=>u.map(v=>v.root===e?{...v,available:!0,context:{...v.context,...h},error:void 0}:v)),pa(u=>u[e]||!h.branch?u:{...u,[e]:h.branch}),ma(u=>{if(u[e])return u;const v=Wd(h);return v?{...u,[e]:v}:u})}catch(h){vr(h)||console.warn("[RightSidebar] Failed to load branch audit repo details",e,h)}finally{Ko.current.delete(e),hl(h=>{const u=new Set(h);return u.delete(e),u})}},[rt,Re,d]);n.useEffect(()=>{if(jo)for(const e of gr)yc(e.root)},[jo,gr,yc]),n.useEffect(()=>{!di||!se||(ya(se.branch||(se.branches?.[0]??"")),wa(se.upstreamRemote||(se.remotes?.includes("origin")?"origin":se.remotes?.[0]??"")),ka(se.upstreamBranch||se.branch||(se.branches?.[0]??"")))},[se,di]);const wc=n.useMemo(()=>{if(Xe)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Nn||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!se?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const e=se.ahead??0,s=se.behind??0;return e>0&&s>0?{text:o("rightSidebar.pushDivergedCount",{ahead:e,behind:s}),className:"bg-destructive/10 text-destructive"}:e>0?{text:o("rightSidebar.pushAheadCount",{count:e}),className:"bg-accent/10 text-accent"}:s>0?{text:o("rightSidebar.pushBehindCount",{count:s}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[se?.ahead,se?.behind,se?.upstream,Nn,pn,Xe,o]),yf=n.useCallback(e=>{if(e&&!J){const s=e.currentTarget.getBoundingClientRect();bt({x:Math.min(s.left,window.innerWidth-352),y:Math.min(s.bottom+6,window.innerHeight-64)})}else bt(null);P?.()},[J,P]),ui=n.useCallback(()=>{bt(null),$?.()},[$]);function kc(){if(!Pn)return null;const e=mc?.label??o("rightSidebar.allRepositories"),s=mc?.count??Ee.size,l=gt(e)||e;return t.jsxs("button",{type:"button",onClick:yf,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${b?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":b,title:e,children:[t.jsx(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 truncate",children:l}),t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${s>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:s}),t.jsx(aa,{size:12,className:"shrink-0"})]})}function wf(){if(!b||!Pn||typeof document>"u")return null;const e=typeof window>"u"?1024:window.innerWidth,s=typeof window>"u"?768:window.innerHeight,l=Math.max(12,Math.min(at?.x??e-368,e-352)),h=Math.max(12,Math.min(at?.y??80,s-420)),u=J?void 0:{left:l,top:h},v=t.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${J?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:ui,children:t.jsxs("div",{className:J?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:u,onClick:y=>y.stopPropagation(),children:[t.jsxs("div",{className:J?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:J?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!J&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[t.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Oa.length}),t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Ee.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Ee.size})]})]}),t.jsx("button",{type:"button",onClick:ui,className:J?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:t.jsx(Xt,{size:J?16:14})})]}),t.jsx("div",{className:J?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:Oa.map(y=>{const X=(y.root??null)===me,Z=gt(y.label)||y.label;return t.jsxs("button",{type:"button",onClick:()=>{Hc(y.root),ui()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${J?"px-3 py-2":"px-2 py-1.5"} ${X?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:y.label,role:"option","aria-selected":X,children:[t.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${X?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),t.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${X?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:t.jsx(br,{size:13})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:`${J?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Z}),t.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:y.root===null?o("rightSidebar.allRepositories"):y.label})]}),y.branch&&t.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:y.branch}),y.deferred?t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${y.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:y.count})]},y.root??"all")})})]})});return bu(v,J,document.body)}function kf(){return wf()}function Sc(e){const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=ho(l,s??d);return{key:xr(e),path:e.path,absolutePath:l,displayName:h.name,displayDir:h.dir,oldPath:e.oldPath,status:e.status,title:l}}function Rc(e){return e.oldPath?t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:e.oldPath})}):null}function Wa(e,s){const l=An(e,d),h=`path:${l}`,u=Oe===h,v=ye===h,y=u||v;return t.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),qt(l,h,X.currentTarget)},...ai($a(l),h),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${y?"max-w-20 px-2":"max-w-20 px-2 md:max-w-0 md:px-0 md:opacity-0 md:group-hover:max-w-20 md:group-hover:px-2 md:group-hover:opacity-100"} ${y?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:s,children:t.jsx("span",{className:"whitespace-nowrap",children:o(v?"rightSidebar.copied":u?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function jc(e){const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=Xf(e),u=Hi(e);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Xg,{actions:h,running:$e,completed:Bn?.path===u?Bn:null}),Wa(l,o("rightSidebar.insertThisFile"))]})}function Cc(e,s){const l=s.root??d;if(!l)return null;const h=An(e,l);return Wa(h,o("fileTree.insertRefTitle"))}function Us(){return t.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[t.jsx("button",{type:"button",onClick:()=>Fc("unified"),"aria-pressed":Ot==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),t.jsx("button",{type:"button",onClick:()=>Fc("split"),"aria-pressed":Ot==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function Nc(){return Os.map(e=>{const s=Yd(e.files.map(([,v])=>v)),l=tl({activeGitRepoRoot:me,groupCount:Os.length,label:e.label,rootName:Qe}),h=!!(l&&e.root&&Sr.has(e.root));return{key:e.root??e.label,root:e.root,label:e.label,branch:e.branch,collapsed:h,files:e.files.map(([,v])=>Sc(v)),header:l?t.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${h?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Uf(e.root),"aria-expanded":!h,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[t.jsx("span",{className:"shrink-0 text-muted-foreground",children:h?t.jsx(ds,{size:13}):t.jsx(aa,{size:13})}),t.jsx(br,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:e.label}),e.branch&&t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:e.branch})]}),t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e.files.length}),s>0&&t.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:s})]}),e.root&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),Qa("stage-all",e.root,e.label)},disabled:!!$e,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),t.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),Qa("stash-all",e.root,e.label)},disabled:!!$e,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const En=n.useMemo(()=>new Map(Array.from(Ee.values(),e=>[xr(e),e])),[Ee]);function Pc(e){const s=En.get(e.key),l=s?ut(s,d):null,h=Xp(xt,l,s?.path??e.path);return t.jsx(Xi,{changeStatus:e.status,auditStatus:h,renderChangeBadge:u=>t.jsx(na,{status:u})})}const qa=n.useCallback(e=>{if(J)return null;const s=Array.from(e.querySelectorAll("[data-diff-stream-item]"));if(s.length===0)return null;const h=e.getBoundingClientRect().top+48;let u=null,v=Number.POSITIVE_INFINITY;for(const X of s){const Z=X.getBoundingClientRect();if(Z.bottom<h)continue;const de=Math.abs(Z.top-h);de<v&&(u=X,v=de)}const y=u?.dataset.diffSelectionPath??u?.dataset.diffStreamItem??null;return y?(Ea.current===y&&U.getState().selectedFilePath===y||(Ea.current=y,tt(y)),y):null},[J,tt]),Sf=!!(!$e&&ve&&!Xe&&(se?.upstream||mn.trim()&&gn.trim())),Rf=!!(!$e&&ve&&!Xe&&(se?.upstream||mn.trim()&&gn.trim())),jf=!!(!$e&&ve&&!Xe&&On.trim()&&On.trim()!==se?.branch),Yt=n.useMemo(()=>{const e=Ve.trim().toLowerCase(),s=Array.from(Ee.entries()).filter(([,l])=>!me||ut(l,d)===me).sort(([l],[h])=>l.localeCompare(h));return e?s.filter(([l,h])=>`${l} ${h.path} ${h.status} ${h.repoRelativeRoot??""} ${h.repoName??""}`.toLowerCase().includes(e)):s},[me,Ee,Ve,d]);n.useEffect(()=>{Qs("selected_file_state",{selectedFilePath:et,selectedChangedFilePath:Kt?.path??null,selectedChangedFileAbsolutePath:Kt?.absolutePath??null,selectedChangedFileRepoRoot:Kt?.repoRoot??null,rootPath:d,activeGitRepoRoot:me,rightTab:Uo,effectiveRightTab:jt,diffPaneActive:Ct,changedFiles:Ee.size,filteredChangedFiles:Yt.length,gitBundleLoading:fr,gitBundleLastLoadedAt:Wn})},[me,Ee.size,Ct,jt,Yt.length,Wn,fr,Uo,d,Kt?.absolutePath,Kt?.path,Kt?.repoRoot,et]);const Os=n.useMemo(()=>{const e=new Map;for(const s of Yt){const[,l]=s,h=ut(l,d),u=Vg(l)||Qe,v=h??u,y=h?rt.get(h):void 0,X=e.get(v)??{root:h,label:u,branch:y?.context?.branch,files:[]};X.files.push(s),e.set(v,X)}return Array.from(e.values()).sort((s,l)=>s.label===Qe?-1:l.label===Qe?1:s.label.localeCompare(l.label))},[Yt,rt,Qe,d]),Hs=n.useMemo(()=>{const e=[],s=new Map;for(const l of Yt)s.set(xr(l[1]),l);for(const l of Os){if(!!(l.root&&tl({activeGitRepoRoot:me,groupCount:Os.length,label:l.label,rootName:Qe})&&Sr.has(l.root)))continue;if(Cr!=="tree"){e.push(...l.files);continue}const u=l.files.map(([,v])=>Sc(v));for(const v of dp(u)){const y=s.get(v.key);y&&e.push(y)}}return e},[me,Sr,Cr,Os,Yt,Qe]),Ec=n.useMemo(()=>Ee.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Hs.map(([,e])=>{const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path);return{key:xr(e),path:e.path,absolutePath:l,status:e.status,repoRoot:s,displayName:ho(l,s).name,displayDir:ho(l,s).dir,auditRecords:xt}}),[xt,Ee.size,Hs,d,o]);n.useEffect(()=>{if(!Ct||Hs.length===0||J)return;const e=[],s=()=>{const l=document.querySelector(".termdock-diff-stream-scroller");if(l&&qa(l))return;const h=document.querySelector("[data-diff-stream-item]"),u=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;if(u){Ea.current=u,tt(u);return}const v=Hs[0]?.[1];if(!v)return;const y=xr(v);Ea.current=y,tt(y)};for(const l of[80,240,600,1200])e.push(window.setTimeout(s,l));return()=>e.forEach(l=>window.clearTimeout(l))},[Ct,J,Hs,tt,qa]);const fi=n.useMemo(()=>{const e=y=>`'${y.replace(/'/g,"'\\''")}'`,s=ar.length>0?wn:Be.filter(y=>y.files.length>0),l=s.length>0?s:d?[{root:d,relativeRoot:".",name:Qe}]:[],h=l.length>0?l.map(y=>`- ${y.relativeRoot==="."?".":y.relativeRoot} (${y.root})`).join(`
1651
- `):`- ${d?".":""}`,u=l.length>0?l.map(y=>` td audit-export ${e(y.root)}`).join(`
1652
- `):" td audit-export",v=l.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${d??""}`,"目标仓库:",h,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",u,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",v,'10. 少量 hunk 或临时补单条时使用:printf "%s\\n" "这里写该 hunk 的改动意义" | td audit-explain <hunkId> <对应仓库绝对路径>',"11. 注入成功后清理本次 payload:rm -f ~/.termdock/change-audit/payload*.json","","payload.walkthrough 示例字段:","{",' "title": "一句话标题",',' "summary": "整批改动的目的和结果",',' "highlights": [{ "what": "改了什么", "effect": "用户或系统得到什么", "tag": "体验" }],',' "nodes": [{ "id": "n1", "title": "节点标题", "kind": "ui", "business": "零上下文业务解释", "anchor": { "repoRoot": "<repoRoot>", "filePath": "<filePath>", "hunkIndex": 0, "hunkFingerprint": "<fingerprint>", "sectionIndex": 0, "sectionFingerprint": "<sectionFingerprint>" } }],',' "edges": [{ "from": "n1", "to": "n2", "label": "调用/传递/消费", "desc": "这条关系的业务含义" }],',' "risks": [{ "title": "真实风险或口径疑问", "anchor": { "filePath": "<filePath>" } }],',' "checks": ["可执行验证动作"]',"}","","写作标准:","- summary:一句话概括该 hunk 在整批改动中的职责。","- explanation:自包含说明业务链路、该 hunk 的作用、解决的问题、与其它 hunk 的关系。","- walkthrough.highlights 必须大白话,不要堆文件名/函数名;只看 highlights 应该知道这次改动干嘛。","- walkthrough.nodes 优先对应方法、关键业务步骤或关键 section;每个有 anchor 的节点必须能跳回真实 diff。","- 面向不了解本轮对话的 AI 编写,补足必要上下文。","- 输出高信息量结论;避免铺垫、套话、流程复述、泛泛风险、逐行翻译 diff。","","完成条件:汇报每个目标仓库已注入的 hunk 数和总数。"].join(`
1653
- `)},[ar.length,wn,Be,Qe,d]),Cf=n.useCallback(async(e="generate",s)=>{if(Pn&&Or.length===0&&!me){rn(!0);return}const l=e==="generate"?fi:[e==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",fi].join(`
1654
- `);return st("insert_change_audit_prompt",{rootPath:d,activeGitRepoRoots:ar,mode:e,hasAuditListCommand:l.includes("td audit-list"),promptLength:l.length}),await Fr(o("rightSidebar.insertChangeAuditPrompt"),l,`${nc}:${e}`,s)?(pr(),p||c(),!0):!1},[me,fi,Or.length,ar,Fr,pr,c,p,d,Pn,o]),Ka=n.useCallback(async e=>{try{await od({ids:[e]}),tn(s=>s.filter(l=>l.id!==e))}catch{pr()}},[pr]),Nf=n.useCallback(async()=>{if(xt.length===0)return;const e=xt.map(s=>s.id);try{await od({ids:e}),tn(s=>s.filter(l=>!e.includes(l.id))),Ur(null)}catch(s){const l=s instanceof Error?s.message:"Failed to clear change audit explanations";Ur(o("rightSidebar.changeAuditClearFailed",{message:l})),pr()}},[xt,pr,o]),Pf=n.useCallback(async e=>{if(e.records.length===0)return;const s=e.records.map(l=>l.id);try{await Ah({ids:s}),Hr(l=>l.filter(h=>!s.includes(h.id))),qe===e.key&&(un(null),lr(!1))}catch(l){zt(o("rightSidebar.branchAuditClearFailed",{message:l instanceof Error?l.message:"Failed to clear branch explanation"})),Ta(null)}},[Ta,qe,o]),Ef=n.useCallback(e=>{$n(s=>e===null?(rn(!1),[]):s.includes(e)?s.filter(l=>l!==e):[...s,e])},[]),Af=n.useCallback(e=>{No(s=>e===null?(Co(!1),[]):s.includes(e)?s.filter(l=>l!==e):[...s,e])},[]),hi=n.useMemo(()=>{if(!nr)return[];const e=s=>{const l=s.diff??"";let h=0,u=0;for(const v of l.split(`
1655
- `))v.startsWith("+++")||v.startsWith("---")||(v.startsWith("+")&&(h+=1),v.startsWith("-")&&(u+=1));return{filePath:s.filePath,oldPath:s.oldPath,newPath:s.newPath,hunkHeader:s.hunkHeader,hunkIndex:s.hunkIndex??0,fingerprint:s.fingerprint,additions:h,deletions:u,diff:l}};return fe?(fe.hunks??[]).map(s=>{const l=fe.comparisonRepos&&fe.comparisonRepos.length>1?[...fe.comparisonRepos].sort((u,v)=>v.label.length-u.label.length).find(u=>s.filePath.startsWith(`${u.label}/`)):void 0,h=er.find(u=>u.repoRoot===fe.repoRoot&&u.baseRef===fe.baseRef&&(u.branchName??null)===(fe.currentBranch??null)&&u.filePath===s.filePath&&u.hunkHeader===s.hunkHeader&&(u.hunkIndex??0)===s.hunkIndex&&u.fingerprint===s.fingerprint)??null;return{key:`${s.filePath}\0${s.hunkHeader}\0${s.hunkIndex}`,repoRoot:l?.repoRoot??fe.repoRoot,repositoryPath:l?s.filePath.slice(l.label.length+1):s.filePath,hunk:s.previewRevert&&!ss(s.previewRevert.cwd,s.previewRevert.comparisonBranch)?{...s,previewRevert:void 0}:s,current:h,stale:null}}):qe?er.filter(s=>zd(s)===qe).map(s=>{const l=e(s);return{key:`${s.filePath}\0${s.hunkHeader}\0${s.hunkIndex??0}`,hunk:l,current:s,stale:null}}):[]},[fe,er,ss,nr,qe]),pi=er.length>0,as=n.useMemo(()=>{if(!nr)return[];const e=new Map;for(const s of er){const l=s.repoRoot,h=rt.get(l),u=h?.relativeRoot==="."?Qe:h?.relativeRoot||h?.name||gt(l),v=zd(s),y=e.get(v)??{key:v,repoRoot:l,repoLabel:u,baseRef:s.baseRef,branchName:s.branchName??null,headRef:s.headRef??null,diffFingerprint:s.diffFingerprint??null,records:[],latestInjectedAt:0};y.records.push(s),y.latestInjectedAt=Math.max(y.latestInjectedAt,s.injectedAt??0),e.set(v,y)}return Array.from(e.values()).sort((s,l)=>l.latestInjectedAt-s.latestInjectedAt)},[er,rt,nr,Qe]),mi=n.useMemo(()=>qe?as.find(e=>e.key===qe)??null:null,[as,qe]),zs=fe?{repoRoot:fe.repoRoot??"",repoLabel:fe.repoRoot?rt.get(fe.repoRoot)?.relativeRoot==="."?Qe:rt.get(fe.repoRoot)?.relativeRoot||rt.get(fe.repoRoot)?.name||gt(fe.repoRoot):Qe,baseRef:fe.baseRef??fe.baseBranch??"",branchName:fe.currentBranch??null,headRef:fe.headRef??null,diffFingerprint:fe.diffFingerprint??null}:mi,Tf=n.useMemo(()=>(Ge?.hunks??[]).map(e=>({key:`${e.filePath}\0${e.hunkHeader}\0${e.hunkIndex}`,repoRoot:Ge?.repoRoot,hunk:e,current:null,stale:null})),[Ge?.hunks,Ge?.repoRoot]),Mf=n.useMemo(()=>{if(fe)return[];const e=mi;return e?bs.filter(s=>s.repoRoot===e.repoRoot&&s.baseRef===e.baseRef&&(s.branchName??null)===e.branchName&&(!e.diffFingerprint||s.diffFingerprint===e.diffFingerprint)):[]},[fe,bs,mi]),Lf=n.useCallback(e=>{const s=hi.find(l=>l.hunk.filePath===e.filePath||(e.repoRoot?`${e.repoRoot}/${l.hunk.filePath}`===e.filePath:!1));s&&(fn(s.key),window.setTimeout(()=>Tn(e),90),window.setTimeout(()=>Tn(e),320),window.setTimeout(()=>Tn(e),760))},[hi]),gi=n.useMemo(()=>{const e=u=>`'${u.replace(/'/g,"'\\''")}'`,s=Bs,l=s.length>0?s.map(u=>`- ${u.label} (${u.root}),目标分支:${rr[u.root]||u.branch||"(current branch)"},基线分支:${Rt[u.root]||"(not set)"},包含本地未提交更改:${ss(u.root,rr[u.root]||u.branch)&&(dn[u.root]??!0)?"是":"否"}`).join(`
1656
- `):`- ${d?".":""}`,h=s.length>0?s.map(u=>{const v=rr[u.root]||u.branch||"",y=Rt[u.root]||"",X=u.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[v?` git -C ${e(u.root)} switch ${e(v)}`:` # ${u.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${e(y)} ${e(u.root)} > ~/.termdock/branch-audit/branch-audit-export-${X}.json`].join(`
1657
- `)}).join(`
1658
- `):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${d??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",l,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",h,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:d??null,repoRoot:"<target repo root>",baseRef:"<target repo base branch>",branchName:"<from export currentBranch>",headRef:"<from export headRef>",diffFingerprint:"<from export diffFingerprint>",generatedBy:"termdock-branch-audit",walkthrough:{title:"<one-line branch change title>",summary:"<branch change goal and effect>",highlights:[{what:"<what changed>",effect:"<user/system effect>",tag:"<category>"}],nodes:[{id:"n1",title:"<node title>",kind:"process",business:"<zero-context business explanation>",anchor:{repoRoot:"<target repo root>",filePath:"<from hunk.filePath>",hunkIndex:0,hunkFingerprint:"<from hunk.fingerprint>"}}],edges:[{from:"n1",to:"n2",label:"<relationship>",desc:"<business meaning>"}],risks:[{title:"<real risk or validation gap>"}],checks:["<executable validation step>"]},records:[{filePath:"<from hunk.filePath>",oldPath:"<from hunk.oldPath or null>",newPath:"<from hunk.newPath or null>",hunkHeader:"<from hunk.hunkHeader>",hunkIndex:0,fingerprint:"<from hunk.fingerprint>",diff:"<copy from hunk.diff exactly>",explanation:"<replace with hunk explanation>",summary:""}]},null,2),"```"].join(`
1659
- `)},[dn,ss,Bs,Rt,rr,d]),If=n.useCallback(async(e="generate",s)=>{const l=e==="generate"?gi:[e==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",gi].join(`
1660
- `);return await Fr(o("rightSidebar.branchAuditShort"),l,`context:branch-audit-scope:${e}`,s)?(p||c(),!0):!1},[gi,Fr,c,p,o]),bi=n.useCallback(async(e={})=>{const s=e.refresh===!0,l=s&&fe?.comparisonRepos?fe.comparisonRepos:Bs.map(y=>{const X=(rr[y.root]||y.branch||"").trim();return{repoRoot:y.root,label:y.label,base:Rt[y.root]?.trim()??"",head:X||null,includeUncommitted:dn[y.root]??!0}});if(!d||l.length===0)return;const h=++T.current,u=d,v=()=>Re(u)&&h===T.current;Te(!0),Me(null),s||(tr(null),ot(null));try{const y=await Promise.all(l.map(async z=>{if(!z.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:z.label}));return id({cwd:d,repoRoot:z.repoRoot,base:z.base,head:z.head,includeUncommitted:e.repoRoot===z.repoRoot?e.includeUncommitted??!1:z.includeUncommitted??fe?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${z.repoRoot}`})}));if(!v())return;const X=y.find(z=>!z.available);if(X){Me(X.error??"Branch diff is unavailable");return}const Z=y.length===1?y[0]:{available:!0,workspaceRoot:d,repoRoot:d,baseRef:y.map(z=>z.baseRef??z.baseBranch).filter(Boolean).join(", "),currentBranch:y.map(z=>z.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:y.map(z=>z.headRef).filter(Boolean).join(", "),diffFingerprint:y.map(z=>z.diffFingerprint).filter(Boolean).join("+"),stat:y.map(z=>z.stat).filter(Boolean).join(`
1661
- `),files:y.flatMap((z,B)=>{const ie=l[B];return(z.files??[]).map(Ce=>`${ie?.label??z.repoRoot??"repo"}/${Ce}`)}),hunks:y.flatMap((z,B)=>{const Ce=l[B]?.label??z.repoRoot??"repo";return(z.hunks??[]).map(_e=>({..._e,filePath:`${Ce}/${_e.filePath}`,oldPath:_e.oldPath?`${Ce}/${_e.oldPath}`:_e.oldPath,newPath:_e.newPath?`${Ce}/${_e.newPath}`:_e.newPath}))}),commits:y.flatMap(z=>z.commits??[]),commitCount:y.reduce((z,B)=>z+(B.commitCount??B.commits?.length??0),0),diff:y.map(z=>z.diff).filter(Boolean).join(`
1662
- `),truncated:y.some(z=>z.truncated)};if(Z.comparisonRepos=l.map((z,B)=>({...z,head:z.head??y[B].currentBranch??null,includeUncommitted:y[B].includeUncommitted===!0,canIncludeUncommitted:y[B].canIncludeUncommitted})),Z.canIncludeUncommitted=y.every(z=>z.canIncludeUncommitted===!0),Z.includeUncommitted=y.some(z=>z.includeUncommitted===!0),Po(z=>({...z,...Object.fromEntries(Z.comparisonRepos.map(B=>[B.repoRoot,B.includeUncommitted??!1]))})),!s&&(Z.hunks??[]).length===0){Me(o("rightSidebar.branchAuditDiffEmpty"));return}const de=Date.now(),je=(s?qe:null)??["preview",Z.repoRoot??d,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??de].join("\0"),Ke=l.length===1?l[0].label:`${l.length} repos`;tr(Z),sn(z=>[{key:je,diff:Z,repoLabel:Ke,createdAt:de},...z.filter(B=>B.key!==je)].slice(0,8)),s||S(z=>z[je]===void 0?z:{...z,[je]:0}),un(je),fn(z=>{const B=Z.hunks?.[0],ie=B?`${B.filePath}\0${B.hunkHeader}\0${B.hunkIndex}`:null;return s&&z&&(Z.hunks??[]).some(Ce=>Ce.filePath===z.split("\0")[0])?z:ie}),lr(!0)}catch(y){if(!v()||vr(y))return;Me(y instanceof Error?y.message:"Failed to load branch diff")}finally{v()&&Te(!1)}},[dn,fe,qe,Bs,Rt,rr,Re,d,o]),$f=n.useCallback(e=>{++T.current,Te(!1),tr(e.diff),Me(null),un(e.key),fn(e.diff.hunks?.[0]?`${e.diff.hunks[0].filePath}\0${e.diff.hunks[0].hunkHeader}\0${e.diff.hunks[0].hunkIndex}`:null),lr(!0)},[]),Ff=n.useCallback(e=>{sn(s=>s.filter(l=>l.key!==e)),S(s=>{if(!(e in s))return s;const l={...s};return delete l[e],l}),qe===e&&(un(null),tr(null),lr(!1))},[qe]),Df=n.useCallback(e=>{++T.current,Te(!1);const s=as.find(l=>l.key===e);s&&(tr(null),Me(null),un(e),fn(s.records[0]?.filePath??null),lr(!0))},[as]),_f=n.useCallback(async e=>{if(!d||!ve)return;const[s]=e.split(/\s+/);if(s){cr(s),an(null),ot(null);try{const l=await Th({cwd:d,repoRoot:ve,commit:s,requestSlotId:"right-sidebar-commit-diff"});if(!l.available){an(l.error??"Commit diff is unavailable");return}ot(l);const h=l.hunks?.[0];fa(h?`${h.filePath}\0${h.hunkHeader}\0${h.hunkIndex}`:null)}catch(l){an(l instanceof Error?l.message:"Failed to load commit diff")}finally{cr(null)}}},[ve,d]),Bf=n.useCallback(e=>{if(!fe||!qe)return;const s=Math.max(0,Math.round(e));S(l=>Math.abs((l[qe]??0)-s)<24?l:{...l,[qe]:s})},[fe,qe]);n.useEffect(()=>{!fe||!qe||sn(e=>e.map(s=>s.key===qe&&s.diff!==fe?{...s,diff:fe}:s))},[fe,qe]);const Ac=!!fe;n.useEffect(()=>{if(!J||!Er||!Ac)return;const e=Gl.current;if(!e||e.destroyed)return;e.update(),e.slideTo(1,0);const s=window.requestAnimationFrame(()=>{e.destroyed||(e.update(),e.slideTo(1,0))});return()=>window.cancelAnimationFrame(s)},[Er,Ac,J]);const Tc=n.useCallback(e=>{e&&Wu(s=>up(s,e))},[]),Mc=Sa.key===et?Sa.key:null,Va=n.useCallback(e=>{const s=U.getState(),l=sb();Qs("select_diff_file",{interactionId:l,path:e,previousSelectedFilePath:s.selectedFilePath,rootPath:s.rootPath,activeGitRepoRoot:me,changedFiles:s.changedFiles.size,gitBundleLoading:s.gitBundleLoading,gitBundleLastLoadedAt:s.gitBundleLastLoadedAt,rightTab:s.rightTab}),tt(e),Mt("diff"),J&&e&&Kl(1),Tc(e),queueMicrotask(()=>{const h=U.getState();Qs("select_diff_file_after",{interactionId:l,requestedPath:e,selectedFilePath:h.selectedFilePath,rootPath:h.rootPath,rightTab:h.rightTab,changedFiles:h.changedFiles.size,activeGitRepoRoot:me})})},[me,J,Tc,tt,Mt,Kl]),Lc=n.useCallback(e=>{const s=Array.from(Ee.values()).find(l=>{const h=ut(l,d),u=xr(l);return l.path===e.filePath||u===e.filePath||l.absolutePath===e.filePath||(h?`${h}/${l.path}`===e.filePath:!1)||e.repoRoot&&h===e.repoRoot&&l.path===e.filePath});if(s){Va(xr(s)),window.setTimeout(()=>Tn(e),90),window.setTimeout(()=>Tn(e),320),window.setTimeout(()=>Tn(e),760);return}Tn(e)},[Ee,d,Va]),Ic=n.useCallback(({slideToDetail:e,fullscreen:s,toggleFullscreen:l}={})=>ms.length>0?t.jsx(su,{walkthroughs:ms,repoRoot:me,fullscreen:s,onToggleFullscreen:l,onNavigate:h=>{J&&window.requestAnimationFrame(()=>e?.()),Lc(h)}}):t.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[t.jsx(sa,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[me,ms,Lc,J,o]),Uf=n.useCallback(e=>{e&&Rr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi($i,l),l})},[]),$c=n.useCallback(e=>{jr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi(Ld,l),l})},[]),Ya=n.useCallback(e=>{ia(e),Pt(vu,e)},[]);n.useEffect(()=>{Ha||Cr!=="ai"||Ya("tree")},[Cr,Ya,Ha]);const Xa=n.useCallback(()=>{ps(e=>{const s=!e;return Pt(yu,s),s})},[]),Fc=n.useCallback(e=>{la(e),Pt(wu,e)},[]),{whitespace:Dc,context:_c}=vp(),Bc=n.useMemo(()=>({algorithm:"histogram",whitespace:Dc,context:_c}),[Dc,_c]),Uc=n.useCallback(e=>{pe(e),Pt(ku,e)},[]),Ja=n.useCallback(async(e,s,l,h)=>{let u=e;for(;u.ok&&u.status==="running";)await new Promise(y=>window.setTimeout(y,1500)),u=await ld({jobId:u.jobId,cwd:s.cwd,action:s.action});if(!u.ok)throw new Error("Git action status is unavailable");if(u.status==="error")throw new Error(u.error||u.message||"Git action failed");const v={action:s.action,path:h,label:l};return Ns(v),window.setTimeout(()=>Ns(y=>y?.action===v.action&&y.path===v.path?null:y),1400),u},[]),mt=n.useCallback(async(e,s,l)=>{const h=d;d&&hr.current.delete(d),zt(null),Ns(null),Cs({action:e.action,path:l});try{const u=await Mh({...e,includeNested:Vs(d)}),v=await Ja(u,e,s,l);if(!Re(h))return!1;const y=d?await Ci(d,void 0,{includeNested:Vs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Xs(d)}).catch(()=>v.bundle):v.bundle;return Re(h)?(y&&Xn(y,{reloadDiff:!0,cacheOnly:!0}),hn(null),!0):!1}catch(u){return Ns(null),zt(o("rightSidebar.gitActionFailed",{message:u instanceof Error?u.message:"Unknown error"})),!1}finally{Re(h)&&Cs(null)}},[Xn,Re,d,o,Ja]),Oc=n.useCallback(async e=>{const s=d;await cd({...e,includeNested:Vs(d)}),Re(s)&&It(d??void 0,{refresh:!0,background:!0})},[Re,It,d]),Of=n.useCallback(async e=>{const s=fe,l=T.current,h=s?.hunks?.find(v=>v.previewRevert?.cwd===e.cwd&&v.previewRevert.path===e.path);if(!s||!h||!e.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));Se(v=>v+1),Me(null);try{await cd(e)}catch(v){throw Se(y=>y-1),v}if(l!==T.current||!Re(d)){Se(v=>v-1);return}const u=v=>{tr(y=>{if(!y||l!==T.current)return y;const X=y.hunks??[],Z=v===void 0?X.filter(je=>!(je.previewRevert?.cwd===e.cwd&&je.previewRevert.patch===e.patch)):[...X.filter(je=>je.filePath!==h.filePath),...v];return{...y,hunks:Z}})};u(),id({cwd:e.cwd,repoRoot:e.cwd,base:e.comparisonBase,comparisonBase:e.comparisonBase,filePath:e.path,requestSlotId:`branch-preview-file:${e.cwd}:${e.path}`}).then(v=>{if(l!==T.current||!Re(d))return;if(!v.available||v.truncated)throw new Error(v.error??o("diffViewer.hunkActionUnavailable"));const y=e.path.slice(e.cwd.length+1),X=h.filePath.slice(0,h.filePath.length-y.length);u((v.hunks??[]).map(Z=>({...Z,filePath:`${X}${Z.filePath}`,oldPath:Z.oldPath?`${X}${Z.oldPath}`:Z.oldPath,newPath:Z.newPath?`${X}${Z.newPath}`:Z.newPath})))}).catch(v=>{l===T.current&&Re(d)&&!vr(v)&&Me(`${o("diffViewer.hunkActionReverted")} · ${v instanceof Error?v.message:String(v)}`)}).finally(()=>Se(v=>v-1))},[fe,Re,d,o]),Qa=n.useCallback((e,s,l)=>{if(s){if(e==="stage-all"){mt({action:"stage-all",cwd:s},o("rightSidebar.stageAll"),`repo:${s}`);return}hn({kind:"stash-all",repoRoot:s,repoLabel:l})}},[mt,o]),Hc=n.useCallback(e=>{dt(e),ya(""),wa(""),ka(""),tt(pc(e)),nt||Mt("diff"),e&&Ua(rt.get(e))},[Ua,pc,nt,rt,tt,dt,Mt]),zc=n.useCallback(e=>{const s=new Set([...Wt.current.keys(),...vn.current,...hr.current]);for(const l of s)l!==e&&(Gt.current.delete(l),Wt.current.get(l)?.abort(),Wt.current.delete(l),yt(`right-sidebar-git-untracked:${l}`),vn.current.delete(l),hr.current.delete(l))},[]),Hf=n.useCallback(async e=>{const s=d;if(!s||(await U.getState().setNestedGitScanRoot(s,e),!Re(s)))return;if(e){await It(s,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}zc(s),ya(""),wa(""),ka(""),No(h=>h.filter(u=>u===s));const l=Kt;l&&ut(l,s)!==s&&tt(null),await It(s,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[zc,Re,It,d,tt,Kt]),zf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=On.trim();!e||e===se?.branch||await mt({action:"switch-branch",cwd:ve,branch:e},o("rightSidebar.switchBranch"))},[se?.branch,ve,Xe,mt,On,o]),Gc=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=va.trim();if(!e)return;await mt({action:"commit",cwd:ve,message:e},o("rightSidebar.commitChanges"))&&yl("")},[ve,va,Xe,mt,o]),Gf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await mt({action:"push",cwd:ve,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pushChanges"))},[ve,gn,mn,Xe,mt,o]),Wf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await mt({action:"pull",cwd:ve,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pullChanges"))},[ve,gn,mn,Xe,mt,o]);n.useEffect(()=>{if(!nt||!ve||$e)return;let e=!1;const s={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const l of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(e)return;const h=await ld({cwd:ve,action:l}).catch(()=>null);if(!h?.ok||h.status!=="running")continue;const u={action:l,cwd:ve},v=s[l]??l;Cs({action:l});try{const y=await Ja(h,u,v);if(e||!Re(d))return;const X=d?await Ci(d,void 0,{includeNested:Vs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Xs(d)}).catch(()=>y.bundle):y.bundle;X&&Xn(X,{reloadDiff:!0,cacheOnly:!0})}catch(y){e||zt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"}))}finally{e||Cs(null)}return}})(),()=>{e=!0}},[ve,Xn,nt,Re,d,$e,o,Ja]);const xi=Bn?.action==="commit",vi=Bn?.action==="switch-branch",yi=Bn?.action==="pull",wi=Bn?.action==="push",Za=nt||zu,ki=Ga?o("rightSidebar.changeAuditScopeAll"):gr.length===1?gr[0].label:`${gr.length} repos`,qf=gr.length>0,Wc=Bs.length>0,Kf=d?t.jsx(qd,{open:jo,onOpenChange:Co,showScopePicker:!0,selectedAll:Ga,repos:Vt,selectedRoots:za,onToggleRepo:Af,onGenerate:e=>If(pi?"regenerate":"generate",e),disabled:!qf,generateDisabled:!Wc,inserted:Oe?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(pi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:ki,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(pi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{bi()},secondaryDisabled:!Wc||Je,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Je,loading:fl.size>0,statusTitle:fl.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:t.jsx("div",{className:"mb-2 space-y-1.5",children:vc.length>0&&t.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:o("rightSidebar.missingBaseReposSkipped",{repositories:vc.map(e=>e.label).join(ae==="zh"?"、":", ")})})}),renderRepoExtra:e=>{const s=rt.get(e.root),l=ss(e.root,rr[e.root]||s?.context?.branch),h=[],u=new Set,v=(de,je)=>{!de||u.has(de)||(u.add(de),h.push({value:de,label:de,meta:je}))};v(rr[e.root]||s?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const de of s?.context?.branches??[])v(de,de===s?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const de of s?.context?.remoteBranches??[])v(de,o("rightSidebar.remoteBranch"));const y=[],X=new Set,Z=(de,je)=>{!de||X.has(de)||(X.add(de),y.push({value:de,label:de,meta:je}))};Z(Rt[e.root],Rt[e.root]?o("rightSidebar.pushUpstreamBadge"):void 0),Z(s?.context?.upstream,s?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const de of s?.context?.remoteBranches??[])Z(de,"remote");for(const de of s?.context?.branches??[])Z(de,de===s?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return t.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[t.jsx(cs,{label:o("rightSidebar.currentBranchLabel"),value:rr[e.root]||s?.context?.branch||"",options:h,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:de=>{pa(je=>({...je,[e.root]:de}))}}),t.jsx(cs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Rt[e.root]||"",options:y,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:de=>{ma(je=>({...je,[e.root]:de}))}}),t.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(l?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),t.jsx("input",{type:"checkbox",checked:l&&(dn[e.root]??!0),disabled:!l,onChange:de=>Po(je=>({...je,[e.root]:de.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,qc=Js(xt.reduce((e,s)=>Math.max(e,s.injectedAt??0),0),ae),Vf=()=>d?t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>ul(e=>{const s=!e;return Pt(Fi,s),s}),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":Rs,children:[t.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:t.jsx(sa,{size:14})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.branchAuditTitle")}),t.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:ki})]}),t.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 ${Rs?"rotate-90":""}`,children:t.jsx(ds,{size:13})})]}),Rs&&t.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",ki]}),Kf]}),ze&&t.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ze}),t.jsxs("div",{className:"mt-2 space-y-1.5",children:[nn.map(e=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${qe===e.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsxs("button",{type:"button",onClick:()=>$f(e),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:e.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[e.diff.hunks?.length??0," hunk"]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.diff.currentBranch??"HEAD"}),t.jsx("span",{className:"text-muted-foreground/60",children:"→"}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.diff.baseRef??e.diff.baseBranch}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),Js(e.createdAt,ae)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Js(e.createdAt,ae)})]}),t.jsx("button",{type:"button",onClick:()=>Ff(e.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:t.jsx(co,{size:12})})]},e.key)),as.length>0?as.slice(0,Math.max(0,8-nn.length)).map(e=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${qe===e.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Df(e.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:e.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[e.records.length," hunk"]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.branchName??"HEAD"}),t.jsx("span",{className:"text-muted-foreground/60",children:"→"}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.baseRef}),e.diffFingerprint&&t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.diffFingerprint})]}),Js(e.latestInjectedAt,ae)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Js(e.latestInjectedAt,ae)??""})})]}),t.jsx("button",{type:"button",onClick:()=>{Pf(e)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:t.jsx(co,{size:12})})]},e.key)):nn.length===0?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Yf=()=>nr&&d&&Nn?t.jsxs("div",{className:Za?"overflow-visible":"overflow-hidden",children:[Vf(),t.jsxs("button",{type:"button",onClick:()=>{nt||Gu(e=>{const s=!e;return s&&ve&&!Nn&&!pn&&Zo(ve),s})},"aria-expanded":Za,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${nt?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[t.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:t.jsx(br,{size:14})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&t.jsx(lt,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!nt&&t.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 ${Za?"rotate-90":""}`,children:t.jsx(ds,{size:13})})]})]}),Za&&t.jsxs("div",{className:"space-y-0",children:[Dt.length>1&&t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:mf})]})}),t.jsx(cs,{label:o("rightSidebar.gitRepositoryLabel"),value:ve??"",options:Dt,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!$e,onChange:e=>{Hc(e||null)}}),Xe&&t.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:o("rightSidebar.selectRepositoryForGitActions")})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),t.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:On!==fc?fc:null})]}),t.jsxs("button",{type:"button",onClick:()=>{zf()},disabled:!jf,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 ${vi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[t.jsx("span",{className:$e?.action==="switch-branch"||vi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),$e?.action==="switch-branch"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),vi&&$e?.action!=="switch-branch"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx(cs,{label:o("rightSidebar.currentBranchLabel"),value:On,options:xf,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!$e,onChange:ya})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Xe?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),t.jsxs("button",{type:"button",onClick:()=>{Gc()},disabled:!!$e||Xe||Cn.staged===0||!va.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 ${xi?"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:Xe?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[t.jsx("span",{className:$e?.action==="commit"||xi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),$e?.action==="commit"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),xi&&$e?.action!=="commit"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx("input",{value:va,onChange:e=>yl(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&(e.preventDefault(),Gc())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!$e,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})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>zr(e=>!e),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":on,children:[t.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[da&&t.jsx(lt,{size:12,className:"animate-spin text-muted-foreground"}),t.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 ${on?"rotate-90":""}`,children:t.jsx(ds,{size:13})})]})]}),on&&t.jsxs("div",{className:"mt-2 space-y-2",children:[t.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:[t.jsx(us,{size:12,className:"shrink-0"}),t.jsx("input",{value:ln,onChange:e=>cn(e.target.value),placeholder:o("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),ln&&t.jsx("button",{type:"button",onClick:()=>cn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(Xt,{size:12})})]}),t.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:gf,children:[Tt.length>0?Tt.map(e=>{const[s,...l]=e.split(/\s+/),h=l.join(" ")||e;return t.jsxs("button",{type:"button",onClick:()=>{_f(e)},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:h,children:[t.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:s}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:h,children:h}),K[s]&&t.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${K[s]==="ahead"?"bg-accent/10 text-accent":K[s]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(K[s]==="ahead"?"rightSidebar.commitAhead":K[s]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Fn===s&&t.jsx(lt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},e)}):da?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):So?null:t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),ua&&t.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:t.jsx(lt,{size:12,className:"animate-spin"})}),Ro&&!ua&&Tt.length>0&&t.jsx("button",{type:"button",onClick:()=>{_s({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:o("rightSidebar.recentCommitsLoadMore")})]})]}),ys&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:ys}),So&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:So})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Wf()},disabled:!Sf,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 ${yi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[t.jsx("span",{className:$e?.action==="pull"||yi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),$e?.action==="pull"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),yi&&$e?.action!=="pull"&&t.jsx("span",{className:"absolute",children:"✓"})]}),t.jsxs("button",{type:"button",onClick:()=>{Gf()},disabled:!Rf,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${wi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[t.jsx("span",{className:$e?.action==="push"||wi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),$e?.action==="push"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),wi&&$e?.action!=="push"&&t.jsx("span",{className:"absolute",children:"✓"})]})]})]}),t.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${wc.className}`,title:se?.upstream??void 0,children:[t.jsx("span",{className:"truncate font-medium",children:wc.text}),t.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:se?.upstream??""})]}),t.jsxs("div",{className:`grid gap-1.5 ${xc?"grid-cols-2":"grid-cols-1"}`,children:[xc&&t.jsx(cs,{label:o("rightSidebar.pushRemoteLabel"),value:mn,options:bc,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!$e,onChange:wa}),t.jsx(cs,{label:o("rightSidebar.pushBranchLabel"),value:gn,options:vf,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:se?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!$e,onChange:ka})]})]})]})]}):null,Xf=n.useCallback(e=>{const s=ut(e,d);if(!s)return[];const l=Hi(e),h=[];return e.canStage&&h.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{mt({action:"stage-file",cwd:s,paths:[e.path]},o("rightSidebar.stageFile"),l)}}),e.canUnstage&&h.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{mt({action:"unstage-file",cwd:s,paths:[e.path]},o("rightSidebar.unstageFile"),l)}}),e.canStash&&h.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{mt({action:"stash-file",cwd:s,paths:[e.path]},o("rightSidebar.stashFile"),l)}}),e.canRestoreWorktree&&h.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>hn({kind:"restore",file:e,phrase:""})}),h},[d,mt,o]),Jf=n.useCallback(()=>{if(m){R?.();return}Tr(0),Lr.current?.slideTo(0),Ar(!1),Ut(null)},[R,m]),Kc=n.useCallback(e=>{if(he(""),Lt(e),tt(null),Ut(null),j(null),J){m&&R?.(),Tr(0),Lr.current?.slideTo(0),Ar(!1);return}},[J,R,m,tt,Lt]);n.useEffect(()=>{if(!G||U.getState().pendingTerminalPath!==G)return;U.setState({pendingTerminalPath:null}),(()=>{const s=G,l=s.path;if(!l.startsWith("/"))return;he(""),Ut(null),Et(null);const h=!!(d&&(l===d||l.startsWith(`${d}/`)));if(s.kind==="file"){const u=lo(l);Ms(l),typeof s.line=="number"&&Number.isSafeInteger(s.line)&&s.line>0&&Et(s.line),Lt(h?null:u),j({path:l,nonce:++F.current});return}tt(null),h?(Lt(null),j({path:l,nonce:++F.current})):(j(null),Lt(l)),J&&(m&&R?.(),Tr(0),Lr.current?.slideTo(0),Ar(!1))})()},[G,Ms,J,R,m,d,tt,Lt]),n.useEffect(()=>{r||(Bt(!1),Zt(!1))},[r]),n.useEffect(()=>{if(!wr&&!Zr)return;const e=s=>{s instanceof globalThis.KeyboardEvent&&s.key!=="Escape"||s instanceof globalThis.MouseEvent&&s.target instanceof Node&&(Ln.current?.contains(s.target)||kr.current?.contains(s.target))||(Bt(!1),Zt(!1))};return window.addEventListener("mousedown",e),window.addEventListener("keydown",e),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("keydown",e)}},[Zr,wr]);const Vc=t.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:[t.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[t.jsx("button",{type:"button",onClick:ff,disabled:!_a,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:t.jsx(al,{size:14})}),t.jsx("button",{type:"button",onClick:sc,disabled:!d||zn===d,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:t.jsx(xd,{size:14})}),t.jsx("button",{type:"button",onClick:hf,disabled:!re,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:wl?o("rightSidebar.fileWatchUnavailable",{message:wl}):o("rightSidebar.refreshFiles"),children:t.jsx(uo,{size:13})}),t.jsx("div",{className:"min-w-0 flex-1 px-1",title:re??void 0,children:t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[t.jsx("span",{className:"truncate",children:df}),Na==="modified"&&t.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:t.jsx(dd,{size:11})})]})}),t.jsx("button",{type:"button",onClick:e=>re&&qt(re,Ft??void 0,e.currentTarget),disabled:!re,...re&&Ft?ai($a(re),Ft):{},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 ${Ft&&(Oe===Ft||ye===Ft)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ft&&ye===Ft?"rightSidebar.copied":Ft&&Oe===Ft?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ft&&(Oe===Ft||ye===Ft)?t.jsx(go,{size:13}):t.jsx(bo,{size:13})}),t.jsx(Wp,{rootPath:re,disabled:!re||!Vu||Wo,pressed:Ca,saving:Wo,onToggle:()=>{if(!re||Wo)return;const e=re;_l(!0),qo(null),Yu(e,!Ca).catch(()=>{const s=U.getState();(s.explorerRoot??s.rootPath)===e&&qo(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>_l(!1))}}),t.jsxs("div",{ref:kr,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Bt(!1),Zt(e=>!e)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${Zr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":Zr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(po,{size:14})}),Zr&&t.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:[t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Zt(!1),pf()},disabled:!li,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Fs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Fs?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Fs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Zt(!1),qu()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Oo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Oo?t.jsx(Ap,{size:14}):t.jsx(Yi,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Oo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!re,onClick:()=>{re&&(Zt(!1),Ku(re,Na==="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:[Na==="modified"?t.jsx(Lh,{size:14}):t.jsx(dd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Na==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),Bl&&t.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:Bl}),d&&(Ba.length>0||uf)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[t.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.pinnedFolders")}),t.jsxs("button",{type:"button",onClick:sc,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 ${re===d?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:d,children:[t.jsx(xd,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Qe})]}),Ba.map(e=>{const s=e.path,l=e.kind==="file",h=l?et===s:re===s;return t.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${h?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:s,children:[t.jsxs("button",{type:"button",onClick:()=>l?Ms(s):Lt(s),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[l?t.jsx(qi,{size:10,className:"shrink-0"}):t.jsx(ro,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:gt(s)})]}),t.jsx("button",{type:"button",onClick:()=>bn(s),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.unpinFolder",{name:gt(s)}),title:o("rightSidebar.unpinFolder",{name:gt(s)}),children:t.jsx(Xt,{size:9})})]},s)})]}),t.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"})]}),Si=n.useMemo(()=>{if(Un===null)return null;const e=typeof navigator>"u"?void 0:navigator.language,s=Math.max(0,Math.floor(($o-Un)/1e3)),l=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),[h,u]=s<60?[-s,"second"]:s<3600?[-Math.floor(s/60),"minute"]:s<86400?[-Math.floor(s/3600),"hour"]:[-Math.floor(s/86400),"day"];return l.format(h,u)},[$o,Un]),eo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Yc=d&&!Qn?t.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{Hf(!Ho)},"aria-checked":Ho,title:o("rightSidebar.multiRepoScanTitle"),className:eo,children:[t.jsx(br,{size:15,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),Ho&&t.jsx(go,{size:14,className:"shrink-0 text-primary"})]}):null,Xc=d?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Si?t.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Si}),children:Si}):null,t.jsx("button",{type:"button",onClick:()=>{Jn()},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":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:t.jsx(uo,{size:13,className:fr?"animate-spin":""})})]}):null,Qf=ql?o("rightSidebar.changeAuditScopeAll"):wn.length===1?wn[0].relativeRoot==="."?Qe:wn[0].relativeRoot||wn[0].name:`${wn.length} repos`,Zf=e=>d?t.jsxs("div",{role:"none",children:[t.jsx(qd,{menuItem:!0,open:gs,onOpenChange:s=>{rn(s),s&&e()},showScopePicker:Pn,selectedAll:ql,repos:Xu,selectedRoots:ar,onToggleRepo:Ef,onGenerate:async s=>{const l=await Cf("generate",s);return l!==!1&&e(),l},disabled:!d,inserted:Oe===nc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Qf,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Br,error:!!Pr,statusTitle:Pr??(Br?o("rightSidebar.changeAuditLoading"):xt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:xt.length})}${qc?` · ${o("rightSidebar.changeAuditLoadedAt",{time:qc})}`:""}`:void 0)}),xt.length>0&&t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Nf()},disabled:Br||xt.length===0,className:eo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[t.jsx(co,{size:15,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,os=or??(Ae?.available&&d&&Ee.size>0&&Be.length<=1?{root:d,label:Qe}:null),Jc=e=>t.jsxs(t.Fragment,{children:[os&&t.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Qa("stage-all",os.root,os.label)},disabled:!!$e,className:eo,children:[t.jsx(_h,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Qa("stash-all",os.root,os.label)},disabled:!!$e,className:eo,children:[t.jsx(op,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),os&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Zf(e),Yc&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Yc]}),to=t.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&&t.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:[t.jsx(br,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Ae.branch})]}),it.modified>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[it.modified,"M"]}),it.added>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",it.added]}),it.deleted>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",it.deleted]}),it.renamed>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[it.renamed,"R"]}),it.copied>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[it.copied,"C"]}),it.untracked>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[it.untracked,"U"]}),it.conflicted>0&&t.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[it.conflicted,"!"]}),it.other>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[it.other,"?"]}),it.staged>0&&t.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:it.staged})})]});return t.jsxs(lp,{side:"right",isOpen:r,drawerWidthPx:i,onClose:c,onOpen:f,push:p,pinned:g,children:[ai.popoverNode,t.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${nf?"hidden":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:d??void 0,children:Qe}),(!J||Mo)&&Ae?.available&&Ae.branch&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:Ae.branch,children:[t.jsx(br,{size:10,className:"shrink-0"}),t.jsx("span",{className:"max-w-[7rem] truncate",children:Ae.branch})]})]})}),t.jsx("button",{type:"button",onClick:()=>{const e=!ee;C(e),e?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):he("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ee?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:t.jsx(us,{size:14})}),t.jsxs("button",{type:"button",role:"switch","aria-checked":N,onClick:()=>{Q(e=>!e),Ye(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${N?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[t.jsx(rp,{size:14}),!N&&kt.trim()&&t.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),t.jsx("input",{ref:jl,type:"file",multiple:!0,className:"hidden",onChange:e=>{const s=e.target.files;!s||s.length===0||(Ls(Array.from(s)),e.target.value="")}}),t.jsx("input",{ref:Cl,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const s=e.target.files?.[0];e.target.value="",s&&of(s,e.currentTarget.closest("[data-sidebar]")??void 0)}}),k&&t.jsx("button",{type:"button",onClick:k,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${g?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:g?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14})}),t.jsxs("div",{ref:Ln,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Zt(!1),Bt(e=>!e)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${wr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":wr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(po,{size:15})}),wr&&t.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[["architecture","computer"].map(e=>t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":sr[e],onClick:()=>af(e,!sr[e]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e==="architecture"?t.jsx(pd,{size:14,className:"text-muted-foreground"}):t.jsx(ud,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:o(e==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),t.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${sr[e]?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${sr[e]?"left-3.5":"left-0.5"}`})})]},e)),t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Wr,onClick:()=>Yl(!Wr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t.jsx(fd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),t.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Wr?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Wr?"left-3.5":"left-0.5"}`})})]}),t.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),jl.current?.click()},disabled:Ma,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:[Ma?t.jsx(lt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(cp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),Cl.current?.click()},disabled:Ma,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:[Ma?t.jsx(lt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx($p,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),k&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),k()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${g?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[g?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),g&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":o("rightSidebar.layoutMode"),children:[t.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("rightSidebar.layoutMode")}),t.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([e,s])=>{const l=L===e;return t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":l,onClick:()=>{q(e),Bt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:s},e)})})]})]})]}),t.jsx("button",{type:"button",onClick:c,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:t.jsx(Xt,{size:14})})]}),ee&&t.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[t.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:[t.jsx(us,{size:12,className:"shrink-0"}),t.jsx("input",{"data-right-search":!0,type:"search",value:W,onChange:e=>he(e.target.value),placeholder:o(ne==="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}),t.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${J?"text-[11px]":"text-[10px]"}`,children:[t.jsx("button",{type:"button",onClick:()=>Uc("name"),"aria-pressed":ne==="name",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${ne==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),t.jsx("button",{type:"button",onClick:()=>Uc("content"),"aria-pressed":ne==="content",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${ne==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),W&&t.jsx("button",{type:"button",onClick:()=>he(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(Xt,{size:12})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.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:[t.jsx(Ih,{size:12,className:"shrink-0 text-primary"}),t.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),t.jsx("input",{"data-search-scope":!0,value:Ne,onChange:e=>we(e.target.value),onKeyDown:e=>{e.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Ne!=="."&&t.jsx("button",{type:"button",onClick:()=>we("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:t.jsx(Xt,{size:11})})]}),t.jsxs("button",{type:"button",onClick:()=>oe(e=>!e),"aria-expanded":ue,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${ue||Es.length>0||Fe||E||ge?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[t.jsx(np,{size:13}),Es.length>0&&t.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:Es.length})]})]}),ue&&t.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[t.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:[t.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchExclude")}),t.jsx("input",{"data-search-exclude":!0,value:Pe,onChange:e=>O(e.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Pe&&t.jsx("button",{type:"button",onClick:()=>O(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:t.jsx(Xt,{size:11})})]}),ne==="content"&&t.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Fe,()=>Ie(e=>!e),Pp,o("rightSidebar.matchCase")],[E,()=>xe(e=>!e),Op,o("rightSidebar.matchWholeWord")],[ge,()=>De(e=>!e),Dp,o("rightSidebar.useRegex")]].map(([e,s,l,h])=>t.jsxs("button",{type:"button",onClick:s,"aria-pressed":e,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${e?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsx(l,{size:12}),h]},h))})]})]}),t.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(Qn?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(Wr)}, minmax(0, 1fr))`},children:[!Qn&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:e=>ts("git",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${jt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(br,{size:12}),o("rightSidebar.tabGit")]}),t.jsxs("button",{type:"button",onClick:e=>ts("diff",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${jt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(lu,{size:12}),o("rightSidebar.tabChanges"),Ee.size>0?t.jsx("span",{className:"text-[10px] text-accent",children:Ee.size}):null]})]}),t.jsxs("button",{type:"button",onClick:e=>ts("files",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${jt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Gi,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&t.jsxs("button",{type:"button",onClick:e=>ts("architecture",e),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(pd,{size:12}),o("architecture.tab")]}),sr.computer&&t.jsxs("button",{type:"button",onClick:e=>ts("computer",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${es?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(ud,{size:12}),o("rightSidebar.tabComputer")]}),Wr&&t.jsxs("button",{type:"button",onClick:e=>ts("android",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${jt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(fd,{size:12}),o("rightSidebar.tabAndroid")]})]}),t.jsx("div",{className:"h-2"}),xl&&t.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:xl})]}),t.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[t.jsx(is,{active:nt,mounted:nr,fallback:t.jsx(Oi,{slow:!1}),children:()=>Ge?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:Tf,diffViewType:Do,inlineMode:Ht,viewControls:g?Us():void 0,renderPathReference:(e,s)=>Wa(An(e,Ge.repoRoot??d),o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Fu,onSelect:fa,emptyText:o("rightSidebar.noChanges"),mobile:J,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Ge.headRef??""}${Ge.commits?.[0]?` · ${Ge.commits[0]}`:""}`,onClose:()=>{ot(null),fa(null)},closeLabel:o("common.back"),wrap:At,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka})}):Er?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:hi,diffViewType:Do,inlineMode:Ht,viewControls:g?Us():void 0,renderPathReference:(e,s)=>{const l=fe?.comparisonRepos,h=l&&l.length>1?[...l].sort((v,y)=>y.label.length-v.label.length).find(v=>e===v.label||e.startsWith(`${v.label}/`)):void 0,u=h?e===h.label?h.repoRoot:An(e.slice(h.label.length+1),h.repoRoot):An(e,zs?.repoRoot||d);return Wa(u,o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Eo,onSelect:fn,emptyText:o(fe?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:J,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(fe?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:zs?`${zs.repoLabel} · ${zs.branchName??"HEAD"} → ${zs.baseRef}`:void 0,onClose:()=>{++T.current,Te(!1),lr(!1),tr(null)},closeLabel:o("common.back"),wrap:At,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,localOptions:fe?.comparisonRepos?.map(e=>({key:e.repoRoot,label:e.label,checked:e.includeUncommitted??fe.includeUncommitted??!1,disabled:!(e.canIncludeUncommitted??ss(e.repoRoot,e.head)),onChange:s=>{bi({refresh:!0,repoRoot:e.repoRoot,includeUncommitted:s})}})),onHunkGitAction:fe?.includeUncommitted?Of:void 0,error:ze,actionsBusy:ce>0,onRefresh:()=>{bi({refresh:!0})},refreshing:Je,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Mf,onWalkthroughNavigate:Lf,initialDetailScrollTop:fe&&qe?vs[qe]:void 0,onDetailScrollPositionChange:Bf,externalSwiperRef:J?Gl:void 0,onMobileSlideChange:J?To:void 0})}):t.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&d&&Nn?t.jsx("div",{className:"px-3",children:Yf()}):fr?t.jsx(Oi,{slow:Il}):xn?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Jd(Ae)?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):Ae?.available===!1?t.jsx(io,{message:Ae.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Jn()}}):d?t.jsx(Oi,{slow:Il}):t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),t.jsx(is,{active:Ir,mounted:_u||Ir,children:()=>J?t.jsxs(ip,{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:e=>{Lr.current=e,e.slideTo(Ao,0)},onSlideChange:e=>{if(Tr(e.activeIndex),Ts.current===e.activeIndex){Ts.current=null;return}e.activeIndex===0&&(Ar(!1),Ut(null),R?.())},children:[t.jsx(md,{className:"h-full min-h-0",children:t.jsxs("div",{ref:qn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Ql,onDrop:Zl,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[kl&&t.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:t.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!W.trim()&&Vc,t.jsx(hd,{rootPath:re??"",onFileSelect:Ms,onPathReference:qt,getReferenceText:$a,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onDirectoryRoot:ac,onSearchFromDirectory:oc,onDirectoryPinToggle:ic,onFilePinToggle:lc,pinnedPaths:Rn,selectedFilePath:et,query:Ve,searchRootPath:Ul,searchOptions:Ol,searchMode:ne,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Ls(s,e),revealDirectory:le,canOpenInFileBrowser:Sl,onOpenInFileBrowser:Jl})]})}),t.jsx(md,{className:"h-full min-h-0",children:t.jsx("div",{className:"h-full overflow-hidden bg-surface",children:t.jsx(yo,{filePath:Du||Ao===1?et:null,active:r&&Ir&&Ao===1,onInsertReference:qt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:mr,onClose:Jf,onDirectoryLinkOpen:Kc,isMobile:!0,lineRange:Dr,onLineRangeChange:Ut,insertedReferenceKey:Oe,copiedReferenceKey:ye,scrollToLine:He,onScrollToLineHandled:()=>Et(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_})})})]}):t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{ref:qn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Ql,onDrop:Zl,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:_o},children:[kl&&t.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:t.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!W.trim()&&Vc,t.jsx(hd,{rootPath:re??"",onFileSelect:Ms,onPathReference:qt,getReferenceText:$a,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onDirectoryRoot:ac,onSearchFromDirectory:oc,onDirectoryPinToggle:ic,onFilePinToggle:lc,pinnedPaths:Rn,selectedFilePath:et,query:Ve,searchRootPath:Ul,searchOptions:Ol,searchMode:ne,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Ls(s,e),revealDirectory:le,canOpenInFileBrowser:Sl,onOpenInFileBrowser:Jl})]}),t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:Ju,onPointerMove:Qu,onPointerUp:Vl,onPointerCancel:Vl,onDoubleClick:()=>{Bo(el),Pt(ea,el)},children:t.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"})}),t.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:t.jsx(yo,{filePath:et,active:r&&Ir,onInsertReference:qt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:mr,onDirectoryLinkOpen:Kc,isMobile:!1,lineRange:Dr,onLineRangeChange:Ut,insertedReferenceKey:Oe,copiedReferenceKey:ye,scrollToLine:He,onScrollToLineHandled:()=>Et(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_})})]})}),t.jsx(is,{active:Ct,mounted:Uu||Ct,children:()=>ei?t.jsx(sp,{}):J?t.jsx(Ki,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:Qo,onMobileSlideChange:To,groups:Yt.length>0?Nc():[],mode:Cr,onModeChange:Ya,selectedKey:et,scrollToKey:Mc,scrollToKeyNonce:Sa.nonce,compact:!1,collapsedDirectoryKeys:oa,onToggleDirectory:$c,onSelectFile:e=>{const s=En.get(e.key);s&&Va(xr(s))},renderLeading:Pc,renderTrailing:e=>{const s=En.get(e.key);return s?jc(s):null},renderDirectoryTrailing:Cc,renderSubtitle:e=>{const s=En.get(e.key);return s?Rc(s):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:e=>d&&t.jsxs("div",{className:"px-0 py-0",children:[to&&t.jsx("div",{className:"mb-2",children:to}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0",children:t.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")})}),t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Yt.length,"/",Ee.size]})]}),t.jsxs(Sd,{actions:Jc,children:[kc(),e,g&&Us(),Xc]},d),or&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:or.label}),or.branch&&t.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:or.branch})]}),!or&&Pn&&t.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:[t.jsx(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Ha?(e=>Ic(e)):void 0,emptyContent:ei?null:xn&&Ee.size===0?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Yt.length===0?t.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:e})=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("button",{type:"button",onClick:e,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[t.jsx(mo,{size:14}),o("rightSidebar.backToChangeList")]}),t.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[g&&Us(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":At,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${At?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:o(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),d&&t.jsx("button",{type:"button",onClick:()=>{Jn()},disabled:fr,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:t.jsx(uo,{size:14,className:fr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Ec,activePane:Ct,wrap:At,diffViewType:Do,inlineMode:Ht,diffOptions:Bc,reloadKey:ca,renderStreamBadge:e=>t.jsx(na,{status:e}),onHunkGitAction:Oc,onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,onDetailScroll:qa}):t.jsx(Ki,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:o("rightSidebar.backToChangeList"),groups:Yt.length>0?Nc():[],mode:Cr,onModeChange:Ya,selectedKey:et,scrollToKey:Mc,scrollToKeyNonce:Sa.nonce,compact:!0,collapsedDirectoryKeys:oa,onToggleDirectory:$c,onSelectFile:e=>{const s=En.get(e.key);s&&Va(xr(s))},renderLeading:Pc,renderTrailing:e=>{const s=En.get(e.key);return s?jc(s):null},renderDirectoryTrailing:Cc,renderSubtitle:e=>{const s=En.get(e.key);return s?Rc(s):null},aiContent:Ha?(e=>Ic(e)):void 0,emptyContent:ei?null:xn&&Ee.size===0?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Yt.length===0?t.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:e=>d&&t.jsxs("div",{className:"px-0 py-0",children:[to&&t.jsx("div",{className:"mb-2",children:to}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")}),t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Yt.length,"/",Ee.size]})})]}),t.jsxs(Sd,{actions:Jc,children:[kc(),e,Us(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":At,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${At?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:o(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Xc]},d),or&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:or.label}),or.branch&&t.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:or.branch})]}),!or&&Pn&&t.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:[t.jsx(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:Ec,activePane:Ct,wrap:At,diffViewType:Ot,inlineMode:Ht,diffOptions:Bc,reloadKey:ca,renderStreamBadge:e=>t.jsx(na,{status:e}),onHunkGitAction:Oc,onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,onDetailScroll:qa})}),t.jsx(is,{active:kn,mounted:sr.architecture&&(tf||r&&kn),children:t.jsx(n.Suspense,{fallback:t.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:t.jsx(wg,{rootPath:d,active:r&&kn,onInsertPrompt:(e,s)=>$r(e,`architecture:${d}`,s),renderSource:e=>d&&t.jsx(ib,{rootPath:d,file:e,active:r&&kn,isMobile:J,onInsertReference:qt,onInsertText:$r,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye},`${e.path}:${e.line??1}`),onOpenFile:e=>{d&&(Mt("files"),Lt(null),ri(`${d.replace(/\/+$/,"")}/${e.path}`,e.line??1))}},d)})}),t.jsx(is,{active:r&&es,mounted:sr.computer&&(Zu||r&&es),children:t.jsx(n.Suspense,{fallback:t.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:t.jsx(kg,{active:r&&es})})}),t.jsx(is,{active:Zn,mounted:Io&&Wr,children:Ou?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[t.jsx("span",{children:o("android.splitDockedHint")}),t.jsx("button",{type:"button",onClick:()=>{ji.getState().setDock(Ai,null),Zs({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):t.jsx(xp,{sessionId:a??null,onCloseTab:()=>Yl(!1),onInsertPrompt:async(e,s)=>{if(!await Fr("android-deps",e,void 0,s))throw new Error(o("rightSidebar.uploadReferenceRejected"))},onInsertFile:cf,onRecordingComplete:lf})})]}),r&&wt&&t.jsx("div",{role:"alert",className:"shrink-0 border-t border-border/15 px-3 py-2 text-xs text-destructive",children:o("rightSidebar.referenceInsertFailed")}),r&&$t.task&&t.jsx(vm,{task:$t.task,onCancel:$t.cancel,onRetry:()=>{$t.retry()},onDismiss:$t.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o($t.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:$t.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:$t.task.files.length})}}),r&&N&&t.jsx(pm,{value:kt,collapsed:ke,autoCollapseAfterSend:ht,focusRequest:Mn,insertError:In?o("rightSidebar.contextDraftInsertFailed"):null,onChange:e=>{en(!1),St(e)},onCollapsedChange:Ye,onAutoCollapseAfterSendChange:yr,onDisable:()=>Q(!1),onClear:()=>St(""),onInsert:e=>rc(!1,e),onInsertAndSend:e=>rc(!0,e),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:e=>o("rightSidebar.contextDraftCharacterCount",{count:e})}}),kf(),pt&&typeof document<"u"&&Qr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>hn(null),children:t.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:e=>e.stopPropagation(),children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:pt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),t.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:pt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:ru(pt.file.absolutePath,d)}):o("rightSidebar.confirmStashAllDescription")}),pt.kind==="restore"&&t.jsx("input",{value:pt.phrase,onChange:e=>hn({...pt,phrase:e.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>hn(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),t.jsx("button",{type:"button",disabled:!!$e||pt.kind==="restore"&&pt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(pt.kind==="restore"){const e=ut(pt.file,d);if(!e)return;mt({action:"restore-worktree-file",cwd:e,paths:[pt.file.path],confirm:{acknowledged:!0,phrase:pt.phrase}},o("rightSidebar.restoreFile"),Hi(pt.file))}else{const e=pt.repoRoot??d;if(!e)return;mt({action:"stash-all",cwd:e},o("rightSidebar.stashAll"),`repo:${e}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${pt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o($e?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const Ab=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:yo,MarkdownImageLightbox:Hh,MarkdownPreview:nu,RightSidebar:lb,__testParseMarkdownListBlock:zh,buildMarkdownPreviewBlocks:Gh,buildMarkdownPreviewRenderResult:Wh,collectKnownGitRepoRoots:Cu,computeMarkdownImageDisplayBox:qh,getMarkdownHeadingOutline:Kh,getMarkdownHeadingPathAtLine:Vh,getNextMarkdownPreviewLineRange:Gg,isSvgImageSrc:Yh,mountRightSidebarRepoPickerOverlay:bu,replaceGitRepositorySnapshot:Iu,resolveMarkdownLocalLinkTarget:Xh,resolveRightSidebarDiffViewType:Ru,shouldCloseMarkdownImageLightboxDrag:Jh,showsGitRepoGroupHeader:tl},Symbol.toStringTag,{value:"Module"}));export{Yi as E,Ab as R,Bp as S,Ap as a,qp as c,Eb as m};