termdock 1.4.249 → 1.4.250

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 (310) hide show
  1. package/dist/client/assets/{App-ySHLLxfl.js → App-DUXUkp6M.js} +3 -3
  2. package/dist/client/assets/App-DUXUkp6M.js.br +0 -0
  3. package/dist/client/assets/App-DUXUkp6M.js.gz +0 -0
  4. package/dist/client/assets/{ChangeWalkthroughPanel-DrsLVbFw.js → ChangeWalkthroughPanel-DuftIP_n.js} +1 -1
  5. package/dist/client/assets/ChangeWalkthroughPanel-DuftIP_n.js.br +0 -0
  6. package/dist/client/assets/ChangeWalkthroughPanel-DuftIP_n.js.gz +0 -0
  7. package/dist/client/assets/{DagPlayground-CBUX-s8X.js → DagPlayground-DUStLbuX.js} +1 -1
  8. package/dist/client/assets/DagPlayground-DUStLbuX.js.br +0 -0
  9. package/dist/client/assets/DagPlayground-DUStLbuX.js.gz +0 -0
  10. package/dist/client/assets/{DiffLab-DD8m9b0G.js → DiffLab-r4yGPw3X.js} +1 -1
  11. package/dist/client/assets/DiffLab-r4yGPw3X.js.br +0 -0
  12. package/dist/client/assets/DiffLab-r4yGPw3X.js.gz +0 -0
  13. package/dist/client/assets/{DiffReview-BEFjWY01.js → DiffReview-Bv30J0_c.js} +1 -1
  14. package/dist/client/assets/DiffReview-Bv30J0_c.js.br +0 -0
  15. package/dist/client/assets/DiffReview-Bv30J0_c.js.gz +0 -0
  16. package/dist/client/assets/{DiffReviewLab-BS1rFkx9.js → DiffReviewLab-DNKv08iv.js} +1 -1
  17. package/dist/client/assets/DiffReviewLab-DNKv08iv.js.br +0 -0
  18. package/dist/client/assets/DiffReviewLab-DNKv08iv.js.gz +0 -0
  19. package/dist/client/assets/{DiffViewer-zb8C5YLR.js → DiffViewer-C2CNzWOk.js} +1 -1
  20. package/dist/client/assets/DiffViewer-C2CNzWOk.js.br +0 -0
  21. package/dist/client/assets/DiffViewer-C2CNzWOk.js.gz +0 -0
  22. package/dist/client/assets/{ModelPreview-BdY9A7GQ.js → ModelPreview-CKrfGqLc.js} +1 -1
  23. package/dist/client/assets/ModelPreview-CKrfGqLc.js.br +0 -0
  24. package/dist/client/assets/ModelPreview-CKrfGqLc.js.gz +0 -0
  25. package/dist/client/assets/RightSidebar-CghCWdM7.js +1678 -0
  26. package/dist/client/assets/RightSidebar-CghCWdM7.js.br +0 -0
  27. package/dist/client/assets/RightSidebar-CghCWdM7.js.gz +0 -0
  28. package/dist/client/assets/{abnfDiagram-VCTEODGH-ChpMiLwB.js → abnfDiagram-VCTEODGH-DL2nfDNT.js} +1 -1
  29. package/dist/client/assets/abnfDiagram-VCTEODGH-DL2nfDNT.js.br +0 -0
  30. package/dist/client/assets/abnfDiagram-VCTEODGH-DL2nfDNT.js.gz +0 -0
  31. package/dist/client/assets/{app-DhyrRqRS.js → app-8tWJbUN-.js} +3 -3
  32. package/dist/client/assets/app-8tWJbUN-.js.br +0 -0
  33. package/dist/client/assets/app-8tWJbUN-.js.gz +0 -0
  34. package/dist/client/assets/{arc-CcPLW1-W.js → arc-V2GgKn7I.js} +1 -1
  35. package/dist/client/assets/arc-V2GgKn7I.js.br +0 -0
  36. package/dist/client/assets/arc-V2GgKn7I.js.gz +0 -0
  37. package/dist/client/assets/{architectureDiagram-5GKGNRK7-CjWa2b5g.js → architectureDiagram-5GKGNRK7-Fg90zpOW.js} +1 -1
  38. package/dist/client/assets/architectureDiagram-5GKGNRK7-Fg90zpOW.js.br +0 -0
  39. package/dist/client/assets/architectureDiagram-5GKGNRK7-Fg90zpOW.js.gz +0 -0
  40. package/dist/client/assets/{blockDiagram-I7D4REHJ-D1AMj3Ey.js → blockDiagram-I7D4REHJ-BH0MOsEc.js} +1 -1
  41. package/dist/client/assets/blockDiagram-I7D4REHJ-BH0MOsEc.js.br +0 -0
  42. package/dist/client/assets/blockDiagram-I7D4REHJ-BH0MOsEc.js.gz +0 -0
  43. package/dist/client/assets/{c4Diagram-7LVT6UL2-Bo4f-Dyo.js → c4Diagram-7LVT6UL2-BCTc14IT.js} +1 -1
  44. package/dist/client/assets/c4Diagram-7LVT6UL2-BCTc14IT.js.br +0 -0
  45. package/dist/client/assets/c4Diagram-7LVT6UL2-BCTc14IT.js.gz +0 -0
  46. package/dist/client/assets/channel-ByAQak-i.js +1 -0
  47. package/dist/client/assets/{chunk-2Q5K7J3B-EA_Ksody.js → chunk-2Q5K7J3B-DcJlbXqa.js} +1 -1
  48. package/dist/client/assets/{chunk-5VM5RSS4-D49nnzNg.js → chunk-5VM5RSS4-YadWuzn7.js} +1 -1
  49. package/dist/client/assets/{chunk-F27PBJKO-BiHLxDgP.js → chunk-F27PBJKO-BTaBHq7k.js} +1 -1
  50. package/dist/client/assets/chunk-F27PBJKO-BTaBHq7k.js.br +0 -0
  51. package/dist/client/assets/chunk-F27PBJKO-BTaBHq7k.js.gz +0 -0
  52. package/dist/client/assets/{chunk-IMKFNOWR-B_x-RlD-.js → chunk-IMKFNOWR-BOqgrA6m.js} +1 -1
  53. package/dist/client/assets/chunk-IMKFNOWR-BOqgrA6m.js.br +0 -0
  54. package/dist/client/assets/chunk-IMKFNOWR-BOqgrA6m.js.gz +0 -0
  55. package/dist/client/assets/{chunk-JWPE2WC7-BO2gECxo.js → chunk-JWPE2WC7-CsX0TZuJ.js} +1 -1
  56. package/dist/client/assets/{chunk-POPQ4Y6H-CTJ8R53n.js → chunk-POPQ4Y6H-Bl2l1Ema.js} +1 -1
  57. package/dist/client/assets/{chunk-SVP7TREG-jDMFhXej.js → chunk-SVP7TREG-DuL_oy8M.js} +1 -1
  58. package/dist/client/assets/chunk-SVP7TREG-DuL_oy8M.js.br +0 -0
  59. package/dist/client/assets/chunk-SVP7TREG-DuL_oy8M.js.gz +0 -0
  60. package/dist/client/assets/{chunk-TICWLB2K-DuOVjlA7.js → chunk-TICWLB2K-BpNqLBuo.js} +1 -1
  61. package/dist/client/assets/chunk-TICWLB2K-BpNqLBuo.js.br +0 -0
  62. package/dist/client/assets/chunk-TICWLB2K-BpNqLBuo.js.gz +0 -0
  63. package/dist/client/assets/{chunk-XXDRQBXY-Dg68j1ru.js → chunk-XXDRQBXY-DvOZIuyY.js} +1 -1
  64. package/dist/client/assets/classDiagram-ZZMXUADV-U0ztcNG4.js +1 -0
  65. package/dist/client/assets/classDiagram-v2-VYDZK3BY-U0ztcNG4.js +1 -0
  66. package/dist/client/assets/{cose-bilkent-JH36ORCC-eC0PV-vF.js → cose-bilkent-JH36ORCC-ChxuLhhv.js} +1 -1
  67. package/dist/client/assets/cose-bilkent-JH36ORCC-ChxuLhhv.js.br +0 -0
  68. package/dist/client/assets/cose-bilkent-JH36ORCC-ChxuLhhv.js.gz +0 -0
  69. package/dist/client/assets/{cynefin-OW5HDTMX-CbwuuKCK.js → cynefin-OW5HDTMX-C071INwn.js} +1 -1
  70. package/dist/client/assets/cynefin-OW5HDTMX-C071INwn.js.br +0 -0
  71. package/dist/client/assets/cynefin-OW5HDTMX-C071INwn.js.gz +0 -0
  72. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-DiL62xjJ.js → cynefinDiagram-5FMLGOSQ-MY_50dMe.js} +1 -1
  73. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-MY_50dMe.js.br +0 -0
  74. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-MY_50dMe.js.gz +0 -0
  75. package/dist/client/assets/{dagre-GXQ25YYZ-BoCcQeIF.js → dagre-GXQ25YYZ-DELhrgXz.js} +1 -1
  76. package/dist/client/assets/dagre-GXQ25YYZ-DELhrgXz.js.br +0 -0
  77. package/dist/client/assets/dagre-GXQ25YYZ-DELhrgXz.js.gz +0 -0
  78. package/dist/client/assets/{diagram-S7CK7UJ4-BHxSkDxD.js → diagram-S7CK7UJ4-B-Be7FNM.js} +1 -1
  79. package/dist/client/assets/diagram-S7CK7UJ4-B-Be7FNM.js.br +0 -0
  80. package/dist/client/assets/diagram-S7CK7UJ4-B-Be7FNM.js.gz +0 -0
  81. package/dist/client/assets/{diagram-UQ7AKVKN-D2t82qXI.js → diagram-UQ7AKVKN-BljlErc_.js} +1 -1
  82. package/dist/client/assets/diagram-UQ7AKVKN-BljlErc_.js.br +0 -0
  83. package/dist/client/assets/diagram-UQ7AKVKN-BljlErc_.js.gz +0 -0
  84. package/dist/client/assets/{diagram-VSXAHHWV-DYQmQwL5.js → diagram-VSXAHHWV-CedNK-uM.js} +1 -1
  85. package/dist/client/assets/diagram-VSXAHHWV-CedNK-uM.js.br +0 -0
  86. package/dist/client/assets/diagram-VSXAHHWV-CedNK-uM.js.gz +0 -0
  87. package/dist/client/assets/{diagram-VX7I27RA-6SfVR4Z9.js → diagram-VX7I27RA-BpF063CL.js} +1 -1
  88. package/dist/client/assets/diagram-VX7I27RA-BpF063CL.js.br +0 -0
  89. package/dist/client/assets/diagram-VX7I27RA-BpF063CL.js.gz +0 -0
  90. package/dist/client/assets/{diagram-Z3DM3KII-CQiCDGAx.js → diagram-Z3DM3KII-DmykUds5.js} +1 -1
  91. package/dist/client/assets/diagram-Z3DM3KII-DmykUds5.js.br +0 -0
  92. package/dist/client/assets/diagram-Z3DM3KII-DmykUds5.js.gz +0 -0
  93. package/dist/client/assets/{ebnfDiagram-PWID7BFC-C7YMHrC7.js → ebnfDiagram-PWID7BFC-DZkhpsQ7.js} +1 -1
  94. package/dist/client/assets/ebnfDiagram-PWID7BFC-DZkhpsQ7.js.br +0 -0
  95. package/dist/client/assets/ebnfDiagram-PWID7BFC-DZkhpsQ7.js.gz +0 -0
  96. package/dist/client/assets/{erDiagram-RLTQ6QDP-C1-5SbSU.js → erDiagram-RLTQ6QDP-7EOAP4ib.js} +1 -1
  97. package/dist/client/assets/erDiagram-RLTQ6QDP-7EOAP4ib.js.br +0 -0
  98. package/dist/client/assets/erDiagram-RLTQ6QDP-7EOAP4ib.js.gz +0 -0
  99. package/dist/client/assets/{flowDiagram-HODETNUW-xNfUeMOl.js → flowDiagram-HODETNUW-Di-NXz6s.js} +1 -1
  100. package/dist/client/assets/flowDiagram-HODETNUW-Di-NXz6s.js.br +0 -0
  101. package/dist/client/assets/flowDiagram-HODETNUW-Di-NXz6s.js.gz +0 -0
  102. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CHiEXULk.js → ganttDiagram-EL5Y4UJY-BXGP48XI.js} +1 -1
  103. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BXGP48XI.js.br +0 -0
  104. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BXGP48XI.js.gz +0 -0
  105. package/dist/client/assets/{gestureArbiter-Q4qvTxJM.js → gestureArbiter-DfjioB30.js} +1 -1
  106. package/dist/client/assets/gestureArbiter-DfjioB30.js.br +0 -0
  107. package/dist/client/assets/gestureArbiter-DfjioB30.js.gz +0 -0
  108. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-DGHj-HHA.js → gitGraphDiagram-WWUBYQGX-DMWvrtdU.js} +1 -1
  109. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DMWvrtdU.js.br +0 -0
  110. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DMWvrtdU.js.gz +0 -0
  111. package/dist/client/assets/{infoDiagram-27XIBGKW-CkKjaZnz.js → infoDiagram-27XIBGKW-B6A9Pji6.js} +1 -1
  112. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BxwoaCAJ.js → ishikawaDiagram-5VMMS53U-BjBHrYpy.js} +1 -1
  113. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BjBHrYpy.js.br +0 -0
  114. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BxwoaCAJ.js.gz → ishikawaDiagram-5VMMS53U-BjBHrYpy.js.gz} +0 -0
  115. package/dist/client/assets/{journeyDiagram-3NMN7TZE-Co0Qn6y1.js → journeyDiagram-3NMN7TZE-B-OK36-I.js} +1 -1
  116. package/dist/client/assets/journeyDiagram-3NMN7TZE-B-OK36-I.js.br +0 -0
  117. package/dist/client/assets/journeyDiagram-3NMN7TZE-B-OK36-I.js.gz +0 -0
  118. package/dist/client/assets/{kanban-definition-UXKFOSKX-BSOfc04T.js → kanban-definition-UXKFOSKX-BkR_GpZf.js} +1 -1
  119. package/dist/client/assets/kanban-definition-UXKFOSKX-BkR_GpZf.js.br +0 -0
  120. package/dist/client/assets/kanban-definition-UXKFOSKX-BkR_GpZf.js.gz +0 -0
  121. package/dist/client/assets/{layout-BmHMb94h.js → layout-B1dVqanE.js} +1 -1
  122. package/dist/client/assets/layout-B1dVqanE.js.br +0 -0
  123. package/dist/client/assets/layout-B1dVqanE.js.gz +0 -0
  124. package/dist/client/assets/{linear-y-Abd9JO.js → linear-DbtXwCMs.js} +1 -1
  125. package/dist/client/assets/linear-DbtXwCMs.js.br +0 -0
  126. package/dist/client/assets/linear-DbtXwCMs.js.gz +0 -0
  127. package/dist/client/assets/{mermaid.core-B4rzVonW.js → mermaid.core-DXBQ8sgL.js} +5 -5
  128. package/dist/client/assets/mermaid.core-DXBQ8sgL.js.br +0 -0
  129. package/dist/client/assets/mermaid.core-DXBQ8sgL.js.gz +0 -0
  130. package/dist/client/assets/{mindmap-definition-YA3MSWOX-DY3bdl53.js → mindmap-definition-YA3MSWOX-aErXsDjT.js} +1 -1
  131. package/dist/client/assets/mindmap-definition-YA3MSWOX-aErXsDjT.js.br +0 -0
  132. package/dist/client/assets/mindmap-definition-YA3MSWOX-aErXsDjT.js.gz +0 -0
  133. package/dist/client/assets/{passwordBootstrap-kiljsfOw.js → passwordBootstrap-LVbx2WyB.js} +1 -1
  134. package/dist/client/assets/{passwordBootstrap-kiljsfOw.js.br → passwordBootstrap-LVbx2WyB.js.br} +0 -0
  135. package/dist/client/assets/passwordBootstrap-LVbx2WyB.js.gz +0 -0
  136. package/dist/client/assets/{pegDiagram-XKGWAZYB-XdVcJb90.js → pegDiagram-XKGWAZYB-B7UP1Iyq.js} +1 -1
  137. package/dist/client/assets/pegDiagram-XKGWAZYB-B7UP1Iyq.js.br +0 -0
  138. package/dist/client/assets/pegDiagram-XKGWAZYB-B7UP1Iyq.js.gz +0 -0
  139. package/dist/client/assets/{pieDiagram-E7YTZNPT-CgAHRPHX.js → pieDiagram-E7YTZNPT-DDVenGYn.js} +1 -1
  140. package/dist/client/assets/pieDiagram-E7YTZNPT-DDVenGYn.js.br +0 -0
  141. package/dist/client/assets/pieDiagram-E7YTZNPT-DDVenGYn.js.gz +0 -0
  142. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-C-nwguRe.js → quadrantDiagram-AXDQQJYC-BfVFS4dx.js} +1 -1
  143. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BfVFS4dx.js.br +0 -0
  144. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BfVFS4dx.js.gz +0 -0
  145. package/dist/client/assets/{railroadDiagram-O6MQD6OU-TcJFsMp6.js → railroadDiagram-O6MQD6OU-DMmkHIlO.js} +1 -1
  146. package/dist/client/assets/railroadDiagram-O6MQD6OU-DMmkHIlO.js.br +0 -0
  147. package/dist/client/assets/railroadDiagram-O6MQD6OU-DMmkHIlO.js.gz +0 -0
  148. package/dist/client/assets/{referenceLongPress-DcD1aZqh.js → referenceLongPress-CxWG0c2F.js} +1 -1
  149. package/dist/client/assets/referenceLongPress-CxWG0c2F.js.br +0 -0
  150. package/dist/client/assets/referenceLongPress-CxWG0c2F.js.gz +0 -0
  151. package/dist/client/assets/{requirementDiagram-BXWQKSXE-CDAoFFyT.js → requirementDiagram-BXWQKSXE-BAK1hsXp.js} +1 -1
  152. package/dist/client/assets/requirementDiagram-BXWQKSXE-BAK1hsXp.js.br +0 -0
  153. package/dist/client/assets/requirementDiagram-BXWQKSXE-BAK1hsXp.js.gz +0 -0
  154. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-rscTAtOd.js → sankeyDiagram-P5KCCOFB-BEvnkr6_.js} +1 -1
  155. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BEvnkr6_.js.br +0 -0
  156. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BEvnkr6_.js.gz +0 -0
  157. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-w_pdEULi.js → sequenceDiagram-WJ2MYXX4-Ie1mihcT.js} +1 -1
  158. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-Ie1mihcT.js.br +0 -0
  159. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-Ie1mihcT.js.gz +0 -0
  160. package/dist/client/assets/{sizeCapture-INFHLROL-tqubtbTJ.js → sizeCapture-INFHLROL-Dxfdgg7e.js} +1 -1
  161. package/dist/client/assets/sizeCapture-INFHLROL-Dxfdgg7e.js.br +0 -0
  162. package/dist/client/assets/sizeCapture-INFHLROL-Dxfdgg7e.js.gz +0 -0
  163. package/dist/client/assets/{sparkles-BQVhXL1X.js → sparkles-EjjUH4DP.js} +1 -1
  164. package/dist/client/assets/{stateDiagram-D77RDMKH-DFm71XIp.js → stateDiagram-D77RDMKH-D9nsU2MY.js} +1 -1
  165. package/dist/client/assets/stateDiagram-D77RDMKH-D9nsU2MY.js.br +0 -0
  166. package/dist/client/assets/stateDiagram-D77RDMKH-D9nsU2MY.js.gz +0 -0
  167. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-EDm7-sTV.js +1 -0
  168. package/dist/client/assets/{swimlanes-42K2YHIH-Bg6TJPYj.js → swimlanes-42K2YHIH-C0-l-AhO.js} +1 -1
  169. package/dist/client/assets/swimlanes-42K2YHIH-C0-l-AhO.js.br +0 -0
  170. package/dist/client/assets/swimlanes-42K2YHIH-C0-l-AhO.js.gz +0 -0
  171. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-B2H2z_dX.js +8 -0
  172. package/dist/client/assets/{timeline-definition-24CTP7MA-CwrKihuj.js → timeline-definition-24CTP7MA-DwOPp-ah.js} +1 -1
  173. package/dist/client/assets/timeline-definition-24CTP7MA-DwOPp-ah.js.br +0 -0
  174. package/dist/client/assets/timeline-definition-24CTP7MA-DwOPp-ah.js.gz +0 -0
  175. package/dist/client/assets/{triangle-alert-DZyRaNWe.js → triangle-alert-BXlTfgBy.js} +1 -1
  176. package/dist/client/assets/{vennDiagram-4TSXK5OY-WqUYcege.js → vennDiagram-4TSXK5OY-BYOmQzP3.js} +1 -1
  177. package/dist/client/assets/vennDiagram-4TSXK5OY-BYOmQzP3.js.br +0 -0
  178. package/dist/client/assets/{vennDiagram-4TSXK5OY-WqUYcege.js.gz → vennDiagram-4TSXK5OY-BYOmQzP3.js.gz} +0 -0
  179. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-B7Xfv-yN.js → wardleyDiagram-VM6X3IG4-B2yYZbOq.js} +1 -1
  180. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B2yYZbOq.js.br +0 -0
  181. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B2yYZbOq.js.gz +0 -0
  182. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BJupQX5U.js → xychartDiagram-S5SC5T6Z-DdqrbuEU.js} +1 -1
  183. package/dist/client/assets/xychartDiagram-S5SC5T6Z-DdqrbuEU.js.br +0 -0
  184. package/dist/client/assets/xychartDiagram-S5SC5T6Z-DdqrbuEU.js.gz +0 -0
  185. package/dist/client/index.html +1 -1
  186. package/dist/client/index.html.br +0 -0
  187. package/dist/client/index.html.gz +0 -0
  188. package/dist/client/sw.js +1 -1
  189. package/dist/client/sw.js.br +0 -0
  190. package/dist/client/sw.js.gz +0 -0
  191. package/dist/server/android/scrcpy.js +54 -12
  192. package/package.json +1 -1
  193. package/runtime-manifest.json +3 -3
  194. package/dist/client/assets/App-ySHLLxfl.js.br +0 -0
  195. package/dist/client/assets/App-ySHLLxfl.js.gz +0 -0
  196. package/dist/client/assets/ChangeWalkthroughPanel-DrsLVbFw.js.br +0 -0
  197. package/dist/client/assets/ChangeWalkthroughPanel-DrsLVbFw.js.gz +0 -0
  198. package/dist/client/assets/DagPlayground-CBUX-s8X.js.br +0 -0
  199. package/dist/client/assets/DagPlayground-CBUX-s8X.js.gz +0 -0
  200. package/dist/client/assets/DiffLab-DD8m9b0G.js.br +0 -0
  201. package/dist/client/assets/DiffLab-DD8m9b0G.js.gz +0 -0
  202. package/dist/client/assets/DiffReview-BEFjWY01.js.br +0 -0
  203. package/dist/client/assets/DiffReview-BEFjWY01.js.gz +0 -0
  204. package/dist/client/assets/DiffReviewLab-BS1rFkx9.js.br +0 -0
  205. package/dist/client/assets/DiffReviewLab-BS1rFkx9.js.gz +0 -0
  206. package/dist/client/assets/DiffViewer-zb8C5YLR.js.br +0 -0
  207. package/dist/client/assets/DiffViewer-zb8C5YLR.js.gz +0 -0
  208. package/dist/client/assets/ModelPreview-BdY9A7GQ.js.br +0 -0
  209. package/dist/client/assets/ModelPreview-BdY9A7GQ.js.gz +0 -0
  210. package/dist/client/assets/RightSidebar-lV2Ca2-c.js +0 -1678
  211. package/dist/client/assets/RightSidebar-lV2Ca2-c.js.br +0 -0
  212. package/dist/client/assets/RightSidebar-lV2Ca2-c.js.gz +0 -0
  213. package/dist/client/assets/abnfDiagram-VCTEODGH-ChpMiLwB.js.br +0 -0
  214. package/dist/client/assets/abnfDiagram-VCTEODGH-ChpMiLwB.js.gz +0 -0
  215. package/dist/client/assets/app-DhyrRqRS.js.br +0 -0
  216. package/dist/client/assets/app-DhyrRqRS.js.gz +0 -0
  217. package/dist/client/assets/arc-CcPLW1-W.js.br +0 -0
  218. package/dist/client/assets/arc-CcPLW1-W.js.gz +0 -0
  219. package/dist/client/assets/architectureDiagram-5GKGNRK7-CjWa2b5g.js.br +0 -0
  220. package/dist/client/assets/architectureDiagram-5GKGNRK7-CjWa2b5g.js.gz +0 -0
  221. package/dist/client/assets/blockDiagram-I7D4REHJ-D1AMj3Ey.js.br +0 -0
  222. package/dist/client/assets/blockDiagram-I7D4REHJ-D1AMj3Ey.js.gz +0 -0
  223. package/dist/client/assets/c4Diagram-7LVT6UL2-Bo4f-Dyo.js.br +0 -0
  224. package/dist/client/assets/c4Diagram-7LVT6UL2-Bo4f-Dyo.js.gz +0 -0
  225. package/dist/client/assets/channel-B5npd3sc.js +0 -1
  226. package/dist/client/assets/chunk-F27PBJKO-BiHLxDgP.js.br +0 -0
  227. package/dist/client/assets/chunk-F27PBJKO-BiHLxDgP.js.gz +0 -0
  228. package/dist/client/assets/chunk-IMKFNOWR-B_x-RlD-.js.br +0 -0
  229. package/dist/client/assets/chunk-IMKFNOWR-B_x-RlD-.js.gz +0 -0
  230. package/dist/client/assets/chunk-SVP7TREG-jDMFhXej.js.br +0 -0
  231. package/dist/client/assets/chunk-SVP7TREG-jDMFhXej.js.gz +0 -0
  232. package/dist/client/assets/chunk-TICWLB2K-DuOVjlA7.js.br +0 -0
  233. package/dist/client/assets/chunk-TICWLB2K-DuOVjlA7.js.gz +0 -0
  234. package/dist/client/assets/classDiagram-ZZMXUADV-BxAMJQEG.js +0 -1
  235. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BxAMJQEG.js +0 -1
  236. package/dist/client/assets/cose-bilkent-JH36ORCC-eC0PV-vF.js.br +0 -0
  237. package/dist/client/assets/cose-bilkent-JH36ORCC-eC0PV-vF.js.gz +0 -0
  238. package/dist/client/assets/cynefin-OW5HDTMX-CbwuuKCK.js.br +0 -0
  239. package/dist/client/assets/cynefin-OW5HDTMX-CbwuuKCK.js.gz +0 -0
  240. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DiL62xjJ.js.br +0 -0
  241. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DiL62xjJ.js.gz +0 -0
  242. package/dist/client/assets/dagre-GXQ25YYZ-BoCcQeIF.js.br +0 -0
  243. package/dist/client/assets/dagre-GXQ25YYZ-BoCcQeIF.js.gz +0 -0
  244. package/dist/client/assets/diagram-S7CK7UJ4-BHxSkDxD.js.br +0 -0
  245. package/dist/client/assets/diagram-S7CK7UJ4-BHxSkDxD.js.gz +0 -0
  246. package/dist/client/assets/diagram-UQ7AKVKN-D2t82qXI.js.br +0 -0
  247. package/dist/client/assets/diagram-UQ7AKVKN-D2t82qXI.js.gz +0 -0
  248. package/dist/client/assets/diagram-VSXAHHWV-DYQmQwL5.js.br +0 -0
  249. package/dist/client/assets/diagram-VSXAHHWV-DYQmQwL5.js.gz +0 -0
  250. package/dist/client/assets/diagram-VX7I27RA-6SfVR4Z9.js.br +0 -0
  251. package/dist/client/assets/diagram-VX7I27RA-6SfVR4Z9.js.gz +0 -0
  252. package/dist/client/assets/diagram-Z3DM3KII-CQiCDGAx.js.br +0 -0
  253. package/dist/client/assets/diagram-Z3DM3KII-CQiCDGAx.js.gz +0 -0
  254. package/dist/client/assets/ebnfDiagram-PWID7BFC-C7YMHrC7.js.br +0 -0
  255. package/dist/client/assets/ebnfDiagram-PWID7BFC-C7YMHrC7.js.gz +0 -0
  256. package/dist/client/assets/erDiagram-RLTQ6QDP-C1-5SbSU.js.br +0 -0
  257. package/dist/client/assets/erDiagram-RLTQ6QDP-C1-5SbSU.js.gz +0 -0
  258. package/dist/client/assets/flowDiagram-HODETNUW-xNfUeMOl.js.br +0 -0
  259. package/dist/client/assets/flowDiagram-HODETNUW-xNfUeMOl.js.gz +0 -0
  260. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHiEXULk.js.br +0 -0
  261. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHiEXULk.js.gz +0 -0
  262. package/dist/client/assets/gestureArbiter-Q4qvTxJM.js.br +0 -0
  263. package/dist/client/assets/gestureArbiter-Q4qvTxJM.js.gz +0 -0
  264. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DGHj-HHA.js.br +0 -0
  265. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DGHj-HHA.js.gz +0 -0
  266. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxwoaCAJ.js.br +0 -0
  267. package/dist/client/assets/journeyDiagram-3NMN7TZE-Co0Qn6y1.js.br +0 -0
  268. package/dist/client/assets/journeyDiagram-3NMN7TZE-Co0Qn6y1.js.gz +0 -0
  269. package/dist/client/assets/kanban-definition-UXKFOSKX-BSOfc04T.js.br +0 -0
  270. package/dist/client/assets/kanban-definition-UXKFOSKX-BSOfc04T.js.gz +0 -0
  271. package/dist/client/assets/layout-BmHMb94h.js.br +0 -0
  272. package/dist/client/assets/layout-BmHMb94h.js.gz +0 -0
  273. package/dist/client/assets/linear-y-Abd9JO.js.br +0 -0
  274. package/dist/client/assets/linear-y-Abd9JO.js.gz +0 -0
  275. package/dist/client/assets/mermaid.core-B4rzVonW.js.br +0 -0
  276. package/dist/client/assets/mermaid.core-B4rzVonW.js.gz +0 -0
  277. package/dist/client/assets/mindmap-definition-YA3MSWOX-DY3bdl53.js.br +0 -0
  278. package/dist/client/assets/mindmap-definition-YA3MSWOX-DY3bdl53.js.gz +0 -0
  279. package/dist/client/assets/passwordBootstrap-kiljsfOw.js.gz +0 -0
  280. package/dist/client/assets/pegDiagram-XKGWAZYB-XdVcJb90.js.br +0 -0
  281. package/dist/client/assets/pegDiagram-XKGWAZYB-XdVcJb90.js.gz +0 -0
  282. package/dist/client/assets/pieDiagram-E7YTZNPT-CgAHRPHX.js.br +0 -0
  283. package/dist/client/assets/pieDiagram-E7YTZNPT-CgAHRPHX.js.gz +0 -0
  284. package/dist/client/assets/quadrantDiagram-AXDQQJYC-C-nwguRe.js.br +0 -0
  285. package/dist/client/assets/quadrantDiagram-AXDQQJYC-C-nwguRe.js.gz +0 -0
  286. package/dist/client/assets/railroadDiagram-O6MQD6OU-TcJFsMp6.js.br +0 -0
  287. package/dist/client/assets/railroadDiagram-O6MQD6OU-TcJFsMp6.js.gz +0 -0
  288. package/dist/client/assets/referenceLongPress-DcD1aZqh.js.br +0 -0
  289. package/dist/client/assets/referenceLongPress-DcD1aZqh.js.gz +0 -0
  290. package/dist/client/assets/requirementDiagram-BXWQKSXE-CDAoFFyT.js.br +0 -0
  291. package/dist/client/assets/requirementDiagram-BXWQKSXE-CDAoFFyT.js.gz +0 -0
  292. package/dist/client/assets/sankeyDiagram-P5KCCOFB-rscTAtOd.js.br +0 -0
  293. package/dist/client/assets/sankeyDiagram-P5KCCOFB-rscTAtOd.js.gz +0 -0
  294. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-w_pdEULi.js.br +0 -0
  295. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-w_pdEULi.js.gz +0 -0
  296. package/dist/client/assets/sizeCapture-INFHLROL-tqubtbTJ.js.br +0 -0
  297. package/dist/client/assets/sizeCapture-INFHLROL-tqubtbTJ.js.gz +0 -0
  298. package/dist/client/assets/stateDiagram-D77RDMKH-DFm71XIp.js.br +0 -0
  299. package/dist/client/assets/stateDiagram-D77RDMKH-DFm71XIp.js.gz +0 -0
  300. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-aTUiN9r3.js +0 -1
  301. package/dist/client/assets/swimlanes-42K2YHIH-Bg6TJPYj.js.br +0 -0
  302. package/dist/client/assets/swimlanes-42K2YHIH-Bg6TJPYj.js.gz +0 -0
  303. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Bwf9yeLM.js +0 -8
  304. package/dist/client/assets/timeline-definition-24CTP7MA-CwrKihuj.js.br +0 -0
  305. package/dist/client/assets/timeline-definition-24CTP7MA-CwrKihuj.js.gz +0 -0
  306. package/dist/client/assets/vennDiagram-4TSXK5OY-WqUYcege.js.br +0 -0
  307. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B7Xfv-yN.js.br +0 -0
  308. package/dist/client/assets/wardleyDiagram-VM6X3IG4-B7Xfv-yN.js.gz +0 -0
  309. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BJupQX5U.js.br +0 -0
  310. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BJupQX5U.js.gz +0 -0
@@ -0,0 +1,1678 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-CKrfGqLc.js","assets/app-8tWJbUN-.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CwuSutCd.css","assets/App-DUXUkp6M.js","assets/gestureArbiter-DfjioB30.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-BXlTfgBy.js","assets/referenceLongPress-CxWG0c2F.js","assets/DiffReview-Bv30J0_c.js","assets/sparkles-EjjUH4DP.js","assets/DiffViewer-C2CNzWOk.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-DuftIP_n.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-DXBQ8sgL.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
2
+ import{a4 as ct,a1 as Yh,bd as t,cH as Nt,cR as Tt,bv as ut,a as ss,aM as ll,C as Ii,c as as,X as tr,cE as cl,c6 as Xh,cG as li,m as _i,L as bt,b1 as Jh,z as js,al as Qh,cL as ne,b5 as Zh,b7 as dl,b8 as em,b9 as uu,b6 as Rs,ay as tm,E as rm,i as nm,b4 as sm,bx as am,bz as om,bA as im,aY as lm,by as fd,y as Lt,f as cm,v as dm,b as um,aX as hd,au as md,aq as fm,aC as La,aD as pd,cS as Ts,ah as Cs,aE as hm,cF as ci,bp as mm,cq as gd,aw as pm,cC as gm,b_ as bm,aH as xm,O as bd,N as ym,ar as vm,av as wm,aA as xd,c0 as km,s as Sm,d as Ta,g as Di,w as fu,ad as jm,_ as Fs,bU as Rm,cP as Cm,bk as Nm,af as Em}from"./app-8tWJbUN-.js";import{y as Mm,h as Am,q as Xa,e as Pm,R as eo,U as $m,P as Lm,L as Tm,B as Im,K as _m,g as Dm,l as Fm,r as hu,s as Om,S as rs,D as Bm,c as mu,a as Um,x as pu,v as Ia,t as zm,u as Hm,w as Wm,T as yd,d as vd,k as di,j as _a,b as Gm,n as qm,i as Vm,f as Km,o as Ym,F as wd,C as Xm,G as Jm}from"./App-DUXUkp6M.js";import{b as a,r as Fr}from"./dnd-BCFAPC0L.js";import{a as Qm,S as Zm,b as gu,c as Fi,F as ep}from"./gestureArbiter-DfjioB30.js";import{D as Oi,C as Is,L as bu,f as tp,n as rp}from"./DiffReview-Bv30J0_c.js";import{T as np,M as ul,L as to,G as Ir}from"./triangle-alert-BXlTfgBy.js";import{S as Os}from"./sparkles-EjjUH4DP.js";import{C as xu,M as yu}from"./ChangeWalkthroughPanel-DuftIP_n.js";import{r as vu,s as wu,l as ku,u as sp,h as Su}from"./DiffViewer-C2CNzWOk.js";import{u as ju,G as Ru}from"./referenceLongPress-CxWG0c2F.js";const ap=[["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"}]],op=ct("case-sensitive",ap);const ip=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],lp=ct("circle",ip);const cp=[["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"}]],dp=ct("eye-off",cp);const up=[["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"}]],Bi=ct("eye",up);const fp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ui=ct("file-text",fp);const hp=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],zi=ct("house",hp);const mp=[["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"}]],pp=ct("image-plus",mp);const gp=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],bp=ct("maximize",gp);const xp=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],yp=ct("minimize",xp);const vp=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],wp=ct("monitor-smartphone",vp);const kp=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Sp=ct("plug",kp);const jp=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Rp=ct("power",jp);const Cp=[["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"}]],Np=ct("regex",Cp);const Ep=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Cu=ct("rotate-cw",Ep);const Mp=[["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"}]],Ap=ct("scan",Mp);const Pp=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Hi=ct("send",Pp);const $p=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Lp=ct("upload",$p);const Tp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],Ip=ct("volume-1",Tp);const _p=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Dp=ct("volume-2",_p);const Fp=[["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=ct("whole-word",Fp);async function Bp(e){let r;try{await Promise.race([e(),new Promise(s=>{r=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(r)}}function Up({active:e,rootPath:r,loading:s,delay:i,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!e||!r||s||d.current===r)return;const h=window.setTimeout(()=>{d.current=r,c(r)},i);return()=>window.clearTimeout(h)},[e,r,s,i,d,c])}function zp(e,r,s){try{const i=e instanceof HTMLImageElement?e.naturalWidth:e.width,d=e instanceof HTMLImageElement?e.naturalHeight:e.height;if(!i||!d)return Promise.resolve(null);const c=e instanceof HTMLImageElement?1400/Math.max(i,d):Math.min(1,1400/Math.max(i,d)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(i*c)),h.height=Math.max(1,Math.round(d*c));const m=h.getContext("2d");if(!m)return Promise.resolve(null);const p=getComputedStyle(document.documentElement);if(m.fillStyle=p.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,h.height),m.drawImage(e,0,0,h.width,h.height),s){const g=Math.max(10,Math.min(16,h.width/35));m.font=`${g}px sans-serif`;const f=[];let S="";for(const v of s.split(" "))S&&m.measureText(`${S} ${v}`).width>h.width-20?(f.push(S),S=v):S=S?`${S} ${v}`:v;S&&f.push(S),m.fillStyle=p.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(g+4)+12),m.fillStyle=p.getPropertyValue("--foreground").trim()||"black",f.forEach((v,P)=>m.fillText(v,10,8+g+P*(g+4)))}if(r){const g=r.xPercent*h.width/100,f=r.yPercent*h.height/100,S=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),v=S*1.6;m.strokeStyle=p.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,S/3),m.beginPath(),m.arc(g,f,S,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(g-v,f),m.lineTo(g+v,f),m.moveTo(g,f-v),m.lineTo(g,f+v),m.stroke()}return new Promise(g=>h.toBlob(g,"image/png"))}catch{return Promise.resolve(null)}}function Hp(e,r,s,i){return[e.trim(),r.trim(),i?`截图:${i}`:""].filter(Boolean).join(`
3
+ `)}function f0(e,r,s){const i=r*Math.PI/360,d=Math.min(i,Math.atan(Math.tan(i)*Math.max(s,.05)));return Math.max(e,1e-6)/Math.sin(d)*1.15}async function Wp(e,r,s,i){if(!s?.snapshot){i.isCurrent()&&i.insert(e,r);return}const d=new Date().toISOString(),c=new AbortController;let h,m;try{m=await Promise.race([(async()=>{const p=await s.snapshot;if(!(!p||c.signal.aborted||!i.isCurrent()))return i.upload(new File([p],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(p=>{h=setTimeout(()=>{c.abort(),p(void 0)},3e3)})])}catch{}finally{clearTimeout(h),c.abort()}i.isCurrent()&&i.insert(m?Hp(e,"",d,m):e,r)}function Gp(e){let r=1,s="terminal";for(;;){let i=!1;for(const d of e.values())if(d.name===s){i=!0;break}if(!i)break;s=`terminal-${r}`,r++}return s}const Wi=Yh((e,r)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:s=>{const i=Mm(),d=Date.now(),c=r().sessions,h=Gp(c),m={id:i,cwd:s,sessionId:null,name:h,customName:!1,createdAt:d,lastActivity:d};return e(p=>{const g=new Map(p.sessions);return g.set(i,m),{sessions:g,activeSessionId:p.activeSessionId??i,nextSessionNumber:p.nextSessionNumber+1}}),i},closeSession:s=>{e(i=>{const d=new Map(i.sessions),c=i.activeSessionId===s;d.delete(s);let h=i.activeSessionId;if(c){const m=Array.from(d.keys());h=m.length>0?m[0]:null}return{sessions:d,activeSessionId:h}})},switchSession:s=>{e(i=>i.sessions.has(s)?{activeSessionId:s}:i)},updateSession:(s,i)=>{e(d=>{const c=d.sessions.get(s);if(!c)return d;const h=new Map(d.sessions);return h.set(s,{...c,...i,lastActivity:Date.now()}),{sessions:h}})},setTerminalSession:(s,i)=>{r().updateSession(s,{sessionId:i.sessionId})},getActiveSession:()=>{const s=r();if(s.activeSessionId)return s.sessions.get(s.activeSessionId)},getSessionCount:()=>r().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}}));function qp(e,r){return e===r||r.endsWith(`/${e}`)||e.endsWith(`/${r}`)}function kd(e,r){return`${e??""}\0${r}`}function Vp(e,r,s){if(!e||e.length===0||!s)return{explained:0,stale:0};const i=kd(r,s);let d=0,c=0;for(const h of e){const m=[h.filePath,h.newPath,h.oldPath].filter(g=>typeof g=="string"&&g.length>0);(m.some(g=>kd(h.repoRoot,g)===i)||m.some(g=>qp(g,s)))&&(d+=1)}return{explained:d,stale:c}}function Kp({status:e}){if(!e)return null;const r=e.stale>0&&e.explained===0;if(!(e.explained>0||e.stale>0))return null;const i=r?"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 ${r?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:i,"aria-label":i,children:r?t.jsx(np,{size:10}):t.jsx(Os,{size:10})})}function Gi({changeStatus:e,auditStatus:r,renderChangeBadge:s}){return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(e),t.jsx(Kp,{status:r})]})}const Nu="termdock:right-sidebar:diff-change-list-mode:v1";function Yp(e){return e==="list"||e==="tree"}function Xp(){return ut(Nu,Yp)??"tree"}function Jp(e){for(const i of e){const d=i.hunk;if(d.oldPath&&d.newPath&&d.oldPath!==d.newPath)return"renamed";if(!d.oldPath&&d.newPath)return"added";if(d.oldPath&&!d.newPath)return"deleted"}const r=e.some(i=>i.hunk.additions>0),s=e.some(i=>i.hunk.deletions>0);return r&&!s?"added":!r&&s?"deleted":"modified"}function Qp(e){const r=new Map;for(const i of e){const d=r.get(i.hunk.filePath)??{key:i.hunk.filePath,filePath:i.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(i),d.additions+=i.hunk.additions,d.deletions+=i.hunk.deletions,i.current&&(d.explained+=1),i.stale&&(d.stale+=1),r.set(i.hunk.filePath,d)}const s=Array.from(r.values()).sort((i,d)=>i.filePath.localeCompare(d.filePath));for(const i of s)i.changeType=Jp(i.items);return s}function Zp(e){const r=e.filePath.split("/").pop()??e.filePath;return{key:e.key,path:e.filePath,displayName:r,displayDir:e.filePath.includes("/")?e.filePath.slice(0,-r.length-1):"",status:e.changeType,title:e.filePath}}function eg(e,r){const s=e.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const i=[],d=new Set;for(const[c,h]of s.entries()){const m=h.split(`
4
+ `),p=m.findIndex(S=>S.startsWith("@@ "));if(p<0){i.push(...m);continue}c===0&&i.push(...m.slice(0,p));const g=r[c];let f=p;for(;f>=0&&f<m.length;){const S=m.findIndex((A,M)=>M>f&&A.startsWith("@@ ")),v=S>=0?S:m.length,P=m.slice(f,v),N=P[0]??"",F=g?N===g:!0,z=N||g||P.join(`
5
+ `);F&&!d.has(z)&&(i.push(...P),d.add(z)),f=S}}return i.join(`
6
+ `)}function tg({groups:e,onInsertDiffReference:r}){return e.map(s=>{const i=eg(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),d=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"";return{key:s.key,path:s.filePath,absolutePath:d[0]?.repoRoot?`${d[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:d[0]?.repoRoot??null,displayName:c,displayDir:h,diffOverride:i,auditRecords:d,onInsertDiffReference:r}})}function rg(e,r,s){const i=Array.from(e.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const c=e.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const g of i){const f=g.getBoundingClientRect();if(f.bottom<c)continue;const S=Math.abs(f.top-c);S<m&&(h=g,m=S)}const p=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!p||p===r||s(p),p}function Sd({items:e,selectedKey:r,onSelect:s,emptyText:i,mobile:d=!1,backLabel:c="Back",headerTitle:h,headerMeta:m,onClose:p,closeLabel:g="Back",wrap:f=!0,onToggleWrap:S,wrapTitle:v,wrapOnLabel:P="Wrap on",wrapOffLabel:N="Wrap off",desktopLayout:F="split",onInsertDiffReference:z,onReferenceCopied:A,insertedReferenceKey:M,copiedReferenceKey:L,onClearAuditRecord:T,walkthroughs:B=[],onWalkthroughNavigate:_,initialDetailScrollTop:o,onDetailScrollPositionChange:w,scrollToKey:O,scrollToKeyNonce:j,externalSwiperRef:X,onMobileSlideChange:se}){const{t:ie}=Nt(),pe=a.useMemo(()=>Qp(e),[e]),q=a.useMemo(()=>new Map(pe.map(fe=>[fe.key,fe])),[pe]),[Z,$]=a.useState(()=>Xp()),[U,K]=a.useState(()=>new Set),[ae,le]=a.useState({key:null,nonce:0}),ge=pe.find(fe=>fe.explained>0||fe.stale>0)?.key??pe[0]?.key??null,be=r&&pe.some(fe=>fe.key===r)?r:ge,Re=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:pe.map(Zp)}],[pe]),E=a.useMemo(()=>tg({groups:pe,onInsertDiffReference:z}),[pe,z]),ee=a.useRef(ge),ue=a.useRef(s);ee.current=ge,ue.current=s,a.useEffect(()=>{!r&&ee.current&&ue.current(ee.current)},[r]);const Le=S?t.jsxs("button",{type:"button",onClick:S,"aria-pressed":f,title:v,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:f?P:N})]}):null,qe=fe=>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:[h&&t.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),m&&t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:m})]}),p&&t.jsxs("button",{type:"button",onClick:p,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(ss,{size:14}),g]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[fe,Le]})]});if(e.length===0){const fe=t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:i});return!h&&!p?fe:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[qe(null),fe]})}const _e=S?({slideToList:fe})=>t.jsxs("div",{className:"flex 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:fe,children:[t.jsx(ss,{size:14}),c]}),t.jsxs("button",{type:"button",onClick:S,"aria-pressed":f,title:v,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:f?P:N})]})]}):void 0;return t.jsx(Oi,{mobile:d,desktopLayout:F,backLabel:c,groups:Re,selectedKey:be,mode:Z,onModeChange:fe=>{$(fe),fe!=="ai"&&Tt(Nu,fe)},compact:d,collapsedDirectoryKeys:U,onToggleDirectory:fe=>{K(re=>{const R=new Set(re);return R.has(fe)?R.delete(fe):R.add(fe),R})},onSelectFile:fe=>{s(fe.key),le(re=>({key:fe.key,nonce:re.nonce+1}))},renderLeading:fe=>{const re=q.get(fe.key);return t.jsx(Gi,{changeStatus:fe.status,auditStatus:re,renderChangeBadge:R=>t.jsx(Is,{status:R})})},renderTrailing:fe=>{const re=q.get(fe.key);return re?t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",re.additions," -",re.deletions]}):null},renderListHeader:qe,aiContent:({slideToDetail:fe,fullscreen:re,toggleFullscreen:R})=>B.length>0&&_?t.jsx(xu,{walkthroughs:B,repoRoot:B[0]?.repoRoot,fullscreen:re,onToggleFullscreen:R,onNavigate:Y=>{d&&window.requestAnimationFrame(fe),_(Y)}}):t.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:ie("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:_e,externalSwiperRef:X,onMobileSlideChange:se,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:o,scrollToKey:O??ae.key,scrollToKeyNonce:O==null?ae.nonce:j,onDetailScroll:fe=>{rg(fe,be,s),w?.(fe.scrollTop)},files:E,activePane:!0,wrap:f,renderStreamBadge:(fe,re)=>{const R=q.get(re.key);return t.jsx(Gi,{changeStatus:fe,auditStatus:R,renderChangeBadge:Y=>t.jsx(Is,{status:Y})})},onInsertDiffReference:z,onReferenceCopied:A,insertedReferenceKey:M,copiedReferenceKey:L,onClearAuditRecord:T,emptyContent:t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:i})})}function ng(e){return e.replace(/\/+$/,"")||"/"}function sg(e){return[...new Set(Array.from(e,ng))].sort((r,s)=>r.localeCompare(s))}function ag(e){return e==="event-storm"||e==="reconnected"||e==="directory-rescan"||e==="polling-fallback"}function og(e){let r=null;return{applicableEvents:e.filter(i=>{const d=i.type==="rescan-required"&&!ag(i.reason);return d&&i.reason&&!r&&(r=i.reason),!d}),unavailableReason:r}}const ig=1400,lg=1200,Eu=44,cg=.7;function ui(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function qi(e){return`termdock:right-sidebar:context-draft-height:${e}:v1`}function dg(e){try{const r=window.localStorage.getItem(qi(e)),s=r===null?NaN:Number(r);return Number.isFinite(s)&&s>=Eu?s:null}catch{return null}}function jd(e,r){try{r===null?window.localStorage.removeItem(qi(e)):window.localStorage.setItem(qi(e),String(r))}catch{}}function Da(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function ug({value:e,collapsed:r,labels:s,focusRequest:i,insertError:d,autoCollapseAfterSend:c,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:p,onDisable:g,onClear:f,onInsert:S,onInsertAndSend:v}){const[P,N]=a.useState(null),[F,z]=a.useState(!1),[A,M]=a.useState(()=>dg(ui())),L=a.useRef(A),T=a.useRef(null),B=a.useRef(null),_=a.useRef(e),o=a.useRef(null),w=a.useRef(null),O=!!e.trim(),j=e.trim().split(`
7
+ `)[0]??"",X=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current),B.current!==null&&window.clearTimeout(B.current)},[]),a.useEffect(()=>{let E=!1;const ee=ui();return ll().then(ue=>{if(E)return;const Le=ue.contextDraftHeight?.[ee]??null;jd(ee,Le),L.current=Le,M(Le)}).catch(()=>{}),()=>{E=!0}},[]),a.useEffect(()=>{if(i!==void 0&&i>0){const E=o.current;if(!E)return;Da()||E.focus(),E.setSelectionRange(E.value.length,E.value.length),E.scrollTop=E.scrollHeight}},[i]),a.useEffect(()=>{const E=_.current;_.current=e,!(!r||e.length<=E.length)&&(z(!0),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,z(!1)},lg))},[e,r]),a.useEffect(()=>{if(r)return;const E=o.current;E&&(E.style.height=A!==null?`${A}px`:"")},[e,r,A]),a.useEffect(()=>{if(r)return;const E=o.current;!E||document.activeElement===E||(E.scrollTop=E.scrollHeight)},[e,r]),a.useEffect(()=>{if(r||Da())return;const E=o.current;!E||document.activeElement===E||(E.focus(),E.setSelectionRange(E.value.length,E.value.length))},[r]);const se=a.useRef(null);a.useLayoutEffect(()=>{if(!Da())return;const E=window.visualViewport;if(!E)return;const ee=()=>{const ue=se.current;if(!ue)return;if(E.height>=window.innerHeight*.75){ue.style.transform="";return}const Le=ue.getBoundingClientRect(),qe=Math.round(E.height-Le.bottom);ue.style.transform=qe!==0?`translateY(${qe}px)`:""};return ee(),E.addEventListener("resize",ee),E.addEventListener("scroll",ee),()=>{E.removeEventListener("resize",ee),E.removeEventListener("scroll",ee),se.current&&(se.current.style.transform="")}},[r]);const ie=E=>{N(E),T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,N(null)},ig)},pe=E=>{m(!1),Da()&&window.requestAnimationFrame(()=>{const ee=o.current;if(!ee)return;ee.focus();const ue=ee.value.length;ee.setSelectionRange(ue,ue),window.requestAnimationFrame(()=>{ee.setSelectionRange(ue,ue)})})},q=()=>{S(),ie("inserted")},Z=()=>{O&&(v(),ie("sent"))},$=E=>{if(E.key==="Escape"){E.preventDefault(),m(!0);return}E.key!=="Enter"||!E.metaKey&&!E.ctrlKey||(E.preventDefault(),Z())},U=E=>{E.preventDefault()},K=E=>{E.preventDefault();const ee=o.current;ee&&(w.current={startY:E.clientY,startHeight:ee.getBoundingClientRect().height},E.currentTarget.setPointerCapture?.(E.pointerId))},ae=E=>{const ee=w.current;if(!ee)return;const ue=window.visualViewport?.height??window.innerHeight,Le=Math.round(Math.min(Math.max(ee.startHeight+(ee.startY-E.clientY),Eu),ue*cg));L.current=Le,M(Le)},le=E=>{const ee=ui();jd(ee,E),cl({contextDraftHeight:{[ee]:E}}).catch(()=>{})},ge=()=>{w.current&&(w.current=null,L.current!==null&&le(L.current))},be=()=>{L.current=null,M(null),le(null)},Re=e.length>0&&t.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(e.length)});return r?t.jsx("section",{ref:se,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:()=>pe(),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!1,"aria-label":s.expand,title:s.expand,children:[t.jsx(Am,{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] ${d?"text-destructive":F?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(F?s.appended:O?j:s.title)})]}),Re,t.jsx("button",{type:"button",onClick:Z,disabled:!O,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:P==="sent"?t.jsx(Ii,{size:12}):t.jsx(Hi,{size:12})})]})}):t.jsxs("section",{ref:se,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:K,onPointerMove:ae,onPointerUp:ge,onPointerCancel:ge,onDoubleClick:be,title:s.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:U,onClick:()=>m(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[t.jsx(as,{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:s.title}),Re]}),t.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:U,onClick:()=>p(!c),className:"inline-flex h-6 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-surface/70 hover:text-foreground","aria-label":s.autoCollapseAfterSend,title:s.autoCollapseAfterSend,children:t.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${c?"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 ${c?"translate-x-2.5":"translate-x-0.5"}`})})}),t.jsx("button",{type:"button",onPointerDown:U,onClick:g,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:t.jsx(tr,{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:o,value:e,onChange:E=>h(E.target.value),onKeyDown:$,placeholder:s.title,rows:1,className:"block min-h-11 w-full resize-none bg-transparent px-2.5 py-2 font-mono text-[12px] leading-relaxed text-foreground placeholder:text-muted-foreground/30 focus:outline-none",autoCapitalize:"sentences",spellCheck:!0,"data-context-draft-input":!0}),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:U,onClick:f,disabled:!O,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:t.jsx(Xa,{size:11})}),d?t.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:d}):t.jsx("span",{className:"flex-1"}),t.jsxs("button",{type:"button",onPointerDown:U,onClick:q,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[t.jsx(Pm,{size:11}),t.jsx("span",{children:P==="inserted"?s.inserted:s.insert})]}),t.jsxs("button",{type:"button",onPointerDown:U,onClick:Z,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${X}`,children:[P==="sent"?t.jsx(Ii,{size:11}):t.jsx(Hi,{size:11}),t.jsx("span",{children:P==="sent"?s.sent:s.send})]})]})]})})]})}async function Mu(e,r){const s=await fetch(e,{...r,headers:{"Content-Type":"application/json",Accept:"application/json",...r?.headers??{}}}),i=await s.json().catch(()=>null);if(!s.ok||!i){const d=i?.error||i?.code||`ANDROID_REQUEST_FAILED_${s.status}`;throw new Error(d)}return i}async function fg(){return Mu("/api/android/devices")}async function hg(e){return Mu("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const ro=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],Bs=ro[1];function Au(e){if(!e||typeof e!="object")return Bs;const r=e,s=ro.find(h=>h.id===r.id);if(s)return s;if(r.id!=="custom")return Bs;const i=typeof r.maxSize=="number"?Math.max(360,Math.min(2160,Math.round(r.maxSize))):1080,d=typeof r.bitRate=="number"?Math.max(3e5,Math.min(3e7,Math.round(r.bitRate))):4e6,c=typeof r.maxFps=="number"?Math.max(0,Math.min(60,Math.round(r.maxFps))):30;return{id:"custom",maxSize:i,bitRate:d,maxFps:c}}function mg(e,r){if(!/^[0-9a-zA-Z_.:\-]{1,128}$/.test(e))throw new Error("INVALID_SERIAL");const s=new URLSearchParams;r&&(s.set("max_size",String(r.maxSize)),s.set("bit_rate",String(r.bitRate)),r.maxFps>0&&s.set("max_fps",String(r.maxFps)));const i=s.toString();return`/api/android/${e}/ws${i?`?${i}`:""}`}function Rd(e){const r={ADB_UNAVAILABLE:"本机没有可用的 adb,请先安装 Android platform-tools。",ADB_NOT_FOUND:"找不到 adb 可执行文件,可用 TERMDOCK_ADB_BIN 指定路径。",SCRCPY_NOT_FOUND:"本机没有 scrcpy,请先安装(含 scrcpy-server)。",SCRCPY_SERVER_NOT_FOUND:"找不到 scrcpy-server,可用 TERMDOCK_SCRCPY_SERVER 指定路径。",SCRCPY_VERSION_UNKNOWN:"无法读取 scrcpy 版本,请确认 scrcpy --version 可执行。",SCRCPY_CONNECT_TIMEOUT:"设备连接超时,请确认已授权 USB 调试并保持解锁。",SCRCPY_UNSUPPORTED_CODEC:"设备返回了不支持的视频编码。",INVALID_ADDRESS:"地址格式不正确,应为 ip:port。",API_NOT_ALLOWED:"当前设备权限不足:投屏需要全权服务授权。"};for(const[s,i]of Object.entries(r))if(e.includes(s))return i;return e}const pg=0,gg=1,bg=2,xg=3,yg=4,vg=5,wg=7,kg=10,Sg=11,jg=16,Rg=17,Cd=0,fi=1,Cg=2,Ng=3,hi=0,Nd=1,Ed=1,Ns=0xffffffffffffffffn,mi=0xfffffffffffffffen,Es={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function Pu(e,r,s){e.setUint32(r,Math.max(0,Math.round(s.x))&4294967295),e.setUint32(r+4,Math.max(0,Math.round(s.y))&4294967295),e.setUint16(r+8,Math.min(65535,Math.round(s.screenWidth))),e.setUint16(r+10,Math.min(65535,Math.round(s.screenHeight)))}function Eg(e,r,s,i,d,c){const h=new Uint8Array(32),m=new DataView(h.buffer);return m.setUint8(0,bg),m.setUint8(1,e),m.setBigUint64(2,r),Pu(m,10,s),m.setUint16(22,Math.max(0,Math.min(65535,Math.round(i*65536)))),m.setUint32(24,d>>>0),m.setUint32(28,c>>>0),h}function pi(e,r,s=0,i=0){const d=new Uint8Array(14),c=new DataView(d.buffer);return c.setUint8(0,pg),c.setUint8(1,e),c.setUint32(2,r>>>0),c.setUint32(6,s>>>0),c.setUint32(10,i>>>0),d}function Mg(e,r,s,i=0){const d=new Uint8Array(21),c=new DataView(d.buffer);c.setUint8(0,xg),Pu(c,1,e);const h=m=>Math.max(-32768,Math.min(32767,Math.round(Math.max(-1,Math.min(1,m/16))*32768)));return c.setInt16(13,h(r)),c.setInt16(15,h(s)),c.setUint32(17,i>>>0),d}function Ag(e){const r=new TextEncoder().encode(e);if(!r.length)return null;const s=r.subarray(0,300),i=new Uint8Array(5+s.length),d=new DataView(i.buffer);return d.setUint8(0,gg),d.setUint32(1,s.length),i.set(s,5),i}function Pg(e){const r=new TextEncoder().encode(e);if(!r.length||r.length>255)return null;const s=new Uint8Array(2+r.length);return s[0]=jg,s[1]=r.length,s.set(r,2),s}function Fa(e){return new Uint8Array([e])}function Md(e){return new Uint8Array([yg,e])}function $g(e){return new Uint8Array([kg,e?1:0])}function Lg(e){let r="";for(let s=0;s<e.length;s+=32768)r+=String.fromCharCode(...e.subarray(s,s+32768));return btoa(r)}function Tg(e){const r=atob(e),s=new Uint8Array(r.length);for(let i=0;i<r.length;i++)s[i]=r.charCodeAt(i);return s}function gi(e){return e.toString(16).padStart(2,"0")}function $u(e,r,s){for(let i=0;i+4<e.length;i++){const d=e[i]===0&&e[i+1]===0&&e[i+2]===1,h=e[i]===0&&e[i+1]===0&&e[i+2]===0&&e[i+3]===1?i+4:d?i+3:-1;if(h<0||h>=e.length)continue;if((s?e[h]>>1&63:e[h]&31)!==r){i=h-1;continue}let p=h+1;for(;p+2<e.length&&!(e[p]===0&&e[p+1]===0&&(e[p+2]===1||e[p+2]===0&&e[p+3]===1));)p++;return e.subarray(h,Math.min(e.length,p))}return null}function Ig(e){const r=e?$u(e,7,!1):null;return r&&r.length>=4?`avc1.${gi(r[1])}${gi(r[2])}${gi(r[3])}`:"avc1.42e01e"}function _g(e){const r=e?$u(e,32,!0):null;if(r&&r.length>=13){const s=r[1]>>6&3,i=r[1]&31,d=r[12];return`hev1.${s}.${i}.L${d}.B0`}return"hev1.1.6.L120.B0"}class Dg{constructor(r,s){this.canvas=r,this.callbacks=s}canvas;callbacks;socket=null;decoder=null;configured=!1;configData=null;header=null;closedByUser=!1;lastMessageAt=0;heartbeat=null;statsTimer=null;pendingConfig=null;needsKeyframe=!1;frameCount=0;receivedFrames=0;decodedFrames=0;controlsSent=0;lastSeq=0;deferredAck=!1;lastType="";bytesSinceSample=0;warnedUnsupported=!1;lastSampleAt=0;serial="";get currentHeader(){return this.header}connect(r,s){this.serial=r,this.closedByUser=!1,this.callbacks.onState("connecting");let i;try{i=Xh(mg(r,s))}catch(d){this.callbacks.onState("error",d instanceof Error?d.message:"ANDROID_STREAM_FAILED");return}this.socket=i,i.onopen=()=>{this.lastMessageAt=Date.now()},i.onmessage=d=>this.handleMessage(d.data),i.onerror=()=>{this.closedByUser||this.callbacks.onState("error","SCRCPY_CONNECTION_LOST")},i.onclose=()=>{this.teardownTimers(),this.closedByUser?this.callbacks.onState("idle"):this.callbacks.onState("error","SCRCPY_CONNECTION_CLOSED")},this.startTimers()}disconnect(){this.closedByUser=!0,this.teardownTimers();try{this.decoder?.close()}catch{}this.decoder=null,this.configured=!1;try{this.socket?.close()}catch{}this.socket=null,this.callbacks.onState("idle")}teardownTimers(){this.heartbeat&&clearInterval(this.heartbeat),this.statsTimer&&clearInterval(this.statsTimer),this.heartbeat=null,this.statsTimer=null}startTimers(){this.lastSampleAt=Date.now(),this.heartbeat=setInterval(()=>{if(!(!this.socket||this.socket.readyState!==1)){if(Date.now()-this.lastMessageAt>45e3){try{this.socket.close()}catch{}return}this.send({type:"ping"})}},15e3),this.statsTimer=setInterval(()=>{const r=Date.now(),s=(r-this.lastSampleAt)/1e3;s<=0||(this.callbacks.onStats({fps:Math.round(this.frameCount/s*10)/10,kbps:Math.round(this.bytesSinceSample*8/s/1e3),width:this.header?.width??0,height:this.header?.height??0,received:this.receivedFrames,decoded:this.decodedFrames,controls:this.controlsSent,last:this.lastType}),this.frameCount=0,this.bytesSinceSample=0,this.lastSampleAt=r)},1e3)}send(r){if(!(!this.socket||this.socket.readyState!==1))try{this.socket.send(JSON.stringify(r))}catch{}}sendControl(r){r&&(this.controlsSent++,this.send({type:"control",data:Lg(r)}))}ack(){this.send({type:"ack",seq:this.lastSeq})}handleMessage(r){if(typeof r!="string")return;this.lastMessageAt=Date.now();let s;try{s=JSON.parse(r)}catch{return}this.lastType=`${s.type??"?"}${s.config?":cfg":""}${s.key?":key":""}`;try{this.dispatchMessage(s)}catch(i){console.warn("[android] message handling failed",i),this.callbacks.onWarning(`处理消息失败:${i instanceof Error?i.message:String(i)}`)}}dispatchMessage(r){switch(r.type){case"header":this.header={deviceName:r.deviceName??this.serial,codec:r.codec??"h264",width:r.width??0,height:r.height??0},this.callbacks.onHeader(this.header),this.callbacks.onState("streaming");break;case"frame":this.handleFrame(r);break;case"error":this.callbacks.onState("error",r.message||"SCRCPY_ERROR");break;case"closed":this.callbacks.onState("error","SCRCPY_SESSION_CLOSED");break}}handleFrame(r){if(typeof r.data!="string")return;typeof r.seq=="number"&&(this.lastSeq=r.seq);const s=Tg(r.data);if(this.bytesSinceSample+=r.data.length,this.receivedFrames++,this.decoder?.state==="closed"&&(this.decoder=null,this.configured=!1),r.config){this.configData=s,this.pendingConfig=s,this.configureDecoder(),this.ackWhenDecoded();return}this.configured||this.configureDecoder();const i=r.key===!0;if(this.needsKeyframe&&!i){this.ackWhenDecoded();return}let d=s;this.pendingConfig&&(d=new Uint8Array(this.pendingConfig.length+s.length),d.set(this.pendingConfig,0),d.set(s,this.pendingConfig.length),this.pendingConfig=null),i&&(this.needsKeyframe=!1),this.decode(d,i,r.pts),this.ackWhenDecoded()}ackWhenDecoded(){(this.decoder?.decodeQueueSize??0)<3?this.ack():this.deferredAck=!0}configureDecoder(){const r=this.header?.codec??"h264";if(!this.decoder||this.decoder.state==="closed"){if(typeof VideoDecoder>"u"){this.warnedUnsupported||(this.warnedUnsupported=!0,this.callbacks.onWarning("当前浏览器不支持 WebCodecs(VideoDecoder),无法解码投屏画面。")),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}try{this.decoder=new VideoDecoder({output:c=>this.onDecodedFrame(c),error:c=>{this.configured=!1,console.warn("[android] video decoder error",c),this.callbacks.onState("error",c instanceof Error?c.message:"VIDEO_DECODER_ERROR"),this.sendControl(Fa(Rg))}})}catch(c){console.warn("[android] VideoDecoder unavailable",c),this.callbacks.onWarning(`创建 VideoDecoder 失败:${c instanceof Error?c.message:String(c)}`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}}const s={codec:"avc1.42e01e",optimizeForLatency:!0};let i;r==="h264"?(i=[Ig(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((h,m,p)=>p.indexOf(h)===m),s.avc={format:"annexb"}):r==="h265"?(i=[_g(this.configData),"hev1.1.6.L120.B0","hvc1.1.6.L120.B0"],s.hevc={format:"annexb"}):i=["av01.0.04M.08"];const d=[];for(const c of i)try{this.decoder.configure({...s,codec:c}),this.configured=!0,this.needsKeyframe=!0,c!==i[0]&&console.warn("[android] decoder configured with fallback codec",c);return}catch(h){d.push(`${c}: ${h instanceof Error?h.message:String(h)}`),console.warn("[android] decoder configure failed",c,h)}this.callbacks.onWarning(`解码器配置失败(${d.join(";")})`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED")}decode(r,s,i){if(!(!this.decoder||this.decoder.state!=="configured"))try{this.decoder.decode(new EncodedVideoChunk({type:s?"key":"delta",timestamp:i?Number(i):this.lastTimestamp+1,data:r})),this.lastTimestamp=i?Number(i):this.lastTimestamp+1}catch(d){this.decodeFailureCount++<3&&(console.warn("[android] decode threw",d),this.callbacks.onWarning(`送入解码器失败:${d instanceof Error?d.message:String(d)}`))}}decodeFailureCount=0;lastTimestamp=0;onDecodedFrame(r){this.frameCount++,this.decodedFrames++;const s=r.displayWidth||r.codedWidth,i=r.displayHeight||r.codedHeight,d=this.canvas;(d.width!==s||d.height!==i)&&(d.width=s,d.height=i,this.header&&(this.header={...this.header,width:s,height:i},this.callbacks.onHeader(this.header)));const c=d.getContext("2d");c&&c.drawImage(r,0,0,d.width,d.height),r.close(),this.deferredAck&&(this.decoder?.decodeQueueSize??0)<2&&(this.deferredAck=!1,this.ack())}pointerPoint(r,s){return{x:r,y:s,screenWidth:this.header?.width??0,screenHeight:this.header?.height??0}}touch(r,s,i,d){const c=r===fi||r===Ng,h=c?0:1,m=d===Ns&&!c?Ed:0,p=(r===Cd||r===fi)&&d===Ns?Ed:0;this.sendControl(Eg(r,d,this.pointerPoint(s,i),h,p,m))}pointerDown(r,s,i){this.touch(Cd,r,s,i==="mouse"?Ns:mi)}pointerMove(r,s,i){this.touch(Cg,r,s,i==="mouse"?Ns:mi)}pointerUp(r,s,i){this.touch(fi,r,s,i==="mouse"?Ns:mi)}scroll(r,s,i,d){this.sendControl(Mg(this.pointerPoint(r,s),i,d))}key(r,s=hi){this.sendControl(pi(s,r))}tapKey(r){this.sendControl(pi(hi,r)),this.sendControl(pi(Nd,r))}back(){this.sendControl(Md(hi)),this.sendControl(Md(Nd))}home(){this.tapKey(Es.HOME)}recents(){this.tapKey(Es.APP_SWITCH)}power(){this.tapKey(Es.POWER)}volumeUp(){this.tapKey(Es.VOLUME_UP)}volumeDown(){this.tapKey(Es.VOLUME_DOWN)}rotate(){this.sendControl(Fa(Sg))}expandNotifications(){this.sendControl(Fa(vg))}collapsePanels(){this.sendControl(Fa(wg))}setDisplayPower(r){this.sendControl($g(r))}sendText(r){this.sendControl(Ag(r))}startApp(r){this.sendControl(Pg(r))}}const Oa="android-mirror",Lu="termdock:android:quality:v1",Ad={low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},Fg=()=>{try{const e=localStorage.getItem(Lu);return e?Au(JSON.parse(e)):Bs}catch{return Bs}},Ms=e=>{try{localStorage.setItem(Lu,JSON.stringify(e))}catch{}};function Og(){const{t:e}=Nt(),r=a.useRef(null),s=a.useRef(null),i=a.useMemo(Fg,[]),d=a.useRef(i),c=a.useRef(null),h=a.useRef(null),m=a.useRef(0),[p,g]=a.useState(null),[f,S]=a.useState(null),[v,P]=a.useState(!0),[N,F]=a.useState(""),[z,A]=a.useState(i.id),[M,L]=a.useState([]),[T,B]=a.useState(null),[_,o]=a.useState(""),[w,O]=a.useState({maxSize:i.maxSize,bitRate:i.bitRate,maxFps:i.maxFps}),[j,X]=a.useState("idle"),[se,ie]=a.useState(null),[pe,q]=a.useState(null),[Z,$]=a.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[U,K]=a.useState(null),[ae,le]=a.useState(!1),[ge,be]=a.useState([]),[Re,E]=a.useState(null),[ee,ue]=a.useState([]),[Le,qe]=a.useState(!1),_e=a.useRef(null),fe=a.useRef(0),re=a.useRef([]),[R,Y]=a.useState(!1),[ke,xe]=a.useState(""),[ze,de]=a.useState(!1),[Qe,Te]=a.useState(!1),[W,V]=a.useState(""),Ce=Wi(k=>k.activeSessionId??k.sessions.keys().next().value??null),Ne=li(k=>!!k.docks[Oa]),dt=li(k=>k.hosts[Oa]),Ze=li(k=>k.setDock),rr=a.useCallback(async()=>{P(!0);try{const k=await fg();g(k),S(null)}catch(k){S(k instanceof Error?k.message:"ADB_UNAVAILABLE")}finally{P(!1)}},[]);a.useEffect(()=>{rr()},[rr]);const tt=p?.devices??[],Bt=tt.find(k=>k.serial===N)??null,Et=!!(f&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(f)),wr=!!(p?.adbAvailable&&!p.scrcpyVersion),kt=a.useCallback(()=>{s.current?.disconnect(),s.current=null,X("idle"),ie(null),q(null)},[]),Ke=a.useCallback(k=>{const Q=r.current;if(!Q||!k)return;s.current?.disconnect(),ie(null),q(null),K(null);const ce=new Dg(Q,{onState:(Se,Me)=>{X(Se),ie(Me??null)},onHeader:Se=>q(Se),onStats:Se=>$(Se),onWarning:Se=>K(Se)});s.current=ce,ce.connect(k,d.current)},[]),ht=a.useCallback(k=>{const Q={...k.quality?{quality:{id:k.quality.id,maxSize:k.quality.maxSize,bitRate:k.quality.bitRate,maxFps:k.quality.maxFps}}:{},...k.activePresetId!==void 0?{activePresetId:k.activePresetId}:{},...k.presets!==void 0?{presets:k.presets}:{},...k.deviceSerial!==void 0?{deviceSerial:k.deviceSerial}:{}};cl({androidPanel:Q}).catch(()=>{})},[]);a.useEffect(()=>{let k=!1;return ll().then(Q=>{if(k)return;const ce=Q.androidPanel;if(ce?.quality){const Se=Au(ce.quality);d.current=Se,A(Se.id),O({maxSize:Se.maxSize,bitRate:Se.bitRate,maxFps:Se.maxFps}),Ms(Se)}L(ce?.presets??[]),B(ce?.activePresetId??null),ce?.deviceSerial&&(h.current=ce.deviceSerial,F(ce.deviceSerial))}).catch(()=>{}),()=>{k=!0}},[]);const nr=a.useCallback(k=>{const Q=++fe.current;be(Se=>[...Se,{id:Q,left:k.left,top:k.top}]);const ce=window.setTimeout(()=>{be(Se=>Se.filter(Me=>Me.id!==Q)),re.current=re.current.filter(Se=>Se!==ce)},300);re.current.push(ce)},[]),Gt=a.useCallback(k=>{if(k.startsWith("user:")){const ce=M.find(Me=>Me.id===k.slice(5));if(!ce)return;const Se={id:"custom",maxSize:ce.maxSize,bitRate:ce.bitRate,maxFps:ce.maxFps};d.current=Se,A("custom"),B(ce.id),O({maxSize:ce.maxSize,bitRate:ce.bitRate,maxFps:ce.maxFps}),Ms(Se),ht({quality:Se,activePresetId:ce.id}),N&&Ke(N);return}if(k==="custom"){const ce=d.current;A("custom"),B(null),O({maxSize:ce.maxSize,bitRate:ce.bitRate,maxFps:ce.maxFps});return}const Q=ro.find(ce=>ce.id===k)??Bs;d.current=Q,A(Q.id),B(null),Ms(Q),ht({quality:Q,activePresetId:null}),N&&Ke(N)},[Ke,N,M,ht]),It=a.useCallback(()=>{const k={id:"custom",maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps};d.current=k,Ms(k),ht({quality:k,activePresetId:null}),A("custom"),B(null),N&&Ke(N)},[Ke,N,w,ht]),qt=a.useCallback(()=>{const k=_.trim();if(!k)return;const Q=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,ce={id:Q,name:k,maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps},Se=[...M.filter(cr=>cr.name!==k),ce].slice(-12),Me={id:"custom",maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps};L(Se),o(""),B(Q),A("custom"),d.current=Me,Ms(Me),ht({quality:Me,activePresetId:Q,presets:Se}),N&&Ke(N)},[_,w,M,N,Ke,ht]),Ut=a.useCallback(()=>{if(!T)return;const k=M.filter(Q=>Q.id!==T);L(k),B(null),ht({activePresetId:null,presets:k})},[T,M,ht]);a.useEffect(()=>()=>{s.current?.disconnect(),s.current=null;for(const k of re.current)window.clearTimeout(k);re.current=[]},[]),a.useEffect(()=>{const k=tt.filter(ce=>ce.state==="device");if(N||k.length!==1)return;const Q=k[0].serial;h.current!==Q&&(h.current=Q,F(Q))},[tt,N]),a.useEffect(()=>{N&&Ke(N)},[N,Ke]),a.useEffect(()=>{if(j==="streaming"){m.current=0,le(!1);return}if(j!=="error"||!N||!Bg(se??""))return;const k=Math.min(8e3,700*2**m.current);m.current+=1,le(!0);const Q=window.setTimeout(()=>{le(!1),Ke(N)},k);return()=>window.clearTimeout(Q)},[j,se,N,Ke]),a.useEffect(()=>{const k=r.current;if(!k)return;const Q=ce=>{const Se=s.current;if(!Se)return;ce.preventDefault();const Me=Ba(k,ce.clientX,ce.clientY);Se.scroll(Me.x,Me.y,ce.deltaX,ce.deltaY)};return k.addEventListener("wheel",Q,{passive:!1}),()=>k.removeEventListener("wheel",Q)},[]);const En=k=>{const Q=s.current,ce=r.current;if(!Q||!ce)return;if(k.pointerType==="mouse"&&k.button!==0){k.preventDefault(),k.button===2?Q.back():k.button===1&&Q.home();return}k.preventDefault(),ce.setPointerCapture?.(k.pointerId),c.current={id:k.pointerId,type:k.pointerType};const Se=Ba(ce,k.clientX,k.clientY);Q.pointerDown(Se.x,Se.y,k.pointerType);const Me=$d(ce,k.clientX,k.clientY);Me&&(_e.current={left:Me.left,top:Me.top},ue([]),qe(!1),E(Me))},Or=k=>{const Q=s.current,ce=r.current;if(!Q||!ce||c.current?.id!==k.pointerId)return;k.preventDefault();const Se=Ba(ce,k.clientX,k.clientY);Q.pointerMove(Se.x,Se.y,c.current.type);const Me=$d(ce,k.clientX,k.clientY),cr=_e.current;!Me||!cr||(E(Me),Math.hypot(Me.left-cr.left,Me.top-cr.top)>=6&&(qe(!0),ue(mt=>{const Ur=mt[mt.length-1];if(Ur&&Math.hypot(Me.left-Ur.x,Me.top-Ur.y)<4)return mt;const Mt=[...mt,{x:Me.left,y:Me.top}];return Mt.length>12?Mt.slice(Mt.length-12):Mt})))},Br=k=>{const Q=s.current,ce=r.current;if(!Q||!ce||c.current?.id!==k.pointerId)return;const Se=Ba(ce,k.clientX,k.clientY);Q.pointerUp(Se.x,Se.y,c.current.type),Re&&nr(Re),E(null),qe(!1),window.setTimeout(()=>ue([]),200),c.current=null,_e.current=null},zt=k=>{const Q=s.current;Q&&(k.key==="Backspace"?(k.preventDefault(),Q.key(67)):k.key==="Escape"?(k.preventDefault(),Q.back()):k.key==="Enter"&&(k.preventDefault(),Q.key(66)))},lr=async()=>{const k=ke.trim();if(k){de(!0);try{const Q=await hg(k);xe(""),Y(!1),await rr(),F(Q.serial)}catch(Q){S(Q instanceof Error?Q.message:"ADB_CONNECT_FAILED")}finally{de(!1)}}},xt=()=>{const k=s.current,Q=W;!k||!Q||(k.sendText(Q),V(""))},nt=j==="streaming",Ie=t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:zt,tabIndex:-1,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[t.jsx(_i,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsxs("select",{value:N,onChange:k=>{const Q=k.target.value;F(Q),h.current=Q,Q&&ht({deviceSerial:Q})},className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] text-foreground outline-none","aria-label":e("android.device"),children:[t.jsx("option",{value:"",children:tt.length?e("android.selectDevice"):e("android.noDevices")}),tt.map(k=>t.jsx("option",{value:k.serial,children:(k.model||k.serial)+Ug(k,e)},k.serial))]}),t.jsxs("select",{value:T?`user:${T}`:z,onChange:k=>Gt(k.target.value),className:"shrink-0 rounded bg-surface-2 px-1.5 py-1 text-[11px] text-foreground outline-none",title:e("android.quality"),"aria-label":e("android.quality"),children:[ro.map(k=>t.jsx("option",{value:k.id,children:e(Ad[k.id])},k.id)),M.map(k=>t.jsx("option",{value:`user:${k.id}`,children:k.name},k.id)),t.jsx("option",{value:"custom",children:e(Ad.custom)})]}),t.jsx("button",{type:"button",onClick:()=>{rr()},className:"rounded p-1.5 text-muted-foreground hover:bg-surface-2",title:e("android.refresh"),children:v?t.jsx(bt,{size:13,className:"animate-spin"}):t.jsx(eo,{size:13})}),nt?t.jsx("button",{type:"button",onClick:kt,className:"rounded p-1.5 text-destructive hover:bg-surface-2",title:e("android.disconnect"),children:t.jsx($m,{size:13})}):t.jsx("button",{type:"button",onClick:()=>N&&Ke(N),disabled:!N,className:"rounded p-1.5 text-primary hover:bg-surface-2 disabled:opacity-40",title:e("android.connect"),children:t.jsx(Sp,{size:13})}),t.jsx("button",{type:"button",onClick:()=>Y(k=>!k),className:"rounded p-1.5 text-muted-foreground hover:bg-surface-2",title:e("android.addDevice"),children:t.jsx(as,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{Ce&&Ze(Oa,Ne?null:{sessionId:Ce,side:"right"})},disabled:!Ce,className:`rounded p-1.5 hover:bg-surface-2 disabled:opacity-40 ${Ne?"text-primary":"text-muted-foreground"}`,title:e(Ne?"android.splitClose":"android.splitOpen"),children:t.jsx(Lm,{size:13})})]}),(z==="custom"||T)&&t.jsxs("div",{className:"grid gap-2 border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[t.jsx(Pd,{label:e("android.qualityResolution"),display:`${w.maxSize}p`,min:360,max:2160,step:8,value:w.maxSize,onChange:k=>O(Q=>({...Q,maxSize:k}))}),t.jsx(Pd,{label:e("android.qualityBitRate"),display:`${(w.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:w.bitRate/1e6,onChange:k=>O(Q=>({...Q,bitRate:Math.round(k*1e6)}))}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e("android.qualityFrameRate")}),t.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(k=>t.jsx("button",{type:"button",onClick:()=>O(Q=>({...Q,maxFps:k})),className:`rounded px-2 py-0.5 ${w.maxFps===k?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:k},k)),t.jsx("button",{type:"button",onClick:()=>O(k=>({...k,maxFps:0})),className:`rounded px-2 py-0.5 ${w.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:e("android.qualityAuto")})]}),t.jsx("button",{type:"button",onClick:It,disabled:!N,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:e("android.qualityApply")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:_,onChange:k=>o(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.nativeEvent.isComposing&&qt()},placeholder:e("android.presetNamePlaceholder"),maxLength:40,className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:qt,disabled:!_.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:e("android.presetSave")}),T&&t.jsx("button",{type:"button",onClick:Ut,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:e("android.presetDelete")})]})]}),R&&t.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[t.jsx("input",{value:ke,onChange:k=>xe(k.target.value),onKeyDown:k=>{k.key==="Enter"&&lr()},placeholder:e("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:()=>{lr()},disabled:ze,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:ze?t.jsx(bt,{size:12,className:"animate-spin"}):e("android.connect")})]}),Et&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:e("android.adbUnavailable")}),!Et&&wr&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:e("android.scrcpyUnavailable")}),Bt&&Bt.state!=="device"&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:zg(Bt,e)}),f&&!Et&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Rd(f)}),U&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:U}),t.jsxs("div",{className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-[var(--chrome-bg)] p-1",children:[t.jsx("canvas",{ref:r,className:"max-h-full max-w-full touch-none select-none rounded",style:{display:nt||pe?"block":"none"},onPointerDown:En,onPointerMove:Or,onPointerUp:Br,onPointerCancel:Br,onContextMenu:k=>k.preventDefault()}),Re&&t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border border-primary/80 bg-primary/35",style:{left:Re.left,top:Re.top}}),ee.length>1&&t.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:Le?1:0,transition:"opacity 160ms linear"},children:ee.slice(1).map((k,Q)=>{const ce=ee[Q],Se=(Q+1)/(ee.length-1);return t.jsx("line",{x1:ce.x,y1:ce.y,x2:k.x,y2:k.y,stroke:"var(--primary)",strokeWidth:1+1.6*Se,strokeLinecap:"round",opacity:.06+.45*Se},Q)})}),ge.map(k=>t.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:k.left,top:k.top}},k.id)),!nt&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[j==="connecting"&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{size:18,className:"animate-spin"}),t.jsx("span",{children:e("android.connecting")})]}),j==="error"&&t.jsxs(t.Fragment,{children:[t.jsx(lp,{size:14,className:"text-destructive"}),t.jsx("span",{className:"max-w-[80%] text-destructive",children:ae?e("android.reconnecting"):Rd(se||"")}),N&&t.jsx("button",{type:"button",onClick:()=>{m.current=0,Ke(N)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:e("android.retry")})]}),j==="idle"&&!Et&&!wr&&t.jsxs(t.Fragment,{children:[t.jsx(wp,{size:22,className:"opacity-60"}),t.jsx("span",{children:tt.length?e("android.idleHint"):e("android.noDevicesHint")})]})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t border-border px-2 py-1.5",children:[t.jsx(_r,{label:e("android.back"),onClick:()=>s.current?.back(),disabled:!nt,children:t.jsx(ss,{size:14})}),t.jsx(_r,{label:e("android.home"),onClick:()=>s.current?.home(),disabled:!nt,children:t.jsx(zi,{size:14})}),t.jsx(_r,{label:e("android.recents"),onClick:()=>s.current?.recents(),disabled:!nt,children:t.jsx(Tm,{size:14})}),t.jsx(_r,{label:e("android.notifications"),onClick:()=>s.current?.expandNotifications(),disabled:!nt,children:t.jsx(Im,{size:14})}),t.jsx(_r,{label:e("android.rotate"),onClick:()=>s.current?.rotate(),disabled:!nt,children:t.jsx(Cu,{size:14})}),t.jsx(_r,{label:e("android.volumeDown"),onClick:()=>s.current?.volumeDown(),disabled:!nt,children:t.jsx(Ip,{size:14})}),t.jsx(_r,{label:e("android.volumeUp"),onClick:()=>s.current?.volumeUp(),disabled:!nt,children:t.jsx(Dp,{size:14})}),t.jsx(_r,{label:e("android.power"),onClick:()=>s.current?.power(),disabled:!nt,children:t.jsx(Rp,{size:14})}),t.jsx(_r,{label:e("android.inputText"),active:Qe,onClick:()=>Te(k=>!k),disabled:!nt,children:t.jsx(_m,{size:14})}),t.jsx("span",{className:"ml-auto whitespace-nowrap text-[10px] tabular-nums text-muted-foreground",children:pe?`${Z.fps} fps · ${Z.kbps} kbps · ${Z.width}×${Z.height}`:""})]}),Qe&&t.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[t.jsx("input",{value:W,onChange:k=>V(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.nativeEvent.isComposing&&(k.preventDefault(),xt())},placeholder:e("android.inputPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground",autoFocus:!0}),t.jsx("button",{type:"button",onClick:xt,disabled:!W,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:e("android.send"),children:t.jsx(Hi,{size:13})})]})]});return Ne&&dt?t.jsxs(t.Fragment,{children:[Fr.createPortal(Ie,dt),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(ul,{size:18,className:"opacity-60"}),t.jsx("span",{children:e("android.splitDockedHint")}),t.jsx("button",{type:"button",onClick:()=>Ze(Oa,null),className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:e("android.splitClose")})]})]}):Ie}function Pd({label:e,display:r,min:s,max:i,step:d,value:c,onChange:h}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e}),t.jsx("input",{type:"range",min:s,max:i,step:d,value:c,onChange:m=>h(Number(m.target.value)),className:"h-1 min-w-0 flex-1 accent-primary","aria-label":e}),t.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",children:r})]})}function _r({label:e,onClick:r,disabled:s,active:i,children:d}){return t.jsx("button",{type:"button",onClick:r,disabled:s,title:e,"aria-label":e,className:`rounded p-1.5 transition active:scale-95 disabled:opacity-30 ${i?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:d})}function $d(e,r,s){const i=e.parentElement;if(!i)return null;const d=e.getBoundingClientRect(),c=i.getBoundingClientRect();return{left:d.left-c.left+(r-d.left),top:d.top-c.top+(s-d.top)}}function Ba(e,r,s){const i=e.getBoundingClientRect(),d=e.width||i.width,c=e.height||i.height,h=i.width?(r-i.left)/i.width*d:0,m=i.height?(s-i.top)/i.height*c:0;return{x:Math.max(0,Math.min(d,h)),y:Math.max(0,Math.min(c,m))}}function Bg(e){return!(/ADB_NOT_FOUND|SCRCPY_NOT_FOUND|SCRCPY_SERVER_NOT_FOUND|SCRCPY_VERSION_UNKNOWN|SCRCPY_UNSUPPORTED_CODEC|VIDEO_DECODER_UNSUPPORTED|decoder|decode/i.test(e)||/INVALID_SERIAL|INVALID_ADDRESS|API_NOT_ALLOWED|AUTHORIZATION_DENIED/i.test(e))}function Ug(e,r){return e.state==="device"?e.androidVersion?` · Android ${e.androidVersion}`:"":e.state==="unauthorized"?` · ${r("android.stateUnauthorized")}`:e.state==="offline"?` · ${r("android.stateOffline")}`:` · ${r("android.stateUnknown")}`}function zg(e,r){return e.state==="unauthorized"?r("android.unauthorizedHint"):e.state==="offline"?r("android.offlineHint"):r("android.stateUnknown")}function Hg(e,r){const s=r.trim();if(!s)return e;if(!e.trim())return s;const i=e.endsWith(`
8
+
9
+ `)?"":e.endsWith(`
10
+ `)?`
11
+ `:`
12
+
13
+ `;return`${e}${i}${s}`}function Wg(e,r){const s=e.trim();return s?r?`${s}\r`:/\s$/.test(e)?e:`${s} `:""}const Vi="termdock:right-sidebar:html-view-mode-by-file:v1";function Gg(e){return e==="preview"||e==="source"}function Tu(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(Gg)}function Iu(e,r){if(!r)return null;const s=e&&!r.startsWith("/")?`${e}/${r}`:r;return e?`${e}::${s}`:s}function Ld(e,r){const s=Iu(e,r);return s?ut(Vi,Tu)?.[s]??"source":"source"}function qg(e,r,s){const i=Iu(e,r);if(!i)return;const d=ut(Vi,Tu)??{};Tt(Vi,{...d,[i]:s})}function Td(e){try{return new URL(e,location.href).pathname.startsWith("/api/")}catch{return!1}}function uo(e,r){const[s,i]=a.useState(()=>!!navigator.serviceWorker?.controller);return a.useEffect(()=>{if(!Td(e)||s)return;const d=navigator.serviceWorker,c=()=>i(!!d?.controller);d?.addEventListener("controllerchange",c),c();const h=window.setTimeout(()=>{d?.controller||r?.()},1e4);return()=>{d?.removeEventListener("controllerchange",c),window.clearTimeout(h)}},[e,s,r]),Td(e)&&!s?void 0:e}function bi(e){const r=Number.isFinite(e)&&e>0?Math.floor(e):0,s=Math.floor(r/3600),i=Math.floor(r%3600/60),d=r%60,c=String(i).padStart(2,"0"),h=String(d).padStart(2,"0");return s>0?`${s}:${c}:${h}`:`${c}:${h}`}function Vg(e,r,s){return!Number.isFinite(s)||s<=0||!r.width?0:Math.min(1,Math.max(0,(e-r.left)/r.width))*s}const Kg=350,Yg=12,Xg=90;function Jg({url:e,onLoadError:r}){const s=uo(e,r),{t:i}=Nt(),d=a.useRef(null),c=a.useRef(null),h=a.useRef(null),m=a.useRef(null),p=a.useRef(!1),g=a.useRef(null),f=a.useRef(null),S=a.useRef(0),v=a.useRef(!1),P=a.useRef(!1),N=a.useRef(!1),F=a.useRef(null),z=a.useRef(null),A=a.useRef(!1),M=a.useRef(1),L=a.useRef(!1),[T,B]=a.useState(0),[_,o]=a.useState(0),[w,O]=a.useState(!1),[j,X]=a.useState(!1),[se,ie]=a.useState(null),[pe,q]=a.useState(!1),[Z,$]=a.useState(0),[U,K]=a.useState(!1),[ae,le]=a.useState({width:0,height:0}),ge=a.useCallback(()=>{F.current!==null&&(clearTimeout(F.current),F.current=null)},[]),be=a.useCallback(()=>{if(ge(),z.current=null,!A.current)return!1;const W=h.current;return W&&(W.playbackRate=M.current),A.current=!1,q(!1),!0},[ge]);a.useEffect(()=>()=>{g.current!==null&&cancelAnimationFrame(g.current),f.current!==null&&clearTimeout(f.current),ge();const W=h.current;W&&A.current&&(W.playbackRate=M.current)},[ge]),a.useEffect(()=>{const W=c.current;if(!W||typeof ResizeObserver>"u")return;const V=new ResizeObserver(([Ce])=>{Ce&&le({width:Ce.contentRect.width,height:Ce.contentRect.height})});return V.observe(W),()=>V.disconnect()},[]),a.useEffect(()=>{const W=()=>K(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const Re=a.useCallback((W,V=!1)=>{const Ce=h.current;if(!Ce)return!1;const Ne=Number.isFinite(Ce.duration)?Ce.duration:W,dt=Math.min(Math.max(W,0),Ne);if(o(dt),Math.abs(Ce.currentTime-dt)<1/120)return!1;const Ze=Ce.fastSeek;return V&&typeof Ze=="function"?Ze.call(Ce,dt):Ce.currentTime=dt,!0},[]),E=a.useCallback(()=>{g.current===null&&(g.current=requestAnimationFrame(()=>{g.current=null;const W=h.current;if(!W||!v.current||P.current||W.seeking)return;const V=N.current;N.current=!1,P.current=Re(S.current,!V)}))},[Re]),ee=a.useCallback(W=>{const V=m.current,Ce=h.current;if(!V||!Ce)return;const Ne=V.getBoundingClientRect(),dt=Vg(W,Ne,Ce.duration);S.current=dt,ie(dt),N.current=!1,E(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,N.current=!0,E()},Xg)},[E]),ue=a.useCallback(()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),N.current=!1,P.current=!1,Re(S.current)},[Re]),Le=a.useCallback(W=>{const V=h.current;if(!(!V||!Number.isFinite(V.duration)||V.duration<=0)){p.current=!V.paused,V.pause(),v.current=!0,X(!0);try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}ee(W.clientX)}},[ee]),qe=a.useCallback(()=>{v.current=!1,ue(),X(!1),ie(null);const W=h.current;W&&p.current&&!W.ended&&W.play().catch(()=>{}),p.current=!1},[ue]),_e=a.useCallback(()=>{const W=h.current;if(W){if(L.current){L.current=!1;return}W.paused?W.play().catch(()=>{}):W.pause()}},[]),fe=a.useCallback(W=>{const V=h.current;!V||V.paused||W.button!==0||(ge(),z.current={id:W.pointerId,x:W.clientX,y:W.clientY},F.current=setTimeout(()=>{F.current=null,M.current=V.playbackRate,V.playbackRate=2,A.current=!0,q(!0)},Kg))},[ge]),re=a.useCallback(W=>{const V=z.current;!V||V.id!==W.pointerId||A.current||Math.hypot(W.clientX-V.x,W.clientY-V.y)>Yg&&(ge(),z.current=null)},[ge]),R=a.useCallback(()=>{be()&&(L.current=!0)},[be]);a.useEffect(()=>(window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R),window.addEventListener("blur",R),()=>{window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R),window.removeEventListener("blur",R)}),[R]);const Y=a.useCallback(async()=>{const W=d.current,V=h.current;if(!(!W||!V))try{document.fullscreenElement===W?await document.exitFullscreen():W.requestFullscreen?await W.requestFullscreen():V.webkitEnterFullscreen?.()}catch{V.webkitEnterFullscreen?.()}},[]),ke=a.useCallback(()=>$(W=>(W+90)%360),[]),xe=a.useCallback(W=>{const V=h.current;if(!V||!Number.isFinite(V.duration))return;const Ce=W.shiftKey?10:5;let Ne=null;W.key==="ArrowLeft"?Ne=V.currentTime-Ce:W.key==="ArrowRight"?Ne=V.currentTime+Ce:W.key==="Home"?Ne=0:W.key==="End"&&(Ne=V.duration),Ne!==null&&(W.preventDefault(),Re(Ne))},[Re]),ze=j&&se!==null?se:_,de=T>0?Math.min(1,Math.max(0,ze/T)):0,Te=(Z===90||Z===270)&&ae.width>0&&ae.height>0?{width:`${ae.height}px`,height:`${ae.width}px`}:{width:"100%",height:"100%"};return t.jsxs("div",{ref:d,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":Z,children:[t.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[t.jsx("video",{ref:h,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...Te,transform:`translate(-50%, -50%) rotate(${Z}deg)`},src:s,preload:"auto",playsInline:!0,onClick:_e,onPointerDown:fe,onPointerMove:re,onPointerUp:R,onPointerCancel:R,onContextMenu:W=>{A.current&&W.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:W=>o(W.currentTarget.currentTime),onSeeked:W=>{const V=W.currentTarget;if(o(V.currentTime),P.current=!1,!v.current)return;const Ce=V.requestVideoFrameCallback;typeof Ce=="function"?Ce.call(V,()=>{v.current&&E()}):requestAnimationFrame(()=>{v.current&&E()})},onLoadedMetadata:W=>B(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onDurationChange:W=>B(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onError:r,children:i("rightSidebar.videoUnsupported")}),pe&&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:i("rightSidebar.videoLongPressSpeed")}),j&&se!==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:`${de*100}%`},"data-testid":"file-preview-video-scrub-time",children:bi(se)})]}),t.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Qm}`,[Zm]:"",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:_e,"aria-label":i(w?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:i(w?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:w?t.jsx(Dm,{size:14}):t.jsx(Fm,{size:14})}),t.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(T),"aria-valuenow":Math.floor(ze),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:Le,onPointerMove:W=>{j&&ee(W.clientX)},onPointerUp:qe,onPointerCancel:qe,onKeyDown:xe,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:`${de*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:`${de*100}%`}})]}),t.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[bi(ze)," / ",bi(T)]}),t.jsx("button",{type:"button",onClick:ke,"aria-label":i("rightSidebar.videoRotate"),title:i("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(Cu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>{Y()},"aria-label":i(U?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:i(U?"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:U?t.jsx(yp,{size:14}):t.jsx(bp,{size:14})})]})})]})}function Qg(e){const r=Math.max(0,Math.min(100,e.xPercent)),s=Math.max(0,Math.min(100,e.yPercent));return{...r<=50?{left:`calc(${r}% + 8px)`}:{right:`calc(${100-r}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function fo({anchor:e,children:r,disabled:s=!1,onClick:i,title:d}){return t.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),i()},title:d,style:Qg(e),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(to,{size:11}),r]})}function Zg(e,r,s,i){if(s.width<=0||s.height<=0||i.width<=0||i.height<=0)return null;const d=Math.min(s.width/i.width,s.height/i.height);if(!Number.isFinite(d)||d<=0)return null;const c=i.width*d,h=i.height*d,m=s.left+(s.width-c)/2,p=s.top+(s.height-h)/2,g=e-m,f=r-p;if(g<0||f<0||g>c||f>h)return null;const S=g/c*100,v=f/h*100;return{x:i.x+i.width*S/100,y:i.y+i.height*v/100,xPercent:S,yPercent:v}}function eb(e,r,s){const i=[`SVG标注: ${e}`,`视图: ${r}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&i.push(`最近文字: ${s.nearestText}`),`"${i.join(" / ")}"`}function tb(e){const r=new DOMParser().parseFromString(e,"image/svg+xml"),s=r.documentElement;if(s.nodeName.toLowerCase()!=="svg"||r.querySelector("parsererror"))throw new Error("Invalid SVG document");return r.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(i=>i.remove()),r.querySelectorAll("*").forEach(i=>{for(const d of Array.from(i.attributes)){const c=d.name.toLowerCase(),h=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&h&&!h.startsWith("#"))&&i.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function rb(e,r,s){let i=null;for(const d of Array.from(e.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const h=Number(d.getAttribute("x")),m=Number(d.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const p=Math.hypot(h-r,m-s);(!i||p<i.distance)&&(i={text:c,distance:p})}return i?.text.slice(0,120)}function _u({blobUrl:e,filePath:r,viewLabel:s,onInsertAnnotation:i}){const d=a.useRef(null),c=a.useRef(null),[h,m]=a.useState(null),[p,g]=a.useState(null),[f,S]=a.useState(1),[v,P]=a.useState(!1),[N,F]=a.useState(null),z=a.useRef(new Map),A=a.useRef(null),M=a.useRef(!1),L=a.useRef(null),T=a.useRef(f);T.current=f,a.useEffect(()=>{const $=new AbortController;return m(null),g(null),F(null),S(1),fetch(e,{signal:$.signal}).then(U=>U.text()).then(U=>m(tb(U))).catch(U=>{$.signal.aborted||g(U instanceof Error?U.message:"SVG preview failed")}),()=>$.abort()},[e]),a.useEffect(()=>{if(!v)return;const $=U=>{U.key==="Escape"&&P(!1)};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[v]),a.useLayoutEffect(()=>{const $=c.current,U=$?.querySelector("[data-svg-document] > svg");if(!$||!U)return;let K;try{K=U.getBBox()}catch{return}if(!K.width||!K.height)return;const ae=Math.max(2,Math.min(K.width,K.height)*.025);U.setAttribute("viewBox",`${K.x-ae} ${K.y-ae} ${K.width+2*ae} ${K.height+2*ae}`),U.style.width=`${f*100}%`,U.style.height=`${f*100}%`,U.style.minWidth=`${f*100}%`,U.style.minHeight=`${f*100}%`,U.style.display="block"},[h,f]);const B=a.useMemo(()=>N?eb(r,s,N):null,[r,N,s]),_=$=>{if(M.current){M.current=!1;return}const U=c.current,K=U?.querySelector("[data-svg-document] > svg"),ae=d.current;if(!U||!K||!ae)return;const le=K.viewBox.baseVal,ge=Zg($.clientX,$.clientY,K.getBoundingClientRect(),le);if(!ge)return;const be=ae.getBoundingClientRect();F({...ge,nearestText:rb(K,ge.x,ge.y),stageX:$.clientX-be.left,stageY:$.clientY-be.top,stageXPercent:($.clientX-be.left)/be.width*100,stageYPercent:($.clientY-be.top)/be.height*100})},o=$=>Math.max(1,Math.min(12,$)),w=($,U)=>{const K=o(U),ae=$.querySelector("[data-svg-document] > svg");if(!ae)return K;const le=`${K*100}%`;return ae.style.width=le,ae.style.height=le,ae.style.minWidth=le,ae.style.minHeight=le,T.current=K,K},O=($,U,K,ae)=>{const le=T.current,ge=$.getBoundingClientRect(),be=K-ge.left,Re=ae-ge.top,E=($.scrollLeft+be)/le,ee=($.scrollTop+Re)/le,ue=w($,U);return $.scrollLeft=E*ue-be,$.scrollTop=ee*ue-Re,ue},j=()=>{const $=Array.from(z.current.values());return $.length>=2?Math.hypot($[0].x-$[1].x,$[0].y-$[1].y):0},X=$=>{if($.pointerType==="mouse"&&$.button!==0)return;const U=c.current;U&&(z.current.set($.pointerId,{x:$.clientX,y:$.clientY}),U.setPointerCapture?.($.pointerId),z.current.size>=2?(A.current={kind:"pinch",startX:$.clientX,startY:$.clientY,startScrollLeft:U.scrollLeft,startScrollTop:U.scrollTop,startDistance:j(),startZoom:T.current,moved:!1},M.current=!0):T.current>1&&(A.current={kind:"pan",startX:$.clientX,startY:$.clientY,startScrollLeft:U.scrollLeft,startScrollTop:U.scrollTop,startZoom:T.current,moved:!1}))},se=$=>{if(!z.current.has($.pointerId))return;z.current.set($.pointerId,{x:$.clientX,y:$.clientY});const U=c.current,K=A.current;if(!(!U||!K)){if(z.current.size>=2&&K.kind==="pinch"){const ae=j();if(!K.startDistance||!ae)return;const le=o(K.startZoom*ae/K.startDistance);if(Math.abs(le-T.current)<.01)return;const ge=Array.from(z.current.values()),be=(ge[0].x+ge[1].x)/2,Re=(ge[0].y+ge[1].y)/2;K.moved=!0,M.current=!0,O(U,le,be,Re),$.preventDefault();return}if(K.kind==="pan"&&z.current.size===1){const ae=$.clientX-K.startX,le=$.clientY-K.startY;if(!K.moved&&Math.hypot(ae,le)<6)return;K.moved=!0,M.current=!0,U.scrollLeft=K.startScrollLeft-ae,U.scrollTop=K.startScrollTop-le,$.preventDefault()}}},ie=$=>{const U=c.current,K=A.current,ae=z.current.size===1&&!K?.moved;z.current.delete($.pointerId);try{U?.releasePointerCapture?.($.pointerId)}catch{}if(z.current.size===1&&K?.kind==="pinch"){const be=Array.from(z.current.values())[0];A.current=U?{kind:"pan",startX:be.x,startY:be.y,startScrollLeft:U.scrollLeft,startScrollTop:U.scrollTop,startZoom:T.current,moved:!1}:null;return}if(z.current.size>0||(A.current=null,K?.kind==="pinch"&&S(T.current),!ae||M.current))return;const le=Date.now(),ge=L.current;ge&&le-ge.time<350&&Math.hypot($.clientX-ge.x,$.clientY-ge.y)<24?(L.current=null,M.current=!0,S(be=>be>1?1:2.5)):L.current={time:le,x:$.clientX,y:$.clientY}},pe=$=>{if(!$.ctrlKey&&!$.metaKey)return;const U=c.current;if(!U)return;$.preventDefault();const K=O(U,T.current*Math.exp(-$.deltaY*.01),$.clientX,$.clientY);S(K)},q=()=>{S(1),T.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},Z=t.jsxs("div",{className:v?"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:d,className:"relative min-h-0 flex-1",children:[t.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:_,onDoubleClick:$=>{$.preventDefault(),S(U=>U>1?1:2.5)},onPointerDown:X,onPointerMove:se,onPointerUp:ie,onPointerCancel:ie,onWheel:pe,onScroll:()=>F(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:p?t.jsx("div",{className:"p-4 text-sm text-destructive",children:p}):h?t.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),N&&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:N.stageX,top:N.stageY}}),N&&B&&t.jsx(fo,{anchor:{xPercent:N.stageXPercent,yPercent:N.stageYPercent},title:"引用 SVG 标注",onClick:()=>{i?.(B,`svg:${N.x.toFixed(2)}:${N.y.toFixed(2)}`),F(null)},children:"引用 SVG 标注"}),t.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&t.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:$=>{$.stopPropagation(),q()},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(Ap,{size:14})}),t.jsx("button",{type:"button","aria-label":v?"退出全屏 SVG":"全屏 SVG",title:v?"退出全屏 SVG":"全屏 SVG",onClick:$=>{$.stopPropagation(),P(U=>!U)},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:v?t.jsx(yu,{size:14}):t.jsx(ul,{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:N?`SVG (${N.x.toFixed(2)}, ${N.y.toFixed(2)}) · ${N.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return v?Fr.createPortal(Z,document.body):Z}function Ja(e){switch(e){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function nb(e,r,s,i){const d=[`电子标注: ${e}`,`视图: ${Ja(r)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(i?.available&&i.xMm!==void 0&&i.yMm!==void 0&&(d.push(`PCB坐标: (${i.xMm.toFixed(2)},${i.yMm.toFixed(2)})mm [KiCad板坐标]`),i.layer&&d.push(`显示层: ${i.layer}`),i.nearest)){const c=[i.nearest.net?`网络 ${i.nearest.net}`:null,`对象层 ${i.nearest.layer}`,`距离 ${i.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");d.push(`最近对象: ${i.nearest.label}${c?`(${c})`:""}`)}return`"${d.join(" / ")}"`}function sb({blobUrl:e,filePath:r,view:s,board:i,onViewChange:d,onInsertAnnotation:c,onRefresh:h,interactive3d:m}){const{t:p}=Nt(),g=a.useRef(null),f=a.useRef(null),S=a.useRef(null),[v,P]=a.useState(null),[N,F]=a.useState(!1);a.useEffect(()=>(S.current?.abort(),P(null),F(!1),()=>S.current?.abort()),[e,s]);const z=a.useMemo(()=>v?nb(r,s,v,v.inspection):null,[r,v,s]),A=L=>{const T=g.current,B=f.current;if(!T||!B||!B.naturalWidth||!B.naturalHeight)return;const _=T.getBoundingClientRect(),o=B.getBoundingClientRect(),w=Math.min(o.width/B.naturalWidth,o.height/B.naturalHeight),O=B.naturalWidth*w,j=B.naturalHeight*w,X=o.left+(o.width-O)/2,se=o.top+(o.height-j)/2,ie=L.clientX-X,pe=L.clientY-se;if(ie<0||pe<0||ie>O||pe>j)return;const q={xPercent:Math.max(0,Math.min(100,ie/O*100)),yPercent:Math.max(0,Math.min(100,pe/j*100)),stageXPercent:(L.clientX-_.left)/_.width*100,stageYPercent:(L.clientY-_.top)/_.height*100,inspecting:i&&s!=="pcb-3d"};if(P(q),S.current?.abort(),!q.inspecting)return;const Z=new AbortController;S.current=Z,Jh(r,s,q.xPercent,q.yPercent,Z.signal).then($=>P(U=>U===q?{...U,inspection:$,inspecting:!1}:U)).catch(()=>{Z.signal.aborted||P($=>$===q?{...$,inspection:{available:!1},inspecting:!1}:$)})},M=i?["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(L=>t.jsx("button",{type:"button",onClick:()=>d(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Ja(L)},L))}),t.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:p("rightSidebar.edaRefresh"),"aria-label":p("rightSidebar.edaRefresh"),children:t.jsx(eo,{size:13})})]}),i&&m?t.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:m}):null,i?s==="pcb-3d"?m?null:t.jsx("div",{className:"min-h-0 flex-1"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:g,role:"button",tabIndex:0,onClick:A,onKeyDown:L=>{L.key!=="Enter"&&L.key!==" "||(L.preventDefault(),P({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:p("rightSidebar.edaPickHint"),children:[t.jsx("img",{ref:f,src:e,alt:`${r} ${Ja(s)}`,onLoad:()=>F(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${N?"opacity-100":"opacity-0"}`}),v&&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:`${v.stageXPercent}%`,top:`${v.stageYPercent}%`}}),v&&z&&t.jsx(fo,{anchor:{xPercent:v.stageXPercent,yPercent:v.stageYPercent},disabled:v.inspecting,title:p("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(z,`eda:${s}:${v.xPercent.toFixed(1)}:${v.yPercent.toFixed(1)}`,{snapshot:f.current?zp(f.current,v):Promise.resolve(null)}),P(null)},children:p("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:v?v.inspecting?p("rightSidebar.edaInspecting"):v.inspection?.available?p("rightSidebar.edaPickedBoardPosition",{x:v.inspection.xMm?.toFixed(2)??"—",y:v.inspection.yMm?.toFixed(2)??"—",object:v.inspection.nearest?.label??p("rightSidebar.edaNoNearbyObject")}):p("rightSidebar.edaPickedPosition",{x:v.xPercent.toFixed(1),y:v.yPercent.toFixed(1)}):p("rightSidebar.edaPickHint")})})]}):t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(_u,{blobUrl:e,filePath:r,viewLabel:Ja(s),onInsertAnnotation:c})})]})}function ab(e){const r=[];let s=[],i="",d=!1;for(let c=0;c<e.length;c+=1){const h=e[c];d?h==='"'&&e[c+1]==='"'?(i+='"',c+=1):h==='"'?d=!1:i+=h:h==='"'?d=!0:h===","?(s.push(i),i=""):h===`
14
+ `?(s.push(i.replace(/\r$/,"")),r.push(s),s=[],i=""):i+=h}return(i||s.length>0)&&(s.push(i.replace(/\r$/,"")),r.push(s)),r}function ob(e,r,s,i,d){const c=r[d]||`第${d+1}列`,h=s[d]??"",m=r.map((p,g)=>`${p||`第${g+1}列`}=${s[g]??""}`).join(";");return`"表格标注: ${e} / 数据行: ${i+1} / 列: ${c} / 值: ${h} / 记录: ${m}"`}function ib({content:e,filePath:r,onInsertAnnotation:s}){const{t:i}=Nt(),d=a.useMemo(()=>ab(e),[e]),c=d[0]??[],h=d.slice(1),m=a.useRef(null),[p,g]=a.useState(null),f=p?h[p.row]:null,S=p&&f?ob(r,c,f,p.row+1,p.column):null;return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[t.jsxs("div",{ref:m,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:"#"}),c.map((v,P)=>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:v||i("rightSidebar.csvUnnamedColumn",{index:P+1})},`${v}:${P}`))]})}),t.jsx("tbody",{children:h.map((v,P)=>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:P+1}),c.map((N,F)=>{const z=p?.row===P&&p.column===F;return t.jsx("td",{className:`border-b border-r border-border/15 p-0 ${z?"bg-primary/15":""}`,children:t.jsx("button",{type:"button",onClick:A=>{const M=m.current?.getBoundingClientRect(),L=A.currentTarget.getBoundingClientRect();if(!M?.width||!M.height)return;const T=A.clientX||L.left+L.width/2,B=A.clientY||L.top+L.height/2;g({row:P,column:F,xPercent:(T-M.left)/M.width*100,yPercent:(B-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:v[F]||" "})},`cell:${P}:${F}`)})]},`row:${P}`))})]})}),p&&S&&t.jsx(fo,{anchor:{xPercent:p.xPercent,yPercent:p.yPercent},title:i("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(S,`csv:${r}:${p.row+1}:${p.column+1}`),g(null)},children:i("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:p&&f?i("rightSidebar.csvSelectedCell",{row:p.row+1,column:c[p.column]||p.column+1}):i("rightSidebar.csvPickHint",{rows:h.length,columns:c.length})})})]})}function Qn(e,r){let s=e;for(const i of r){if(!s||typeof s!="object")return;s=s[i]}return s}function lb(e,r){const s=JSON.parse(e),i=Qn(s,["meta","version"]);if(r)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(i??"未知")},{label:"活动层编号",value:String(Qn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Qn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Qn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=Qn(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=Qn(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(i??"未知")},{label:"网络类数量",value:String(Array.isArray(d)?d.length:0)},{label:"默认间距",value:c?.clearance!==void 0?`${c.clearance} mm`:"未设置"},{label:"默认线宽",value:c?.track_width!==void 0?`${c.track_width} mm`:"未设置"},{label:"默认过孔",value:c?.via_diameter!==void 0?`${c.via_diameter} / ${c.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(h)?h.length:0)}]}function cb(e,r){return`"KiCad项目标注: ${e} / 项: ${r.label} / 值: ${r.value}"`}function db({content:e,filePath:r,localState:s,onInsertAnnotation:i}){const{t:d}=Nt(),c=a.useRef(null),[h,m]=a.useState(null),p=a.useMemo(()=>{try{return{items:lb(e,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[e,s]),g=h===null?null:p.items[h.index];return p.error?t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:e}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&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:d("rightSidebar.kicadLocalStateNotice")}),t.jsxs("div",{ref:c,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:p.items.map((f,S)=>t.jsxs("button",{type:"button",onClick:v=>{const P=c.current?.getBoundingClientRect(),N=v.currentTarget.getBoundingClientRect();if(!P?.width||!P.height)return;const F=v.clientX||N.left+N.width/2,z=v.clientY||N.top+N.height/2;m({index:S,xPercent:(F-P.left)/P.width*100,yPercent:(z-P.top)/P.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${h?.index===S?"bg-primary/10":""}`,children:[t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:f.label}),t.jsx("span",{className:"break-words text-xs text-foreground",children:f.value})]},f.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:d("rightSidebar.kicadShowRawJson")}),t.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:e})]})]}),g&&h&&t.jsx(fo,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:()=>{i?.(cb(r,g),`kicad-project:${r}:${g.label}`),m(null)},children:d("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:g?`${g.label}: ${g.value}`:d("rightSidebar.kicadProjectPickHint")})})]})}const ub=`/** 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
+ `,fb=`/* 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
+ `,Ua="/api/terminal/fs/preview/",hb=8*1024*1024,mb=32*1024*1024,pb=128,gb="data:,";function Ot(e){throw new Error(e)}function bb(e){return JSON.stringify(e).replace(/</g,"\\u003c")}async function Id(e,r,s){let i="",d=0;for(const c of e.matchAll(r))i+=e.slice(d,c.index)+await s(c),d=c.index+c[0].length;return i+e.slice(d)}async function Du(e,r){const s=r.origin??location.origin,i=new URL(e,s);(i.origin!==s||!js(i.pathname)?.startsWith(Ua))&&Ot("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,h=[],m=q=>{!h.includes(q)&&h.length<20&&h.push(q)},p=new Set,g=[],f=new Set,S=new Map,v=new Map;let P=0,N=!1;const F=new Set,z=()=>{N=!0;for(const q of[...F])q();p.clear(),g.length=0};async function A(q){q.ok||Ot(`预览资源读取失败(${q.status})`);const Z=q.body?.getReader(),$=[];let U=0;try{if(Z)for(;;){const le=await Z.read();if(le.done)break;U+=le.value.byteLength,P+=le.value.byteLength,(U>hb||P>mb)&&Ot("预览资源超出大小限制"),$.push(le.value)}}catch(le){throw await Z?.cancel().catch(()=>{}),le}finally{Z?.releaseLock()}const K=new Uint8Array(U);let ae=0;for(const le of $)K.set(le,ae),ae+=le.length;return{bytes:K,type:q.headers.get("content-type")??"application/octet-stream",status:q.status}}let M=i,L;for(let q=0;q<4;q++){const Z=await r.fetch(M.pathname+M.search,{signal:r.signal,redirect:"manual"});if(![301,302,303,307,308].includes(Z.status)){L=Z;break}const $=Z.headers.get("location");await Z.body?.cancel(),$||Ot("预览重定向缺少目标");const U=new URL($,M);(U.origin!==s||!js(U.pathname)?.startsWith(Ua))&&Ot("预览重定向越出文件范围"),M=U}L||Ot("预览重定向次数过多");const T=js(M.pathname),B=T.slice(Ua.length).split("/");/^[a-f0-9]{32}$/.test(B[0])||Ot("服务未提供有效的预览资源授权");const _=js(i.pathname).slice(Ua.length).split("/");/^[a-f0-9]{32}$/.test(_[0])&&_.shift(),_.join("/").replace(/\/$/,"")!==B.slice(1).join("/").replace(/\/$/,"")&&Ot("预览重定向改变了文件范围");const o=T.endsWith("/")?T:T.slice(0,T.lastIndexOf("/")+1),w=new URL(M.pathname.endsWith("/")?M.pathname:M.pathname.slice(0,M.pathname.lastIndexOf("/")+1),s);function O(q,Z){const $=new URL(q,Z);return $.origin!==s?null:(js($.pathname)?.startsWith(o)||Ot("已阻止预览访问目录之外的资源"),$)}function j(q){const Z=new URL(q,c);(Z.origin!==new URL(c).origin||!Z.pathname.startsWith(new URL(c).pathname))&&Ot("已阻止预览访问服务接口或目录之外的资源");const $=Z.pathname.slice(new URL(c).pathname.length)+Z.search;return O($,w)??Ot("预览资源无效")}function X(q){const Z=q.pathname+q.search,$=S.get(Z);if($)return $;if(N||r.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(S.size>=pb)return Promise.reject(new Error("预览资源数量超出限制"));const U=r.fetch(Z,{signal:r.signal,redirect:"manual"}).then(A);return S.set(Z,U),U}function se(q,Z){N&&Ot("预览已关闭");const $=`termdock-resource-${d}-${g.length}`;return g.push({token:$,data:q,type:Z}),p.add($),$}async function ie(q,Z,$,U=new Set){if(!q||q.startsWith("#")||/^data:(?:image|font)\//i.test(q)&&$==="resource")return q;try{const K=O(q,Z);if(!K){const Re=new URL(q,Z);return(Re.protocol!=="https:"||Re.username||Re.password||Re.origin===new URL(c).origin)&&Ot("已阻止不安全的外部资源"),f.add(Re.origin),Re.href}const ae=`${$}:${K.href}`;(U.has(ae)||U.size>=8)&&Ot("预览资源存在循环或过深引用");const le=v.get(ae);if(le)return le;const ge=new Set(U);ge.add(ae);const be=(async()=>{const Re=await X(K);return $==="css"?se(await pe(new TextDecoder().decode(Re.bytes),K,ge),"text/css"):$==="script"?se(Re.bytes,"text/javascript"):se(Re.bytes,Re.type)})();return v.set(ae,be),await be}catch(K){return m(K instanceof Error?K.message:"部分预览资源未能加载"),gb}}async function pe(q,Z,$){return q=await Id(q,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async U=>`@import url("${await ie(U[1],Z,"css",$)}")${U[2]};`),Id(q,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async U=>{const K=(U[1]??U[2]??U[3]).trim();return p.has(K)?U[0]:`url("${await ie(K,Z,"resource",$)}")`})}try{const q=await A(L),Z=se(ub,"text/javascript"),$=new DOMParser().parseFromString(new TextDecoder().decode(q.bytes),"text/html");$.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(E=>E.remove());for(const E of $.querySelectorAll("*")){if(E.removeAttribute("ping"),E.removeAttribute("srcdoc"),E.hasAttribute("style")&&E.setAttribute("style",await pe(E.getAttribute("style"),M,new Set)),E.tagName==="STYLE"&&(E.textContent=await pe(E.textContent??"",M,new Set)),E.tagName==="A"||E.tagName==="AREA"){const ee=E.getAttribute("href");try{if(ee&&!ee.startsWith("#")){const ue=O(ee,M);if(ue)E.setAttribute("href",new URL(ue.pathname.slice(w.pathname.length)+ue.search+ue.hash,c).href);else{const Le=new URL(ee,M);if(Le.protocol!=="https:"){E.removeAttribute("href");continue}f.add(Le.origin),E.setAttribute("href",Le.href)}}}catch(ue){E.removeAttribute("href"),m(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const ee of["data","manifest"])E.removeAttribute(ee);if(E.tagName==="SCRIPT"&&E.getAttribute("type")==="module"){E.setAttribute("type","module-shim");const ee=E.getAttribute("src");if(ee){const ue=O(ee,M);if(ue)E.setAttribute("src",new URL(ue.pathname.slice(w.pathname.length)+ue.search,c).href);else{const Le=new URL(ee,M);if(Le.protocol!=="https:"){E.remove();continue}f.add(Le.origin),E.setAttribute("src",Le.href)}}continue}if(E.tagName==="SCRIPT"&&E.getAttribute("type")==="importmap"){E.setAttribute("type","importmap-shim");continue}if(E.tagName==="LINK"){const ee=(E.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ee)){E.remove();continue}const ue=E.getAttribute("href");ue&&E.setAttribute("href",await ie(ue,M,ee==="stylesheet"?"css":"resource"))}if(E.hasAttribute("src")&&E.setAttribute("src",await ie(E.getAttribute("src"),M,E.tagName==="SCRIPT"?"script":"resource")),E.hasAttribute("poster")&&E.setAttribute("poster",await ie(E.getAttribute("poster"),M,"resource")),E.hasAttribute("srcset")){const ee=E.getAttribute("srcset");/data:/i.test(ee)?(E.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):E.setAttribute("srcset",(await Promise.all(ee.split(",").map(async ue=>{const[Le,...qe]=ue.trim().split(/\s+/);return`${await ie(Le,M,"resource")} ${qe.join(" ")}`}))).join(", "))}E.setAttribute("referrerpolicy","no-referrer"),E.removeAttribute("integrity"),E.removeAttribute("crossorigin")}const U=[...f].join(" "),K=$.createElement("meta");K.httpEquiv="Content-Security-Policy",K.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${U}; style-src 'unsafe-inline' blob: ${U}; img-src blob: data: ${U}; font-src blob: data: ${U}; media-src blob: data: ${U}; connect-src blob: ${U} ${[...f].map(E=>E.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ae=$.createElement("base");ae.href=c;const le=$.createElement("meta");le.name="referrer",le.content="no-referrer";const ge=$.createElement("script");ge.textContent=fb+`
1636
+ installPreviewRuntime(`+[d,c,[...f],Z].map(bb).join(",")+");";const be=$.createElement("script");be.src=Z,$.head.prepend(K,le,ae,ge,be);const Re=`<!doctype html>
1637
+ `+$.documentElement.outerHTML;return{html:Re,shellUrl:`/preview-shell.html#${d}`,errors:h,attach(E,ee){const ue=new Set,Le=_e=>{if(_e.source!==E.contentWindow||_e.data?.capability!==d)return;if(_e.data.type==="preview-ready"){E.contentWindow?.postMessage({type:"preview-init",capability:d,html:Re,resources:g},"*");return}if(_e.data.type==="preview-error"){ee("部分动态内容被安全预览限制");return}if(_e.data.type==="preview-navigate"){(async()=>{const re=j(String(_e.data.url)),R=await Du(re.pathname+re.search,r);if(N){R.dispose();return}const Y=R.attach(E,ee);F.add(()=>{Y(),R.dispose()}),E.src=R.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(re=>ee(re instanceof Error?re.message:"无法打开预览页面"));return}if(_e.data.type==="preview-external"){try{const re=new URL(String(_e.data.url));re.protocol==="https:"&&f.has(re.origin)&&window.open(re.href,"_blank","noopener,noreferrer")}catch{}return}if(_e.data.type!=="preview-fetch"||_e.ports.length!==1)return;const fe=_e.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(_e.data.method)){fe.postMessage({error:"预览仅允许读取已授权目录资源"}),fe.close();return}ue.add(fe),(async()=>{const re=j(String(_e.data.url)),R=await X(re);if(!ue.has(fe)||N)return;const Y=_e.data.method==="HEAD"?new Uint8Array:R.bytes.slice();fe.postMessage({status:R.status,headers:{"content-type":R.type},data:Y.buffer},[Y.buffer])})().catch(()=>{fe.postMessage({error:"预览资源不在授权范围或无法加载"}),ee("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(fe),fe.close()})};window.addEventListener("message",Le);const qe=()=>{window.removeEventListener("message",Le);for(const _e of ue)_e.close();ue.clear(),F.delete(qe)};return F.add(qe),qe},dispose:z}}catch(q){throw z(),q}}const xb=a.forwardRef(function({src:r,title:s,exitFullscreenLabel:i,onFullscreenChange:d},c){const h=a.useRef(null),[m,p]=a.useState(null),[g,f]=a.useState(),[S,v]=a.useState("");a.useEffect(()=>{const T=new AbortController;let B;return f(void 0),v(""),(async()=>{const _=await Qh();if(B=await Du(r,{fetch:(o,w)=>_.fetch(o,w),signal:T.signal}),T.signal.aborted){B.dispose();return}f(B),B.errors.length&&v(B.errors.join(";"))})().catch(_=>{T.signal.aborted||v(_ instanceof Error?_.message:"安全预览加载失败")}),()=>{T.abort(),B?.dispose()}},[r]),a.useEffect(()=>{if(!(!g||!m))return g.attach(m,v)},[g,m]);const[P,N]=a.useState(!1),[F,z]=a.useState(!1),A=P||F;a.useEffect(()=>{d?.(A)},[A,d]),a.useEffect(()=>{const T=()=>{N(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",T),()=>document.removeEventListener("fullscreenchange",T)},[]),a.useEffect(()=>{if(!F)return;const T=B=>{B.key==="Escape"&&z(!1)};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[F]);const M=a.useCallback(async()=>{const T=h.current;if(T){if(F){z(!1);return}if(document.fullscreenElement===T){await document.exitFullscreen();return}if(T.requestFullscreen&&document.fullscreenEnabled!==!1)try{await T.requestFullscreen();return}catch{}z(!0)}},[F]);a.useImperativeHandle(c,()=>({toggleFullscreen:M}),[M]);const L=t.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:A?"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:[A&&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:s}),t.jsx("button",{type:"button",onClick:()=>{M()},"aria-label":i,title:`${i} (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(yu,{size:15})})]}),S&&t.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:S}),!g&&!S&&t.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),t.jsx("iframe",{ref:p,src:g?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return F?Fr.createPortal(L,document.body):L}),Fu="termdock-file-search-match",Ki="termdock-file-search-current";function yb(e){const r=e.metaKey||e.ctrlKey,s=e.key.toLocaleLowerCase();return r&&s==="f"?"open":r&&s==="g"||e.key==="F3"?e.shiftKey?"previous":"next":e.key==="Escape"?"close":null}function vb(e){return e.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function wb(e,r){const s=r.trim().toLocaleLowerCase();if(!s)return[];const i=[];let d="",c=null;const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const S=vb(f);if(!S)continue;c&&c!==S&&(d+=`
1638
+ `);const v=d.length;d+=f.data,i.push({node:f,start:v,end:d.length,group:S}),c=S}const m=d.toLocaleLowerCase(),p=[];let g=0;for(;g<=m.length-s.length;){const f=m.indexOf(s,g);if(f<0)break;const S=f+s.length,v=i.find(N=>N.start<=f&&N.end>f),P=i.find(N=>N.start<S&&N.end>=S);if(v&&P&&v.group===P.group){const N=document.createRange();N.setStart(v.node,f-v.start),N.setEnd(P.node,S-P.start),p.push(N)}g=f+Math.max(s.length,1)}return p}function Ou(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function za(){const e=Ou();e?.delete(Fu),e?.delete(Ki)}function _d(e,r){const s=Ou();if(!s||typeof Highlight>"u")return;s.set(Fu,new Highlight(...e));const i=e[r];i?s.set(Ki,new Highlight(i)):s.delete(Ki)}function Dd(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function kb(e){return Array.from(new Set(e.split(/[\n,]/).map(r=>r.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Sb(e,r){const s=r.trim();return!s||s==="."?e:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${e.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function jb(e,r){if(r===e)return".";const s=`${e.replace(/[\\/]+$/,"")}/`;return r.startsWith(s)?r.slice(s.length):r}function Bu(e,r,s){return r?e:Fr.createPortal(e,s)}const fl="termdock:right-sidebar:file-tree-scroll:v1",hl="termdock:right-sidebar:file-preview-reading-state:v1",$s="termdock:right-sidebar:file-tree-width:v1",Uu="termdock:right-sidebar:markdown-view-mode:v1",zu="termdock:right-sidebar:diff-change-list-mode:v1",Hu="termdock:right-sidebar:diff-wrap:v1",Wu="termdock:diff-viewer:view-type:v1",Gu="termdock:right-sidebar:file-search-mode:v1",xi="termdock:right-sidebar:collapsed-git-repo-groups:v1",Fd="termdock:right-sidebar:collapsed-diff-directories:v1",yi="termdock:right-sidebar:branch-audit-module-open:v1",qu="termdock:right-sidebar:branch-audit-module:v1",Rb=150,Vu="termdock:right-sidebar:active-git-repo:v1",Od="termdock:right-sidebar:context-draft-enabled:v1",Bd="termdock:right-sidebar:context-draft-collapsed:v1",Ud="termdock:right-sidebar:context-draft-auto-collapse:v1",vi="termdock:right-sidebar:context-draft-text:v1",Cb=300,Nb=20,Eb=120,Mb=250,Ab=250,Pb=120,$b=700,wi=600;function Zn(e){return!!(e&&ne.getState().nestedGitScanRoots[e])}const zd=[2e3,5e3,15e3,3e4],Lb=320,Tb=500,Ib=20,_b=12e3,Yi=300,Hd=240,Db=560,Ku="border-r px-2 py-1.5 sm:px-3 sm:py-2",no="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Yu=`${Ku} border-b border-border/15 font-semibold last:border-r-0`,Xu=`${Ku} border-border/10 align-top text-muted-foreground last:border-r-0`,ml="termdock-file-preview-horizontal-scroll",Wd=a.lazy(()=>Fs(()=>import("./ModelPreview-CKrfGqLc.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Ju=`${ml} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Qu(e,r,s){return e&&!r?"unified":s}const Fb=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Ob(e){return e==="preview"||e==="source"}function Bb(e){return e==="list"||e==="tree"||e==="ai"}function Gd(){return ut(Uu,Ob)??"preview"}function Ub(){return ut(zu,Bb)??"tree"}function Ls(e){return typeof e=="boolean"}function zb(e){return typeof e=="string"}function Hb(){return ut(Hu,Ls)??!0}function Wb(e){return e==="unified"||e==="split"}function Gb(){return ut(Wu,Wb)??"unified"}function qb(e){return e==="name"||e==="content"||e==="regex"}function Vb(){return ut(Gu,qb)??"name"}function Zu(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:Ct(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function Kb(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(r=>r===null||typeof r=="string")}function ef(){return ut(Vu,Kb)??{}}function qd(e){if(!e)return;const r=ef();return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function ki(e,r){e&&Tt(Vu,{...ef(),[e]:r})}function Yb(e,r){if(!r)return null;const s=new Set((e.repoFilters??[]).map(i=>i.root));return s.has(r)?r:s.size>0?null:(e.repositories??[]).some(i=>i.root===r)?r:null}function Xi(e){return!e.activeGitRepoRoot&&(e.groupCount>1||e.label!==e.rootName)}function tf(...e){const r=new Set;for(const s of e)for(const i of s)r.add(i.root);return r}function Ji(e){return Array.isArray(e)&&e.every(r=>typeof r=="string")}function Vd(e){const r=ut(e,Ji);return r?new Set(r):new Set}function Si(e,r){Tt(e,[...r])}function Xb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.filePath=="string"&&typeof r.hunkHeader=="string"&&typeof r.hunkIndex=="number"&&typeof r.fingerprint=="string"&&typeof r.additions=="number"&&typeof r.deletions=="number"&&typeof r.diff=="string"&&(r.oldPath===void 0||r.oldPath===null||typeof r.oldPath=="string")&&(r.newPath===void 0||r.newPath===null||typeof r.newPath=="string")&&(r.source===void 0||r.source==="committed"||r.source==="uncommitted"||r.source==="unknown")&&(r.commit===void 0||r.commit===null||typeof r.commit=="string")}function Jb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.available=="boolean"&&(r.repoRoot===void 0||typeof r.repoRoot=="string")&&(r.workspaceRoot===void 0||typeof r.workspaceRoot=="string")&&(r.baseRef===void 0||typeof r.baseRef=="string")&&(r.baseBranch===void 0||typeof r.baseBranch=="string")&&(r.currentBranch===void 0||r.currentBranch===null||typeof r.currentBranch=="string")&&(r.headRef===void 0||r.headRef===null||typeof r.headRef=="string")&&(r.diffFingerprint===void 0||typeof r.diffFingerprint=="string")&&(r.stat===void 0||typeof r.stat=="string")&&(r.files===void 0||Ji(r.files))&&(r.hunks===void 0||Array.isArray(r.hunks)&&r.hunks.every(Xb))&&(r.commits===void 0||Ji(r.commits))&&(r.commitCount===void 0||typeof r.commitCount=="number")&&(r.diff===void 0||typeof r.diff=="string")&&(r.truncated===void 0||typeof r.truncated=="boolean")&&(r.error===void 0||typeof r.error=="string")}function Qb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.key=="string"&&Jb(r.diff)&&typeof r.repoLabel=="string"&&typeof r.createdAt=="number"}function Zb(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(r=>{if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(i=>typeof i=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(i=>typeof i=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(i=>typeof i=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(Qb))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(i=>typeof i=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Kd(){return ut(qu,Zb)??{}}function Yd(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function Xd(e){const r=e?.trim()??"",s=r.indexOf("/");return s>=0?r.slice(s+1):r}function rf(e,r){const s=e?.trim(),i=r?.trim();return!s||!i?!1:s===i||Xd(s)===Xd(i)}function Jd(e){const r=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(i=>i&&!rf(i,r))??""}function Qi(e,r){const s=Math.max(Hd,r-320),i=Math.min(Db,s);return Math.min(i,Math.max(Hd,e))}function ex(e){return typeof e=="number"&&Number.isFinite(e)}function tx(e){return Qi(ut($s,ex)??Yi,e)}function nf(e){const r=e.split(/[\\/]/).pop()??e,s=r.lastIndexOf(".");return s>=0?r.slice(s).toLowerCase():""}function As(e){return Fb.has(nf(e))}function sf(e){const r=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(r)||/^\*{3,}$/.test(r)||/^_{3,}$/.test(r)}function Zi(e){const r=e.trim();return/^#{1,6}\s+/.test(r)||sf(e)||/^>\s?/.test(r)||/^(```|~~~)/.test(r)||/^(?:[-+*]|\d+[.)])\s+/.test(r)}function af(e){const r=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(r)||!/^[a-z][a-z0-9+.-]*:/i.test(r)&&!/[<>]/.test(r)?r:null}const of=a.createContext(null);function Qa(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function lf(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function cf(e){return e.replace(/\s+#+\s*$/,"").trim()}function el(e,r){const i=lf(e).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=r.headingSlugCounts.get(i)??0;return r.headingSlugCounts.set(i,d+1),d===0?i:`${i}-${d}`}function Qd(e){return lf(e)||e.trim()}function so(e){const r=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!r)return null;const s=rl(r[2]);return s?{id:Qa(r[1]),definition:{href:s.href,title:s.title}}:null}function rx(e){const r=new Map;for(const s of e){const i=so(s);i&&r.set(i.id,i.definition)}return r}function df(e){return e.trim().toLowerCase()}function uf(e){const r=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return r?{id:df(r[1]),text:r[2]}:null}function nx(e){const r=new Map;let s=null;for(const i of e){const d=uf(i);if(d){s=d.id,r.set(d.id,{id:d.id,text:d.text,index:r.size+1});continue}if(s&&/^\s{4,}\S/.test(i)){const c=r.get(s);c&&(c.text=`${c.text} ${i.trim()}`);continue}i.trim()&&(s=null)}return r}function ff(e){const r=new Set;let s=!1;return e.forEach((i,d)=>{if(uf(i)){r.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(i)){r.add(d);return}i.trim()&&(s=!1)}),r}function sx(e){const r=[...e];let s=0;const i=e[0]?.trim();if(i==="---"||i==="+++"){for(r[0]="",s=1;s<e.length&&e[s].trim()!==i;)r[s]="",s+=1;s<e.length&&(r[s]="",s+=1)}for(;s<e.length;){const d=e[s].trim();if(d.startsWith("<!--")){if(r[s]="",!d.includes("-->")){for(s+=1;s<e.length&&!e[s].includes("-->");)r[s]="",s+=1;s<e.length&&(r[s]="")}s+=1;continue}s+=1}return r}function hf(e){const r=e.replace(/\/+$/,""),s=r.lastIndexOf("/");return s<=0?s===0?"/":"":r.slice(0,s)}function _s(e){const r=e.split(/[?#]/,1)[0],s=r.startsWith("/"),i=[];for(const c of r.split("/"))if(!(!c||c===".")){if(c===".."){i.length>0&&i.pop();continue}i.push(c)}return`${s?"/":""}${i.join("/")}`||(s?"/":".")}function pl(e,r,s){const i=e.trim();if(!i||/^(?:https?:|mailto:|javascript:|data:)/i.test(i)||/^[a-z][a-z0-9+.-]*:/i.test(i))return null;if(i.startsWith("#")){if(!r)return null;try{return{path:r,fragment:decodeURIComponent(i.slice(1))||null,directory:!1}}catch{return null}}const d=i.indexOf("#"),c=d>=0?i.slice(0,d):i,h=d>=0?i.slice(d+1):"",m=c.split("?",1)[0];if(!m)return null;let p,g=null;try{p=decodeURIComponent(m),g=h?decodeURIComponent(h):null}catch{return null}const f=s?_s(s):null;let S;if(p.startsWith("/")){const v=f&&(p===f||p.startsWith(`${f}/`));S=_s(f&&!v?`${f}/${p.slice(1)}`:p)}else{if(!r)return null;S=_s(`${hf(r)}/${p}`)}return f&&S!==f&&!S.startsWith(`${f}/`)?null:{path:S,fragment:g,directory:/\/$/.test(m)}}function gl(e,r,s,i,d){const c=e.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!i(c.split(/[?#]/,1)[0]))return null;let h;if(c.startsWith("/")){const m=s&&(c===s||c.startsWith(`${s}/`));h=_s(s&&!m?`${s}/${c.slice(1)}`:c)}else{if(!r)return null;h=_s(`${hf(r)}/${c}`)}return d(h)}function ax(e,r,s){return gl(e,r,s,dl,i=>`/api/terminal/fs/blob?path=${encodeURIComponent(i)}`)}function ox(e,r,s){return gl(e,r,s,uu,fu)}const tl=128,ix=360,ji=480;function ho(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function mf(e,r,s,i,d=0){if(!r||!s)return null;let c,h;return d>0?(c=i>0?Math.min(d,i):d,h=s*c/r):ho(e)?(h=Math.min(Math.max(s,tl),ix),c=r*h/s):(c=r,h=s),i>0&&c>i&&(h=h*i/c,c=i),h>ji&&(c=c*ji/h,h=ji),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(h))}}function lx(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function pf(e){const r=lx(e),s=ne(i=>r?(i.fileChangeVersions.get(r)??0)+i.fileWatchEpoch:0);return r&&s>0?`${e}&v=${s}`:e}function cx({src:e,alt:r,title:s,requestedWidthPx:i}){const d=ho(e),c=pf(e),h=uo(c),m=a.useRef(null),[p,g]=a.useState(!1),[f,S]=a.useState(0),[v,P]=a.useState({status:"loading"}),[N,F]=a.useState(null);a.useLayoutEffect(()=>{const M=m.current,L=M?.parentElement?.parentElement??M?.parentElement;if(!L)return;const T=()=>S(L.clientWidth);if(T(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(T);return B.observe(L),()=>B.disconnect()},[]),a.useEffect(()=>{if(p)return;const M=m.current;if(!M||typeof IntersectionObserver>"u"){g(!0);return}const L=new IntersectionObserver(T=>{T.some(B=>B.isIntersecting)&&(g(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(M),()=>L.disconnect()},[p]),a.useEffect(()=>{if(!p)return;const M=new AbortController;let L=null;P({status:"loading"});const T=window.setTimeout(()=>{M.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Em(c,{signal:M.signal}).then(async B=>{if(!B.ok)throw new Error(`HTTP ${B.status}`);const _=Number(B.headers.get("X-Image-Width"))||0,o=Number(B.headers.get("X-Image-Height"))||0;return{blob:await B.blob(),width:_,height:o}}).then(({blob:B,width:_,height:o})=>{M.signal.aborted||(L=URL.createObjectURL(B),_>0&&o>0&&F({width:_,height:o}),P({status:"ready",objectUrl:L}))}).catch(()=>{const B=M.signal.reason;M.signal.aborted&&!(B instanceof DOMException&&B.name==="TimeoutError")||P({status:"fallback"})}).finally(()=>{window.clearTimeout(T)}),()=>{window.clearTimeout(T),M.abort(),L&&URL.revokeObjectURL(L)}},[p,c]);const z=mf(e,N?.width??0,N?.height??0,f,i??0),A=z??(i?{width:f>0?Math.min(i,f):i,height:Math.round(i*.75)}:{width:tl*2,height:tl});return t.jsx("div",{ref:m,className:"block max-w-full",style:z?{width:z.width,height:z.height}:void 0,children:v.status==="ready"?t.jsx("img",{src:v.objectUrl,alt:r,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:z?{width:z.width,height:z.height}:void 0,onLoad:M=>{if(N)return;const L=M.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):v.status==="fallback"?t.jsx("img",{src:h,alt:r,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:z?{width:z.width,height:z.height}:void 0,onLoad:M=>{if(N)return;const L=M.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):t.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:A.width,height:A.height},children:t.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:r||"…"})})})}function Ds(e,r,s,i,d,c){const h=ax(s,d.markdownFilePath,d.rootPath);if(!h)return c?.fallbackText??`![${r}](${s})`;const m=d.images.length;d.images.push({kind:"image",src:h,alt:r,title:i});const p=t.jsx(cx,{src:h,alt:r,title:i,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?t.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:i||r||"Open image",onClick:g=>{g.stopPropagation(),d.onImageOpen?.(m)},children:p},e):t.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:p},e)}function Ri(e){let r=e,s="";for(;/[.,;:!?)]$/.test(r);)s=`${r.slice(-1)}${s}`,r=r.slice(0,-1);return{linkText:r,suffix:s}}function Zd(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function rl(e){const r=e.trim(),s=r.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const i=r.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return i?{href:i[1],title:i[2]??i[3]??i[4]}:null}const gf="",dx=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function ux(e){return e.replace(dx,(r,s)=>`${gf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function eu(e){return e.replace(new RegExp(`${gf}([0-9a-f]{4})`,"g"),(r,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function fx(e){const r=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(r)&&/[^ ]/.test(r.slice(1,-1))?r.slice(1,-1):r}const bf={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let Ha=null;function xf(){return Ha||(Ha=Fs(()=>import("./purify.es-4eNOHKSq.js"),[]).then(e=>e.default??e).catch(e=>{throw Ha=null,e})),Ha}function yf({html:e}){const{t:r}=Nt(),[s,i]=a.useState(null);return a.useEffect(()=>{let d=!1;return i(null),xf().then(c=>{d||i(c.sanitize(e,bf))}).catch(()=>{d||i("")}),()=>{d=!0}},[e]),s===null?t.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:r("rightSidebar.renderingHtml")}):s?t.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function hx({html:e}){const[r,s]=a.useState(null);return a.useEffect(()=>{let i=!1;return s(null),xf().then(d=>{i||s(d.sanitize(e,bf))}).catch(()=>{i||s("")}),()=>{i=!0}},[e]),r===null?null:r?t.jsx("span",{dangerouslySetInnerHTML:{__html:r}}):e}function vf(e){const r=e.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!r)return null;const s=r[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(e)}}let Wa=null;function mx(){return Wa||(Wa=Promise.all([Fs(()=>import("./katex-DnlPpQZa.js"),[]),Fs(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([e])=>e.default??e).catch(e=>{throw Wa=null,e})),Wa}function Us({tex:e,display:r=!1}){const[s,i]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let m=!1;return i(null),c(!1),mx().then(p=>{m||i(p.renderToString(e,{displayMode:r,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||c(!0)}),()=>{m=!0}},[r,e]),d)return t.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:r?`$$${e}$$`:`$${e}$`});if(!s)return t.jsx("span",{className:"text-muted-foreground/70",children:r?"Rendering formula...":e});const h=r?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return t.jsx("span",{className:h,dangerouslySetInnerHTML:{__html:s}})}function bl(e){const r=new Map;for(const s of e.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))r.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return r}function tu(e){const r=bl(e),s=r.get("src")?.trim()??"",i=r.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:r.get("alt"),title:r.get("title"),widthPx:i?Number(i[1]):void 0}}function px(e){const r=e.indexOf(">"),s=r<0?e:e.slice(0,r+1),i=bl(s),d=i.get("src")?.trim()??"",c=i.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),m=r<0?"":e.slice(r+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:m,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function gx({url:e,fallbackText:r,widthPx:s,hasControls:i}){const{t:d}=Nt(),[c,h]=a.useState(!1),m=uo(e,()=>h(!0));return m?t.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c?t.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:r?.trim()||d("rightSidebar.videoUnsupported")}):t.jsx("video",{className:"block max-w-full",src:m,style:s?{width:`${s}px`}:void 0,controls:i,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function bx(e,r,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(e)){const h=e.slice(0,e.indexOf(">")+1),m=bl(h).get("href")?.trim()??"",p=e.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:g,alt:f,title:S,widthPx:v}=tu(p);if(!g)return null;const P=gl(g,s.markdownFilePath,s.rootPath,dl,M=>M);if(!P)return null;const N=m?pl(m,s.markdownFilePath,s.rootPath):null,z=!!!(N&&N.path===P)&&m?af(m):null,A=Ds(r,f??"",g,S,s,{requestedWidthPx:v,interactive:z?!1:void 0});return z?t.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:A},r):A}if(/^<\s*img\b[^>]*>$/i.test(e)){const{src:h,alt:m,title:p,widthPx:g}=tu(e);return h?Ds(r,m??"",h,p,s,{fallbackText:e,requestedWidthPx:g}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(e)){const{src:h,fallbackText:m,widthPx:p,controls:g}=px(e);if(!h)return null;const f=ox(h,s.markdownFilePath,s.rootPath);return f?t.jsx(gx,{url:f,fallbackText:m,widthPx:p,hasControls:g},r):null}if(/^<br\s*\/?>$/i.test(e))return t.jsx("br",{},r);const i=e.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!i)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(e)?t.jsx(hx,{html:e},r):null;const d=i[1].toLowerCase(),c=ft(i[2],`${r}-${d}`,!0,s);return d==="kbd"?t.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:c},r):d==="mark"?t.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},r):d==="sub"?t.jsx("sub",{children:c},r):t.jsx("sup",{children:c},r)}function ft(e,r,s=!0,i){const d=ux(e),c=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<\s*img\b[^>]*>|<\s*video\b[^>]*>[\s\S]*?<\/video\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let m=0,p;for(;(p=c.exec(d))!==null;){p.index>m&&h.push(eu(d.slice(m,p.index)));const g=p[0],f=`${r}-${p.index}`,S=g.startsWith("<")?bx(g,f,i):null;if(S)h.push(S);else if(g.startsWith("\\(")&&g.endsWith("\\)"))h.push(t.jsx(Us,{tex:g.slice(2,-2)},f));else if(g.startsWith("$")&&g.endsWith("$"))h.push(t.jsx(Us,{tex:g.slice(1,-1)},f));else if(g.startsWith("`")){const v=g.match(/^`+/)?.[0].length??1;h.push(t.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:fx(g.slice(v,-v))},f))}else if(g.startsWith("~~"))h.push(t.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ft(g.slice(2,-2),`${f}-del`,s,i)},f));else if(g.startsWith("**")||g.startsWith("__"))h.push(t.jsx("strong",{className:"font-semibold text-foreground",children:ft(g.slice(2,-2),`${f}-strong`,s,i)},f));else if(g.startsWith("*")||g.startsWith("_"))h.push(t.jsx("em",{className:"italic",children:ft(g.slice(1,-1),`${f}-em`,s,i)},f));else if(g.startsWith("![")){const v=g.match(/^!\[([^\]]*)\]\((.*)\)$/),P=g.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),N=g.match(/^!\[([^\]]+)\]$/);if(v){const F=rl(v[2]);h.push(F?Ds(f,v[1],F.href,F.title,i):g)}else if(P){const F=P[2]||P[1],z=i.referenceDefinitions.get(Qa(F));h.push(z?Ds(f,P[1],z.href,z.title,i):g)}else if(N){const F=i.referenceDefinitions.get(Qa(N[1]));h.push(F?Ds(f,N[1],F.href,F.title,i):g)}else h.push(g)}else if(g.startsWith("[^")){const v=df(g.slice(2,-1)),P=i.footnoteDefinitions.get(v);h.push(P?t.jsx("sup",{id:`fnref-${P.id}`,title:P.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:t.jsx("a",{href:`#fn-${P.id}`,className:"text-primary no-underline",children:P.index})},f):g)}else if(g.startsWith("<http")){const v=g.slice(1,-1);h.push(t.jsx("a",{href:v,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f))}else if(g.startsWith("<")&&g.endsWith(">")&&Zd(g.slice(1,-1))){const v=g.slice(1,-1);h.push(t.jsx("a",{href:`mailto:${v}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f))}else if(Zd(Ri(g).linkText)){const{linkText:v,suffix:P}=Ri(g);h.push(t.jsx("a",{href:`mailto:${v}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f)),P&&h.push(P)}else if(g.startsWith("http")||g.startsWith("www.")){const{linkText:v,suffix:P}=Ri(g),N=v.startsWith("www.")?`https://${v}`:v;h.push(t.jsx("a",{href:N,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f)),P&&h.push(P)}else{const v=g.match(/^\[([^\]]+)\]\((.*)\)$/),P=g.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),N=g.match(/^\[([^\]]+)\]$/),F=P?P[2]||P[1]:N?.[1]??null,z=F?i.referenceDefinitions.get(Qa(F)):null,A=v?rl(v[2]):null,M=A?.href??z?.href??null,L=M?af(M):null,T=v?.[1]??P?.[1]??N?.[1]??"";h.push(L?t.jsx("a",{href:L,title:A?.title??z?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ft(T,`${f}-link`,s,i)},f):g)}m=c.lastIndex}return m<d.length&&h.push(eu(d.slice(m))),h.length>0?h:[e]}function wf(e){return/(?: {2,}|\\)$/.test(e)}function kf(e){return e.replace(/(?: {2,}|\\)$/,"")}function ao(e){return/^(?: {4}|\t)/.test(e)}function Sf(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function jf(e,r,s){const i=[];return e.forEach((d,c)=>{const h=wf(d);i.push(...ft(kf(d),`${r}-${c}`,!0,s)),c<e.length-1&&i.push(h?t.jsx("br",{},`${r}-${c}-br`):" ")}),i}function nl(e,r,s){const i=[],d=[];return e.forEach((c,h)=>{d.push(wf(c)),i.push(ft(kf(c),`${r}-${h}`,!0,s))}),{perLine:i,hardBreaks:d}}function sl(e,r,s,i,d){const c=[];return e.forEach((h,m)=>{const p=s[m]??0,g=!!(d&&p>=d.start&&p<=d.end);c.push(t.jsx("span",{"data-md-ref-start":p,"data-md-ref-end":p,"data-selected":g?"true":void 0,children:h},`${i}-ref-${m}`)),m<e.length-1&&c.push(r[m]?t.jsx("br",{},`${i}-${m}-br`):" ")}),c}function zs(e){const r=e.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let i="",d=!1,c=0,h=0;for(let m=0;m<r.length;m+=1){const p=r[m];if(d){i+=p,d=!1;continue}if(p==="\\"){d=!0;continue}if(p==="`"){const g=m;for(;m+1<r.length&&r[m+1]==="`";)m+=1;const f=m-g+1;i+="`".repeat(f),c===0?c=f:c===f&&(c=0);continue}if(c===0&&p==="["?h+=1:c===0&&p==="]"&&h>0&&(h-=1),p==="|"&&c===0&&h===0){s.push(i.trim()),i="";continue}i+=p}return d&&(i+="\\"),s.push(i.trim()),s}function Rf(e){return zs(e).map(r=>/^:-+:$/.test(r)?"center":/^-+:$/.test(r)?"right":/^:-+$/.test(r)?"left":null)}function oo(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function io(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function Cf(e,r){return e>96||e>44&&r>.35}function mo(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Hs(e){const r=e.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!r)return null;const s=/^\d+[.)]$/.test(r[1]);return{ordered:s,start:s?Number.parseInt(r[1],10):void 0,content:r[2]}}function xl(e,r,s,i,d,c=new Set){const h=[],m=[];let p=r;for(;p<e.length;){const g=e[p];if(d&&(so(g)||c.has(p))){p+=1;continue}const f=Hs(g),S=mo(g);if(!f){if(S>s&&m.length>0){([...m].reverse().find(F=>F.indent<S)?.item??m[m.length-1].item).paragraphs.push(g.trim());for(const F of m)F.item.lineEnd=p+1;p+=1;continue}break}if(S<s||S===s&&f.ordered!==i)break;const v={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:p+1,lineEnd:p+1};for(;m.length>0&&m[m.length-1].indent>=S;)m.pop();const P=m[m.length-1]?.item??null;P?P.children.push(v):h.push(v),m.push({indent:S,item:v});for(const N of m)N.item.lineEnd=p+1;p+=1}return{items:h,nextIndex:p}}function xx(e){const r=e.find(i=>Hs(i));if(!r)return[];const s=Hs(r);return s?xl(e,0,mo(r),s.ordered,!0,ff(e)).items:[]}function yl(e,r,s,i=0){return e.map((d,c)=>{const h=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!h,refStart:d.lineStart+i,refEnd:d.lineEnd+i,content:t.jsxs(t.Fragment,{children:[h?t.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ft(h?.[2]??d.content,`li-${r}-${c}`,!0,s),d.paragraphs.length>0&&t.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((m,p)=>t.jsx("p",{children:ft(m,`li-${r}-${c}-p-${p}`,!0,s)},`paragraph-${p}`))})]}),groups:yx(d.children,`${r}-${c}`,s,i)}})}function yx(e,r,s,i=0){const d=[];for(const c of e){const h=d[d.length-1];h&&h.ordered===c.ordered?h.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,h)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:yl(c.items,`${r}-g${h}`,s,i)}))}function vl(e,r){return e.map(s=>{const i=!!(r&&s.refStart<=r.end&&s.refEnd>=r.start);return t.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":i?"true":void 0,children:[s.content,s.groups.length>0&&vx(s.groups,r)]},s.key)})}function vx(e,r){return e.map((s,i)=>{const d=s.ordered?"ol":"ul";return t.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:vl(s.items,r)},`nested-${i}`)})}function wx(e){const r=Array.from(e.footnoteDefinitions.values()).sort((s,i)=>s.index-i.index);return r.length===0?null:t.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.footnotesLabel}),t.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:r.map(s=>t.jsxs("li",{id:`fn-${s.id}`,children:[ft(s.text,`footnote-${s.id}`,!0,e)," ",t.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":e.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function kx(e,r,s,i){const d=[];let c=0;const h=m=>i?.[m]??m+1;for(;c<e.length;){const m=e[c],p=m.trim();if(!p){c+=1;continue}if(/^<details>\s*$/i.test(p)){const A=c;let M="Details";const L=[];for(c+=1;c<e.length&&!/^<\/details>\s*$/i.test(e[c].trim());){const T=e[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);T?M=T[1].trim()||M:L.push(e[c].trimStart()),c+=1}c<e.length&&(c+=1),d.push({kind:"static",node:t.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ft(M,`${r}-details-${A}-summary`,!0,s)}),L.length>0&&t.jsx("div",{className:"mt-2 text-sm leading-6",children:jf(L,`${r}-details-${A}`,s)})]},`${r}-details-${A}`)});continue}const g=vf(m);if(g){const A=[m],M=c;for(c+=1;c<e.length&&!g.selfContained&&!new RegExp(`</${g.tag}>`,"i").test(e[c]);)A.push(e[c]),c+=1;c<e.length&&!g.selfContained&&(A.push(e[c]),c+=1),d.push({kind:"static",node:t.jsx(yf,{html:A.join(`
1639
+ `)},`${r}-html-${M}`)});continue}const f=p.match(/^(```|~~~)\s*(.*)$/);if(f){const A=[],M=f[1],L=f[2]?.trim(),T=c;for(c+=1;c<e.length&&!e[c].trim().startsWith(M);)A.push(e[c]),c+=1;c<e.length&&(c+=1),L.toLowerCase()==="mermaid"?d.push({kind:"static",node:t.jsx(Ef,{code:A.join(`
1640
+ `),blockKey:`${r}-code-${T}`},`${r}-code-${T}`)}):["math","latex","tex"].includes(L.toLowerCase())?d.push({kind:"static",node:t.jsx(Us,{tex:A.join(`
1641
+ `),display:!0},`${r}-code-${T}`)}):d.push({kind:"code",key:`${r}-code-${T}`,code:A.join(`
1642
+ `),lang:L,blockKey:`${r}-code-${T}`,codeStartLine:h(T)+1});continue}if(ao(m)){const A=[],M=c;for(;c<e.length&&(ao(e[c])||!e[c].trim());)A.push(e[c].trim()?Sf(e[c]):""),c+=1;d.push({kind:"code",key:`${r}-indented-code-${M}`,code:A.join(`
1643
+ `).replace(/\n+$/,""),lang:"",blockKey:`${r}-indented-code-${M}`,codeStartLine:h(M)});continue}const S=p.match(/^(#{1,6})\s+(.+)$/);if(S){const M=`h${Math.min(6,S[1].length+1)}`,L=cf(S[2]),T=el(L,s);d.push({kind:"static",node:t.jsx(M,{id:T,className:"scroll-mt-16 font-semibold text-foreground",children:ft(L,`${r}-heading-${c}`,!0,s)},`${r}-heading-${c}`)}),c+=1;continue}if(c+1<e.length&&m.includes("|")&&io(e[c+1])){const A=zs(m),M=Rf(e[c+1]),L=[],T=c;for(c+=2;c<e.length&&e[c].includes("|")&&e[c].trim();)L.push(zs(e[c])),c+=1;d.push({kind:"static",node:t.jsx("div",{className:Ju,"data-markdown-table-scroll":!0,children:t.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[t.jsx("thead",{className:"bg-surface-2 text-foreground",children:t.jsx("tr",{children:A.map((B,_)=>t.jsx("th",{className:`${Yu} ${oo(M[_]??null)}`,children:t.jsx("div",{className:no,children:ft(B,`${r}-th-${T}-${_}`,!0,s)})},`h-${_}`))})}),t.jsx("tbody",{children:L.map((B,_)=>t.jsx("tr",{className:"border-t border-border/10",children:A.map((o,w)=>t.jsx("td",{className:`${Xu} ${oo(M[w]??null)}`,children:t.jsx("div",{className:no,children:ft(B[w]??"",`${r}-td-${T}-${_}-${w}`,!0,s)})},`c-${w}`))},`r-${_}`))})]})},`${r}-table-${T}`)});continue}const v=Hs(m);if(v){const A=v.ordered,M=mo(m),L=v.start,T=c,B=xl(e,c,M,A,!1);c=B.nextIndex,d.push({kind:"list",keyPrefix:`${r}-list-${T}`,ordered:A,start:A?L:void 0,renders:yl(B.items,`${r}-list-${T}`,s,h(0)-1)});continue}const P=[m.trimStart()],N=[h(c)],F=c;for(c+=1;c<e.length&&e[c].trim()&&!Zi(e[c])&&!(c+1<e.length&&e[c].includes("|")&&io(e[c+1]));)P.push(e[c].trimStart()),N.push(h(c)),c+=1;const z=nl(P,`${r}-p-${F}`,s);d.push({kind:"paragraph",keyPrefix:`${r}-p-${F}`,perLine:z.perLine,hardBreaks:z.hardBreaks,lineNums:N})}return d}function Sx(e,r){return e.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return t.jsx("p",{children:sl(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,r)},s.keyPrefix);case"list":{const i=s.ordered?"ol":"ul";return t.jsx(i,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:vl(s.renders,r)},s.keyPrefix)}case"code":return t.jsx(lo,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:r},s.key)}})}let Ga=null,ru=!1;const qa=16,Nf=192;function jx(){return Ga||(Ga=Fs(()=>import("./mermaid.core-DXBQ8sgL.js").then(e=>e.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(e=>e.default??e).catch(e=>{throw Ga=null,e})),Ga}function Rx(e){ru||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),ru=!0)}function Cx(e){const r=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!r)return e;const[,,s]=r,i=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=i;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return e;const h=Math.max(Nf,Math.ceil(d)),m=Math.ceil(h/d*c);return e.replace(/<svg\b([^>]*)>/i,(p,g)=>`<svg${g.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function Nx(e){const r=e?.querySelector("svg");if(!r)return;let s;try{s=r.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const i=s.x-qa,d=s.y-qa,c=s.width+qa*2,h=s.height+qa*2,m=Math.max(Nf,Math.ceil(c)),p=Math.ceil(m/c*h);r.setAttribute("viewBox",`${i} ${d} ${c} ${h}`),r.setAttribute("width",String(m)),r.setAttribute("height",String(p)),r.removeAttribute("style")}function Ex(e){const r=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!r)return null;const s=r.replace(/^language-/,"");return vu(`code.${s}`)??s}function Ef({code:e,blockKey:r}){const{t:s}=Nt(),[i,d]=a.useState(null),[c,h]=a.useState(!1),m=a.useRef(null),p=a.useContext(of);a.useEffect(()=>{let f=!1;return d(null),h(!1),jx().then(async S=>{Rx(S);const v=`termdock-md-mermaid-${r.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:P}=await S.render(v,e);f||d(Cx(P))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[r,e]),a.useLayoutEffect(()=>{i&&Nx(m.current)},[i]);const g=a.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??i;f&&p?.(f)},[p,i]);return c?t.jsx(lo,{code:e,lang:"mermaid",blockKey:`${r}-fallback`}):t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[t.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),t.jsx("div",{className:"bg-surface p-3",children:i?t.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),g()},children:t.jsx("span",{ref:m,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:i}})}):t.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function lo({code:e,lang:r,blockKey:s,codeStartLine:i,lineRange:d}){const c=Ex(r),[h,m]=a.useState(null);a.useEffect(()=>{if(!c||!wu(e)){m(null);return}let g=!1;return ku().then(f=>{if(g||!f.registered(c)){g||m(null);return}try{m(Su(f,e,c))}catch{g||m(null)}}).catch(()=>{g||m(null)}),()=>{g=!0}},[s,e,c]);const p=h??(e||" ").split(`
1644
+ `).map(g=>[g||" "]);return t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[r&&t.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:r}),t.jsx("pre",{className:`${ml} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:t.jsx("code",{children:p.map((g,f)=>{const S=i!=null?i+f:null,v=!!(d&&S!=null&&S>=d.start&&S<=d.end);return t.jsxs("span",{"data-md-ref-start":S??void 0,"data-md-ref-end":S??void 0,"data-selected":v?"true":void 0,children:[g,f<p.length-1?`
1645
+ `:null]},`${s}-line-${f}`)})})})]})}function wl(e,r,s,i,d){e=sx(e);const c=rx(e),h=ff(e),m=[],p={markdownFilePath:r,rootPath:s,referenceDefinitions:c,footnoteDefinitions:nx(e),headingSlugCounts:new Map,images:m,onImageOpen:i,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(v=>`Back to footnote ${v}`)},g=[];let f=0;for(;f<e.length;){const v=e[f],P=v.trim();if(so(v)||h.has(f)){f+=1;continue}if(!P){f+=1;continue}if(/^<details>\s*$/i.test(P)){const _=f;let o="Details";const w=[];for(f+=1;f<e.length&&!/^<\/details>\s*$/i.test(e[f].trim());){const O=e[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);O?o=O[1].trim()||o:w.push(e[f].trimStart()),f+=1}f<e.length&&(f+=1),g.push({key:`details-${_}`,startLine:_+1,endLine:f,content:t.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ft(o,`details-${_}-summary`,!0,p)}),w.length>0&&t.jsx("div",{className:"mt-2 text-sm leading-6",children:jf(w,`details-${_}`,p)})]})});continue}const N=vf(v);if(N){const _=[v],o=f;for(f+=1;f<e.length&&!N.selfContained&&!new RegExp(`</${N.tag}>`,"i").test(e[f]);)_.push(e[f]),f+=1;f<e.length&&!N.selfContained&&(_.push(e[f]),f+=1),g.push({key:`html-${o}`,startLine:o+1,endLine:f,content:t.jsx(yf,{html:_.join(`
1646
+ `)})});continue}const F=P.match(/^(```|~~~)\s*(.*)$/);if(F){const _=[],o=F[1],w=F[2]?.trim(),O=f;for(f+=1;f<e.length&&!e[f].trim().startsWith(o);)_.push(e[f]),f+=1;f<e.length&&(f+=1),g.push({key:`code-${O}`,startLine:O+1,endLine:f,fineGrained:w.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(w.toLowerCase()),content:w.toLowerCase()==="mermaid"?t.jsx(Ef,{code:_.join(`
1647
+ `),blockKey:`code-${O}`}):["math","latex","tex"].includes(w.toLowerCase())?t.jsx(Us,{tex:_.join(`
1648
+ `),display:!0}):j=>t.jsx(lo,{code:_.join(`
1649
+ `),lang:w,blockKey:`code-${O}`,codeStartLine:O+2,lineRange:j})});continue}if(ao(v)){const _=[],o=f;for(f+=0;f<e.length&&(ao(e[f])||!e[f].trim());)_.push(e[f].trim()?Sf(e[f]):""),f+=1;g.push({key:`indented-code-${o}`,startLine:o+1,endLine:f,fineGrained:!0,content:w=>t.jsx(lo,{code:_.join(`
1650
+ `).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${o}`,codeStartLine:o+1,lineRange:w})});continue}if(P.startsWith("$$")){const _=[],o=f,w=P.replace(/^\$\$\s*/,"");if(w.endsWith("$$")&&w.length>2)_.push(w.replace(/\s*\$\$$/,"")),f+=1;else{for(w&&_.push(w),f+=1;f<e.length&&!e[f].trim().endsWith("$$");)_.push(e[f]),f+=1;if(f<e.length){const O=e[f].trim().replace(/\s*\$\$$/,"");O&&_.push(O),f+=1}}g.push({key:`math-${o}`,startLine:o+1,endLine:f,content:t.jsx(Us,{tex:_.join(`
1651
+ `),display:!0})});continue}if(f+1<e.length&&P&&!Zi(v)&&/^(=+|-+)\s*$/.test(e[f+1].trim())){const _=e[f+1].trim().startsWith("=")?1:2,o=`h${_}`,w=el(P,p),O={level:_,text:Qd(P),id:w};g.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:O,content:t.jsx(o,{id:w,className:`scroll-mt-16 font-semibold text-foreground ${_===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:ft(P,`setext-heading-${f}`,!0,p)})}),f+=2;continue}const z=P.match(/^(#{1,6})\s+(.+)$/);if(z){const _=z[1].length,o=cf(z[2]),w={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},O=`h${_}`,j=el(o,p),X={level:_,text:Qd(o),id:j};g.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:X,content:t.jsx(O,{id:j,className:`scroll-mt-16 font-semibold text-foreground ${w[_]}`,children:ft(o,`heading-${f}`,!0,p)})}),f+=1;continue}if(sf(v)){g.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:t.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(P.startsWith(">")){const _=[],o=[],w=f;for(;f<e.length&&/^>\s?/.test(e[f].trim());)_.push(e[f].trim().replace(/^>\s?/,"")),o.push(f+1),f+=1;const O=_[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const X=O[1].toUpperCase(),se=O[2]?.trim(),ie=[...se?[se]:[],..._.slice(1)],pe=[...se?[o[0]]:[],...o.slice(1)],q=nl(ie,`callout-${w}`,p);g.push({key:`callout-${w}`,startLine:w+1,endLine:f,fineGrained:!0,content:Z=>t.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:X}),ie.length>0&&t.jsx("div",{children:sl(q.perLine,q.hardBreaks,pe,`callout-${w}`,Z)})]})});continue}const j=kx(_,`quote-${w}`,p,o);g.push({key:`quote-${w}`,startLine:w+1,endLine:f,fineGrained:!0,content:X=>t.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:Sx(j,X)})});continue}if(f+1<e.length&&v.includes("|")&&io(e[f+1])){const _=zs(v),o=Rf(e[f+1]),w=[],O=f;for(f+=2;f<e.length&&e[f].includes("|")&&e[f].trim();)w.push(zs(e[f])),f+=1;const j=_.map((se,ie)=>ft(se,`th-${O}-${ie}`,!0,p)),X=w.map((se,ie)=>_.map((pe,q)=>ft(se[q]??"",`td-${O}-${ie}-${q}`,!0,p)));g.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:se=>{const ie=pe=>!!(se&&pe>=se.start&&pe<=se.end);return t.jsx("div",{className:Ju,"data-markdown-table-scroll":!0,children:t.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[t.jsx("thead",{className:"bg-surface-2 text-foreground",children:t.jsx("tr",{"data-markdown-table-row-line":O+1,"data-md-ref-start":O+1,"data-md-ref-end":O+1,"data-selected":ie(O+1)?"true":void 0,children:j.map((pe,q)=>t.jsx("th",{className:`${Yu} ${oo(o[q]??null)}`,children:t.jsx("div",{className:no,children:pe})},`h-${q}`))})}),t.jsx("tbody",{children:X.map((pe,q)=>{const Z=O+q+3;return t.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":Z,"data-md-ref-start":Z,"data-md-ref-end":Z,"data-selected":ie(Z)?"true":void 0,children:_.map(($,U)=>t.jsx("td",{className:`${Xu} ${oo(o[U]??null)}`,children:t.jsx("div",{className:no,children:pe[U]})},`c-${U}`))},`r-${q}`)})})]})})}});continue}const A=Hs(v);if(A){const _=A.ordered,o=mo(v),w=A.start,O=f,j=xl(e,f,o,_,!0,h);f=j.nextIndex;const X=_?"ol":"ul",se=yl(j.items,`list-${O}`,p);g.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:ie=>t.jsx(X,{start:_?w:void 0,className:`${_?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:vl(se,ie)})});continue}const M=[v.trimStart()],L=[f+1],T=f;for(f+=1;f<e.length&&e[f].trim()&&!Zi(e[f])&&!(f+1<e.length&&e[f].includes("|")&&io(e[f+1]));){if(so(e[f])||h.has(f)){f+=1;continue}M.push(e[f].trimStart()),L.push(f+1),f+=1}const B=nl(M,`p-${T}`,p);g.push({key:`p-${T}`,startLine:T+1,endLine:f,fineGrained:!0,content:_=>t.jsx("p",{className:"text-muted-foreground",children:sl(B.perLine,B.hardBreaks,L,`p-${T}`,_)})})}const S=wx(p);return S&&g.push({key:"footnotes",startLine:e.length,endLine:e.length,content:S}),{blocks:g,images:m}}function Mx(e,r,s){return wl(e,r,s).blocks}function Mf(e,r){const s=[];for(const i of e){if(i.startLine>r)break;if(i.heading){for(;s.length>0&&s[s.length-1].level>=i.heading.level;)s.pop();s.push({...i.heading,startLine:i.startLine})}}return s}function Af(e){return e.filter(r=>!!r.heading).map(r=>({...r.heading,startLine:r.startLine}))}function Ax({src:e,alt:r,onZoomChange:s,onDoubleTap:i}){const d=pf(e);return t.jsx(Hf,{src:d,alt:r,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:i})}function Pf({images:e,index:r,onChange:s,onClose:i}){const{t:d}=Nt(),c=e[r],h=e.length>1,m=a.useRef(null),p=a.useRef(null),g=a.useRef(null),f=a.useRef(0),[S,v]=a.useState(!1),[P,N]=a.useState(0),[F,z]=a.useState(!1),A=a.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),M=a.useCallback(()=>{S||Date.now()<f.current||(A(),g.current=window.setTimeout(()=>{g.current=null,i()},450))},[A,S,i]),L=a.useCallback(o=>{if(e.length===0)return;const w=(o+e.length)%e.length;m.current?.slideTo(w),s(w)},[e.length,s]),T=a.useCallback(()=>L(r-1),[L,r]),B=a.useCallback(()=>L(r+1),[L,r]);if(a.useEffect(()=>{A(),N(0),z(!1),v(!1)},[A,r]),a.useEffect(()=>{const o=m.current;o&&(o.allowTouchMove=h&&!S)},[h,S]),a.useEffect(()=>{const o=m.current;!o||o.activeIndex===r||o.slideTo(r,0)},[r]),a.useEffect(()=>A,[A]),a.useEffect(()=>{const o=w=>{if(w.key==="Escape"){w.preventDefault(),i();return}h&&(w.key==="ArrowLeft"?(w.preventDefault(),T()):w.key==="ArrowRight"&&(w.preventDefault(),B()))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[h,B,T,i]),pu({onDrag:({movement:[o,w],pinching:O})=>{O||S||Math.abs(w)<Math.abs(o)*1.15&&P===0||(z(!0),Math.abs(w)>8&&(f.current=Date.now()+300),N(Math.max(0,w)))},onDragEnd:({movement:[o,w],velocity:[,O],pinching:j,canceled:X})=>{if(z(!1),j||X||S||Math.abs(w)<Math.abs(o)*1.15){N(0);return}if(Math.abs(w)>8&&(f.current=Date.now()+300),Cf(w,O)){i();return}N(0)}},{target:p,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const _=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:Fr.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:i}),t.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[t.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-sm font-medium",children:_}),t.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[r+1," / ",e.length]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[h&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:T,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.previousImage"),title:d("common.previous"),children:t.jsx(ss,{size:17})}),t.jsx("button",{type:"button",onClick:B,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":d("rightSidebar.nextImage"),title:d("common.next"),children:t.jsx(um,{size:17})})]}),t.jsx("button",{type:"button",onClick:i,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:t.jsx(tr,{size:18})})]})]}),t.jsx("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:M,children:t.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${P}px, 0) scale(${Math.max(.86,1-P/900)})`,opacity:Math.max(.35,1-P/360),transition:F?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:t.jsx(gu,{onSwiper:o=>{m.current=o,o.allowTouchMove=h&&!S},onSlideChange:o=>{o.activeIndex!==r&&s(o.activeIndex)},onSliderMove:()=>{A(),f.current=Date.now()+450},initialSlide:r,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:e.map((o,w)=>t.jsx(Fi,{className:"h-full",children:t.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:o.kind==="image"?t.jsx(Ax,{src:o.src,alt:o.alt||o.title||d("rightSidebar.markdownImage"),onZoomChange:v,onDoubleTap:A}):t.jsx(qx,{svg:o.svg,title:o.title||o.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:v,onDoubleTap:A})})},`${o.kind}-${w}-${o.alt}`))})})})]})]}),document.body)}function $f({content:e,filePath:r,rootPath:s,lineRange:i,onLineRangeClick:d,onLineRangeDrag:c,scrollTop:h,outlineOpen:m,outlineCloseSignal:p,onOutlineOpen:g,onOutlineClose:f,lightboxOpen:S,lightboxCloseSignal:v,onLightboxOpen:P,onLightboxClose:N,onLocalLinkOpen:F}){const{t:z}=Nt(),[A,M]=a.useState(null),[L,T]=a.useState(null),[B,_]=a.useState(1),[o,w]=a.useState(null),O=a.useRef(null),j=a.useRef(null),{blocks:X,images:se}=a.useMemo(()=>wl(e.split(`
1652
+ `),r,s,R=>{T(null),M(R),P?.()},{footnotes:z("rightSidebar.footnotes"),backToFootnote:R=>z("rightSidebar.backToFootnote",{index:R})}),[e,r,s,P,z]),ie=a.useMemo(()=>L?[...se,L]:se,[se,L]),pe=a.useCallback(R=>{T({kind:"mermaid",svg:R,alt:"Mermaid diagram",title:"Mermaid diagram"}),M(se.length),P?.()},[se.length,P]);a.useEffect(()=>{M(null),T(null)},[e,r]),a.useEffect(()=>{M(null),T(null)},[v]),a.useEffect(()=>{S||(M(null),T(null))},[S]),a.useEffect(()=>{_(1)},[e,r]),a.useLayoutEffect(()=>{const R=O.current;if(!R||X.length===0)return;const Y=Array.from(R.querySelectorAll("[data-markdown-preview-block-start]"));let ke=1;const xe=28;for(const ze of Y)if(ze.offsetTop-h<=xe)ke=Number(ze.dataset.markdownPreviewBlockStart)||ke;else break;_(ze=>ze===ke?ze:ke)},[X,h]);const q=a.useMemo(()=>Mf(X,B),[B,X]),Z=a.useMemo(()=>Af(X),[X]),$=`${r??""}
1653
+ ${e}`,U=a.useRef($),K=a.useRef(null),ae=a.useRef(null),le=a.useRef(!1);a.useEffect(()=>{U.current!==$&&(U.current=$,f?.())},[f,$]),a.useEffect(()=>{p!==void 0&&w(null)},[p]),a.useLayoutEffect(()=>{if(!m){w(null);return}const R=()=>{const Y=j.current;if(!Y)return;const ke=Y.getBoundingClientRect(),xe=window.innerWidth;w({top:ke.bottom+6,right:Math.max(8,xe-ke.right)})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[m,h,q]);const ge=a.useCallback(R=>{const Y=O.current,ke=Y?.closest("[data-markdown-preview-scroller]"),xe=Y?.querySelector(`[data-markdown-preview-block-start="${R.startLine}"]`);if(!ke||!xe)return;const ze=ke.getBoundingClientRect(),de=xe.getBoundingClientRect(),Te=Y?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,W=de.top-ze.top+ke.scrollTop;ke.scrollTo({top:Math.max(0,W-Te-8),behavior:"smooth"}),_(R.startLine),f?.()},[f]),be=a.useCallback(R=>{R.pointerType==="mouse"&&R.button!==0||$i(R.target)||(K.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY})},[]),Re=a.useCallback((R,Y,ke)=>{const xe=K.current;if(K.current=null,!xe||xe.pointerId!==R.pointerId)return;const ze=Math.abs(R.clientX-xe.startX),de=Math.abs(R.clientY-xe.startY);if(ze>8||de>8)return;const Qe=R.target;if($i(Qe)||ol())return;const Te=du(Qe,Y,ke);d(R,Te.start,Te.end)},[d]),E=a.useCallback(R=>{K.current?.pointerId===R.pointerId&&(K.current=null)},[]),ee=a.useCallback((R,Y)=>{const ke=O.current;if(!ke||typeof document.elementFromPoint!="function")return null;const xe=document.elementFromPoint(R,Y);if(!(xe instanceof HTMLElement)||!ke.contains(xe))return null;const ze=xe.closest("[data-md-ref-start]");if(ze){const Ce=Number(ze.dataset.mdRefStart);if(Number.isFinite(Ce)&&Ce>0)return Ce}const de=xe.closest("[data-markdown-preview-block-start]");if(!de)return null;const Qe=Number(de.dataset.markdownPreviewBlockStart),Te=X.find(Ce=>Ce.startLine===Qe);if(!Te)return Number.isFinite(Qe)&&Qe>0?Qe:null;if(Te.endLine<=Te.startLine)return Te.startLine;const W=de.getBoundingClientRect(),V=W.height>0?Math.min(1,Math.max(0,(Y-W.top)/W.height)):0;return Math.round(Te.startLine+V*(Te.endLine-Te.startLine))},[X]),ue=a.useCallback(R=>{if(!c||R.pointerType==="mouse"&&R.button!==0)return;const Y=ee(R.clientX+24,R.clientY);if(Y!=null){ae.current={pointerId:R.pointerId,anchorLine:Y,moved:!1};try{R.currentTarget.setPointerCapture(R.pointerId)}catch{}}},[c,ee]),Le=a.useCallback(R=>{const Y=ae.current;if(!Y||Y.pointerId!==R.pointerId||!c)return;const ke=ee(R.clientX+16,R.clientY);ke!=null&&(!Y.moved&&ke===Y.anchorLine||(Y.moved=!0,le.current=!0,c(R,Math.min(Y.anchorLine,ke),Math.max(Y.anchorLine,ke),"move")))},[c,ee]),qe=a.useCallback(R=>{const Y=ae.current;if(ae.current=null,!Y||Y.pointerId!==R.pointerId||!c||!Y.moved)return;const ke=ee(R.clientX+16,R.clientY)??Y.anchorLine;c(R,Math.min(Y.anchorLine,ke),Math.max(Y.anchorLine,ke),"end")},[c,ee]),_e=a.useCallback(R=>{ae.current?.pointerId===R.pointerId&&(ae.current=null)},[]),fe={onPointerDown:ue,onPointerMove:Le,onPointerUp:qe,onPointerCancel:_e},re=()=>le.current?(le.current=!1,!0):!1;return X.length===0?t.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:t.jsx("p",{className:"text-muted-foreground",children:z("rightSidebar.emptyFile")})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:O,className:"relative min-w-0 max-w-full",onClickCapture:R=>{const Y=R.target instanceof Element?R.target.closest("a[href]"):null;if(!Y||!F)return;const ke=Y.getAttribute("href");if(!ke)return;const xe=pl(ke,r,s);xe&&(R.preventDefault(),F(xe))},children:[q.length>0&&t.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:q.map(R=>R.text).join(" / "),children:[t.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:q[q.length-1].text}),Z.length>1&&t.jsxs("button",{ref:j,type:"button",onClick:()=>{m?f?.():g?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${m?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":m,"aria-label":z("rightSidebar.markdownOutline"),title:z("rightSidebar.markdownOutline"),children:[t.jsx(bu,{size:12}),t.jsx("span",{children:z("rightSidebar.markdownOutlineShort")})]})]})}),m&&typeof document<"u"&&Fr.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:f}),t.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:o?{top:`${o.top}px`,right:`${o.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:t.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:Z.map(R=>{const Y=q[q.length-1]?.startLine===R.startLine;return t.jsxs("button",{type:"button",onClick:()=>ge(R),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${Y?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[t.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Y?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),t.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",R.level]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`desktop-${R.id}-${R.startLine}`)})})}),t.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[t.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:z("rightSidebar.markdownOutlineShort")}),t.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":z("rightSidebar.closeMarkdownOutline"),title:z("common.close"),children:t.jsx(tr,{size:14})})]}),t.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:Z.map(R=>{const Y=q[q.length-1]?.startLine===R.startLine;return t.jsxs("button",{type:"button",onClick:()=>ge(R),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${Y?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[t.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Y?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),t.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",R.level]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`${R.id}-${R.startLine}`)})})]})]}),document.body),t.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:t.jsx(of.Provider,{value:pe,children:X.map(R=>{const Y=!!(i&&R.startLine<=i.end&&R.endLine>=i.start),ke=!!(i&&i.start<=R.startLine&&i.end>=R.endLine),xe=R.kind==="table"?!1:R.fineGrained?ke:Y,ze=R.kind==="table"&&i?.start===R.startLine&&i.end===R.endLine;let de=null;if(R.kind!=="table"&&R.fineGrained&&Y&&!ke&&i){const V=R.endLine-R.startLine+1,Ce=Math.max(i.start,R.startLine),Ne=Math.min(i.end,R.endLine),dt=(Ce-R.startLine)/V,Ze=(Ne-Ce+1)/V;de=t.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${dt})`,height:`calc((100% - 0.5rem) * ${Ze})`}})}const Qe=typeof R.content=="function"?R.content(i):R.content,Te=R.startLine===R.endLine?String(R.startLine):`${R.startLine}-${R.endLine}`,W=t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:Mi(xe),"aria-hidden":"true",...fe,children:[t.jsx("span",{className:Ai(xe)}),de]}),t.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:Qe})]});return R.interactive===!1?t.jsxs("div",{"data-markdown-preview-block-start":R.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${xe?"bg-primary/10":""}`,title:`Line ${Te}`,"aria-label":`Line ${Te}`,children:[R.kind==="table"?t.jsx("button",{type:"button",className:Mi(ze,"self"),onClick:V=>{V.preventDefault(),!re()&&d(V,R.startLine,R.endLine)},title:`Reference table lines ${Te}`,"aria-label":`Reference table lines ${Te}`,...fe,children:t.jsx("span",{className:Ai(ze,"self")})}):t.jsxs("span",{className:Mi(xe,"none"),"aria-hidden":"true",...fe,children:[t.jsx("span",{className:Ai(xe,"none")}),de]}),t.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:be,onPointerUp:V=>Re(V,R.startLine,R.endLine),onPointerCancel:E,onKeyDown:V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),d(V,R.startLine,R.endLine))},title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:Qe})]},R.key):t.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":R.startLine,onClick:V=>{const Ce=V.target;if($i(Ce)||ol()||re())return;const Ne=du(Ce,R.startLine,R.endLine);d(V,Ne.start,Ne.end)},onKeyDown:V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),d(V,R.startLine,R.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${xe?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Te}`,"aria-label":`Reference line ${Te}`,children:W},R.key)})})})]}),S&&A!==null&&ie[A]&&t.jsx(Pf,{images:ie,index:A,onChange:M,onClose:()=>{M(null),T(null),N?.()}})]})}function es({label:e,value:r,options:s,placeholder:i,searchPlaceholder:d,emptyText:c,disabled:h,onChange:m}){const{t:p}=Nt(),[g,f]=a.useState(!1),[S,v]=a.useState(""),[P,N]=a.useState(null),F=a.useRef(null),z=a.useRef(null),A=S.trim().toLowerCase(),M=a.useMemo(()=>A?s.filter(o=>`${o.label} ${o.meta??""}`.toLowerCase().includes(A)):s,[A,s]),L=s.find(o=>o.value===r),T=()=>{const o=S.trim();o&&(m(o),f(!1),v(""))},B=a.useCallback(()=>{const o=F.current?.getBoundingClientRect();if(!o)return!1;const w=12,O=Math.max(220,Math.min(o.width,window.innerWidth-w*2)),j=Math.min(Math.max(w,o.left),window.innerWidth-O-w),X=window.innerHeight-o.bottom-w,se=o.top-w,ie=X>=180||X>=se,pe=Math.max(96,(ie?X:se)-4),q=Math.min(320,pe);return N({left:j,top:ie?o.bottom+4:Math.max(w,o.top-q-4),width:O,maxHeight:q}),!0},[]),_=()=>{B(),f(!0)};return a.useEffect(()=>{if(!g)return;let o=0;const w=()=>{o||(o=window.requestAnimationFrame(()=>{o=0,B()}))},O=j=>{const X=j.target;X instanceof Node&&(F.current?.contains(X)||z.current?.contains(X)||(f(!1),v("")))};return window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),document.addEventListener("pointerdown",O,!0),()=>{o&&window.cancelAnimationFrame(o),window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),document.removeEventListener("pointerdown",O,!0)}},[g,B]),t.jsxs("div",{className:"relative min-w-0",children:[t.jsxs("button",{ref:F,type:"button",disabled:h,onClick:()=>{if(!h){if(v(""),g){f(!1);return}_()}},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:e}),t.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${r?"text-foreground":"text-muted-foreground/70"}`,children:L?.label??(r||i)})]}),t.jsx(as,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${g?"rotate-180":""}`})]}),g&&!h&&typeof document<"u"&&Fr.createPortal(t.jsxs("div",{ref:z,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:o=>o.stopPropagation(),style:{left:P?.left??12,top:P?.top??12,width:P?.width??260,maxHeight:P?.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(rs,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsx("input",{autoFocus:!0,value:S,onChange:o=>v(o.target.value),onKeyDown:o=>{if(o.key==="Escape"){o.preventDefault(),f(!1),v("");return}o.key==="Enter"&&(o.preventDefault(),T())},onBlur:()=>{S.trim()&&M.length===0&&T()},placeholder:d,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,(P?.maxHeight??320)-46)},children:[S.trim()&&!s.some(o=>o.value===S.trim())&&t.jsxs("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:T,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[t.jsx("span",{className:"min-w-0 truncate",children:S.trim()}),t.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:p("common.use")})]}),M.length>0?M.map(o=>t.jsxs("button",{type:"button",onClick:()=>{m(o.value),f(!1),v("")},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 ${o.value===r?"bg-accent/10 text-accent":"text-foreground"}`,children:[t.jsx("span",{className:"min-w-0 truncate font-medium",children:o.label}),o.meta&&t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:o.meta})]},o.value)):t.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function nu({open:e,onOpenChange:r,showScopePicker:s,selectedAll:i,repos:d,selectedRoots:c,onToggleRepo:h,onGenerate:m,onSecondaryAction:p,disabled:g,generateDisabled:f,secondaryDisabled:S,inserted:v,buttonLabel:P,insertedLabel:N,title:F,ariaLabel:z,scopeTitle:A,scopeLabel:M,allLabel:L,generateLabel:T,secondaryLabel:B,secondaryTitle:_,secondaryLoading:o,loading:w,error:O,statusTitle:j,extraContent:X,renderRepoExtra:se}){return t.jsxs("div",{className:"relative inline-flex shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>{s?r(!e):f||m()},disabled:g,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 ${O?"text-destructive hover:bg-destructive/5":v?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":z,title:j??(s?`${A}: ${M}`:F),children:[w?t.jsx(bt,{size:13,className:"animate-spin"}):t.jsx(Os,{size:13}),t.jsx("span",{children:v?N:P}),s&&t.jsx(as,{size:11,className:`shrink-0 transition ${e?"rotate-180":""}`}),O&&t.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&e&&typeof document<"u"&&Fr.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:()=>r(!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:ie=>ie.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:A}),t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:M})]}),t.jsx("button",{type:"button",onClick:()=>r(!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(tr,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[X,t.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${i?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[t.jsx("span",{className:"truncate",children:L}),i&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),d.map(ie=>{const pe=c.includes(ie.root);return t.jsxs("div",{className:`mt-1 rounded-md transition ${pe?"bg-primary/15 text-primary":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>h(ie.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${pe?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:ie.root,children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate",children:ie.label}),ie.branch&&t.jsx("span",{className:"block truncate text-[9px] opacity-70",children:ie.branch})]}),pe&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),se&&(i||pe)&&t.jsx("div",{className:"px-2 pb-2",children:se(ie)})]},ie.root)})]}),t.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${p&&B?"sm:grid-cols-2":""}`,children:[p&&B&&t.jsxs("button",{type:"button",onClick:()=>{S||(r(!1),p())},disabled:S,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:_,children:[o?t.jsx(bt,{size:12,className:"animate-spin"}):t.jsx(Ru,{size:12}),B]}),t.jsxs("button",{type:"button",onClick:()=>{f||(r(!1),m())},disabled:f,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:F,children:[t.jsx(Os,{size:12}),T]})]})]})}),document.body)]})}function Px(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(const r of Object.values(e)){if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Lf(){return ut(fl,Px)??{}}function $x(e,r){const s=Lf(),i=Object.entries({...s,[e]:{top:r,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Nb);Ts(fl,Object.fromEntries(i),Mb)}function Lx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.start=="number"&&Number.isFinite(r.start)&&typeof r.end=="number"&&Number.isFinite(r.end)&&r.start>=1&&r.end>=r.start}function Tx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(const r of Object.values(e)){if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Lx(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function kl(e,r){if(!r)return null;const s=e&&!r.startsWith("/")?`${e}/${r}`:r;return e?`${e}::${s}`:s}function Tf(){return ut(hl,Tx)??{}}function su(e,r){const s=kl(e,r);return s?Tf()[s]??null:null}function Ci(e,r,s){const i=kl(e,r);if(!i)return;const d=Tf(),c=d[i]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...d,[i]:{...c,...s,updatedAt:Date.now()}}).sort(([,m],[,p])=>p.updatedAt-m.updatedAt).slice(0,Eb);Ts(hl,Object.fromEntries(h),Ab)}function Va({active:e,mounted:r=!0,fallback:s=null,children:i}){return t.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${e?"block":"hidden"}`,"aria-hidden":!e,children:r?typeof i=="function"?i():i:s})}function Ni({slow:e}){return t.jsx(Jm,{slow:e})}function Ka({message:e,onRetry:r}){const{t:s}=Nt();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:s("rightSidebar.gitChangesLoadFailed")}),t.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:e}),t.jsx("button",{type:"button",onClick:r,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function Za(e,r){const s=r&&e.startsWith(`${r}/`)?e.slice(r.length+1):e,i=s.split("/").filter(Boolean);return{name:i.pop()||s,dir:i.join("/")}}function Ct(e){if(!e)return"";const r=e.replace(/\/+$/,"");return r.split("/").pop()||r||"/"}function Ei(e){if(!e)return null;const r=e.replace(/\/+$/,"")||"/";if(r==="/")return null;const s=r.slice(0,r.lastIndexOf("/"))||"/";return s===r?null:s}function al(e,r,s){const i=Math.min(r,s),d=Math.max(r,s);return e?.start===i&&e.end===d?null:e&&e.start===e.end?{start:Math.min(e.start,i),end:Math.max(e.end,d)}:{start:i,end:d}}function Ix(e,r,s){return al(e,r,s)}function Mi(e,r="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${e?"bg-primary/20":`bg-[var(--surface-2)] ${r==="group"?"group-hover:bg-[var(--surface-elevated)]":r==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function Ai(e,r="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${e?"bg-primary":`bg-[var(--border-strong)] ${r==="group"?"group-hover:bg-[var(--muted-foreground)]":r==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function au(e,r){return`pointer-events-auto absolute z-30 inline-flex items-center gap-1 rounded-full font-semibold shadow-lg ring-1 transition active:scale-95 ${e?"h-9 px-4 text-[12px]":"h-7 px-3 text-[11px]"} ${r?"bg-surface-elevated text-foreground ring-border-strong/40 hover:bg-surface-2":"bg-primary text-primary-foreground ring-primary/30 hover:bg-primary/90"}`}function If(e){const r=new Map;for(const s of e)r.set(Sl(s),s);return r}function _f(e,r){const s=new Map(e);for(const i of r)s.set(Sl(i),i);return s}function ou(e,r){let s=0;for(const i of e){const d=wt(i,r);d&&r&&d!==r&&(s+=1)}return s}function _x(e){return e.reduce((r,s)=>r+(s.staged?1:0),0)}function Dx(e,r){return Array.from(_f(If(e),r).values()).sort((s,i)=>s.path.localeCompare(i.path))}function Fx(e,r){const s=e.relativeRoot==="."?Ct(r??e.root)||e.name||e.root:e.relativeRoot||e.name||Ct(e.root)||e.root;return{root:e.root,label:s,branch:e.context?.branch??null,count:e.files.length,staged:_x(e.files)}}function Df(e,r){const s=Ct(r??"")||r||"";return e.map(i=>Fx(i,r)).sort((i,d)=>s&&i.label===s?-1:s&&d.label===s?1:i.label.localeCompare(d.label))}function Ff(e,r,s,i,d){const c=Zu(s),h=c.find(F=>F.root===i)??c[0]??null,m=r.find(F=>F.root===i)??null,p=m?.relativeRoot??h?.relativeRoot??".",g=m?.name??h?.name??(Ct(i)||i),f=(h?.files??s.files).map(F=>({...F,repoRoot:i,repoRelativeRoot:p,repoName:g})),S=h?.context??s.context,v={...m??h??{id:i,root:i,relativeRoot:p,name:g,depth:0,nested:!!(d&&i!==d),available:s.available,files:[],context:null},...h??{},id:m?.id??h?.id??i,root:i,displayRoot:m?.displayRoot??h?.displayRoot,relativeRoot:p,name:g,depth:m?.depth??h?.depth??0,nested:m?.nested??h?.nested??!!(d&&i!==d),available:h?.available??s.available,files:f,context:S?{...S,root:i,changedFiles:f.map(F=>({path:F.path,absolutePath:F.absolutePath,status:F.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},P=m?r.map(F=>F.root===i?v:F):[...r,v];return{files:Array.from(e).filter(F=>wt(F,d)!==i).concat(f),repositories:P,repoFilters:Df(P,d)}}function wt(e,r){return e.repoRoot??r}function Sl(e){return`${e.repoRoot??""}\0${e.path}`}function Rt(e){return e.absolutePath||e.path}function Pi(e){return Sl(e)}function Ox(e){return e.repoRelativeRoot&&e.repoRelativeRoot!=="."?e.repoRelativeRoot:e.repoName??""}function iu(e){return e.reduce((r,s)=>r+(s.staged?1:0),0)}function lu(e){const r={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of e)s.status==="added"?r.added+=1:s.status==="modified"?r.modified+=1:s.status==="deleted"?r.deleted+=1:s.status==="renamed"?r.renamed+=1:s.status==="copied"?r.copied+=1:s.status==="untracked"?r.untracked+=1:s.status==="conflicted"?r.conflicted+=1:r.other+=1,s.staged&&(r.staged+=1);return r}function ts(e){let r=0;const s=e??"root";for(let i=0;i<s.length;i+=1)r=Math.imul(r^s.charCodeAt(i),16777619);return`right-sidebar-git-bundle:${(r>>>0).toString(36)}`}function Ps(e,r){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:new Intl.DateTimeFormat(r==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(e))}function Dr(e){return e instanceof DOMException&&e.name==="AbortError"}function Bx(e){const r=e.error??e.context?.error??"";return r.includes("request was cancelled")||r.includes("IO_REQUEST_CANCELLED")}function cu(e){return e?.available===!1&&e.code==="NOT_GIT_REPOSITORY"}function ol(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function $i(e){return e instanceof HTMLElement&&!!e.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function du(e,r,s){const i=e instanceof HTMLElement?e.closest("[data-md-ref-start]"):null,d=Number(i?.dataset.mdRefStart),c=Number(i?.dataset.mdRefEnd??i?.dataset.mdRefStart);return Number.isFinite(d)&&d>0&&Number.isFinite(c)&&c>0?{start:Math.min(d,c),end:Math.max(d,c)}:{start:r,end:s}}function Ux({actions:e,running:r,completed:s}){const{t:i}=Nt(),[d,c]=a.useState(!1),h=a.useRef(null),m=e.find(g=>r?.action===g.key),p=e.find(g=>s?.action===g.key);return e.length===0?null:(a.useEffect(()=>{if(!d)return;const g=S=>{const v=S.target;v instanceof Node&&h.current?.contains(v)||c(!1)},f=S=>{S.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",f)}},[d]),t.jsxs("div",{ref:h,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),c(f=>!f)},disabled:e.every(g=>g.disabled)&&!r&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${d?"bg-surface-elevated text-foreground":p?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:m?.label??p?.label??i("rightSidebar.gitQuickActions"),children:m?t.jsx(bt,{size:13,className:"animate-spin"}):p?t.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):t.jsx(Di,{size:14})}),d&&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:e.map(g=>{const f=r?.action===g.key,S=s?.action===g.key;return t.jsxs("button",{type:"button",onClick:v=>{v.stopPropagation(),g.onClick(),c(!1)},disabled:g.disabled||!!r,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 ${S?"bg-accent/10 text-accent":g.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:f?t.jsx(bt,{size:13,className:"animate-spin"}):S?"✓":null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label})]},g.key)})})]}))}function zx(e){const r=window.getComputedStyle(e).overflowY;return(r==="auto"||r==="scroll")&&e.scrollHeight>e.clientHeight+1}function Of(e){let r=e;for(;r;){if(r.classList.contains("termdock-diff-stream-scroller")&&zx(r))return r;r=r.parentElement}return e.closest(".termdock-diff-stream-scroller")}function ns(e){return e.getClientRects().length>0&&window.getComputedStyle(e).visibility!=="hidden"}const Li=new WeakMap;function co(e){const r=Li.get(e);r!==void 0&&window.clearTimeout(r),e.classList.remove("diff-walkthrough-target"),e.offsetWidth,e.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{e.classList.remove("diff-walkthrough-target"),Li.delete(e)},1700);Li.set(e,s)}function Hx(e){const r=CSS.escape(e),s=[`[data-diff-stream-item="${r}"]`,`[data-diff-selection-path="${r}"]`,`[data-diff-absolute-path="${r}"]`].join(","),i=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let d=null;for(const m of i){if(!ns(m))continue;const p=m.querySelector(s);if(p&&ns(p)){d=p;break}}if(d??=Array.from(document.querySelectorAll(s)).find(ns)??null,!d)return;const c=Of(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),co(d);return}const h=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,h),behavior:"instant"}),co(d)}function Nn(e){const r=CSS.escape(e.filePath),s=typeof e.sectionIndex=="number"?String(e.sectionIndex):null,i=typeof e.hunkIndex=="number"?String(e.hunkIndex):null,d=e.sectionFingerprint?CSS.escape(e.sectionFingerprint):null,c=e.hunkFingerprint?CSS.escape(e.hunkFingerprint):null,h=[s!==null&&d?`[data-diff-section-audit="${r}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null&&d?`[data-diff-section-anchor="${r}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null?`[data-diff-section-audit="${r}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${r}"][data-diff-section-index="${s}"]`:null,i!==null&&c?`[data-diff-hunk-anchor="${r}"][data-diff-hunk-index="${i}"][data-diff-hunk-fingerprint="${c}"]`:null,i!==null?`[data-diff-hunk-anchor="${r}"][data-diff-hunk-index="${i}"]`:null,`[data-diff-file-path="${r}"]`].filter(N=>!!N),m=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let p=null;for(const N of m)if(ns(N)){for(const F of h){const z=N.querySelector(F);if(z&&ns(z)){p=z;break}}if(p)break}if(p??=h.flatMap(N=>Array.from(document.querySelectorAll(N))).find(ns)??null,!p){Hx(e.filePath);return}const g=Of(p);if(!g){p.scrollIntoView({block:"center",behavior:"smooth"}),co(p);return}const f=p.getBoundingClientRect(),S=g.getBoundingClientRect(),P=f.top-S.top+g.scrollTop-Math.max(24,(g.clientHeight-f.height)/2);g.scrollTo({top:Math.max(0,P),behavior:"instant"}),co(p)}const Bf=1,Uf=8;function Wx(e){return Math.min(Uf,Math.max(Bf,e))}function zf({resetKey:e,onZoomChange:r,onDoubleTap:s,children:i}){const d=a.useRef(null),[c,h]=a.useState({scale:1,x:0,y:0}),[m,p]=a.useState(!1),g=a.useRef(null),f=a.useRef(new Set),S=a.useRef(!1),v=a.useRef(null),P=a.useRef(0),N=a.useRef(c);N.current=c,a.useEffect(()=>{h({scale:1,x:0,y:0})},[e]);const F=a.useCallback((L,T,B)=>{const _=d.current;if(!_)return{x:T,y:B};const o=_.firstElementChild instanceof HTMLElement?_.firstElementChild:null,w=o?.clientWidth||_.clientWidth,O=o?.clientHeight||_.clientHeight,j=Math.max(0,(w*L-_.clientWidth)/2),X=Math.max(0,(O*L-_.clientHeight)/2);return{x:Math.min(j,Math.max(-j,T)),y:Math.min(X,Math.max(-X,B))}},[]),z=a.useCallback((L,T,B)=>{h(_=>{const o=Wx(L),w=d.current;if(!w||o===1)return{scale:o,x:0,y:0};const O=w.getBoundingClientRect(),j=(T??O.left+O.width/2)-O.left-O.width/2,X=(B??O.top+O.height/2)-O.top-O.height/2,se=o/_.scale,ie=j-(j-_.x)*se,pe=X-(X-_.y)*se;return{scale:o,...F(o,ie,pe)}})},[F]),A=a.useCallback((L,T)=>{p(!0),N.current.scale>1?h({scale:1,x:0,y:0}):z(2.5,L,T),window.setTimeout(()=>p(!1),220)},[z]);a.useEffect(()=>{const L=d.current;if(!L)return;const T=o=>{if(o.pointerType==="mouse"&&o.button!==0)return;const w=f.current.size===0;if(f.current.add(o.pointerId),w){const O=Date.now(),j=v.current;if(j&&O-j.time<350&&Math.hypot(o.clientX-j.x,o.clientY-j.y)<24){v.current=null,P.current=O,s?.(),A(o.clientX,o.clientY);return}}if(f.current.size>1){S.current=!0,g.current=null;return}if(!(N.current.scale<=1)){o.preventDefault(),g.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:N.current.x,originY:N.current.y,moved:!1};try{L.setPointerCapture?.(o.pointerId)}catch{}p(!1)}},B=o=>{const w=g.current;if(!w||w.pointerId!==o.pointerId)return;const O=o.clientX-w.startX,j=o.clientY-w.startY;if(!w.moved){if(Math.hypot(O,j)<6)return;w.moved=!0}o.stopPropagation(),o.preventDefault(),h(X=>({...X,...F(X.scale,w.originX+O,w.originY+j)}))},_=o=>{const w=g.current,O=w?.pointerId===o.pointerId&&w.moved;if(w?.pointerId===o.pointerId){w.moved&&o.stopPropagation(),g.current=null;try{L.releasePointerCapture?.(o.pointerId)}catch{}}f.current.delete(o.pointerId)&&f.current.size===0&&(!S.current&&!O&&(v.current={time:Date.now(),x:o.clientX,y:o.clientY}),S.current=!1)};return L.addEventListener("pointerdown",T,{capture:!0,passive:!1}),window.addEventListener("pointermove",B,{capture:!0,passive:!1}),window.addEventListener("pointerup",_,{capture:!0}),window.addEventListener("pointercancel",_,{capture:!0}),()=>{L.removeEventListener("pointerdown",T,{capture:!0}),window.removeEventListener("pointermove",B,{capture:!0}),window.removeEventListener("pointerup",_,{capture:!0}),window.removeEventListener("pointercancel",_,{capture:!0})}},[F,s,A]),pu({onPinch:({offset:[L],origin:[T,B]})=>{p(!1),z(L,T,B)},onWheel:({event:L,delta:[T,B],ctrlKey:_})=>{if(_){L.preventDefault(),L.stopPropagation(),p(!1),z(N.current.scale*(1-B*.01),L.clientX,L.clientY);return}N.current.scale<=1||(L.preventDefault(),L.stopPropagation(),p(!1),h(o=>({...o,...F(o.scale,o.x-T,o.y-B)})))}},{target:d,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Bf,max:Uf},from:()=>[N.current.scale,0],rubberband:!0}});const M=c.scale>1;return a.useEffect(()=>{r?.(M)},[r,M]),t.jsx("div",{ref:d,"data-sidebar-gesture-ignore":M?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:M?"grab":"zoom-in"},onDoubleClick:L=>{L.stopPropagation(),!(Date.now()-P.current<500)&&(s?.(),A(L.clientX,L.clientY))},children:i({scale:c.scale,zoomed:M,animateTransform:m,transformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0)`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Hf({src:e,alt:r,vector:s,onLoad:i,onError:d,onZoomChange:c,onDoubleTap:h}){const m=uo(e,d),[p,g]=a.useState(null),f=s??ho(e);return a.useEffect(()=>{g(null)},[e]),t.jsx(zf,{resetKey:e,onZoomChange:c,onDoubleTap:h,children:({transformStyle:S,vectorTransformStyle:v,scale:P,animateTransform:N})=>{const F=t.jsx("img",{src:m,alt:r,draggable:!1,className:"max-h-full max-w-full touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:f&&p?{position:"absolute",left:"50%",top:"50%",width:p.width*P,height:p.height*P,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:N?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}:p?{...S,width:p.width,height:p.height}:f?v:S,onLoad:z=>{const A=z.currentTarget,M=A.parentElement;if(M&&A.naturalWidth>0&&A.naturalHeight>0){const L=Math.max(1,M.clientWidth-2),T=Math.max(1,M.clientHeight-2),B=Math.min(L/A.naturalWidth,T/A.naturalHeight),_=f?B:Math.min(B,1);g({width:Math.max(1,Math.round(A.naturalWidth*_)),height:Math.max(1,Math.round(A.naturalHeight*_))})}i(z)},onError:d});return!f||!p?F:t.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...v,width:p.width,height:p.height},children:F})}})}function Gx({svg:e,title:r,scale:s,vectorTransformStyle:i}){const d=a.useRef(null);return a.useLayoutEffect(()=>{const c=d.current,h=c?.querySelector("svg");if(!c||!h)return;const m=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let S=f[2],v=f[3];if((!Number.isFinite(S)||!Number.isFinite(v)||S<=0||v<=0)&&(S=Number(h.getAttribute("width")),v=Number(h.getAttribute("height"))),!Number.isFinite(S)||!Number.isFinite(v)||S<=0||v<=0)return;const P=Math.max(1,c.clientWidth-24),N=Math.max(1,c.clientHeight-24),F=Math.min(P/S,N/v,1);h.style.width=`${Math.max(1,Math.floor(S*F*s))}px`,h.style.height=`${Math.max(1,Math.floor(v*F*s))}px`,h.style.maxWidth="none",h.style.maxHeight="none",h.style.transform=String(i.transform??""),h.style.transformOrigin="center center",h.style.transition=String(i.transition??"none")};m();const p=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return p?.observe(c),()=>p?.disconnect()},[s,e,i]),t.jsx("div",{ref:d,role:"img","aria-label":r,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:e}})}function qx({svg:e,title:r,onZoomChange:s,onDoubleTap:i}){return t.jsx(zf,{resetKey:e,onZoomChange:s,onDoubleTap:i,children:({vectorTransformStyle:d,scale:c})=>t.jsx(Gx,{svg:e,title:r,scale:c,vectorTransformStyle:d})})}let Vx=0,Kx=0,Yx=0,Xx=0,Jx=0;function Ti(e,r={}){if(typeof window>"u")return;const s=JSON.stringify({level:e==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${e}`,data:{ts:Date.now(),...r}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function lt(e,r={}){if(typeof window>"u")return;const s=JSON.stringify({level:e==="error"||e==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${e}`,data:{seq:++Kx,ts:Date.now(),...r}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Ya(e,r={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${e}`,data:{seq:++Xx,ts:Date.now(),...r}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Qx(){return`diff-ui-${Date.now().toString(36)}-${(++Jx).toString(36)}`}function Zx(e){return e instanceof Element?e.closest("[data-diff-selection-path]"):null}function e0(e){const r=e.target instanceof HTMLElement?e.target:null;return{eventType:e.type,button:e.button,pointerType:e instanceof globalThis.PointerEvent?e.pointerType:void 0,targetTag:r?.tagName,targetClass:r?.className,targetText:r?.textContent?.slice(0,80)}}function il({onReviewReference:e,filePath:r,onInsertReference:s,onInsertText:i,onInsertFeature:d,onReferenceCopied:c,onClose:h,onDirectoryLinkOpen:m,isMobile:p,markdownOutlineOpen:g,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:S,onCloseMarkdownOutline:v,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:N,onOpenMarkdownImageLightbox:F,onCloseMarkdownImageLightbox:z,lineRange:A,onLineRangeChange:M,insertedReferenceKey:L,copiedReferenceKey:T,scrollToLine:B,onScrollToLineHandled:_}){const{t:o}=Nt(),w=ne(D=>D.rootPath),O=ne(D=>D.selectFile),[j,X]=a.useState({kind:"idle"}),[se,ie]=a.useState("schematic"),[pe,q]=a.useState(null),Z=a.useRef(null),[$,U]=a.useState(null),K=a.useRef(new Map),ae=a.useRef(null),[le,ge]=a.useState(null),[be,Re]=a.useState(()=>Gd()),[E,ee]=a.useState(()=>Ld(w,r)),ue=a.useRef(null),[Le,qe]=a.useState(!1),[_e,fe]=a.useState(null),[re,R]=a.useState(0),[Y,ke]=a.useState([]),[xe,ze]=a.useState(null),de=a.useRef(null),Qe=a.useRef(r),[Te,W]=a.useState(null),[V,Ce]=a.useState({status:"idle"}),[Ne,dt]=a.useState(!1),[Ze,rr]=a.useState(""),[tt,Bt]=a.useState([]),[Et,wr]=a.useState(0),kt=a.useRef(null),Ke=ju(c),ht=kl(w,r);a.useEffect(()=>{if(Qe.current===r)return;Qe.current=r;const D=r&&w&&!r.startsWith("/")?`${w}/${r}`:r;if(de.current===D){de.current=null;return}de.current=null,ke([]),ze(null),dt(!1),rr("")},[r,w]);const nr=r?w&&!r.startsWith("/")?`${w}/${r}`:r:null,Gt=ne(D=>nr?(D.fileChangeVersions.get(nr)??0)+D.fileWatchEpoch:D.fileWatchEpoch),It=a.useRef(null),qt=a.useRef(null),[Ut,En]=a.useState(0),Or=a.useCallback(()=>En(D=>D+1),[]);a.useEffect(()=>{const D=Z.current;return Z.current=null,q(null),D&&URL.revokeObjectURL(D.objectUrl),()=>{const G=Z.current;Z.current=null,G&&URL.revokeObjectURL(G.objectUrl)}},[nr,Gt,Ut]),a.useEffect(()=>{if(!r){It.current=null,X({kind:"idle"});return}const D=w&&!r.startsWith("/")?`${w}/${r}`:r,G=new AbortController,he=++Vx,we=`right-sidebar-file-preview:${he}`,Ve=performance.now();let Fe=!1;const Xe=(te,Ge={})=>{Fe||(Fe=!0,Ti("end",{loadingId:he,reason:te,durationMs:Math.round(performance.now()-Ve),filePath:r,fullPath:D,rootPath:w,...Ge}))};let We=null;const pt=Zh(D),yt=pt?D.toLowerCase().endsWith(".kicad_pcb")?se==="schematic"?"pcb-front":se:"schematic":se,fr=!pt&&dl(D),Cr=!pt&&!fr&&em(D),Ln=!pt&&!fr&&!Cr&&uu(D),dn=As(D),ds=Rs(D),hr=pt?"eda":fr?"image":Cr?"model3d":Ln?"video":"text",us=It.current!==D;if(It.current=D,us){Ti("start",{loadingId:he,filePath:r,fullPath:D,rootPath:w,mode:hr,externalVersion:Gt}),Ce({status:"idle"}),X({kind:"loading",mode:hr}),qt.current=null;const te=su(w,r);M(te?.lineRange??null),Re(dn?Gd():"source"),ee(ds?Ld(w,r):"source"),pt&&ie(tm(D))}us||X(te=>te.kind==="error"?{kind:"loading",mode:hr}:te);const un=window.setTimeout(()=>{Fe||G.signal.aborted||Ti("still_active",{loadingId:he,filePath:r,fullPath:D,rootPath:w,mode:hr,durationMs:Math.round(performance.now()-Ve),isPathChange:us})},3e3),qr=window.setTimeout(()=>{if(Fe||G.signal.aborted)return;const te=pt?o("rightSidebar.edaTimeout"):Cr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";G.abort(new DOMException(te,"TimeoutError")),X({kind:"error",message:te}),Xe("stuck_timeout",{error:te})},pt?rm+5e3:Cr?nm+5e3:sm(D)?35e3:_b);if(pt){const te=yt==="pcb-3d"?Z.current:null;te?(X(te),Xe("eda_3d_client_cache_hit",{bytes:te.meta.size,view:te.view,mimeType:te.meta.mimeType})):am(D,yt,G.signal,"view_file",we).then(Ge=>{if(G.signal.aborted)return;We=URL.createObjectURL(Ge.blob);const Kt={kind:"eda",sourcePath:Ge.path||D,objectUrl:We,view:Ge.view,meta:{size:Ge.size,mimeType:Ge.mimeType,modified:Ge.modified}};if(Ge.view==="pcb-3d"){const Nr=Z.current;Nr&&Nr.objectUrl!==We&&URL.revokeObjectURL(Nr.objectUrl),Z.current=Kt,q(Kt),We=null}X(Kt),Xe("eda_loaded",{bytes:Ge.size,view:Ge.view,mimeType:Ge.mimeType})}).catch(Ge=>{G.signal.aborted||(X({kind:"error",message:Ge instanceof Error&&/timed out/i.test(Ge.message)?o("rightSidebar.edaTimeout"):Ge instanceof Error?Ge.message:o("rightSidebar.edaLoadFailed")}),Xe("error",{error:Ge instanceof Error?Ge.message:String(Ge)}))})}else if(fr)om(D,G.signal,"view_file",we).then(te=>{We=URL.createObjectURL(te.blob),X({kind:"image",objectUrl:We,meta:{size:te.size,mimeType:te.mimeType,modified:te.modified}}),Xe("image_loaded",{bytes:te.size,mimeType:te.mimeType})}).catch(te=>{G.signal.aborted||(X({kind:"error",message:te instanceof Error?te.message:o("rightSidebar.imageLoadFailed")}),Xe("error",{error:te instanceof Error?te.message:String(te)}))});else if(Cr)im(D,G.signal,"view_file",we).then(te=>{G.signal.aborted||(We=URL.createObjectURL(te.blob),X({kind:"model3d",sourcePath:te.path||D,objectUrl:We,ext:te.ext,meta:{size:te.size,mimeType:te.mimeType,modified:te.modified}}),Xe("model3d_loaded",{bytes:te.size,ext:te.ext}))}).catch(te=>{G.signal.aborted||(X({kind:"error",message:te instanceof Error&&(te.name==="TimeoutError"||/timed out/i.test(te.message))?o("rightSidebar.model3dTimeout"):te instanceof Error?te.message:o("rightSidebar.model3dLoadFailed")}),Xe("error",{error:te instanceof Error?te.message:String(te)}))});else if(Ln){const te=lm(D)??"",Ge=fu(D);X(Kt=>Kt.kind==="video"&&Kt.url===Ge?Kt:{kind:"video",url:Ge,meta:{size:null,mimeType:te,modified:null}}),Xe("video_ready",{mimeType:te})}else fd(D,G.signal,"view_file",we).then(te=>{if(!G.signal.aborted){if(te.binary){X({kind:"binary"});return}X({kind:"text",content:te.content,sourcePath:te.path||D,meta:{size:te.size,truncated:te.truncated}}),Xe("text_loaded",{bytes:te.size,truncated:!!te.truncated})}}).catch(te=>{G.signal.aborted||(X({kind:"error",message:te instanceof Error?te.message:"Failed to read file"}),Xe("error",{error:te instanceof Error?te.message:String(te)}))});return()=>{G.abort(),Lt(we),window.clearTimeout(un),window.clearTimeout(qr),We&&URL.revokeObjectURL(We),Xe("cleanup")}},[r,w,Gt,Ut,M,o,se]),a.useEffect(()=>{if(j.kind!=="model3d"||!r){U(null);return}let D=!1;const G=r.lastIndexOf("/"),he=G>=0?r.slice(G+1):r,we=G>=0?r.slice(0,G):"",Ve=we.lastIndexOf("/"),Fe=Ve>=0?we.slice(0,Ve):"",Xe=he.replace(/\.(stl|glb|gltf)$/i,""),We=`${Fe?`${Fe}/`:""}features/${Xe}.json`;return fd(We).then(pt=>{if(!D)try{const yt=JSON.parse(pt.content);U(yt.version===1&&Array.isArray(yt.features)&&yt.features.length>0?yt.features:null)}catch{U(null)}}).catch(()=>{D||U(null)}),()=>{D=!0}},[j,r]),a.useEffect(()=>{if(j.kind!=="text"){W(null);return}const D=w&&r&&!r.startsWith("/")?`${w}/${r}`:r,G=vu(D),he=j.content,we=As(D??"")&&be==="preview",Ve=Rs(D??"")&&E==="preview";if(!G||we||Ve||!wu(he)){W(null);return}let Fe=!1;const Xe=We=>{if(Fe||!We.registered(G)){Fe||W(null);return}try{W(Su(We,he,G))}catch{W(null)}};return _e?Xe(_e):(W(null),ku().then(We=>{Fe||(fe(We),Xe(We))}).catch(()=>{})),()=>{Fe=!0}},[j,_e,r,w,be,E]),a.useLayoutEffect(()=>{if(!ht||j.kind!=="text")return;const D=`${ht}:${be}:${E}`;if(qt.current===D)return;const G=su(w,r);if(qt.current=D,!G)return;const he=requestAnimationFrame(()=>{const we=ae.current;if(!we)return;const Ve=be==="preview"?G.markdownTop??G.top:G.top;we.scrollTo({top:Math.max(0,Ve??0),left:Math.max(0,G.left??0)}),R(be==="preview"?Math.max(0,Ve??0):0)});return()=>cancelAnimationFrame(he)},[r,be,E,j.kind,ht,w]),a.useEffect(()=>{ht&&Ci(w,r,{lineRange:A})},[r,A,ht,w]),a.useEffect(()=>{if(B==null||j.kind!=="text")return;ge(null),M({start:B,end:B});const D=B,G=requestAnimationFrame(()=>{const he=K.current.get(D);he&&he.scrollIntoView({block:"center"}),_?.()});return()=>cancelAnimationFrame(G)},[B,j,M,_]);const Br=a.useCallback(D=>{const G=ae.current;if(!G)return!1;const he=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(D):D.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),we=G.querySelector(`#${he}`);return we?(we.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const D=w&&r&&!r.startsWith("/")?`${w}/${r}`:r,G=j.kind==="text"&&As(D??"")&&be==="preview";if(!xe||!G)return;const he=requestAnimationFrame(()=>{Br(xe)&&ze(null)});return()=>cancelAnimationFrame(he)},[r,Br,be,xe,j,w]),a.useLayoutEffect(()=>{const D=ae.current;if(!D||!A){ge(null);return}if(le)return;const G=j.kind==="image"||j.kind==="loading"&&j.mode==="image",he=w&&r&&!r.startsWith("/")?`${w}/${r}`:r,we=j.kind==="text"&&As(he??"")&&be==="preview",Ve=j.kind==="text"&&Rs(he??"")&&E==="preview";if(j.kind!=="text"||G||we||Ve){ge(null);return}const Fe=()=>{const We=K.current.get(A.end);if(!We||!D){ge(null);return}const pt=We.offsetTop+We.offsetHeight/2,yt=D.scrollLeft+Math.max(8,D.clientWidth-120);ge({top:pt,left:yt})};Fe();const Xe=new ResizeObserver(()=>Fe());return Xe.observe(D),()=>Xe.disconnect()},[A,le,j,be,E,r,w,Te]);const zt=j.kind==="text"&&!(Rs(nr??"")&&E==="preview")&&!nr?.toLowerCase().endsWith(".csv")&&!nr?.toLowerCase().endsWith(".kicad_pro")&&!nr?.toLowerCase().endsWith(".kicad_prl"),lr=a.useCallback(()=>{dt(!1),rr(""),Bt([]),wr(0),za()},[]),xt=a.useCallback(()=>{zt&&(dt(!0),requestAnimationFrame(()=>{kt.current?.focus(),kt.current?.select()}))},[zt]),nt=a.useCallback(D=>{wr(G=>tt.length===0?0:(G+D+tt.length)%tt.length)},[tt.length]);if(a.useEffect(()=>{const D=G=>{const he=yb(G);if(he==="open"&&zt){G.preventDefault(),xt();return}Ne&&(he==="close"?(G.preventDefault(),lr()):(he==="next"||he==="previous")&&(G.preventDefault(),nt(he==="previous"?-1:1)))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[lr,Ne,nt,xt,zt]),a.useLayoutEffect(()=>{if(za(),!Ne||!Ze.trim()||!ae.current){Bt([]),wr(0);return}const D=wb(ae.current,Ze);return Bt(D),wr(0),_d(D,0),Dd(D[0]),za},[Ne,Ze,Te,be,j]),a.useEffect(()=>{Ne&&(_d(tt,Et),Dd(tt[Et]))},[Et,tt,Ne]),a.useEffect(()=>za,[]),!r)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 Ie=w&&!r.startsWith("/")?`${w}/${r}`:r,k=Za(Ie,w),Q=hu(Ie,w),ce=j.kind==="text"&&j.content?j.content.split(`
1654
+ `):[],Se=Math.max(2,String(ce.length).length)+1,Me=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,cr=As(Ie),mt=Ie.toLowerCase().endsWith(".csv"),Ur=Ie.toLowerCase().endsWith(".kicad_pro"),Mt=Ie.toLowerCase().endsWith(".kicad_prl"),sn=j.kind==="text"&&cr&&be==="preview",os=Rs(Ie),kr=j.kind==="text"&&os&&E==="preview",po=j.kind==="image"||j.kind==="loading"&&j.mode==="image",_t=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",an=j.kind==="video"||j.kind==="loading"&&j.mode==="video",is=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",ls=j.kind==="text"?j.sourcePath:Ie,zr=Om(ls,w,A),Hr=(()=>{if(!A||j.kind!=="text"||ce.length===0)return zr;const D=[];for(let we=A.start;we<=A.end;we+=1)D.push(`${we} ${ce[we-1]??""}`);const G=nf(Ie).replace(/^\./,""),he="```";return`${zr}
1655
+ ${he}${G}
1656
+ ${D.join(`
1657
+ `)}
1658
+ ${he}
1659
+ `})(),Wr=`path:${Ie}`,Vt=A?`path:${Ie}:${A.start}-${A.end}`:Wr,on=L===Wr,ln=L===Vt,Ws=T===Wr,Gr=T===Vt,Sr=ln||Gr,jr=A?A.start===A.end?`L${A.start}`:`L${A.start}-${A.end}`:null,Mn=D=>{const G=ae.current;if(!G)return;const he=G.getBoundingClientRect(),we=D.currentTarget.getBoundingClientRect(),Ve=D.clientX||we.left+we.width/2,Xe=(D.clientY||we.top+we.height/2)-he.top+G.scrollTop,We=p?116:132,pt=G.scrollLeft+Math.max(8,G.clientWidth-We),yt=Math.min(Math.max(8,Ve-he.left+G.scrollLeft+10),pt);ge({top:Xe,left:yt})},An=(D,G)=>{ol()||(Mn(D),M(he=>{const we=al(he,G,G);return we||ge(null),we}))},Rr=(D,G,he)=>{Mn(D),M(we=>{const Ve=al(we,G,he);return Ve||ge(null),Ve})},dr=(D,G,he,we)=>{we==="end"&&Mn(D),M({start:G,end:he})},De=D=>{const{scrollTop:G,scrollLeft:he}=D.currentTarget;R(G),Ci(w,r,{top:G,left:he,markdownTop:G})},ur=D=>{if(D.directory){m?.(D.path);return}if(D.path===Ie||j.kind==="text"&&D.path===j.sourcePath){D.fragment&&Br(D.fragment);return}ke(G=>[...G,Ie]),de.current=D.path,ze(D.fragment),M(null),O(D.path)},cn=()=>{const D=Y[Y.length-1];D&&(ke(G=>G.slice(0,-1)),de.current=D,ze(null),M(null),O(D))},cs=D=>{const{scrollTop:G,scrollLeft:he}=D.currentTarget;Ci(w,r,{top:G,left:he})},Pn=()=>{if(e){e(Hr,Vt);return}A&&i(Hr,Vt)},$n=async()=>{if(!(!Ie||V.status==="pending")&&!(j.kind==="loading"||j.kind==="error")){Ce({status:"pending"});try{await jm(Ie),Ce({status:"idle"})}catch(D){Ce({status:"error",message:D instanceof Error?D.message:o("rightSidebar.downloadFailed")})}}};return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Ke.popoverNode,t.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(sn||kr)?"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:[p&&h&&t.jsx("button",{type:"button",onClick:h,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:t.jsx(bu,{size:16})}),Y.length>0&&t.jsxs("button",{type:"button",onClick:cn,className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-primary/10 text-primary transition hover:bg-primary/15 active:scale-95 ${p?"w-9":"px-2.5"}`,"aria-label":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[t.jsx(ss,{size:15}),!p&&t.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),t.jsxs("div",{className:"min-w-0",title:Ie,children:[t.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:k.name}),k.dir&&t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:k.dir})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[zt&&t.jsx("button",{type:"button",onClick:Ne?lr:xt,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 ${Ne?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:t.jsx(rs,{size:14})}),cr&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{g&&v?.(),Re(D=>{const G=D==="preview"?"source":"preview";return Tt(Uu,G),G}),M(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(be==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(be==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?be==="preview"?t.jsx(Ui,{size:14}):t.jsx(Bi,{size:14}):o(be==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),os&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{ee(D=>{const G=D==="preview"?"source":"preview";return qg(w,r,G),G}),M(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${p?"w-9 px-0":"px-3"}`,"aria-label":o(E==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(E==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?E==="preview"?t.jsx(Ui,{size:14}):t.jsx(Bi,{size:14}):o(E==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),kr&&t.jsx("button",{type:"button",onClick:()=>{ue.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:t.jsx(ul,{size:15})}),!p&&t.jsx("button",{type:"button",onClick:()=>s(Ie,Wr),...Ke(Q,Wr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${on||Ws?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Q}),children:o(Ws?"rightSidebar.copied":on?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),t.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Q)},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:Q}),"aria-label":o("rightSidebar.copyFileRef"),children:t.jsx(cm,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{$n()},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.message??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:V.status==="pending"?t.jsx(bt,{size:13,className:"animate-spin"}):t.jsx(Bm,{size:14})})]})]}),Ne&&zt&&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(rs,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),t.jsx("input",{ref:kt,type:"search",value:Ze,onChange:D=>rr(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),nt(D.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:tt.length>0?`${Et+1}/${tt.length}`:"0/0"})]}),t.jsx("button",{type:"button",onClick:()=>nt(-1),disabled:tt.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(mu,{size:13})}),t.jsx("button",{type:"button",onClick:()=>nt(1),disabled:tt.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(Um,{size:13})}),t.jsx("button",{type:"button",onClick:lr,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(tr,{size:13})})]}),Me&&!(p&&(sn||kr))&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Me.size!==null&&t.jsx("span",{children:o("rightSidebar.byteCount",{count:Me.size.toLocaleString()})}),"truncated"in Me&&Me.truncated&&t.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Me&&t.jsx("span",{children:Me.mimeType}),"dimensions"in j&&j.dimensions&&t.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(p&&(sn||kr))&&!_t&&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:is?o("rightSidebar.edaPickHint"):mt?o("rightSidebar.csvTablePreview"):Ur||Mt?o("rightSidebar.kicadProjectPickHint"):an?o("rightSidebar.videoPreviewHint"):po?o("rightSidebar.imagePreviewHint"):sn?A?o("rightSidebar.selectedLineHint",{lineLabel:jr??""}):o("rightSidebar.markdownPreviewHint"):kr?o("rightSidebar.htmlPreviewHint"):A?o("rightSidebar.selectedLineHint",{lineLabel:jr??""}):o("rightSidebar.multiLineHint")})})]}),j.kind==="loading"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:j.mode==="eda"?o("rightSidebar.edaLoading"):j.mode==="image"?o("rightSidebar.loadingImage"):j.mode==="model3d"?o("rightSidebar.model3dLoading"):j.mode==="video"?o("rightSidebar.loadingVideo"):"Loading file…"}):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:Or,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(_u,{blobUrl:j.objectUrl,filePath:Ie,viewLabel:"SVG 文件",onInsertAnnotation:d}):t.jsx(Hf,{src:j.objectUrl,alt:k.name,vector:!1,onLoad:D=>{const G=D.currentTarget;X(he=>he.kind==="image"?{...he,dimensions:{width:G.naturalWidth,height:G.naturalHeight}}:he)},onError:()=>X({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(Jg,{url:j.url,onLoadError:()=>X({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(sb,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:Ie.toLowerCase().endsWith(".kicad_pcb"),onViewChange:ie,onInsertAnnotation:e??d,onRefresh:Or,interactive3d:pe?t.jsx(a.Suspense,{fallback:t.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.model3dLoading")}),children:t.jsx(Wd,{blobUrl:pe.objectUrl,ext:".glb",fileName:k.name,filePath:pe.sourcePath,features:null,onInsertFeature:e??d,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:D=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(D)?D:"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(a.Suspense,{fallback:t.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.model3dLoading")}),children:t.jsx(Wd,{blobUrl:j.objectUrl,ext:j.ext,fileName:k.name,filePath:j.sourcePath,features:$,onInsertFeature:e??d,onRefresh:Or})})}):j.kind==="text"&&mt?t.jsx(ib,{content:j.content,filePath:Ie,onInsertAnnotation:e??d},Ie):j.kind==="text"&&(Ur||Mt)?t.jsx(db,{content:j.content,filePath:Ie,localState:Mt,onInsertAnnotation:e??d},Ie):sn?t.jsxs("div",{ref:ae,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:De,style:{touchAction:"pan-x pan-y"},children:[t.jsx($f,{content:j.content,filePath:j.sourcePath,rootPath:w,lineRange:A,onLineRangeClick:Rr,onLineRangeDrag:dr,scrollTop:re,outlineOpen:g,outlineCloseSignal:f,onOutlineOpen:S,onOutlineClose:v,lightboxOpen:P,lightboxCloseSignal:N,onLightboxOpen:F,onLightboxClose:z,onLocalLinkOpen:ur}),A&&le&&t.jsxs("button",{type:"button",onClick:Pn,...Ke(Hr,Vt),style:{top:le.top,left:le.left,transform:"translateY(-50%)"},className:au(p,Sr),title:`Insert markdown reference: ${zr}`,children:[t.jsx(to,{size:p?13:11}),Gr?o("rightSidebar.copied"):ln?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:jr??""})]})]}):kr?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(xb,{ref:ue,src:dm(Ie),title:`${k.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:qe},`${Ie}:${Gt}:${Ut}`)}):j.kind==="text"?t.jsxs("div",{ref:ae,onScroll:cs,className:`${ml} 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:[ce.length>0?t.jsx("div",{className:"min-w-full",children:ce.map((D,G)=>{const he=G+1,we=!!(A&&he>=A.start&&he<=A.end),Ve=Te&&Te.length===ce.length?Te[G]:null;return t.jsxs("div",{ref:Fe=>{Fe?K.current.set(he,Fe):K.current.delete(he)},role:"button","data-file-preview-line":he,tabIndex:0,onClick:Fe=>An(Fe,he),onKeyDown:Fe=>{Fe.key!=="Enter"&&Fe.key!==" "||(Fe.preventDefault(),An(Fe,he))},style:{gridTemplateColumns:`${Se}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${we?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Q}:${he}`,children:[t.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${we?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:he}),t.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ve??(D||" ")})]},G)})}):"Empty file.",A&&le&&t.jsxs("button",{type:"button",onClick:Pn,...Ke(Hr,Vt),style:{top:le.top,left:le.left,transform:"translateY(-50%)"},className:au(p,Sr),title:`Insert code reference: ${zr}`,children:[t.jsx(to,{size:p?13:11}),Gr?o("rightSidebar.copied"):ln?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:jr??""})]})]}):null]})}function t0({isOpen:e,drawerWidthPx:r,onClose:s,onOpen:i,push:d,pinned:c=!1,onTogglePinned:h,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:g,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:S=!1,rightSidebarRepoPickerCloseSignal:v,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:N,markdownOutlineOpen:F=!1,markdownOutlineCloseSignal:z,onOpenMarkdownOutline:A,onCloseMarkdownOutline:M,markdownImageLightboxOpen:L=!1,markdownImageLightboxCloseSignal:T,onOpenMarkdownImageLightbox:B,onCloseMarkdownImageLightbox:_}){const{t:o,locale:w}=Nt(),[O,j]=a.useState(""),[X,se]=a.useState(null),ie=ne(n=>n.rightSearchOpen),pe=ne(n=>n.setRightSearchOpen),q=ne(n=>n.rightSidebarLayoutPreference),Z=ne(n=>n.setRightSidebarLayoutPreference),[$,U]=a.useState(()=>Vb()),[K,ae]=a.useState("."),[le,ge]=a.useState(""),[be,Re]=a.useState(!1),[E,ee]=a.useState(!1),[ue,Le]=a.useState(!1),[qe,_e]=a.useState(!1),fe=a.useDeferredValue(O),[re,R]=a.useState(null),[Y,ke]=a.useState([]),[xe,ze]=a.useState([]),[de,Qe]=a.useState(null),[Te,W]=a.useState(null),[V,Ce]=a.useState(null),[Ne,dt]=a.useState(null),[Ze,rr]=a.useState(()=>ut(Od,Ls)??!1),[tt,Bt]=a.useState(()=>ut(Bd,Ls)??!1),[Et,wr]=a.useState(()=>ut(Ud,Ls)??!1),[kt,Ke]=a.useState(()=>ut(vi,zb)??""),[ht,nr]=a.useState(0),[Gt,It]=a.useState(!1),[qt,Ut]=a.useState(!1),En=a.useRef(null),Or=a.useRef(null),[Br,zt]=a.useState(!1),[lr,xt]=a.useState(null),[nt,Ie]=a.useState(null),[k,Q]=a.useState(()=>Vd(xi)),[ce,Se]=a.useState(()=>Vd(Fd)),[Me,cr]=a.useState(()=>Ub()),[mt,Ur]=a.useState(()=>Hb()),[Mt,sn]=a.useState(()=>Gb()),os="words",[kr,po]=a.useState(0),[_t,an]=a.useState([]),[is,ls]=a.useState([]),[zr,Hr]=a.useState(!1),[Wr,Vt]=a.useState(null),[on,ln]=a.useState([]),[Ws,Gr]=a.useState(!1),[Sr,jr]=a.useState([]),[Mn,An]=a.useState([]),[Rr,dr]=a.useState(!1),[De,ur]=a.useState(null),[cn,cs]=a.useState([]),[Pn,$n]=a.useState({}),[D,G]=a.useState(!1),[he,we]=a.useState(null),[Ve,Fe]=a.useState(null),[Xe,We]=a.useState(null),[pt,yt]=a.useState(null),[fr,Cr]=a.useState(!1),[Ln,dn]=a.useState(""),ds=a.useDeferredValue(Ln),[hr,us]=a.useState({}),[un,qr]=a.useState([]),[te,Ge]=a.useState(!1),[Kt,Nr]=a.useState(!1),[jl,Tn]=a.useState(null),[go,In]=a.useState(!1),mr=a.useRef(null),Vr=a.useRef(0),Rl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Wf,Gs]=a.useState(null),[fs,Cl]=a.useState(()=>ut(yi,Ls)??!1),[bo,xo]=a.useState(!1),[qs,yo]=a.useState([]),[Er,Vs]=a.useState({}),[Dt,Ks]=a.useState({}),[Kr,Nl]=a.useState(!0),[El,Ml]=a.useState(()=>new Set),[it,fn]=a.useState(null),[vo,hn]=a.useState(null),[Gf,Mr]=a.useState(!1),[Al,Ar]=a.useState(0),[,wo]=a.useState(0),[ko,Ys]=a.useState(!1),[pr,So]=a.useState(!1),[qf,Pl]=a.useState(()=>ne.getState().rightTab==="diff"),[Vf,$l]=a.useState(()=>ne.getState().rightTab==="android"),[Yr,Ll]=a.useState(!0),[Oe,hs]=a.useState(null),[_n,ms]=a.useState(null),[St,Xr]=a.useState(null),[Tl,jt]=a.useState(null),[Dn,Il]=a.useState(null),[jo,Kf]=a.useState(()=>Date.now()),[Yf,Xf]=a.useState(!1),[mn,Xs]=a.useState(!1),[Js,_l]=a.useState(""),[Fn,Qs]=a.useState(""),[pn,Zs]=a.useState(""),[gn,ea]=a.useState(""),[Dl,On]=a.useState(null),[ta,ra]=a.useState(!1),[Fl,Ro]=a.useState(!1),[Ol,Bl]=a.useState(!1),[na,Jf]=a.useState({key:null,nonce:0}),Ul=a.useRef(null),zl=a.useRef(null),oe=Rm(r,c,q),Qf=Qu(oe,c,Mt),[Co,No]=a.useState(()=>tx(r)),Eo=ne(n=>n.rightTab),gr=ne(n=>n.setRightTab),b=ne(n=>n.rootPath),Bn=ne(n=>n.explorerRoot),Hl=ne(n=>n.pinnedExplorerRootsCache),Wl=ne(n=>n.hydratePinnedExplorerRoots),Gl=ne(n=>n.syncPinnedExplorerRoots),Yt=ne(n=>n.setExplorerRoot),ql=ne(n=>n.resetExplorerToProject),Un=ne(n=>n.pinExplorerRoot),bn=ne(n=>n.unpinExplorerRoot),st=ne(n=>n.selectedFilePath),at=ne(n=>n.selectFile),Mo=ne(n=>n.showHiddenFiles),Zf=ne(n=>n.toggleShowHiddenFiles),Ao=ne(n=>!!(b&&n.nestedGitScanRoots[b])),Ee=ne(n=>n.changedFiles),sa=ne(n=>n.setChangedFiles),aa=ne(n=>n.invalidateDirectoryCache),eh=ne(n=>n.setDirectorySortMode),Vl=ne(n=>n.applyFileWatchEvents),Kl=ne(n=>n.reconcileDirectoryCache),Yl=ne(n=>n.bumpFileWatchEpoch),Jr=ne(n=>n.gitBundleLoading),Xl=ne(n=>n.gitBundleSlow),xn=ne(n=>n.gitBundleError),zn=ne(n=>n.gitBundleLastLoadedAt),Jl=ne(n=>n.beginGitBundleLoading),Ql=ne(n=>n.setGitBundleSlowFor),Po=ne(n=>n.finishGitBundleLoading),oa=ne(n=>n.resetGitBundleLoading),$o=ne(n=>n.setGitBundleError),Zl=ne(n=>n.markGitBundleLoaded),ye=Bn??b,ec=a.useMemo(()=>ye?Sb(ye,K):"",[ye,K]),ps=a.useMemo(()=>kb(le),[le]),tc=a.useMemo(()=>({excludePatterns:ps,caseSensitive:E,wholeWord:ue,regex:qe}),[E,ps,qe,ue]),ia=ne(n=>ye?n.fileSortModes[ye]??"name":"name"),rc=ne(n=>!!(ye&&n.directoryCache.has(ye))),Hn=a.useRef(null),At=a.useRef(0),[nc]=a.useState(()=>++Yx),Pr=a.useRef(null),Qr=a.useRef(null),la=a.useRef(0),Xt=a.useRef(new Map),Jt=a.useRef(new Map),br=a.useRef(new Set),yn=a.useRef(new Set),vn=a.useRef(0),Zr=a.useRef(null),Wn=a.useRef(0),Gn=a.useRef(null),qn=a.useRef(0),en=a.useRef(null),Lo=a.useRef(new Set),To=a.useRef(null),Io=a.useRef(null),ca=a.useRef(null),_o=a.useRef(null);a.useEffect(()=>{if(Dn===null)return;const n=Math.max(0,Date.now()-Dn),l=n<6e4?1e3:n<36e5?6e4:n<864e5?36e5:864e5,u=Math.max(50,l-n%l),x=window.setTimeout(()=>Kf(Date.now()),u);return()=>window.clearTimeout(x)},[jo,Dn]);const da=a.useRef(null),$r=a.useRef(null),ua=a.useRef(null),gs=a.useRef(null),Ae=a.useCallback(n=>ne.getState().rootPath===n,[]);a.useEffect(()=>{if(!e||typeof window>"u")return;const n=l=>{const u=Zx(l.target);u&&Ya("global_change_row_event",{...e0(l),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:ne.getState().selectedFilePath,rightTab:ne.getState().rightTab,activeGitRepoRoot:de,changedFiles:ne.getState().changedFiles.size})};return window.addEventListener("pointerdown",n,{capture:!0}),window.addEventListener("click",n,{capture:!0}),()=>{window.removeEventListener("pointerdown",n,{capture:!0}),window.removeEventListener("click",n,{capture:!0})}},[de,e]);const sc=a.useCallback(async(n=b??void 0)=>{if(!n)return null;if(br.current.has(n)||yn.current.has(n))return lt("untracked_skip_cached",{cwd:n,rootPath:b,completed:br.current.has(n),running:yn.current.has(n)}),null;const l=b,u=la.current+1;la.current=u,Xt.current.set(n,u);const x=`right-sidebar-git-untracked:${n}`,y=new AbortController;Jt.current.set(n,y),yn.current.add(n),lt("untracked_start",{requestId:u,cwd:n,rootPath:b});try{let C=await hd(n,y.signal,x),I=0;for(;C.status==="running"&&I<120;){if(Xt.current.get(n)!==u||y.signal.aborted)return lt("untracked_stale_result",{requestId:u,activeRequestId:Xt.current.get(n),cwd:n,status:C.status}),null;if(!Ae(l))return lt("untracked_root_changed",{requestId:u,cwd:n,expectedRootPath:l,currentRootPath:ne.getState().rootPath}),null;await new Promise(J=>window.setTimeout(J,I<10?1e3:3e3)),I+=1,C=await hd(n,y.signal,x)}if(Xt.current.get(n)!==u||!Ae(l))return lt("untracked_stale_result",{requestId:u,activeRequestId:Xt.current.get(n),cwd:n,expectedRootPath:l,currentRootPath:ne.getState().rootPath,files:C.files.length,status:C.status}),null;if(C.status==="done")return sa(_f(ne.getState().changedFiles,C.files)),C.files.length>0&&ke(J=>{const Ye=new Map(J.map($e=>[$e.root,$e])).get(n);if(!Ye)return J;const Be=Dx(Ye.files,C.files),He=J.map($e=>$e.root===n?{...$e,files:Be,context:$e.context?{...$e.context,changedFiles:Be.map(et=>({path:et.path,absolutePath:et.absolutePath,status:et.status})),truncated:!1}:$e.context,untrackedDeferred:!1}:$e);ze(Df(He,b));const ve=He.find($e=>$e.root===b);return ve?.context&&R($e=>$e?.root===ve.root?{...$e,...ve.context}:$e),He}),br.current.add(n),lt("untracked_apply",{requestId:u,cwd:n,files:C.files.length}),C;const H=C.error||(C.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return br.current.add(n),lt("untracked_error",{requestId:u,cwd:n,message:H,code:C.code,status:C.status}),null}catch(C){if(Xt.current.get(n)!==u||!Ae(l)||Dr(C))return lt("untracked_aborted",{requestId:u,activeRequestId:Xt.current.get(n),cwd:n,expectedRootPath:l,currentRootPath:ne.getState().rootPath,message:C instanceof Error?C.message:String(C)}),null;const I=C instanceof Error?C.message:"Failed to scan untracked files";return br.current.add(n),lt("untracked_error",{requestId:u,cwd:n,message:I}),null}finally{Jt.current.get(n)===y&&Jt.current.delete(n),Xt.current.get(n)===u&&Xt.current.delete(n),yn.current.delete(n)}},[re,Ae,b,sa]),sr=a.useMemo(()=>{const n=new Set(xe.map(u=>u.root)),l=on.filter(u=>n.has(u));return l.length>0?l:de?[de]:[]},[de,on,xe]),ac=sr.length===0,wn=a.useMemo(()=>sr.map(n=>Y.find(l=>l.root===n)).filter(n=>!!n),[sr,Y]),th=a.useMemo(()=>xe.map(n=>({root:n.root,label:n.label,branch:n.branch??null})),[xe]),xr=a.useCallback(async()=>{if(!b){an([]),ls([]);return}const n=b,l=Wn.current+1;Wn.current=l,Gn.current?.abort();const u=new AbortController;Gn.current=u,Hr(_t.length===0),Vt(null);try{const x=sr.length>0?await Promise.all(sr.map(y=>md({workspaceRoot:b,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(C=>C.records),walkthroughs:y.flatMap(C=>C.walkthroughs??[])})):await md({workspaceRoot:b},u.signal);if(Wn.current!==l||!Ae(n))return;an(x.records),ls(x.walkthroughs??[])}catch(x){if(Wn.current!==l||!Ae(n)||Dr(x))return;Vt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{Gn.current===u&&(Gn.current=null),Wn.current===l&&Ae(n)&&Hr(!1)}},[_t.length,sr,Ae,b]),fa=a.useCallback(async(n,l,u)=>{if(!n&&!b){jr([]),An([]);return}const x=b,y=qn.current+1;qn.current=y,en.current?.abort();const C=new AbortController;en.current=C;try{const I=n?[n]:Array.from(new Set([b,...Y.map(J=>J.root)].filter(J=>!!J))),H=await Promise.all(I.map(J=>fm({repoRoot:J,baseRef:l,branchName:u},C.signal))).then(J=>{const Pe=new Map,Ye=new Map;for(const Be of J){for(const He of Be.records)Pe.set(He.id,He);for(const He of Be.walkthroughs??[])Ye.set(He.id,He)}return{records:Array.from(Pe.values()),walkthroughs:Array.from(Ye.values())}});if(qn.current!==y||!Ae(x))return;jr(H.records),An(H.walkthroughs??[])}catch(I){if(qn.current!==y||!Ae(x)||Dr(I))return;console.warn("[RightSidebar] Failed to load branch explanations",I)}finally{en.current===C&&(en.current=null)}},[Y,Ae,b]),tn=a.useCallback((n,l={})=>{if(!Ae(b)){lt("apply_skipped_root_changed",{expectedRootPath:b,currentRootPath:ne.getState().rootPath,bundleRoot:n.context?.root,files:n.files.length});return}lt(n.files.length===0?"empty_bundle":"apply",{rootPath:b,available:n.available,files:n.files.length,repositories:n.repositories?.map(ve=>({root:ve.root,relativeRoot:ve.relativeRoot,files:ve.files.length,available:ve.available,error:ve.error})),repoFilters:n.repoFilters?.map(ve=>({root:ve.root,label:ve.label,count:ve.count})),cached:n.cached,stale:n.stale,cacheAgeMs:n.cacheAgeMs,untrackedDeferred:n.untrackedDeferred,error:n.error});let u=Zu(n),x=n.repoFilters??[],y=n.files;const C=ne.getState().changedFiles;if(!!(l.cacheOnly&&!n.cached&&n.files.length===0&&u.length===0)&&(C.size>0||Y.length>0||re)){lt("cache_only_apply_skipped_empty_backend_cache",{rootPath:b,currentFiles:C.size,currentRepositories:Y.length});return}const H=u.some(ve=>ve.deferred);if(H&&!l.replaceWorkspace){const ve=new Set(u.filter(et=>!et.deferred||et.root===b).map(et=>et.root));y=[...Array.from(C.values()).filter(et=>!ve.has(wt(et,b)??"")),...n.files]}const J=ou(C.values(),b),Pe=ou(n.files,b),Ye=u.some(ve=>ve.root!==b);if(!!(l.background&&!H&&!l.replaceWorkspace&&C.size>0&&(n.files.length===0&&!n.error||J>0&&Pe===0&&!Ye))){lt("background_apply_skipped_degraded_bundle",{rootPath:b,currentFiles:C.size,nextFiles:n.files.length,currentNestedCount:J,nextNestedCount:Pe,nextRepositories:u.map(ve=>({root:ve.root,relativeRoot:ve.relativeRoot,files:ve.files.length})),cached:n.cached,stale:n.stale,error:n.error});return}if(l.replaceRepoRoot){const ve=Ff(C.values(),Y,n,l.replaceRepoRoot,b);y=ve.files,u=ve.repositories,x=ve.repoFilters}if(sa(If(y)),ke(u),ze(x),l.syncActiveRepo!==!1){const ve=l.activeRepoRoot!==void 0?l.activeRepoRoot:de??qd(b),$e=Yb({...n,repositories:u,repoFilters:x},ve);Qe($e),ki(b,$e)}typeof n.cacheUpdatedAt=="number"&&Il(n.cacheUpdatedAt),R(ve=>{if(l.replaceRepoRoot&&l.replaceRepoRoot!==b)return ve;if(!n.context)return null;const $e=ve?.root??b;return!ve?.available||$e!==(n.context.root??b)?n.context:{...ve,...n.context}}),l.reloadDiff&&po(ve=>ve+1);const He=ne.getState().selectedFilePath;if(He&&!He.startsWith("/")&&!y.some(ve=>ve.path===He||ve.absolutePath===He)&&at(null),Q(ve=>{const $e=new Set(y.map(ir=>wt(ir,b)).filter(Boolean)),et=new Set;for(const ir of ve)$e.has(ir)&&et.add(ir);return Si(xi,et),et}),l.loadDeferred!==!1){const ve=u.filter($e=>$e.untrackedDeferred&&$e.root).map($e=>$e.root);for(const $e of ve)sc($e)}l.loadAudit!==!1&&xr()},[de,Ae,xr,sc,b,at,sa]);a.useEffect(()=>{oa(),To.current=null,Io.current=b;const n=[],l=[],x=qd(b);At.current+=1,vn.current+=1,la.current+=1,Pr.current?.abort(),Lt(ts(Qr.current?.cwd??b??void 0)),Qr.current=null,Pr.current=null,Zr.current?.abort(),Lt("right-sidebar-git-details"),Zr.current=null;for(const J of Jt.current.values())J.abort();for(const J of Jt.current.keys())Lt(`right-sidebar-git-untracked:${J}`);Jt.current.clear(),Xt.current.clear(),Wn.current+=1,Gn.current?.abort(),Gn.current=null,qn.current+=1,en.current?.abort(),en.current=null,Vr.current+=1,mr.current?.abort(),Lt("right-sidebar-recent-commits"),mr.current=null,an([]),ls([]),Hr(!1),Vt(null),ln([]),Gr(!1),jr([]),An([]),dr(!1),ur(null),G(!1),we(null),Fe(null),We(null),yt(null),Cr(!1),dn(""),qr([]),Ge(!1),Nr(!1),Tn(null),In(!1),Gs(null),fn(null),hn(null),Cl(!1),Tt(yi,!1),xo(!1);const y=b?Kd()[b]:null,C=y?.previewEntries??[],I=y?.selectedPreviewKey??null,H=I?C.find(J=>J.key===I)??null:null;yo(y?.selectedRepoRoots??[]),Vs(y?.repoTargetBranches??{}),Ks(y?.repoBaseBranches??{}),cs(C),$n(y?.previewScrollTops??{}),H&&y?.previewDetailOpen&&(H.diff.hunks?.length??0)>0&&(ur(H.diff),fn(H.key),hn(y.selectedPreviewFileKey??(H.diff.hunks?.[0]?`${H.diff.hunks[0].filePath}\0${H.diff.hunks[0].hunkHeader}\0${H.diff.hunks[0].hunkIndex}`:null)),dr(!0)),Nl(y?.includeUncommitted??!0),To.current=b,Xs(!1),Qe(x??null),br.current.clear(),yn.current.clear(),hs(null),ms(null),Xr(null),jt(null),Il(null),ke(n),ze(l),R(null),_o.current=null},[oa,b]);const ar=a.useCallback(async(n=b??void 0,l={})=>{if(!n)return null;const u=b,x=At.current;if(await Bp(ne.getState().hydrateNestedGitScanRoots),At.current!==x||!Ae(u))return null;const y=n===b&&Zn(b),C=l.includeNested??y,I=l.refresh??l.reloadDiff??!1,H=l.cacheOnly??!1,J=l.background??!1,Pe=C&&(l.discoverOnly??!1);I&&br.current.clear();const Ye=Qr.current;if(Ye&&Ye.cwd===n&&Ye.includeNested===C&&Ye.refresh===I&&Ye.cacheOnly===H&&Ye.discoverOnly===Pe)return lt("reuse_pending",{cwd:n,includeNested:C,refresh:I,cacheOnly:H,discoverOnly:Pe}),Ye.promise;const Be=At.current+1;At.current=Be;const He=`right-sidebar:${nc}:${Be}`;Pr.current?.abort();const ve=ts(n);Lt(ve);const $e=new AbortController;Pr.current=$e;let et=null;J||Jl(He),$o(null),lt("start",{requestId:Be,cwd:n,rootPath:b,requestSlotId:ve,includeNested:C,refresh:I,cacheOnly:H,background:J,existingChanges:Ee.size,lastLoadedAt:zn}),!J&&typeof window<"u"&&(et=window.setTimeout(()=>{At.current===Be&&Ql(He,!0)},$b));const ir=(async()=>{const Ue=await La(n,$e.signal,{includeNested:C,refresh:I,cacheOnly:H,discoverOnly:Pe,action:I?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:ve,requestTimeoutMs:I?null:void 0});if(Bx(Ue)){if(lt("cancelled_result_ignored",{requestId:Be,activeRequestId:At.current,cwd:n,error:Ue.error??Ue.context?.error}),$e.signal.aborted)return null;throw new Error(Ue.error??Ue.context?.error??"Failed to load Git changes")}return At.current!==Be||!Ae(u)?(lt("stale_result",{requestId:Be,activeRequestId:At.current,cwd:n,expectedRootPath:u,currentRootPath:ne.getState().rootPath,files:Ue.files.length,repositories:Ue.repositories?.length??0}),null):(tn(Ue,{reloadDiff:l.reloadDiff,syncActiveRepo:l.replaceWorkspace?!0:C,background:J,cacheOnly:H,replaceRepoRoot:l.replaceRepoRoot,replaceWorkspace:l.replaceWorkspace}),Ue)})();Qr.current={cwd:n,includeNested:C,refresh:I,cacheOnly:H,discoverOnly:Pe,promise:ir};try{const Ue=await ir;return At.current===Be&&Ue&&Ae(u)?Zl({cached:Ue.cached,stale:Ue.stale,cacheAgeMs:Ue.cacheAgeMs,nestedDeferred:!C||Ue.nestedDeferred,untrackedDeferred:Ue.untrackedDeferred}):At.current===Be&&Ae(u)&&Po(He),Ue}catch(Ue){return At.current!==Be||!Ae(u)||$e.signal.aborted?(lt("aborted",{requestId:Be,activeRequestId:At.current,cwd:n,expectedRootPath:u,currentRootPath:ne.getState().rootPath,message:Ue instanceof Error?Ue.message:String(Ue)}),null):(lt("error",{requestId:Be,cwd:n,includeNested:C,refresh:I,background:J,message:Ue instanceof Error?Ue.message:String(Ue)}),J||(R(null),$o(Ue instanceof Error?Ue.message:"Failed to load Git changes")),null)}finally{et!==null&&window.clearTimeout(et),Pr.current===$e&&(Pr.current=null),Qr.current?.promise===ir&&(Qr.current=null),!J&&At.current===Be&&Ae(u)&&Po(He)}},[tn,Jl,Ee.size,Po,nc,zn,Ae,Zl,b,$o,Ql]),bs=a.useCallback(async()=>{b&&await ar(b,{reloadDiff:!0,refresh:!0})},[ar,b]),Do=a.useCallback(async(n=b??void 0)=>{if(!n)return null;const l=b,u=vn.current+1;vn.current=u,Zr.current?.abort(),Lt("right-sidebar-git-details");const x=new AbortController;Zr.current=x,Xs(!0);try{const y=await pd(n,x.signal,"load_git_details","right-sidebar-git-details");return vn.current!==u||!Ae(l)?null:(ke(C=>C.map(I=>I.root===y.root?{...I,available:y.available,context:y,error:y.error}:I)),R(C=>C?.root&&y.root&&C.root!==y.root?C:!C?.available||!y.available?y:{...C,...y}),y)}catch(y){return Dr(y)||!Ae(l)||vn.current===u&&jt(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Zr.current===x&&(Zr.current=null),vn.current===u&&Ae(l)&&Xs(!1)}},[Ae,b]);a.useEffect(()=>{if(!e){At.current+=1,oa(),_o.current=null,vn.current+=1,la.current+=1,Pr.current?.abort(),Lt(ts(Qr.current?.cwd??b??void 0)),Qr.current=null,Pr.current=null,Zr.current?.abort(),Lt("right-sidebar-git-details"),Zr.current=null;for(const n of Jt.current.values())n.abort();for(const n of Jt.current.keys())Lt(`right-sidebar-git-untracked:${n}`);Jt.current.clear(),Xt.current.clear(),qn.current+=1,en.current?.abort(),en.current=null,Vr.current+=1,mr.current?.abort(),Lt("right-sidebar-recent-commits"),mr.current=null,Xs(!1),G(!1),we(null),Fe(null),We(null),yt(null),Cr(!1),dn(""),qr([]),Ge(!1),Nr(!1),Tn(null),In(!1),j(""),pe(!1),xt(null),So(!1),$l(!1),oe&&Pl(!1)}},[oe,e,oa,pe]),a.useEffect(()=>{if(!ie)return;const n=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(n)},[ie]),a.useEffect(()=>{oe||Mr(!1)},[oe]);const xs=a.useCallback(n=>{wo(n);const l=ua.current;l&&(l.update(),l.slideTo(n,0),window.requestAnimationFrame(()=>{l.update(),l.slideTo(n,0)}))},[]);a.useEffect(()=>{if(oe)if(Mr(m),m&&st){Ar(1);const n=$r.current;n&&(n.update(),n.activeIndex!==1&&(gs.current=1,n.slideTo(1,0)))}else{Ar(0);const n=$r.current;n&&n.activeIndex!==0&&(gs.current=0,n.slideTo(0,0)),xt(null)}},[oe,m,b,st]),a.useEffect(()=>{if(p!==void 0&&!m){Ar(0);const n=$r.current;n&&n.activeIndex!==0&&(gs.current=0,n.slideTo(0,0)),Mr(!1),xt(null)}},[p,m]),a.useEffect(()=>{v!==void 0&&W(null)},[v]),a.useEffect(()=>{!oe&&m&&f?.()},[oe,f,m]),a.useEffect(()=>{No(n=>Qi(n,r))},[r]);const rh=a.useCallback(n=>{oe||(n.preventDefault(),da.current={startX:n.clientX,startWidth:Co,pointerId:n.pointerId},n.currentTarget.setPointerCapture(n.pointerId))},[Co,oe]),nh=a.useCallback(n=>{const l=da.current;if(!l||l.pointerId!==n.pointerId)return;const u=Qi(l.startWidth+n.clientX-l.startX,r);No(u),Ts($s,u,Pb)},[r]),oc=a.useCallback(n=>{const l=da.current;if(!(!l||l.pointerId!==n.pointerId)){da.current=null,Cs($s);try{n.currentTarget.releasePointerCapture(n.pointerId)}catch{}}},[]),Vn=!!(b&&zn!==null&&cu(re)),Fo=!!(b&&!xn&&Ee.size===0&&zn===null),yr=(()=>{let n=Eo;return n==="android"&&!Yr&&(n="files"),Vn&&(n==="git"||n==="diff")&&(n="files"),n})(),ot=yr==="git",Kn=yr==="files",Pt=yr==="diff",Oo=yr==="android";a.useEffect(()=>{if(!oe){Ys(!0);return}if(!e){const l=window.setTimeout(()=>{Ys(!1)},Tb);return()=>window.clearTimeout(l)}Ys(!1);const n=window.setTimeout(()=>{Ys(!0)},Lb);return()=>window.clearTimeout(n)},[oe,e]),a.useEffect(()=>{if(!oe||!Pt)return;const n=ua.current;if(!n)return;const l=window.requestAnimationFrame(()=>{n.update()});return()=>window.cancelAnimationFrame(l)},[Pt,oe]),a.useEffect(()=>{if(!Vn||!b||Jr)return;const n=window.setTimeout(()=>{ar(b,{background:!0})},3e3);return()=>window.clearTimeout(n)},[Vn,b,Jr,ar]);const sh=a.useCallback(n=>{ar(n,{discoverOnly:!0})},[ar]);Up({active:e&&(ot||Pt),rootPath:b,loading:Jr,delay:ot&&!oe?0:wi,lastStartedRoot:_o,load:sh}),a.useEffect(()=>{!e||!ot||(!oe||ko)&&So(!0)},[ot,oe,e,ko]),a.useEffect(()=>{if(!e||ot)return;const n=window.setTimeout(()=>{So(!0)},wi);return()=>window.clearTimeout(n)},[ot,e]),a.useEffect(()=>{Pt&&Pl(!0)},[Pt]),a.useEffect(()=>{Oo&&$l(!0)},[Oo]),a.useEffect(()=>{let n=!1;return ll().then(l=>{!n&&l.androidPanel&&Ll(l.androidPanel.enabled!==!1)}).catch(()=>{}),()=>{n=!0}},[]);const ah=a.useCallback(n=>{Ll(n),!n&&ne.getState().rightTab==="android"&&gr("files"),cl({androidPanel:{enabled:n}}).catch(()=>{})},[gr]),ic=a.useCallback(n=>{ye&&$x(ye,n.currentTarget.scrollTop)},[ye]);a.useEffect(()=>()=>{Pr.current?.abort(),Cs(fl),Cs(hl),Cs($s),Cs(vi)},[]),a.useEffect(()=>{if(!ye||!rc)return;const n=Lf()[ye]?.top;if(typeof n!="number")return;let l=window.requestAnimationFrame(()=>{Hn.current&&(Hn.current.scrollTop=n),l=window.requestAnimationFrame(()=>{Hn.current&&(Hn.current.scrollTop=n)})});return()=>window.cancelAnimationFrame(l)},[ye,rc]),a.useEffect(()=>{if(!e)return;const n=new AbortController;return hm(n.signal).then(l=>Bl(!!l.available)).catch(()=>Bl(!1)),()=>n.abort()},[e]);const ys=a.useCallback(n=>{if(se(null),at(n),xt(null),oe){Mr(!0),Ar(1),$r.current?.slideTo(1),g?.();return}},[oe,g,at]),lc=a.useCallback((n,l)=>{if(se(null),at(n),Ie(l),oe){Mr(!0),Ar(1),$r.current?.slideTo(1),g?.();return}},[oe,g,at]),vs=a.useCallback(async(n,l)=>{const u=l||Bn||b;if(!(!u||n.length===0)){ra(!0);try{await ci(u,n),aa(u,!1)}catch(x){jt(x instanceof Error?x.message:o("rightSidebar.uploadFailed")),window.setTimeout(()=>jt(null),4e3)}finally{ra(!1)}}},[Bn,b,aa,o]),cc=a.useCallback(async n=>{try{await mm(n)}catch(l){jt(l instanceof Error?l.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>jt(null),4e3)}},[o]),ha=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),n.dataTransfer.types.includes("Files")&&Ro(!0)},[]),dc=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),Ro(!1)},[]),uc=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),Ro(!1);const l=n.dataTransfer.files;l.length>0&&vs(Array.from(l))},[vs]),Bo=a.useCallback(n=>{Ce(n),window.setTimeout(()=>Ce(l=>l===n?null:l),1400)},[]),Lr=a.useCallback(n=>{dt(n),window.setTimeout(()=>dt(l=>l===n?null:l),1400)},[]);a.useEffect(()=>{Tt(Od,Ze)},[Ze]),a.useEffect(()=>{Tt(Bd,tt)},[tt]),a.useEffect(()=>{Tt(Ud,Et)},[Et]),a.useEffect(()=>{Ts(vi,kt,Cb)},[kt]),a.useEffect(()=>(Wl().catch(()=>{}),gd(n=>{n.type==="pinned-explorer-roots"&&Gl(n.pinnedExplorerRoots)})),[Wl,Gl]);const fc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ma=a.useRef(null),kn=a.useRef(null),[hc,Uo]=a.useState(!1);a.useEffect(()=>{if(!e)return;Uo(!1);let n=!1;pm().then(u=>{n||(ma.current=u.text,Ke(x=>u.text&&u.text!==x?u.text:x),Uo(!0))}).catch(()=>{n||Uo(!0)});const l=gd(u=>{u.type==="context-draft"&&u.origin!==fc.current&&(ma.current=u.text,Ke(u.text))});return()=>{n=!0,l(),kn.current!==null&&(window.clearTimeout(kn.current),kn.current=null)}},[e]),a.useEffect(()=>{if(!hc||ma.current===kt)return;kn.current!==null&&window.clearTimeout(kn.current);const n=kt;kn.current=window.setTimeout(()=>{kn.current=null,gm(n,fc.current).then(()=>{ma.current=n}).catch(()=>{})},500)},[kt,hc]);const Yn=a.useCallback((n,l,u)=>{if(n){if(bm(u?n+u:n)){Bo(l);return}Ze?(Ke(x=>Hg(x,n)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(Bt(!1),nr(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?n+u:n,focus:!0}})),Bo(l)}},[Ze,Bo]),pa=a.useCallback(n=>{const l=Ia(n,b);return zm(l,b)},[b]),zo=ju(Lr),rn=a.useCallback((n,l)=>{const u=Ia(n,b);Yn(Hm(u,b),l??`path:${u}`)},[b,Yn]),oh=a.useCallback(async n=>{ra(!0);try{await Wm(n,ci,l=>{rn(l,`path:${l}`)}),oe&&!Ze&&s()}catch(l){jt(l instanceof Error?l.message:o("rightSidebar.uploadFailed")),window.setTimeout(()=>jt(null),4e3)}finally{ra(!1)}},[Ze,rn,oe,s,o]),Tr=a.useCallback((n,l)=>{if(!n)return;const u=n.includes(`
1660
+ `)?`
1661
+ `:void 0;Yn(n.endsWith(`
1662
+ `)||n.endsWith(" ")?n:`${n} `,l,u)},[Yn]),mc=a.useRef(Tr);mc.current=Tr;const Ho=a.useRef(!0);a.useEffect(()=>(Ho.current=!0,()=>{Ho.current=!1}),[]);const Wo=a.useRef(new Set),pc=a.useCallback((n,l,u)=>{if(Wo.current.has(l))return;const x=Wi.getState().activeSessionId;Wo.current.add(l),Wp(n,l,u,{insert:Tr,upload:async(y,C)=>(await ci("/tmp",[y],C)).files[0]?.path,isCurrent:()=>Ho.current&&mc.current===Tr&&x===Wi.getState().activeSessionId}).finally(()=>Wo.current.delete(l))},[Tr]),nn=a.useCallback((n,l,u)=>{l&&Yn(l.endsWith(" ")?l:`${l} `,u??`context:${n}`,`
1663
+ `)},[Yn]),gc=a.useCallback(n=>{const l=Wg(kt,n);if(!l)return;const u=n&&kt.trim().includes(`
1664
+ `),x=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let y=!1;const C=J=>{y||(y=!0,window.removeEventListener("termdock-insert-reference-ack",I),window.clearTimeout(H),J?(zt(!1),Ke(""),Et&&Bt(!0)):(zt(!0),Bt(!1)))},I=J=>{const Pe=J.detail;Pe?.nonce===x&&C(Pe.ok===!0)},H=window.setTimeout(()=>C(!1),1500);window.addEventListener("termdock-insert-reference-ack",I),zt(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:l,focus:!0,paste:u,nonce:x}}))},[Et,kt]),rt=a.useMemo(()=>b?Ct(b):o("rightSidebar.workspace"),[b,o]),ih=a.useMemo(()=>Ct(ye)||rt,[ye,rt]),ga=a.useMemo(()=>Ei(ye),[ye]),ba=a.useMemo(()=>b?Hl[b]??[]:[],[Hl,b]),Sn=a.useMemo(()=>new Set(ba.map(n=>n.path)),[ba]),ws=!!(ye&&Sn.has(ye)),Go=!!(b&&ye&&ye!==b),lh=!!(b&&Bn&&Bn!==b),Ht=ye?`path:${ye}`:null,bc="context:change-audit",ch=a.useCallback(()=>{ga&&Yt(ga)},[ga,Yt]),xc=a.useCallback(()=>{ql()},[ql]),dh=a.useCallback(()=>{ye&&(aa(ye,!0),Yl())},[Yl,ye,aa]),uh=a.useCallback(()=>{!ye||!Go||(ws?bn(ye):Un(ye,"directory"))},[Go,ye,ws,Un,bn]),yc=a.useCallback(n=>{Yt(n),j("")},[Yt]),vc=a.useCallback(n=>{ye&&(ae(jb(ye,n)),pe(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ye,pe]),wc=a.useCallback(n=>{!b||n===b||(Sn.has(n)?bn(n):Un(n,"directory"))},[Un,Sn,b,bn]),kc=a.useCallback(n=>{!b||!n||(Sn.has(n)?bn(n):Un(n,"file"))},[Un,Sn,b,bn]),Sc=ne(n=>n.expandedPaths),qo=a.useMemo(()=>{const n=new Set;if(Kn&&ye){n.add(ye);const l=`${ye.replace(/\/+$/,"")}/`;for(const u of Sc)u.startsWith(l)&&n.add(u)}if(Kn&&b&&st){const l=st.startsWith("/")?st:`${b}/${st}`,u=Ei(l);u&&n.add(u)}return sg(n).join(`
1665
+ `)},[Sc,Kn,ye,b,st]),jn=a.useRef(new Map);a.useEffect(()=>{const n=qo?qo.split(`
1666
+ `):[];if(!e||n.length===0){On(null);return}const l=new AbortController;let u=!1,x=0,y=0;On(null);const C=async()=>{let I=0;for(;!u&&!l.signal.aborted;){let H=null;try{On(null),await Cm(n,Pe=>{const{applicableEvents:Ye,unavailableReason:Be}=og(Pe);Ye.length>0&&Vl(Ye);for(const He of Ye){if(He.type!=="rescan-required")continue;const ve=ne.getState();if(!ve.directoryCache.has(He.path))continue;jn.current.get(He.path)?.abort();const et=new AbortController;jn.current.set(He.path,et);const ir=`file-watch-rescan:${He.path}`;Lt(ir),Nm(He.path,et.signal,ve.showHiddenFiles,"watch_rescan",ir,ve.fileSortModes[He.path]??"name").then(Ue=>{jn.current.get(He.path)===et&&Kl(He.path,Ue.entries)}).catch(Ue=>{Dr(Ue)||On(Ue instanceof Error?Ue.message:"File refresh unavailable")}).finally(()=>{jn.current.get(He.path)===et&&jn.current.delete(He.path)})}Be&&On(Be)},l.signal),H=new Error("File watch stream ended")}catch(Pe){H=Pe}if(u||l.signal.aborted||Dr(H))return;On(H instanceof Error?H.message:"File watching unavailable");const J=zd[Math.min(I,zd.length-1)];I+=1,await new Promise(Pe=>{y=window.setTimeout(Pe,J)})}};return x=window.setTimeout(()=>{u||C()},wi),()=>{u=!0,window.clearTimeout(x),window.clearTimeout(y),l.abort();for(const I of jn.current.values())I.abort();jn.current.clear()}},[Vl,e,Kl,qo]),a.useEffect(()=>{if(!b||To.current!==b)return;if(Io.current===b){Io.current=null;return}const n=Kd();Ts(qu,{...n,[b]:{selectedRepoRoots:qs,repoTargetBranches:Er,repoBaseBranches:Dt,previewEntries:cn,selectedPreviewKey:De&&Rr?it:null,selectedPreviewFileKey:De&&Rr?vo:null,previewDetailOpen:!!(De&&Rr),previewScrollTops:Pn,previewMobileSlideIndex:1,includeUncommitted:Kr,updatedAt:Date.now()}},Rb)},[Rr,Kr,De,cn,Pn,Dt,Er,qs,b,vo,it]);const gt=a.useMemo(()=>lu(Ee.values()),[Ee]),$t=a.useMemo(()=>{const n=new Map;for(const l of Y)n.set(l.root,l);return n},[Y]),Vo=a.useMemo(()=>{const n=new Map;for(const l of Y)l.deferred||n.set(l.root,l.files.length);return n},[Y]),Ft=a.useMemo(()=>de?xe.find(n=>n.root===de)??null:null,[de,xe]),Qt=a.useMemo(()=>st?Array.from(Ee.values()).find(n=>n.path===st||n.absolutePath===st)??null:null,[Ee,st]),Wt=a.useMemo(()=>{const n=new Map;for(const l of Y)l.available&&l.context?.available&&n.set(l.root,l);return n.size===0&&re?.available&&re.root&&n.set(re.root,{id:re.root,root:re.root,relativeRoot:".",name:rt,depth:0,nested:!1,available:!0,files:Array.from(Ee.values()).filter(l=>wt(l,b)===re.root),context:re}),Array.from(n.values()).sort((l,u)=>l.root===b?-1:u.root===b?1:(l.relativeRoot||l.name).localeCompare(u.relativeRoot||u.name)).map(l=>{const u=l.relativeRoot==="."?rt:l.relativeRoot||l.name||Ct(l.root),x=iu(l.files),y=l.files.length;return{value:l.root,label:u,meta:[l.context?.branch,y>0?o("rightSidebar.repoChangedCount",{count:y}):null,x>0?o("rightSidebar.repoStagedCount",{count:x}):null].filter(Boolean).join(" · ")}})},[Ee,re,Y,rt,b,o]),je=a.useMemo(()=>de&&Wt.some(n=>n.value===de)?de:Qt?.repoRoot&&Wt.some(n=>n.value===Qt.repoRoot)?Qt.repoRoot:Wt.length===1||Wt.length>1?Wt[0].value:null,[de,Wt,Qt?.repoRoot]),jc=je?$t.get(je)??null:null,me=jc?.context?.available?jc.context:je===re?.root?re:null,Je=Wt.length>0&&!je,Rc=a.useMemo(()=>Je?[]:je?Array.from(Ee.values()).filter(n=>wt(n,b)===je):Array.from(Ee.values()),[je,Ee,Je,b]),Rn=a.useMemo(()=>lu(Rc),[Rc]),Ko=!!(me?.available&&me.root&&je&&me.root===je),fh=je?Wt.find(n=>n.value===je)?.label??Ct(je):o("rightSidebar.gitRepositoryPlaceholder"),Cc=Ko?me?.branch??"HEAD":Je?o("rightSidebar.selectRepositoryForGitActions"):mn?o("rightSidebar.gitActionRunning"):"HEAD",Xn=!!(me?.available&&me.root===je&&me.status);a.useEffect(()=>{Rl.current={count:un.length,loading:te,loadingMore:Kt,hasMore:go}},[un.length,go,te,Kt]),a.useEffect(()=>{Vr.current+=1,mr.current?.abort(),Lt("right-sidebar-recent-commits"),mr.current=null,dn(""),qr([]),Ge(!1),Nr(!1),Tn(null),In(!1)},[je]);const ks=a.useCallback(async(n={})=>{if(!b||!je||Je)return;const l=n.reset??!1,u=Rl.current,x=l?0:u.count;if(!l&&(u.loading||u.loadingMore||!u.hasMore))return;const y=Vr.current+1;Vr.current=y,mr.current?.abort(),Lt("right-sidebar-recent-commits");const C=new AbortController;mr.current=C,l?Ge(!0):Nr(!0),Tn(null);try{const I=await xm({cwd:b,repoRoot:je,limit:Ib,skip:x,query:ds.trim(),requestSlotId:"right-sidebar-recent-commits"},C.signal);if(Vr.current!==y)return;if(!I.available){Tn(I.error??"Recent commits are unavailable"),l&&qr([]),In(!1);return}us(H=>l?I.commitSyncStatus??{}:{...H,...I.commitSyncStatus}),qr(H=>l?I.commits:[...H,...I.commits]),In(I.hasMore)}catch(I){if(Vr.current!==y||Dr(I))return;Tn(I instanceof Error?I.message:"Failed to load recent commits"),l&&qr([]),In(!1)}finally{mr.current===C&&(mr.current=null),Vr.current===y&&(Ge(!1),Nr(!1))}},[je,ds,Je,b]);a.useEffect(()=>{fr&&ks({reset:!0})},[ds,ks,fr,me?.ahead,me?.behind,me?.upstream]);const hh=a.useCallback(n=>{const l=n.currentTarget;l.scrollTop+l.clientHeight<l.scrollHeight-48||ks({reset:!1})},[ks]);a.useEffect(()=>{!je||!re?.available||!ot||!pr||Xn||mn||Je||Do(je)},[je,re?.available,Xn,mn,ot,pr,Do,Je]),a.useEffect(()=>{!e||!Pt&&!ot||!b||xr()},[Pt,ot,e,xr,b]),a.useEffect(()=>{!e||!ot||!pr||!fs||!b||fa(null)},[fs,ot,pr,e,fa,b]);const mh=a.useMemo(()=>{if(!de)return 0;const n=xe.findIndex(l=>l.root===de);return n>=0?n+1:0},[de,xe]),Nc=a.useCallback(n=>{if(!n)return null;const l=Array.from(Ee.values()).filter(u=>wt(u,b)===n).sort((u,x)=>u.path.localeCompare(x.path))[0];return l?Rt(l):null},[Ee,b]),Cn=xe.length>1,xa=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ee.size,branch:null,deferred:!1},...xe.map(n=>({root:n.root,label:n.label,count:n.deferred?Vo.get(n.root)??0:n.count,branch:n.branch??null,deferred:!!n.deferred&&!Vo.has(n.root)}))],[Ee.size,xe,Vo,o]),Ec=xa[mh]??xa[0],ya=!!de,Mc=a.useMemo(()=>tf(xe,Y),[xe,Y]);a.useEffect(()=>{de&&!Mc.has(de)&&(Qe(null),ki(b,null)),ln(n=>n.filter(l=>xe.some(u=>u.root===l)))},[de,xe,Mc,b]);const ph=a.useMemo(()=>{const n=new Set;me?.branch&&n.add(me.branch);for(const l of me?.branches??[])n.add(l);return Array.from(n).map(l=>({value:l,label:l,meta:l===me?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[me?.branch,me?.branches,o]),Ac=a.useMemo(()=>{const n=new Set;me?.upstreamRemote&&n.add(me.upstreamRemote);for(const l of me?.remotes??[])n.add(l);return Array.from(n).map(l=>({value:l,label:l,meta:l===me?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[me?.remotes,me?.upstreamRemote,o]),Pc=Ac.length>1,gh=a.useMemo(()=>{const n=[],l=new Set,u=(y,C)=>{!y||l.has(y)||(l.add(y),n.push({value:y,label:y,meta:C}))};u(me?.upstreamBranch,me?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(me?.branch,me?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const y of me?.branches??[])u(y,y===me?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const x=me?.upstreamRemote;for(const y of me?.remoteBranches??[]){const C=y.indexOf("/"),I=C>=0?y.slice(0,C):null,H=C>=0?y.slice(C+1):y;(!x||I===x)&&u(H,"remote")}return n},[me?.branch,me?.branches,me?.remoteBranches,me?.upstreamBranch,me?.upstreamRemote,o]),Zt=a.useMemo(()=>Wt.map(n=>{const l=$t.get(n.value);return{root:n.value,label:n.label,branch:l?.context?.branch??null}}),[Wt,$t]);a.useEffect(()=>{Zt.length!==0&&(Vs(n=>{let l=!1;const u={...n},x=new Set(Zt.map(y=>y.root));for(const y of Object.keys(u))x.has(y)||(delete u[y],l=!0);for(const y of Zt)!u[y.root]&&y.branch&&(u[y.root]=y.branch,l=!0);return l?u:n}),Ks(n=>{let l=!1;const u={...n},x=new Set(Zt.map(y=>y.root));for(const y of Object.keys(u))x.has(y)||(delete u[y],l=!0);for(const y of Zt){const C=$t.get(y.root)?.context;if(u[y.root]&&rf(u[y.root],C?.branch)&&(delete u[y.root],l=!0),u[y.root])continue;const I=Jd(C);I&&(u[y.root]=I,l=!0)}return l?u:n}))},[Zt,$t]);const va=a.useMemo(()=>{const n=new Set(Zt.map(l=>l.root));return qs.filter(l=>n.has(l))},[qs,Zt]),wa=va.length===0,vr=a.useMemo(()=>wa?Zt:Zt.filter(n=>va.includes(n.root)),[Zt,va,wa]),or=a.useMemo(()=>vr.filter(n=>!!Dt[n.root]?.trim()),[Dt,vr]),$c=a.useMemo(()=>vr.filter(n=>!Dt[n.root]?.trim()),[Dt,vr]),Lc=a.useCallback(async n=>{if(!n||Lo.current.has(n))return;const l=$t.get(n)?.context;if((l?.branches?.length??0)>0||(l?.remoteBranches?.length??0)>0||l?.upstream)return;const u=b;Lo.current.add(n),Ml(x=>new Set(x).add(n));try{const x=await pd(n,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${n}`);if(!x.available||!Ae(u))return;ke(y=>y.map(C=>C.root===n?{...C,available:!0,context:{...C.context,...x},error:void 0}:C)),Vs(y=>y[n]||!x.branch?y:{...y,[n]:x.branch}),Ks(y=>{if(y[n])return y;const C=Jd(x);return C?{...y,[n]:C}:y})}catch(x){Dr(x)||console.warn("[RightSidebar] Failed to load branch audit repo details",n,x)}finally{Lo.current.delete(n),Ml(x=>{const y=new Set(x);return y.delete(n),y})}},[$t,Ae,b]);a.useEffect(()=>{if(bo)for(const n of vr)Lc(n.root)},[bo,vr,Lc]),a.useEffect(()=>{!Ko||!me||(Qs(me.branch||(me.branches?.[0]??"")),Zs(me.upstreamRemote||(me.remotes?.includes("origin")?"origin":me.remotes?.[0]??"")),ea(me.upstreamBranch||me.branch||(me.branches?.[0]??"")))},[me,Ko]);const Tc=a.useMemo(()=>{if(Je)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Xn||mn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!me?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const n=me.ahead??0,l=me.behind??0;return n>0&&l>0?{text:o("rightSidebar.pushDivergedCount",{ahead:n,behind:l}),className:"bg-destructive/10 text-destructive"}:n>0?{text:o("rightSidebar.pushAheadCount",{count:n}),className:"bg-accent/10 text-accent"}:l>0?{text:o("rightSidebar.pushBehindCount",{count:l}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[me?.ahead,me?.behind,me?.upstream,Xn,mn,Je,o]),bh=a.useCallback(n=>{if(n&&!oe){const l=n.currentTarget.getBoundingClientRect();W({x:Math.min(l.left,window.innerWidth-352),y:Math.min(l.bottom+6,window.innerHeight-64)})}else W(null);P?.()},[oe,P]),Yo=a.useCallback(()=>{W(null),N?.()},[N]);function Ic(){if(!Cn)return null;const n=Ec?.label??o("rightSidebar.allRepositories"),l=Ec?.count??Ee.size,u=Ct(n)||n;return t.jsxs("button",{type:"button",onClick:bh,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 ${S?"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":S,title:n,children:[t.jsx(Ir,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 truncate",children:u}),t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${l>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:l}),t.jsx(as,{size:12,className:"shrink-0"})]})}function xh(){if(!S||!Cn||typeof document>"u")return null;const n=typeof window>"u"?1024:window.innerWidth,l=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(Te?.x??n-368,n-352)),x=Math.max(12,Math.min(Te?.y??80,l-420)),y=oe?void 0:{left:u,top:x},C=t.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${oe?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Yo,children:t.jsxs("div",{className:oe?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:y,onClick:I=>I.stopPropagation(),children:[t.jsxs("div",{className:oe?"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:oe?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!oe&&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:xa.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:Yo,className:oe?"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(tr,{size:oe?16:14})})]}),t.jsx("div",{className:oe?"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:xa.map(I=>{const H=(I.root??null)===de,J=Ct(I.label)||I.label;return t.jsxs("button",{type:"button",onClick:()=>{td(I.root),Yo()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${oe?"px-3 py-2":"px-2 py-1.5"} ${H?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:I.label,role:"option","aria-selected":H,children:[t.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${H?"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 ${H?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:t.jsx(Ir,{size:13})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:`${oe?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:J}),t.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:I.root===null?o("rightSidebar.allRepositories"):I.label})]}),I.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:I.branch}),I.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] ${I.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:I.count})]},I.root??"all")})})]})});return Bu(C,oe,document.body)}function yh(){return xh()}function _c(n){const l=wt(n,b),u=n.absolutePath||(l?`${l}/${n.path}`:n.path),x=Za(u,l??b);return{key:Rt(n),path:n.path,absolutePath:u,displayName:x.name,displayDir:x.dir,oldPath:n.oldPath,status:n.status,title:u}}function Dc(n){return n.oldPath?t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:n.oldPath})}):null}function Fc(n,l){const u=Ia(n,b),x=`path:${u}`,y=V===x,C=Ne===x,I=y||C;return t.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),rn(u,x)},...zo(pa(u),x),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 ${I?"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"} ${I?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:l,children:t.jsx("span",{className:"whitespace-nowrap",children:o(C?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Oc(n){const l=wt(n,b),u=n.absolutePath||(l?`${l}/${n.path}`:n.path),x=qh(n),y=Pi(n);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Ux,{actions:x,running:Oe,completed:_n?.path===y?_n:null}),Fc(u,o("rightSidebar.insertThisFile"))]})}function Bc(n,l){const u=l.root??b;if(!u)return null;const x=Ia(n,u);return Fc(x,o("fileTree.insertRefTitle"))}function Xo(){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:()=>Yc("unified"),"aria-pressed":Mt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),t.jsx("button",{type:"button",onClick:()=>Yc("split"),"aria-pressed":Mt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function Uc(){return Ss.map(n=>{const l=iu(n.files.map(([,C])=>C)),u=Xi({activeGitRepoRoot:de,groupCount:Ss.length,label:n.label,rootName:rt}),x=!!(u&&n.root&&k.has(n.root));return{key:n.root??n.label,root:n.root,label:n.label,branch:n.branch,collapsed:x,files:n.files.map(([,C])=>_c(C)),header:u?t.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${x?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Fh(n.root),"aria-expanded":!x,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:x?t.jsx(Ta,{size:13}):t.jsx(as,{size:13})}),t.jsx(Ir,{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:n.label}),n.branch&&t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:n.branch})]}),t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:n.files.length}),l>0&&t.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:l})]}),n.root&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),Aa("stage-all",n.root,n.label)},disabled:!!Oe,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:C=>{C.stopPropagation(),Aa("stash-all",n.root,n.label)},disabled:!!Oe,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}})}function zc(){return Ee.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Sa.map(([,n])=>{const l=wt(n,b),u=n.absolutePath||(l?`${l}/${n.path}`:n.path);return{key:Rt(n),path:n.path,absolutePath:u,status:n.status,repoRoot:l,displayName:Za(u,l).name,displayDir:Za(u,l).dir,auditRecords:_t}})}function Hc(n){const l=Array.from(Ee.values()).find(y=>Rt(y)===n.key),u=l?wt(l,b):null,x=Vp(_t,u,l?.path??n.path);return t.jsx(Gi,{changeStatus:n.status,auditStatus:x,renderChangeBadge:y=>t.jsx(Is,{status:y})})}const ka=a.useCallback(n=>{if(oe)return null;const l=Array.from(n.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const x=n.getBoundingClientRect().top+48;let y=null,C=Number.POSITIVE_INFINITY;for(const H of l){const J=H.getBoundingClientRect();if(J.bottom<x)continue;const Pe=Math.abs(J.top-x);Pe<C&&(y=H,C=Pe)}const I=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return I?(ca.current===I&&ne.getState().selectedFilePath===I||(ca.current=I,at(I)),I):null},[oe,at]),vh=!!(!Oe&&je&&!Je&&(me?.upstream||pn.trim()&&gn.trim())),wh=!!(!Oe&&je&&!Je&&(me?.upstream||pn.trim()&&gn.trim())),kh=!!(!Oe&&je&&!Je&&Fn.trim()&&Fn.trim()!==me?.branch),er=a.useMemo(()=>{const n=fe.trim().toLowerCase(),l=Array.from(Ee.entries()).filter(([,u])=>!de||wt(u,b)===de).sort(([u],[x])=>u.localeCompare(x));return n?l.filter(([u,x])=>`${u} ${x.path} ${x.status} ${x.repoRelativeRoot??""} ${x.repoName??""}`.toLowerCase().includes(n)):l},[de,Ee,fe,b]);a.useEffect(()=>{Ya("selected_file_state",{selectedFilePath:st,selectedChangedFilePath:Qt?.path??null,selectedChangedFileAbsolutePath:Qt?.absolutePath??null,selectedChangedFileRepoRoot:Qt?.repoRoot??null,rootPath:b,activeGitRepoRoot:de,rightTab:Eo,effectiveRightTab:yr,diffPaneActive:Pt,changedFiles:Ee.size,filteredChangedFiles:er.length,gitBundleLoading:Jr,gitBundleLastLoadedAt:zn})},[de,Ee.size,Pt,yr,er.length,zn,Jr,Eo,b,Qt?.absolutePath,Qt?.path,Qt?.repoRoot,st]);const Ss=a.useMemo(()=>{const n=new Map;for(const l of er){const[,u]=l,x=wt(u,b),y=Ox(u)||rt,C=x??y,I=x?$t.get(x):void 0,H=n.get(C)??{root:x,label:y,branch:I?.context?.branch,files:[]};H.files.push(l),n.set(C,H)}return Array.from(n.values()).sort((l,u)=>l.label===rt?-1:u.label===rt?1:l.label.localeCompare(u.label))},[er,$t,rt,b]),Sa=a.useMemo(()=>{const n=[],l=new Map;for(const u of er)l.set(Rt(u[1]),u);for(const u of Ss){if(!!(u.root&&Xi({activeGitRepoRoot:de,groupCount:Ss.length,label:u.label,rootName:rt})&&k.has(u.root)))continue;if(Me!=="tree"){n.push(...u.files);continue}const y=u.files.map(([,C])=>_c(C));for(const C of tp(y)){const I=l.get(C.key);I&&n.push(I)}}return n},[de,k,Me,Ss,er,rt]);a.useEffect(()=>{if(!Pt||Sa.length===0||oe)return;const n=[],l=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&ka(u))return;const x=document.querySelector("[data-diff-stream-item]"),y=x?.dataset.diffSelectionPath??x?.dataset.diffStreamItem??null;if(y){ca.current=y,at(y);return}const C=Sa[0]?.[1];if(!C)return;const I=Rt(C);ca.current=I,at(I)};for(const u of[80,240,600,1200])n.push(window.setTimeout(l,u));return()=>n.forEach(u=>window.clearTimeout(u))},[Pt,oe,Sa,at,ka]);const Jo=a.useMemo(()=>{const n=I=>`'${I.replace(/'/g,"'\\''")}'`,l=sr.length>0?wn:Y.filter(I=>I.files.length>0),u=l.length>0?l:b?[{root:b,relativeRoot:".",name:rt}]:[],x=u.length>0?u.map(I=>`- ${I.relativeRoot==="."?".":I.relativeRoot} (${I.root})`).join(`
1667
+ `):`- ${b?".":""}`,y=u.length>0?u.map(I=>` td audit-export ${n(I.root)}`).join(`
1668
+ `):" td audit-export",C=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${b??""}`,"目标仓库:",x,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",y,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",C,'10. 少量 hunk 或临时补单条时使用:printf "%s\\n" "这里写该 hunk 的改动意义" | td audit-explain <hunkId> <对应仓库绝对路径>',"11. 注入成功后清理本次 payload:rm -f ~/.termdock/change-audit/payload*.json","","payload.walkthrough 示例字段:","{",' "title": "一句话标题",',' "summary": "整批改动的目的和结果",',' "highlights": [{ "what": "改了什么", "effect": "用户或系统得到什么", "tag": "体验" }],',' "nodes": [{ "id": "n1", "title": "节点标题", "kind": "ui", "business": "零上下文业务解释", "anchor": { "repoRoot": "<repoRoot>", "filePath": "<filePath>", "hunkIndex": 0, "hunkFingerprint": "<fingerprint>", "sectionIndex": 0, "sectionFingerprint": "<sectionFingerprint>" } }],',' "edges": [{ "from": "n1", "to": "n2", "label": "调用/传递/消费", "desc": "这条关系的业务含义" }],',' "risks": [{ "title": "真实风险或口径疑问", "anchor": { "filePath": "<filePath>" } }],',' "checks": ["可执行验证动作"]',"}","","写作标准:","- summary:一句话概括该 hunk 在整批改动中的职责。","- explanation:自包含说明业务链路、该 hunk 的作用、解决的问题、与其它 hunk 的关系。","- walkthrough.highlights 必须大白话,不要堆文件名/函数名;只看 highlights 应该知道这次改动干嘛。","- walkthrough.nodes 优先对应方法、关键业务步骤或关键 section;每个有 anchor 的节点必须能跳回真实 diff。","- 面向不了解本轮对话的 AI 编写,补足必要上下文。","- 输出高信息量结论;避免铺垫、套话、流程复述、泛泛风险、逐行翻译 diff。","","完成条件:汇报每个目标仓库已注入的 hunk 数和总数。"].join(`
1669
+ `)},[sr.length,wn,Y,rt,b]),Sh=a.useCallback((n="generate")=>{if(Cn&&on.length===0&&!de){Gr(!0);return}const l=n==="generate"?Jo:[n==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Jo].join(`
1670
+ `);lt("insert_change_audit_prompt",{rootPath:b,activeGitRepoRoots:sr,mode:n,hasAuditListCommand:l.includes("td audit-list"),promptLength:l.length}),nn(o("rightSidebar.insertChangeAuditPrompt"),l,`${bc}:${n}`),xr(),d||s()},[de,Jo,on.length,sr,nn,xr,s,d,b,Cn,o]),ja=a.useCallback(async n=>{try{await bd({ids:[n]}),an(l=>l.filter(u=>u.id!==n))}catch{xr()}},[xr]),jh=a.useCallback(async()=>{if(_t.length===0)return;const n=_t.map(l=>l.id);try{await bd({ids:n}),an(l=>l.filter(u=>!n.includes(u.id))),Vt(null)}catch(l){const u=l instanceof Error?l.message:"Failed to clear change audit explanations";Vt(o("rightSidebar.changeAuditClearFailed",{message:u})),xr()}},[_t,xr,o]),Rh=a.useCallback(async n=>{if(n.records.length===0)return;const l=n.records.map(u=>u.id);try{await ym({ids:l}),jr(u=>u.filter(x=>!l.includes(x.id))),it===n.key&&(fn(null),dr(!1))}catch(u){jt(o("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),fa(null)}},[fa,it,o]),Ch=a.useCallback(n=>{ln(l=>n===null?(Gr(!1),[]):l.includes(n)?l.filter(u=>u!==n):[...l,n])},[]),Nh=a.useCallback(n=>{yo(l=>n===null?(xo(!1),[]):l.includes(n)?l.filter(u=>u!==n):[...l,n])},[]),Qo=a.useMemo(()=>{if(!pr)return[];const n=l=>{const u=l.diff??"";let x=0,y=0;for(const C of u.split(`
1671
+ `))C.startsWith("+++")||C.startsWith("---")||(C.startsWith("+")&&(x+=1),C.startsWith("-")&&(y+=1));return{filePath:l.filePath,oldPath:l.oldPath,newPath:l.newPath,hunkHeader:l.hunkHeader,hunkIndex:l.hunkIndex??0,fingerprint:l.fingerprint,additions:x,deletions:y,diff:u}};return De?(De.hunks??[]).map(l=>{const u=Sr.find(x=>x.repoRoot===De.repoRoot&&x.baseRef===De.baseRef&&(x.branchName??null)===(De.currentBranch??null)&&x.filePath===l.filePath&&x.hunkHeader===l.hunkHeader&&(x.hunkIndex??0)===l.hunkIndex&&x.fingerprint===l.fingerprint)??null;return{key:`${l.filePath}\0${l.hunkHeader}\0${l.hunkIndex}`,hunk:l,current:u,stale:null}}):it?Sr.filter(l=>Yd(l)===it).map(l=>{const u=n(l);return{key:`${l.filePath}\0${l.hunkHeader}\0${l.hunkIndex??0}`,hunk:u,current:l,stale:null}}):[]},[De,Sr,pr,it]),Zo=Sr.length>0,Jn=a.useMemo(()=>{if(!pr)return[];const n=new Map;for(const l of Sr){const u=l.repoRoot,x=$t.get(u),y=x?.relativeRoot==="."?rt:x?.relativeRoot||x?.name||Ct(u),C=Yd(l),I=n.get(C)??{key:C,repoRoot:u,repoLabel:y,baseRef:l.baseRef,branchName:l.branchName??null,headRef:l.headRef??null,diffFingerprint:l.diffFingerprint??null,records:[],latestInjectedAt:0};I.records.push(l),I.latestInjectedAt=Math.max(I.latestInjectedAt,l.injectedAt??0),n.set(C,I)}return Array.from(n.values()).sort((l,u)=>u.latestInjectedAt-l.latestInjectedAt)},[Sr,$t,pr,rt]),ei=a.useMemo(()=>it?Jn.find(n=>n.key===it)??null:null,[Jn,it]),Ra=De?{repoRoot:De.repoRoot??"",repoLabel:De.repoRoot?$t.get(De.repoRoot)?.relativeRoot==="."?rt:$t.get(De.repoRoot)?.relativeRoot||$t.get(De.repoRoot)?.name||Ct(De.repoRoot):rt,baseRef:De.baseRef??De.baseBranch??"",branchName:De.currentBranch??null,headRef:De.headRef??null,diffFingerprint:De.diffFingerprint??null}:ei,Eh=a.useMemo(()=>(Ve?.hunks??[]).map(n=>({key:`${n.filePath}\0${n.hunkHeader}\0${n.hunkIndex}`,hunk:n,current:null,stale:null})),[Ve?.hunks]),Mh=a.useMemo(()=>{if(De)return[];const n=ei;return n?Mn.filter(l=>l.repoRoot===n.repoRoot&&l.baseRef===n.baseRef&&(l.branchName??null)===n.branchName&&(!n.diffFingerprint||l.diffFingerprint===n.diffFingerprint)):[]},[De,Mn,ei]),Ah=a.useCallback(n=>{const l=Qo.find(u=>u.hunk.filePath===n.filePath||(n.repoRoot?`${n.repoRoot}/${u.hunk.filePath}`===n.filePath:!1));l&&(hn(l.key),window.setTimeout(()=>Nn(n),90),window.setTimeout(()=>Nn(n),320),window.setTimeout(()=>Nn(n),760))},[Qo]),ti=a.useMemo(()=>{const n=y=>`'${y.replace(/'/g,"'\\''")}'`,l=or,u=l.length>0?l.map(y=>`- ${y.label} (${y.root}),目标分支:${Er[y.root]||y.branch||"(current branch)"},基线分支:${Dt[y.root]||"(not set)"}`).join(`
1672
+ `):`- ${b?".":""}`,x=l.length>0?l.map(y=>{const C=Er[y.root]||y.branch||"",I=Dt[y.root]||"",H=y.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[C?` git -C ${n(y.root)} switch ${n(C)}`:` # ${y.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${n(I)} ${n(y.root)} > ~/.termdock/branch-audit/branch-audit-export-${H}.json`].join(`
1673
+ `)}).join(`
1674
+ `):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${b??""}`,`包含本地未提交更改:${Kr?"是":"否"}`,"目标仓库:",u,"","操作指令:",Kr?"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。导出内容需要包含目标分支相对基线分支的提交改动,以及当前工作区 staged/unstaged/untracked 改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:":"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。不要包含本地 staged/unstaged/untracked 改动;如果导出结果里混入了本地工作区改动,生成解释时必须忽略这些本地改动,只解释目标分支相对基线分支的提交改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:",x,"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:b??null,repoRoot:"<target repo root>",baseRef:"<target repo base branch>",branchName:"<from export currentBranch>",headRef:"<from export headRef>",diffFingerprint:"<from export diffFingerprint>",generatedBy:"termdock-branch-audit",walkthrough:{title:"<one-line branch change title>",summary:"<branch change goal and effect>",highlights:[{what:"<what changed>",effect:"<user/system effect>",tag:"<category>"}],nodes:[{id:"n1",title:"<node title>",kind:"process",business:"<zero-context business explanation>",anchor:{repoRoot:"<target repo root>",filePath:"<from hunk.filePath>",hunkIndex:0,hunkFingerprint:"<from hunk.fingerprint>"}}],edges:[{from:"n1",to:"n2",label:"<relationship>",desc:"<business meaning>"}],risks:[{title:"<real risk or validation gap>"}],checks:["<executable validation step>"]},records:[{filePath:"<from hunk.filePath>",oldPath:"<from hunk.oldPath or null>",newPath:"<from hunk.newPath or null>",hunkHeader:"<from hunk.hunkHeader>",hunkIndex:0,fingerprint:"<from hunk.fingerprint>",diff:"<copy from hunk.diff exactly>",explanation:"<replace with hunk explanation>",summary:""}]},null,2),"```"].join(`
1675
+ `)},[Kr,or,Dt,Er,b]),Ph=a.useCallback((n="generate")=>{const l=n==="generate"?ti:[n==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",ti].join(`
1676
+ `);nn(o("rightSidebar.branchAuditShort"),l,`context:branch-audit-scope:${n}`),d||s()},[ti,nn,s,d,o]),$h=a.useCallback(async()=>{if(!b||or.length===0)return;const n=b;G(!0),we(null),ur(null),Fe(null);try{const l=await Promise.all(or.map(async H=>{const J=Dt[H.root]?.trim();if(!J)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:H.label}));const Pe=(Er[H.root]||H.branch||"").trim();return vm({cwd:b,repoRoot:H.root,base:J,head:Pe&&Pe!==H.branch?Pe:null,includeUncommitted:Kr,requestSlotId:`right-sidebar-branch-preview:${H.root}`})}));if(!Ae(n))return;const u=l.find(H=>!H.available);if(u){we(u.error??"Branch diff is unavailable");return}const x=l.length===1?l[0]:{available:!0,workspaceRoot:b,repoRoot:b,baseRef:l.map(H=>H.baseRef??H.baseBranch).filter(Boolean).join(", "),currentBranch:l.map(H=>H.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:l.map(H=>H.headRef).filter(Boolean).join(", "),diffFingerprint:l.map(H=>H.diffFingerprint).filter(Boolean).join("+"),stat:l.map(H=>H.stat).filter(Boolean).join(`
1677
+ `),files:l.flatMap((H,J)=>{const Pe=or[J];return(H.files??[]).map(Ye=>`${Pe?.label??H.repoRoot??"repo"}/${Ye}`)}),hunks:l.flatMap((H,J)=>{const Ye=or[J]?.label??H.repoRoot??"repo";return(H.hunks??[]).map(Be=>({...Be,filePath:`${Ye}/${Be.filePath}`,oldPath:Be.oldPath?`${Ye}/${Be.oldPath}`:Be.oldPath,newPath:Be.newPath?`${Ye}/${Be.newPath}`:Be.newPath}))}),commits:l.flatMap(H=>H.commits??[]),commitCount:l.reduce((H,J)=>H+(J.commitCount??J.commits?.length??0),0),diff:l.map(H=>H.diff).filter(Boolean).join(`
1678
+ `),truncated:l.some(H=>H.truncated)};if((x.hunks??[]).length===0){we(o("rightSidebar.branchAuditDiffEmpty"));return}const y=Date.now(),C=["preview",x.repoRoot??b,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??y].join("\0"),I=or.length===1?or[0].label:`${or.length} repos`;ur(x),cs(H=>[{key:C,diff:x,repoLabel:I,createdAt:y},...H.filter(J=>J.key!==C)].slice(0,8)),$n(H=>H[C]===void 0?H:{...H,[C]:0}),fn(C),hn(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),dr(!0)}catch(l){if(!Ae(n)||Dr(l))return;we(l instanceof Error?l.message:"Failed to load branch diff")}finally{Ae(n)&&G(!1)}},[Kr,or,Dt,Er,Ae,b,o]),Lh=a.useCallback(n=>{ur(n.diff),we(null),fn(n.key),hn(n.diff.hunks?.[0]?`${n.diff.hunks[0].filePath}\0${n.diff.hunks[0].hunkHeader}\0${n.diff.hunks[0].hunkIndex}`:null),dr(!0)},[]),Th=a.useCallback(n=>{cs(l=>l.filter(u=>u.key!==n)),$n(l=>{if(!(n in l))return l;const u={...l};return delete u[n],u}),it===n&&(fn(null),ur(null),dr(!1))},[it]),Ih=a.useCallback(n=>{const l=Jn.find(u=>u.key===n);l&&(ur(null),we(null),fn(n),hn(l.records[0]?.filePath??null),dr(!0))},[Jn]),_h=a.useCallback(async n=>{if(!b||!je)return;const[l]=n.split(/\s+/);if(l){We(l),yt(null),Fe(null);try{const u=await wm({cwd:b,repoRoot:je,commit:l,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){yt(u.error??"Commit diff is unavailable");return}Fe(u);const x=u.hunks?.[0];Gs(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){yt(u instanceof Error?u.message:"Failed to load commit diff")}finally{We(null)}}},[je,b]),Dh=a.useCallback(n=>{if(!De||!it)return;const l=Math.max(0,Math.round(n));$n(u=>Math.abs((u[it]??0)-l)<24?u:{...u,[it]:l})},[De,it]);a.useEffect(()=>{!oe||!Rr||!De||xs(1)},[Rr,De,oe,xs]);const Wc=a.useCallback(n=>{n&&Jf(l=>rp(l,n))},[]),Gc=na.key===st?na.key:null,Ca=a.useCallback(n=>{const l=ne.getState(),u=Qx();Ya("select_diff_file",{interactionId:u,path:n,previousSelectedFilePath:l.selectedFilePath,rootPath:l.rootPath,activeGitRepoRoot:de,changedFiles:l.changedFiles.size,gitBundleLoading:l.gitBundleLoading,gitBundleLastLoadedAt:l.gitBundleLastLoadedAt,rightTab:l.rightTab}),at(n),gr("diff"),oe&&n&&xs(1),Wc(n),queueMicrotask(()=>{const x=ne.getState();Ya("select_diff_file_after",{interactionId:u,requestedPath:n,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:de})})},[de,oe,Wc,at,gr,xs]),qc=a.useCallback(n=>{const l=Array.from(Ee.values()).find(u=>{const x=wt(u,b),y=Rt(u);return u.path===n.filePath||y===n.filePath||u.absolutePath===n.filePath||(x?`${x}/${u.path}`===n.filePath:!1)||n.repoRoot&&x===n.repoRoot&&u.path===n.filePath});if(l){Ca(Rt(l)),window.setTimeout(()=>Nn(n),90),window.setTimeout(()=>Nn(n),320),window.setTimeout(()=>Nn(n),760);return}Nn(n)},[Ee,b,Ca]),Vc=a.useCallback(({slideToDetail:n,fullscreen:l,toggleFullscreen:u}={})=>is.length>0?t.jsx(xu,{walkthroughs:is,repoRoot:de,fullscreen:l,onToggleFullscreen:u,onNavigate:x=>{oe&&window.requestAnimationFrame(()=>n?.()),qc(x)}}):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(Os,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[de,is,qc,oe,o]),Fh=a.useCallback(n=>{n&&Q(l=>{const u=new Set(l);return u.has(n)?u.delete(n):u.add(n),Si(xi,u),u})},[]),Kc=a.useCallback(n=>{Se(l=>{const u=new Set(l);return u.has(n)?u.delete(n):u.add(n),Si(Fd,u),u})},[]),Na=a.useCallback(n=>{cr(n),Tt(zu,n)},[]);a.useEffect(()=>{ya||Me!=="ai"||Na("tree")},[Me,Na,ya]);const Ea=a.useCallback(()=>{Ur(n=>{const l=!n;return Tt(Hu,l),l})},[]),Yc=a.useCallback(n=>{sn(n),Tt(Wu,n)},[]),{whitespace:Xc,context:Jc}=sp(),Qc=a.useMemo(()=>({algorithm:"histogram",whitespace:Xc,context:Jc}),[Xc,Jc]),Zc=a.useCallback(n=>{U(n),Tt(Gu,n)},[]),Ma=a.useCallback(async(n,l,u,x)=>{let y=n;for(;y.ok&&y.status==="running";)await new Promise(I=>window.setTimeout(I,1500)),y=await xd({jobId:y.jobId,cwd:l.cwd,action:l.action});if(!y.ok)throw new Error("Git action status is unavailable");if(y.status==="error")throw new Error(y.error||y.message||"Git action failed");const C={action:l.action,path:x,label:u};return ms(C),window.setTimeout(()=>ms(I=>I?.action===C.action&&I.path===C.path?null:I),1400),y},[]),vt=a.useCallback(async(n,l,u)=>{const x=b;b&&br.current.delete(b),jt(null),ms(null),hs({action:n.action,path:u});try{const y=await km({...n,includeNested:Zn(b)}),C=await Ma(y,n,l,u);if(!Ae(x))return!1;const I=b?await La(b,void 0,{includeNested:Zn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:ts(b)}).catch(()=>C.bundle):C.bundle;return Ae(x)?(I&&tn(I,{reloadDiff:!0,cacheOnly:!0}),Xr(null),!0):!1}catch(y){return ms(null),jt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Ae(x)&&hs(null)}},[tn,Ae,b,o,Ma]),ed=a.useCallback(async n=>{const l=b,u=await Sm({...n,includeNested:Zn(b)});if(!Ae(l))return;const x=b?await La(b,void 0,{includeNested:Zn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:ts(b)}).catch(()=>u.bundle):u.bundle;Ae(l)&&x&&tn(x,{reloadDiff:!0,cacheOnly:!0})},[tn,Ae,b]),Aa=a.useCallback((n,l,u)=>{if(l){if(n==="stage-all"){vt({action:"stage-all",cwd:l},o("rightSidebar.stageAll"),`repo:${l}`);return}Xr({kind:"stash-all",repoRoot:l,repoLabel:u})}},[vt,o]),td=a.useCallback(n=>{Qe(n),ki(b,n),Qs(""),Zs(""),ea(""),at(Nc(n)),ot||gr("diff"),n&&n!==b&&Y.find(u=>u.root===n)?.deferred&&ar(n,{includeNested:!1,background:!0,replaceRepoRoot:n})},[Nc,ot,Y,ar,b,at,gr]),rd=a.useCallback(n=>{const l=new Set([...Jt.current.keys(),...yn.current,...br.current]);for(const u of l)u!==n&&(Xt.current.delete(u),Jt.current.get(u)?.abort(),Jt.current.delete(u),Lt(`right-sidebar-git-untracked:${u}`),yn.current.delete(u),br.current.delete(u))},[]),Oh=a.useCallback(async n=>{const l=b;if(!l||(await ne.getState().setNestedGitScanRoot(l,n),!Ae(l)))return;if(n){await ar(l,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}rd(l),Qs(""),Zs(""),ea(""),yo(x=>x.filter(y=>y===l));const u=Qt;u&&wt(u,l)!==l&&at(null),await ar(l,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[rd,Ae,ar,b,at,Qt]),Bh=a.useCallback(async()=>{if(!je||Je){jt(o("rightSidebar.selectRepositoryForGitActions"));return}const n=Fn.trim();!n||n===me?.branch||await vt({action:"switch-branch",cwd:je,branch:n},o("rightSidebar.switchBranch"))},[me?.branch,je,Je,vt,Fn,o]),nd=a.useCallback(async()=>{if(!je||Je){jt(o("rightSidebar.selectRepositoryForGitActions"));return}const n=Js.trim();if(!n)return;await vt({action:"commit",cwd:je,message:n},o("rightSidebar.commitChanges"))&&_l("")},[je,Js,Je,vt,o]),Uh=a.useCallback(async()=>{if(!je||Je){jt(o("rightSidebar.selectRepositoryForGitActions"));return}const n=pn.trim(),l=gn.trim();await vt({action:"push",cwd:je,...n?{remote:n}:{},...l?{branch:l}:{}},o("rightSidebar.pushChanges"))},[je,gn,pn,Je,vt,o]),zh=a.useCallback(async()=>{if(!je||Je){jt(o("rightSidebar.selectRepositoryForGitActions"));return}const n=pn.trim(),l=gn.trim();await vt({action:"pull",cwd:je,...n?{remote:n}:{},...l?{branch:l}:{}},o("rightSidebar.pullChanges"))},[je,gn,pn,Je,vt,o]);a.useEffect(()=>{if(!ot||!je||Oe)return;let n=!1;const l={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(n)return;const x=await xd({cwd:je,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const y={action:u,cwd:je},C=l[u]??u;hs({action:u});try{const I=await Ma(x,y,C);if(n||!Ae(b))return;const H=b?await La(b,void 0,{includeNested:Zn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:ts(b)}).catch(()=>I.bundle):I.bundle;H&&tn(H,{reloadDiff:!0,cacheOnly:!0})}catch(I){n||jt(o("rightSidebar.gitActionFailed",{message:I instanceof Error?I.message:"Unknown error"}))}finally{n||hs(null)}return}})(),()=>{n=!0}},[je,tn,ot,Ae,b,Oe,o,Ma]);const ri=_n?.action==="commit",ni=_n?.action==="switch-branch",si=_n?.action==="pull",ai=_n?.action==="push",Pa=ot||Yf,oi=wa?o("rightSidebar.changeAuditScopeAll"):vr.length===1?vr[0].label:`${vr.length} repos`,Hh=vr.length>0,sd=or.length>0,Wh=b?t.jsx(nu,{open:bo,onOpenChange:xo,showScopePicker:!0,selectedAll:wa,repos:Zt,selectedRoots:va,onToggleRepo:Nh,onGenerate:()=>Ph(Zo?"regenerate":"generate"),disabled:!Hh,generateDisabled:!sd,inserted:V?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Zo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:oi,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Zo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{$h()},secondaryDisabled:!sd||D,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:D,loading:El.size>0,statusTitle:El.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:t.jsxs("div",{className:"mb-2 space-y-1.5",children:[t.jsxs("label",{className:"flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[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("rightSidebar.includeUncommittedHint")})]}),t.jsx("input",{type:"checkbox",checked:Kr,onChange:n=>Nl(n.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),$c.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:$c.map(n=>n.label).join(w==="zh"?"、":", ")})})]}),renderRepoExtra:n=>{const l=$t.get(n.root),u=[],x=new Set,y=(J,Pe)=>{!J||x.has(J)||(x.add(J),u.push({value:J,label:J,meta:Pe}))};y(Er[n.root]||l?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const J of l?.context?.branches??[])y(J,J===l?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const J of l?.context?.remoteBranches??[])y(J,o("rightSidebar.remoteBranch"));const C=[],I=new Set,H=(J,Pe)=>{!J||I.has(J)||(I.add(J),C.push({value:J,label:J,meta:Pe}))};H(Dt[n.root],Dt[n.root]?o("rightSidebar.pushUpstreamBadge"):void 0),H(l?.context?.upstream,l?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const J of l?.context?.remoteBranches??[])H(J,"remote");for(const J of l?.context?.branches??[])H(J,J===l?.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(es,{label:o("rightSidebar.currentBranchLabel"),value:Er[n.root]||l?.context?.branch||"",options:u,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:J=>{Vs(Pe=>({...Pe,[n.root]:J}))}}),t.jsx(es,{label:o("rightSidebar.branchAuditBaseLabel"),value:Dt[n.root]||"",options:C,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:J=>{Ks(Pe=>({...Pe,[n.root]:J}))}})]})}}):null,ad=Ps(_t.reduce((n,l)=>Math.max(n,l.injectedAt??0),0),w),Gh=b?t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>Cl(n=>{const l=!n;return Tt(yi,l),l}),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":fs,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(Os,{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:oi})]}),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 ${fs?"rotate-90":""}`,children:t.jsx(Ta,{size:13})})]}),fs&&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"),": ",oi]}),Wh]}),he&&t.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:he}),t.jsxs("div",{className:"mt-2 space-y-1.5",children:[cn.map(n=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${it===n.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:()=>Lh(n),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:n.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[n.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:n.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:n.diff.baseRef??n.diff.baseBranch}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),Ps(n.createdAt,w)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Ps(n.createdAt,w)})]}),t.jsx("button",{type:"button",onClick:()=>Th(n.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(Xa,{size:12})})]},n.key)),Jn.length>0?Jn.slice(0,Math.max(0,8-cn.length)).map(n=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${it===n.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:()=>Ih(n.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:n.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[n.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:n.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:n.baseRef}),n.diffFingerprint&&t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:n.diffFingerprint})]}),Ps(n.latestInjectedAt,w)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Ps(n.latestInjectedAt,w)??""})})]}),t.jsx("button",{type:"button",onClick:()=>{Rh(n)},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(Xa,{size:12})})]},n.key)):cn.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,od=pr&&b&&Xn?t.jsxs("div",{className:Pa?"overflow-visible":"overflow-hidden",children:[Gh,t.jsxs("button",{type:"button",onClick:()=>{ot||Xf(n=>{const l=!n;return l&&je&&!Xn&&!mn&&Do(je),l})},"aria-expanded":Pa,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${ot?"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(Ir,{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 ${Rn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[mn&&t.jsx(bt,{size:10,className:"animate-spin"}),Rn.staged>0?o("rightSidebar.stagedCount",{count:Rn.staged}):o("rightSidebar.noStagedChangesShort")]}),!ot&&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 ${Pa?"rotate-90":""}`,children:t.jsx(Ta,{size:13})})]})]}),Pa&&t.jsxs("div",{className:"space-y-0",children:[Wt.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:fh})]})}),t.jsx(es,{label:o("rightSidebar.gitRepositoryLabel"),value:je??"",options:Wt,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!Oe,onChange:n=>{td(n||null)}}),Je&&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:Fn!==Cc?Cc:null})]}),t.jsxs("button",{type:"button",onClick:()=>{Bh()},disabled:!kh,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 ${ni?"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:Oe?.action==="switch-branch"||ni?"opacity-0":"",children:o("rightSidebar.switchBranch")}),Oe?.action==="switch-branch"&&t.jsx(bt,{size:12,className:"absolute animate-spin"}),ni&&Oe?.action!=="switch-branch"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx(es,{label:o("rightSidebar.currentBranchLabel"),value:Fn,options:ph,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!Oe,onChange:Qs})]}),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:Je?o("rightSidebar.selectRepositoryForGitActions"):Rn.staged>0?o("rightSidebar.commitReadyHint",{count:Rn.staged}):o("rightSidebar.commitNeedsStaged")})]}),t.jsxs("button",{type:"button",onClick:()=>{nd()},disabled:!!Oe||Je||Rn.staged===0||!Js.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 ${ri?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:Je?o("rightSidebar.selectRepositoryForGitActions"):Rn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[t.jsx("span",{className:Oe?.action==="commit"||ri?"opacity-0":"",children:o("rightSidebar.commitChanges")}),Oe?.action==="commit"&&t.jsx(bt,{size:12,className:"absolute animate-spin"}),ri&&Oe?.action!=="commit"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx("input",{value:Js,onChange:n=>_l(n.target.value),onKeyDown:n=>{(n.metaKey||n.ctrlKey)&&n.key==="Enter"&&(n.preventDefault(),nd())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!Oe,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:()=>Cr(n=>!n),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":fr,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:[te&&t.jsx(bt,{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 ${fr?"rotate-90":""}`,children:t.jsx(Ta,{size:13})})]})]}),fr&&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(rs,{size:12,className:"shrink-0"}),t.jsx("input",{value:Ln,onChange:n=>dn(n.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:()=>dn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(tr,{size:12})})]}),t.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:hh,children:[un.length>0?un.map(n=>{const[l,...u]=n.split(/\s+/),x=u.join(" ")||n;return t.jsxs("button",{type:"button",onClick:()=>{_h(n)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:x,children:[t.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:l}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),hr[l]&&t.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${hr[l]==="ahead"?"bg-accent/10 text-accent":hr[l]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(hr[l]==="ahead"?"rightSidebar.commitAhead":hr[l]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Xe===l&&t.jsx(bt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},n)}):te?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),Kt&&t.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:t.jsx(bt,{size:12,className:"animate-spin"})}),go&&!Kt&&un.length>0&&t.jsx("button",{type:"button",onClick:()=>{ks({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")})]})]}),pt&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:pt}),jl&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:jl})]}),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:()=>{zh()},disabled:!vh,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 ${si?"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:Oe?.action==="pull"||si?"opacity-0":"",children:o("rightSidebar.pullChanges")}),Oe?.action==="pull"&&t.jsx(bt,{size:12,className:"absolute animate-spin"}),si&&Oe?.action!=="pull"&&t.jsx("span",{className:"absolute",children:"✓"})]}),t.jsxs("button",{type:"button",onClick:()=>{Uh()},disabled:!wh,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 ${ai?"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:Oe?.action==="push"||ai?"opacity-0":"",children:o("rightSidebar.pushChanges")}),Oe?.action==="push"&&t.jsx(bt,{size:12,className:"absolute animate-spin"}),ai&&Oe?.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] ${Tc.className}`,title:me?.upstream??void 0,children:[t.jsx("span",{className:"truncate font-medium",children:Tc.text}),t.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:me?.upstream??""})]}),t.jsxs("div",{className:`grid gap-1.5 ${Pc?"grid-cols-2":"grid-cols-1"}`,children:[Pc&&t.jsx(es,{label:o("rightSidebar.pushRemoteLabel"),value:pn,options:Ac,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!Oe,onChange:Zs}),t.jsx(es,{label:o("rightSidebar.pushBranchLabel"),value:gn,options:gh,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:me?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!Oe,onChange:ea})]})]})]})]}):null,qh=a.useCallback(n=>{const l=wt(n,b);if(!l)return[];const u=Pi(n),x=[];return n.canStage&&x.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{vt({action:"stage-file",cwd:l,paths:[n.path]},o("rightSidebar.stageFile"),u)}}),n.canUnstage&&x.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{vt({action:"unstage-file",cwd:l,paths:[n.path]},o("rightSidebar.unstageFile"),u)}}),n.canStash&&x.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{vt({action:"stash-file",cwd:l,paths:[n.path]},o("rightSidebar.stashFile"),u)}}),n.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Xr({kind:"restore",file:n,phrase:""})}),x},[b,vt,o]),Vh=a.useCallback(()=>{if(m){f?.();return}Ar(0),$r.current?.slideTo(0),Mr(!1),xt(null)},[f,m]),id=a.useCallback(n=>{if(j(""),Yt(n),at(null),xt(null),se(null),oe){m&&f?.(),Ar(0),$r.current?.slideTo(0),Mr(!1);return}},[oe,f,m,at,Yt]);a.useEffect(()=>{const n=l=>{const u=l.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;j(""),xt(null),Ie(null);const y=!!(b&&(x===b||x.startsWith(`${b}/`)));if(u.kind==="file"){const C=Ei(x);ys(x),typeof u.line=="number"&&Number.isSafeInteger(u.line)&&u.line>0&&Ie(u.line),Yt(y?null:C),se(I=>({path:x,nonce:(I?.nonce??0)+1}));return}at(null),y?(Yt(null),se(C=>({path:x,nonce:(C?.nonce??0)+1}))):(se(null),Yt(x)),oe&&(m&&f?.(),Ar(0),$r.current?.slideTo(0),Mr(!1))};return window.addEventListener(yd,n),()=>window.removeEventListener(yd,n)},[ys,oe,f,m,b,at,Yt]),a.useEffect(()=>{e||(It(!1),Ut(!1))},[e]),a.useEffect(()=>{if(!Gt&&!qt)return;const n=l=>{l instanceof globalThis.KeyboardEvent&&l.key!=="Escape"||l instanceof globalThis.MouseEvent&&l.target instanceof Node&&(En.current?.contains(l.target)||Or.current?.contains(l.target))||(It(!1),Ut(!1))};return window.addEventListener("mousedown",n),window.addEventListener("keydown",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",n)}},[qt,Gt]);const ld=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:ch,disabled:!ga,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(mu,{size:14})}),t.jsx("button",{type:"button",onClick:xc,disabled:!b||Bn===b,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:t.jsx(zi,{size:14})}),t.jsx("button",{type:"button",onClick:dh,disabled:!ye,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:Dl?o("rightSidebar.fileWatchUnavailable",{message:Dl}):o("rightSidebar.refreshFiles"),children:t.jsx(eo,{size:13})}),t.jsx("div",{className:"min-w-0 flex-1 px-1",title:ye??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:ih}),ia==="modified"&&t.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:t.jsx(vd,{size:11})})]})}),t.jsx("button",{type:"button",onClick:()=>ye&&rn(ye,Ht??void 0),disabled:!ye,...ye&&Ht?zo(pa(ye),Ht):{},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 ${Ht&&(V===Ht||Ne===Ht)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ht&&Ne===Ht?"rightSidebar.copied":Ht&&V===Ht?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ht&&(V===Ht||Ne===Ht)?t.jsx(Ii,{size:13}):t.jsx(to,{size:13})}),t.jsxs("div",{ref:Or,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{It(!1),Ut(n=>!n)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${qt?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":qt,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(Di,{size:14})}),qt&&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:()=>{Ut(!1),uh()},disabled:!Go,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${ws?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ws?t.jsx(di,{size:14}):t.jsx(_a,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(ws?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ut(!1),Zf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Mo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Mo?t.jsx(dp,{size:14}):t.jsx(Bi,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Mo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!ye,onClick:()=>{ye&&(Ut(!1),eh(ye,ia==="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:[ia==="modified"?t.jsx(Gm,{size:14}):t.jsx(vd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(ia==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),b&&(ba.length>0||lh)&&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:xc,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 ${ye===b?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:b,children:[t.jsx(zi,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:rt})]}),ba.map(n=>{const l=n.path,u=n.kind==="file",x=u?st===l:ye===l;return t.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:l,children:[t.jsxs("button",{type:"button",onClick:()=>u?ys(l):Yt(l),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?t.jsx(Ui,{size:10,className:"shrink-0"}):t.jsx(_a,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Ct(l)})]}),t.jsx("button",{type:"button",onClick:()=>bn(l),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:Ct(l)}),title:o("rightSidebar.unpinFolder",{name:Ct(l)}),children:t.jsx(tr,{size:9})})]},l)})]}),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"})]}),ii=a.useMemo(()=>{if(Dn===null)return null;const n=typeof navigator>"u"?void 0:navigator.language,l=Math.max(0,Math.floor((jo-Dn)/1e3)),u=new Intl.RelativeTimeFormat(n,{numeric:"auto"}),[x,y]=l<60?[-l,"second"]:l<3600?[-Math.floor(l/60),"minute"]:l<86400?[-Math.floor(l/3600),"hour"]:[-Math.floor(l/86400),"day"];return u.format(x,y)},[jo,Dn]),cd=b&&!Vn?t.jsx("button",{type:"button",onClick:()=>{Oh(!Ao)},"aria-pressed":Ao,title:o("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${Ao?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:o("rightSidebar.multiRepoScan")}):null,dd=b?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[ii?t.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:ii}),children:ii}):null,t.jsx("button",{type:"button",onClick:()=>{bs()},disabled:Jr,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(eo,{size:13,className:Jr?"animate-spin":""})})]}):null,Kh=ac?o("rightSidebar.changeAuditScopeAll"):wn.length===1?wn[0].relativeRoot==="."?rt:wn[0].relativeRoot||wn[0].name:`${wn.length} repos`,ud=b?t.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[t.jsx(nu,{open:Ws,onOpenChange:Gr,showScopePicker:Cn,selectedAll:ac,repos:th,selectedRoots:sr,onToggleRepo:Ch,onGenerate:()=>Sh(),disabled:!b,inserted:V===bc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Kh,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:zr,error:!!Wr,statusTitle:Wr??(zr?o("rightSidebar.changeAuditLoading"):_t.length>0?`${o("rightSidebar.changeAuditLoaded",{count:_t.length})}${ad?` · ${o("rightSidebar.changeAuditLoadedAt",{time:ad})}`:""}`:void 0)}),t.jsx("button",{type:"button",onClick:()=>{jh()},disabled:zr||_t.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${_t.length>0?"":"invisible"}`,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:t.jsx(Xa,{size:12})})]}):null,$a=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:[re?.available&&re.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:re.branch,children:[t.jsx(Ir,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:re.branch})]}),gt.modified>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[gt.modified,"M"]}),gt.added>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",gt.added]}),gt.deleted>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",gt.deleted]}),gt.renamed>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[gt.renamed,"R"]}),gt.copied>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[gt.copied,"C"]}),gt.untracked>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[gt.untracked,"U"]}),gt.conflicted>0&&t.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[gt.conflicted,"!"]}),gt.other>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[gt.other,"?"]}),gt.staged>0&&t.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:gt.staged})}),re?.available&&b&&Ee.size>0&&Y.length<=1&&t.jsx("button",{type:"button",onClick:()=>{vt({action:"stage-all",cwd:b},o("rightSidebar.stageAll"))},disabled:!!Oe,className:"rounded-md bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),re?.available&&b&&Ee.size>0&&Y.length<=1&&t.jsx("button",{type:"button",onClick:()=>Xr({kind:"stash-all",repoRoot:b,repoLabel:rt}),disabled:!!Oe,className:"rounded-md bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]});return t.jsxs(qm,{side:"right",isOpen:e,drawerWidthPx:r,onClose:s,onOpen:i,push:d,pinned:c,children:[zo.popoverNode,t.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",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:b??void 0,children:rt}),(!oe||ko)&&re?.available&&re.branch&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:re.branch,children:[t.jsx(Ir,{size:10,className:"shrink-0"}),t.jsx("span",{className:"max-w-[7rem] truncate",children:re.branch})]})]})}),t.jsx("button",{type:"button",onClick:()=>{const n=!ie;pe(n),n?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):j("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ie?"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(rs,{size:14})}),t.jsxs("button",{type:"button",role:"switch","aria-checked":Ze,onClick:()=>{rr(n=>!n),Bt(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Ze?"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(Vm,{size:14}),!Ze&&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:Ul,type:"file",multiple:!0,className:"hidden",onChange:n=>{const l=n.target.files;!l||l.length===0||(vs(Array.from(l)),n.target.value="")}}),t.jsx("input",{ref:zl,type:"file",accept:"image/*",className:"hidden",onChange:n=>{const l=n.target.files?.[0];n.target.value="",l&&oh(l)}}),h&&t.jsx("button",{type:"button",onClick:h,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${c?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:c?t.jsx(di,{size:14}):t.jsx(_a,{size:14})}),t.jsxs("div",{ref:En,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Ut(!1),It(n=>!n)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Gt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Gt,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(Di,{size:15})}),Gt&&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:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Yr,onClick:()=>ah(!Yr),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(_i,{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 ${Yr?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Yr?"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:()=>{It(!1),Ul.current?.click()},disabled:ta,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:[ta?t.jsx(bt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(Lp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{It(!1),zl.current?.click()},disabled:ta,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:[ta?t.jsx(bt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(pp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),h&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{It(!1),h()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${c?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[c?t.jsx(di,{size:14}):t.jsx(_a,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(c?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),c&&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(([n,l])=>{const u=q===n;return t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{Z(n),It(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:l},n)})})]})]})]}),t.jsx("button",{type:"button",onClick:s,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:t.jsx(tr,{size:14})})]}),ie&&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(rs,{size:12,className:"shrink-0"}),t.jsx("input",{"data-right-search":!0,type:"search",value:O,onChange:n=>j(n.target.value),placeholder:o($==="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 ${oe?"text-[11px]":"text-[10px]"}`,children:[t.jsx("button",{type:"button",onClick:()=>Zc("name"),"aria-pressed":$==="name",className:`rounded-full px-2 transition active:scale-95 ${oe?"py-1":"py-0.5"} ${$==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),t.jsx("button",{type:"button",onClick:()=>Zc("content"),"aria-pressed":$==="content",className:`rounded-full px-2 transition active:scale-95 ${oe?"py-1":"py-0.5"} ${$==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),O&&t.jsx("button",{type:"button",onClick:()=>j(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(tr,{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(Km,{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:K,onChange:n=>ae(n.target.value),onKeyDown:n=>{n.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}),K!=="."&&t.jsx("button",{type:"button",onClick:()=>ae("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:t.jsx(tr,{size:11})})]}),t.jsxs("button",{type:"button",onClick:()=>Re(n=>!n),"aria-expanded":be,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${be||ps.length>0||E||ue||qe?"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(Ym,{size:13}),ps.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:ps.length})]})]}),be&&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:le,onChange:n=>ge(n.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}),le&&t.jsx("button",{type:"button",onClick:()=>ge(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:t.jsx(tr,{size:11})})]}),$==="content"&&t.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[E,()=>ee(n=>!n),op,o("rightSidebar.matchCase")],[ue,()=>Le(n=>!n),Op,o("rightSidebar.matchWholeWord")],[qe,()=>_e(n=>!n),Np,o("rightSidebar.useRegex")]].map(([n,l,u,x])=>t.jsxs("button",{type:"button",onClick:l,"aria-pressed":n,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${n?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsx(u,{size:12}),x]},x))})]})]}),t.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(Vn?2:3)+(Yr?1:0)}, minmax(0, 1fr))`},children:[!Vn&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>gr("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${yr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Ir,{size:12}),o("rightSidebar.tabGit")]}),t.jsxs("button",{type:"button",onClick:()=>gr("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${yr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Ru,{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:()=>gr("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${yr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(ep,{size:12}),o("rightSidebar.tabFiles")]}),Yr&&t.jsxs("button",{type:"button",onClick:()=>gr("android"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${yr==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(_i,{size:12}),o("rightSidebar.tabAndroid")]})]}),t.jsx("div",{className:"h-2"}),Tl&&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:Tl})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[t.jsx(Va,{active:ot,mounted:pr,fallback:t.jsx(Ni,{slow:!1}),children:Ve?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(Sd,{items:Eh,selectedKey:Wf,onSelect:Gs,emptyText:o("rightSidebar.noChanges"),mobile:oe,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Ve.headRef??""}${Ve.commits?.[0]?` · ${Ve.commits[0]}`:""}`,onClose:()=>{Fe(null),Gs(null)},closeLabel:o("common.back"),wrap:mt,onToggleWrap:oe?Ea:void 0,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:oe?"stacked":"split",onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:V,copiedReferenceKey:Ne,onClearAuditRecord:ja})}):Rr?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(Sd,{items:Qo,selectedKey:vo,onSelect:hn,emptyText:o(De?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:oe,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(De?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Ra?`${Ra.repoLabel} · ${Ra.branchName??"HEAD"} → ${Ra.baseRef}`:void 0,onClose:()=>{dr(!1),ur(null)},closeLabel:o("common.back"),wrap:mt,onToggleWrap:oe?Ea:void 0,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:oe?"stacked":"split",onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:V,copiedReferenceKey:Ne,onClearAuditRecord:ja,walkthroughs:Mh,onWalkthroughNavigate:Ah,initialDetailScrollTop:De&&it?Pn[it]:void 0,onDetailScrollPositionChange:Dh,externalSwiperRef:oe?ua:void 0,onMobileSlideChange:oe?wo:void 0})}):t.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:od?t.jsx("div",{className:"px-3",children:od}):Jr?t.jsx(Ni,{slow:Xl}):xn?t.jsx(Ka,{message:xn,onRetry:()=>{bs()}}):cu(re)?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):re?.available===!1?t.jsx(Ka,{message:re.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{bs()}}):b?t.jsx(Ni,{slow:Xl}):t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),t.jsx(Va,{active:Kn,children:oe?t.jsxs(gu,{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:n=>{$r.current=n,n.slideTo(Al,0)},onSlideChange:n=>{if(Ar(n.activeIndex),gs.current===n.activeIndex){gs.current=null;return}n.activeIndex===0&&(Mr(!1),xt(null),f?.())},children:[t.jsx(Fi,{className:"h-full min-h-0",children:t.jsxs("div",{ref:Hn,onScroll:ic,onDragOver:ha,onDragEnter:ha,onDragLeave:dc,onDrop:uc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[Fl&&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")})}),!O.trim()&&ld,t.jsx(wd,{rootPath:ye??"",onFileSelect:ys,onPathReference:rn,getReferenceText:pa,onReferenceCopied:Lr,insertedReferenceKey:V,copiedReferenceKey:Ne,onDirectoryRoot:yc,onSearchFromDirectory:vc,onDirectoryPinToggle:wc,onFilePinToggle:kc,pinnedPaths:Sn,selectedFilePath:st,query:fe,searchRootPath:ec,searchOptions:tc,searchMode:$,onContentMatchSelect:lc,onDirectoryDropFiles:(n,l)=>vs(l,n),revealDirectory:X,canOpenInFileBrowser:Ol,onOpenInFileBrowser:cc})]})}),t.jsx(Fi,{className:"h-full min-h-0",children:t.jsx("div",{className:"h-full overflow-hidden bg-surface",children:t.jsx(il,{filePath:Kn&&(Gf||Al===1)?st:null,onInsertReference:rn,onInsertText:Tr,onInsertFeature:Tr,onReviewReference:pc,onReferenceCopied:Lr,onClose:Vh,onDirectoryLinkOpen:id,isMobile:!0,lineRange:lr,onLineRangeChange:xt,insertedReferenceKey:V,copiedReferenceKey:Ne,scrollToLine:nt,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:z,onOpenMarkdownOutline:A,onCloseMarkdownOutline:M,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:T,onOpenMarkdownImageLightbox:B,onCloseMarkdownImageLightbox:_})})})]}):t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{ref:Hn,onScroll:ic,onDragOver:ha,onDragEnter:ha,onDragLeave:dc,onDrop:uc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Co},children:[Fl&&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")})}),!O.trim()&&ld,t.jsx(wd,{rootPath:ye??"",onFileSelect:ys,onPathReference:rn,getReferenceText:pa,onReferenceCopied:Lr,insertedReferenceKey:V,copiedReferenceKey:Ne,onDirectoryRoot:yc,onSearchFromDirectory:vc,onDirectoryPinToggle:wc,onFilePinToggle:kc,pinnedPaths:Sn,selectedFilePath:st,query:fe,searchRootPath:ec,searchOptions:tc,searchMode:$,onContentMatchSelect:lc,onDirectoryDropFiles:(n,l)=>vs(l,n),revealDirectory:X,canOpenInFileBrowser:Ol,onOpenInFileBrowser:cc})]}),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:rh,onPointerMove:nh,onPointerUp:oc,onPointerCancel:oc,onDoubleClick:()=>{No(Yi),Tt($s,Yi)},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(il,{filePath:Kn?st:null,onInsertReference:rn,onInsertText:Tr,onInsertFeature:Tr,onReviewReference:pc,onReferenceCopied:Lr,onDirectoryLinkOpen:id,isMobile:!1,lineRange:lr,onLineRangeChange:xt,insertedReferenceKey:V,copiedReferenceKey:Ne,scrollToLine:nt,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:z,onOpenMarkdownOutline:A,onCloseMarkdownOutline:M,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:T,onOpenMarkdownImageLightbox:B,onCloseMarkdownImageLightbox:_})})]})}),t.jsx(Va,{active:Pt,mounted:qf||Pt,children:()=>Fo?t.jsx(Xm,{}):oe?t.jsx(Oi,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:ua,onMobileSlideChange:wo,groups:er.length>0?Uc():[],mode:Me,onModeChange:Na,selectedKey:st,scrollToKey:Gc,scrollToKeyNonce:na.nonce,compact:!1,collapsedDirectoryKeys:ce,onToggleDirectory:Kc,onSelectFile:n=>{const l=Array.from(Ee.values()).find(u=>Rt(u)===n.key);l&&Ca(Rt(l))},renderLeading:Hc,renderTrailing:n=>{const l=Array.from(Ee.values()).find(u=>Rt(u)===n.key);return l?Oc(l):null},renderDirectoryTrailing:Bc,renderSubtitle:n=>{const l=Array.from(Ee.values()).find(u=>Rt(u)===n.key);return l?Dc(l):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:n=>b&&t.jsxs("div",{className:"px-0 py-0",children:[$a&&t.jsx("div",{className:"mb-2",children:$a}),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:[er.length,"/",Ee.size]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Ic(),cd,n,c&&Xo(),ud,dd]}),Ft&&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:Ft.label}),Ft.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:Ft.branch})]}),!Ft&&Cn&&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(Ir,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:ya?(n=>Vc(n)):void 0,emptyContent:Fo?null:xn&&Ee.size===0?t.jsx(Ka,{message:xn,onRetry:()=>{bs()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):er.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:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>xs(0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[t.jsx(ss,{size:14}),o("rightSidebar.backToChangeList")]}),t.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[c&&Xo(),t.jsxs("button",{type:"button",onClick:Ea,"aria-pressed":mt,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 ${mt?"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(mt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:zc(),activePane:Pt,wrap:mt,diffViewType:Qf,inlineMode:os,diffOptions:Qc,reloadKey:kr,renderStreamBadge:n=>t.jsx(Is,{status:n}),onHunkGitAction:ed,onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:V,copiedReferenceKey:Ne,onClearAuditRecord:ja,onDetailScroll:ka}):t.jsx(Oi,{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:er.length>0?Uc():[],mode:Me,onModeChange:Na,selectedKey:st,scrollToKey:Gc,scrollToKeyNonce:na.nonce,compact:!0,collapsedDirectoryKeys:ce,onToggleDirectory:Kc,onSelectFile:n=>{const l=Array.from(Ee.values()).find(u=>Rt(u)===n.key);l&&Ca(Rt(l))},renderLeading:Hc,renderTrailing:n=>{const l=Array.from(Ee.values()).find(u=>Rt(u)===n.key);return l?Oc(l):null},renderDirectoryTrailing:Bc,renderSubtitle:n=>{const l=Array.from(Ee.values()).find(u=>Rt(u)===n.key);return l?Dc(l):null},aiContent:ya?(n=>Vc(n)):void 0,emptyContent:Fo?null:xn&&Ee.size===0?t.jsx(Ka,{message:xn,onRetry:()=>{bs()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):er.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:n=>b&&t.jsxs("div",{className:"px-0 py-0",children:[$a&&t.jsx("div",{className:"mb-2",children:$a}),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:[er.length,"/",Ee.size]})})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Ic(),cd,n,Xo(),t.jsxs("button",{type:"button",onClick:Ea,"aria-pressed":mt,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 ${mt?"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(mt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),ud,dd]}),Ft&&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:Ft.label}),Ft.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:Ft.branch}),t.jsx("button",{type:"button",onClick:()=>Aa("stage-all",Ft.root,Ft.label),disabled:!!Oe,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:()=>Aa("stash-all",Ft.root,Ft.label),disabled:!!Oe,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")})]}),!Ft&&Cn&&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(Ir,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:zc(),activePane:Pt,wrap:mt,diffViewType:Mt,inlineMode:os,diffOptions:Qc,reloadKey:kr,renderStreamBadge:n=>t.jsx(Is,{status:n}),onHunkGitAction:ed,onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:V,copiedReferenceKey:Ne,onClearAuditRecord:ja,onDetailScroll:ka})}),t.jsx(Va,{active:Oo,mounted:Vf&&Yr,children:t.jsx(Og,{})})]}),e&&Ze&&t.jsx(ug,{value:kt,collapsed:tt,autoCollapseAfterSend:Et,focusRequest:ht,insertError:Br?o("rightSidebar.contextDraftInsertFailed"):null,onChange:n=>{zt(!1),Ke(n)},onCollapsedChange:Bt,onAutoCollapseAfterSendChange:wr,onDisable:()=>rr(!1),onClear:()=>Ke(""),onInsert:()=>gc(!1),onInsertAndSend:()=>gc(!0),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:n=>o("rightSidebar.contextDraftCharacterCount",{count:n})}}),yh(),St&&typeof document<"u"&&Fr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Xr(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:n=>n.stopPropagation(),children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:St.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),t.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:St.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:hu(St.file.absolutePath,b)}):o("rightSidebar.confirmStashAllDescription")}),St.kind==="restore"&&t.jsx("input",{value:St.phrase,onChange:n=>Xr({...St,phrase:n.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:()=>Xr(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:!!Oe||St.kind==="restore"&&St.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(St.kind==="restore"){const n=wt(St.file,b);if(!n)return;vt({action:"restore-worktree-file",cwd:n,paths:[St.file.path],confirm:{acknowledged:!0,phrase:St.phrase}},o("rightSidebar.restoreFile"),Pi(St.file))}else{const n=St.repoRoot??b;if(!n)return;vt({action:"stash-all",cwd:n},o("rightSidebar.stashAll"),`repo:${n}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${St.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(Oe?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const h0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:il,MarkdownImageLightbox:Pf,MarkdownPreview:$f,RightSidebar:t0,__testParseMarkdownListBlock:xx,buildMarkdownPreviewBlocks:Mx,buildMarkdownPreviewRenderResult:wl,collectKnownGitRepoRoots:tf,computeMarkdownImageDisplayBox:mf,getMarkdownHeadingOutline:Af,getMarkdownHeadingPathAtLine:Mf,getNextMarkdownPreviewLineRange:Ix,isSvgImageSrc:ho,mountRightSidebarRepoPickerOverlay:Bu,replaceGitRepositorySnapshot:Ff,resolveMarkdownLocalLinkTarget:pl,resolveRightSidebarDiffViewType:Qu,shouldCloseMarkdownImageLightboxDrag:Cf,showsGitRepoGroupHeader:Xi},Symbol.toStringTag,{value:"Module"}));export{Bi as E,zi as H,bp as M,h0 as R,dp as a,yp as b,zp as c,f0 as m};